Forum Discussion
Dynamic y-Axis calculation with Deneb
- 1 year ago
Hi distra,
The area mark is designed to have a zero baseline, so even if you cut the domain, it is trying to plot the remainder of the shape outside the domain (as the second y-value is zero). It would work with a line mark as there is only a single y-coordinate to worry about.
So, what is happening here is that your y-scale and axis are being correctly set to the desired range, but the size of your chart is condensing the vertical scale into the equivalent amount of space. You can see it "kind of" working if you make the visual container larger, e.g.:
(ignore the 'undefined'; that's a copy/paste issue with your sample data at my end)
One way to resolve this is to instruct Vega-Lite to clip the area mark. You should be able to make the following changes to your spec:
1. Update the scale as follows (removing "zero": false), e.g.:
{ ... "encoding": { "y": { "field": "Avg Rate dynamic Currency", "type": "quantitative", "scale": { "domain": [80, 235] // or whatever you need min/max to be }, ... }, ... } ... }2. Update the area mark definition to include a clip as follows:
{ ... "layer": [ { "description": "sparkline definition", "mark": { "type":"area", "clip": true }, ... }, ... } ... }This will now cut the baseline of the plotted area, e.g.:
Hopefully this should be all you need to resolve. Good luck!
(and thanks for using Deneb!)
Daniel
Hi distra ,
Apologies for the delayed response. Could you please review the following configuration and confirm if it meets the requirement.
"scale": {
"zero": false,
"domain": [225, 235]
}
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Community Support Team
Hello v-menakakota,
no problem at all, take all the time you need please.
It was my understanding that the exact code you put there would scale my y-Axis to the samE range that I had shared in my example. However, when I add it, the visual output is the following:
The y-Axis and area shading completely disappear, although the range is absolutely correct.
For your reference, I added it here:
"encoding": {
"y": {
"field": "Avg Rate dynamic Currency",
"type": "quantitative",
"scale": {
"zero": false,
"domain": [225, 235]
},
"axis": {
"title": null,
"labels": true,
"ticks": true,
"grid": true,
"domain": true,
"labelColor": "#605E5C",
"labelFont": "Segoe UI Semibold",
"labelFontSize": 10,
"tickColor": "#E1DFDD",
"gridColor": "#F3F2F1",
"domainColor": "#E1DFDD"
}
},
"x": {
"field": "Month",
"type": "temporal"
}
},
This is the encoding block after the fransforms and before the layers (please reference my full configuration in my other comment if more context is needed). If I defined it in the wrong way or position, please let me know. I am quite confused why this does not work, because I had exactly the same approach.
Thank you for your continous support!
- v-menakakota1 year agoCommunity Support
Hi distra ,
Thank you for sharing the sample data.
We are currently trying to reproduce the issue on our side for further analysis. To help with that, could you please also share the corresponding pbix file? This will ensure we are aligned with your visual configurations.
Thank you. - distra1 year agoFrequent Visitor
Hi v-menakakota,
unfortunately the pbix contains sensitive information which I cannot share.Since Deneb is a standalone visual, which can be configured completely decoupled from the rest of my file, what can I provide besides the sample dataset that could help you?
I will try to provide whatever is required to solve this.Thank you!