Dynamic range of y-axis

I would my y-axis to range from 0 to just above the max of my data.
I tried the following:
"yaxis": {
"autotypenumbers": "strict",
"dtick": "0.01",
"title": {
"text": "",
"standoff": 6,
"font": {
"size": 12
"type": "linear",
"tickformat": ".0%",
"automargin": true,
"fixedrange": true,
"zerolinecolor": "#DEDEDE",
"range": [0, Math.max(...{{ap_prov_monthly.data.abschluss_prov_ng}})]
I got the following error message: "The value has to be of type 'object', you provided a value of type 'string'"
the data i provide cannot be strings as they are the exact same data points that are plotted on the chart, and they are of type float.

I also tried to set the range to [0, null] and also tried changing the value of fixedrange from true to false, but nothing happend.

Hey @seppi! Would it be alright if I stepped into your app to take a look at this? If so, sharing the name of your app would be most helpful :slight_smile:

The app is self-hosted. Is that a problem?
The name of the app is called Versicherungen - RSV/2. Selection and you can try doing it for the chart in 2.5 or 2.6, where the axis should start 0.1 below the minimum and up to 0.1 above the max of the depicted data.
Thanks in advance.

Darn, I can't step into self-hosted apps actually :sweat_smile:

Would you mind sharing an app export instead? It doesn't export with any data or resource connections, but I'd at least be able to check out your chart JSON. You can export your apps by clicking the 3 dots in the top right corner of the app > Export to JSON.

I contacted Ben M., and he was so kind to help me out with the problem.
Though, thanks for your reply as well!

1 Like

Oh, so glad to hear it! Feel free to share the solution here as well, if you'd like :slight_smile:

Sure! Here is the solution:
Instead of trying to make it work in the Layout section, I created a new JS query (called MaxPoint) like so:

return Math.max(...ap_prov_monthly.data.abschluss_prov_ng) + .05

and then referenced to that query in the range values. For instance:

"yaxis": {
    "range": [0.3, {{ MaxPoint.data }}],
1 Like

Thank you so much for sharing that!