I have this chart that displays the breakdown of electricity prices. I’m trying to set a dynamic value for the y-axis maximum. When I use max: auto, the maximum is set to 5, and the chart isn’t fully visible.
I would like to set the maximum to, for example, 110% of the highest value (the total price). I thought about creating a sensor for this, but I don’t know how to set the y-axis maximum to the value of that sensor.
There is an ongoing discussion thread for all things Apex Charts, in which you will certainly find answers. This now has almost 3900 postings covering all issues.
Also, there is excellent documentation, which provides the information you require.
Y-axis, min or max options, additional formats
Try something like
max: ‘|+10|’
since Apex Charts does not permit variables in settings I don’t believe it is possible to set for +10% of the current value, however +2 might be satisfactory for your graph.
Thanks a lof fro your advice.
According to the documentation, it should work, for example: max: '|+2|' max: ~50
But unfortunately, none of it works in my chart. The chart still displays maximum=5.
I have found that these options are working for me on simple line graphs.
~1500 works, as does “|+100|”
My guess is that some other combinations of settings is confusing the ‘max’ setting.
You have the graph set to ‘stacked’ and a set column series (so the maximum of these is the largest sum of each column)
One series is from a data generator, the rest are grouped averages at 1 hour intervals
You have one additional line graph, being a grouped average at 1 hour
You have set the chart height
I assume that the ‘stacked’ option computes the maximum from the largest summed value of all series, however the line graph cannot be stacked so is plotted as is, but is still possibly being ‘added-in’ for the max computation.
And, low and behold, this issue has been raised as a bug in the last three weeks.
Version 2.1.2, so you could either wait for a fix, unstack your graph, or go back to an earlier version…
It really seems, as you wrote, that the maximum is the sum of the values of all sensors. And the bug you mentioned is indeed the same problem. I’ll hope that the next version will fix it.
Thank you.