Hello Everyone,
I am trying to design a scatter plot with vega. I want a drop down box to choose the values for both x-axis and y-axis, which on choosing would change the scatter plot accordingly. But i tried with the examples given in "https://vega.github.io/vega/examples/scatter-plot-null-values/", it seems that i could only get the drop down menu with an empty plot.
Initially i was using vega-lite to display the scatter plot which was fine but after i added the code to add drop down box , the scatter plot gets removed and only the drop down box remains.
Here is the script:
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"signals": [
{ "name": "y-axis", "value": "_source.MeanWindSpeed",
"bind": {"input": "select", "options": ["_source.MeanWindSpeed"]} },
{ "name": "x-axis", "value": "_source.Status",
"bind": {"input": "select", "options": ["_source.Status"]} },
{ "name": "nullSize", "value": 8 },
{ "name": "nullGap", "update": "nullSize + 10" }
],
data: {
url: {
%context%: true
index: s164_dfig_47_040105
body: {
size: 10000,
_source: ["Status", "MeanWindSpeed"]
}
}
format: {property: "hits.hits" }
}
mark: {type: "point"},
encoding: {
x: {
field: _source.Status
type: nominal
}
y: {
field: _source.MeanWindSpeed
type: quantitative
},
color: {
// Make the color of each point depend on the _source.extension field
field: _source.Status
// Treat different values as completely unrelated values to each other.
// You could switch this to quantitative if you have a numeric field and
// want to create a color scale from one color to another depending on that
// field's value.
type: nominal
// Rename the legend title so it won't just state: "_source.extension"
legend: { title: 'Load Case Result' }
}
shape: {
// Also make the shape of each point dependent on the extension.
field: _source.Status
type: quantitative
}
}
}
Thanks in advance..
Best Regards,
Nirajan Shrestha