Hello,
Can anyone provide me any ideas to plot scatter plot with the data from an index?
Without using drop down box (combo box), i am able to plot it. But when i want to change the axes to different index fields using drop down box using "signals" with ("input": "select"),the plot shows wrong values.
I got stuck on this issue since days..just could not find the solution to this.
Here is my code...
{
"$schema": "https://vega.github.io/schema/vega/v4.json",
"padding": 5,
"width": 450,
"height": 580,
"autosize": {"type": "pad"},
"signals": [
{ "name": "yField", "value": "_source.SensorID",
"bind": {"input": "select", "options": ["_source.MeanWindSpeed","_source.ExpectationIDEvents","_source.SensorID", "_source.Mean","_source.Min", "_source.Max"]} },
{ "name": "xField", "value": "_source.Min",
"bind": {"input": "select", "options": ["_source.Result","_source.Status","_source.TimeStamp","_source.Min", "_source.Max","_source.Mean"]} },
{ "name": "nullSize", "value": 8 },
{ "name": "nullGap", "update": "nullSize + 10" }
],
"data": [
{
"name": "loadcase",
url: {
index: test_index
body: {
size: 10000,
query: {
match_all: {}
}
}
},
format: {property: "hits.hits" }
}
],
"scales": [
{
"name": "yscale",
"type": "linear",
"range": [{"signal": "height - nullGap"}, 0],
"nice": true,
"domain": {"data": "loadcase", "field": {"signal": "yField"}}
},
{
"name": "xscale",
"type": "linear",
"range": [{"signal": "nullGap"}, {"signal": "width"}],
"nice": true,
"domain": {"data": "loadcase", "field": {"signal": "xField"}}
}
],
"axes": [
{
"orient": "bottom", "scale": "xscale", "offset": 5, "format": "s",
"title": {"signal": "xField"}
},
{
"orient": "left", "scale": "yscale", "offset": 5,"format": "s",
"title": {"signal": "yField"}
}
],
"marks": [
{
"type": "symbol",
"from": {"data": "loadcase"},
"encode": {
"enter": {"size": {"value": 50}, "tooltip": {"field": "tooltip"}},
"update": {
"x": {"scale": "xscale", "field": "_source.Min"},
"y": {"scale": "yscale", "field": "_source.SensorID"},
"fill": {"value": "red"},
"fillOpacity": {"value": 0.5},
"zindex": {"value": 0}
},
"hover": {
"fill": {"value": "black"},
"fillOpacity": {"value": 1},
"zindex": {"value": 1}
}
}
}
]
}
I followed an example provided in Example Gallery: Vega (https://vega.github.io/vega/examples/scatter-plot-null-values/).
Any help would be greatly appreciated.
Thanks in advance..
Best Regards,
Nirajan