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 ,
Thanks for reaching out to the Microsoft fabric community forum.
Make sure the values you're plotting actually fall within the domain [150, 250] in the layer where you're applying the scale.
In layered visuals like KPI cards, ensure the scale override is set on the correct layer, ideally the one rendering the line/chart.
Make sure that axis is not set to null or being turned off in your encoding.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Community Support Team
- distra1 year agoFrequent Visitor
Thank you v-menakakota,
all values are well within that range, these are my current values:
Maybe I did not understand the concept of layers well enough to define the axis correctly. THis is my code that defines the encoding:
"encoding": { "y": { "field": "Avg Rate dynamic Currency", "type": "quantitative", "scale": { "zero": false, "domain": [80,300] }, "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" } },But actually, this is not defined inside the layer definitions, maybe that's the mistake?
- v-menakakota1 year agoCommunity Support
Hi distra ,
Please go through the below blog and solved issues which may help you in resolving the issues:DENEB and Power BI Enthusiasts - Microsoft Fabric Community
Solved: Deneb Vega Lite Sub Columns? - Microsoft Fabric Community
Solved: haRe: dynamic y-axis with dynamic y-axis label - Microsoft Fabric Community
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Community Support Team- distra1 year agoFrequent Visitor
Hello v-menakakota,
thank you for your reply. I checked the group and the two solved issues but unfortunately none of the displayed visuals contained what I need to achieve.
Maybe to make it clearer, all I need to achieve with this visual is to define a range for the y-axis which I want to see. Let me give you an example:
In my case I want the y axis to begin at the lower and at min_avg_rate - ( 40% of min_avg_rate). And the top end of the axis should be max_avg_rate + ( 40% of min_avg_rate).
And I tried to first scale the y-axis with static values, but even that gets me weird results. The boundaries are not respected and the y-Axis is not displayed properly anymore.
I am wondering if I defined the scale of the axis with the domain in the wrong place or in the wrong way.