Forum Discussion
Vega Lite - scatter plot
haha.
Thanks lbendlin
I have it already. The biggest problem for me is to find max and put it as field.
- lbendlin2 years agoSuper User
You can do that in DAX, and add it as a column in the Deneb visual.
- dm-p2 years agoSuper User
Hi AdamMG,
If you just want to draw a line across the width/height of the visible view, you can do something like this, where you create a layer with a simple, empty dataset (like the fixed line example) :{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": {"url": "data/cars.json"}, "layer": [ { "data": {"values": [{}]}, "mark": "rule", "encoding": { "x": {"value": 0}, "x2": {"value": "width"}, "y": {"value": "height"}, "y2": {"value": 0} } }, { "mark": "point", "encoding": { "x": {"field": "Horsepower"}, "y": {"field": "Miles_per_Gallon"} } } ], "encoding": {"x": {"type": "quantitative"}, "y": {"type": "quantitative"}} }You could also use the expression language to interrogate the assigned scale domains, e.g.:
{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": {"url": "data/cars.json"}, "layer": [ { "data": {"values": [{}]}, "mark": "rule", "encoding": { "x": {"datum": {"expr": "domain('x')[0]"}}, "x2": {"datum": {"expr": "domain('x')[1]"}}, "y": {"datum": {"expr": "domain('y')[0]"}}, "y2": {"datum": {"expr": "domain('y')[1]"}} } }, { "mark": "point", "encoding": { "x": {"field": "Horsepower"}, "y": {"field": "Miles_per_Gallon"} } } ], "encoding": {"x": {"type": "quantitative"}, "y": {"type": "quantitative"}} }
If you want to do something fancier with the range of data for each encoding channel, this may be possible but would require a sample of your dataset to ensure that I could come up with an optimal approach. If you're not able to share, you might be able to consider an aggregate transform, to find the min/max of each series and plot based on those, or possibly a regression transform may be an option.Hopefully, some of this may help you come up with more ideas. And thanks very much for trying Deneb!
Regards,
Daniel