Thanks @timroes for your help yesterday. I tried to change your script so that I can import data from elasticsearch but it doesn't work. Do you know what I did wrong?
{
"$schema": "https://vega.github.io/schema/vega/v4.3.json",
"description": "A basic line chart example.",
"padding": 5,
data: {
name:"table"
url: {
%context%: true
%timefield%: timestamp
index: modbusdata_new
body: {
size: 10000,
_source: ["timestamp", "T107","C106"]
},
}
}
transform: [
{
calculate: "toDate(datum._source['timestamp'])"
as: "time"
}
],
"scales": [
{
"name": "timex", //Changed the scale names so that I wouldnt confuse the y scale with the y value and so on
"type": "time",
"range": "width",
"domain": {"data": "table", "field": "time"}
},
{
"name": "NameT107",
"type": "linear",
"range": "height",
"nice": true,
"zero": true,
"domain": {"data": "table", "field": "_source.T107"} // "_source.['T107']" or "T107" doesn't work either
},
{
"name": "NameC107",
"type": "linear",
"range": "height",
"nice": true,
"zero": true,
"domain": {"data": "table", "field": "_source.C106"}
}
],
"axes": [
{"orient": "bottom", "scale": "timex", "format": "%H:%m"},
{"orient": "left", "scale": "NameT107"},
{
"orient": "left",
"scale": "NameC107",
"offset": 30,
"domainColor": "#FF00FF",
"labelColor": "#FF00FF",
"tickColor": "#FF00FF"
}
],
"marks": [
{
"type": "line",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "timex", "field": "time"},
"y": {"scale": "NameT107", "field": "_source.T107"}
}
}
},
{
"type": "line",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "timex", "field": "time"},
"y": {"scale": "NameC107", "field": "_source.C106"},
"stroke": {"value": "#FF00FF"}
}
}
}
]
}
I get the error: Cannot read property 'T107' of undefined
.
If I change the line "domain": {"data": "table", "field": "_source.T107"}
to "domain": {"data": "table", "field": "Whatever"}
the error changes to Cannot read property 'Whatever' of undefined
.
The output of F12->Console as requested is:
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
but below it it says: A single error about an inline script not firing due to content security policy is expected!
Haven't found a solution for this. Any ideas?
Thanks,
defalt.