amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
Other
343 stars 91 forks source link

how to get Max Value from Yaxis #1555

Closed bossbelle closed 2 months ago

bossbelle commented 3 months ago

I used 2 axis ranges like CodePen below so that only LineChart shows axis ranges. However, in the actual code, the final value of Y-axis 2 is not a fixed value.

Is there a way to get the maximum value of the y-axis? Or is there a way to set the axial range throughout the axis without setting the maximum value?

myCodepen

martynasma commented 3 months ago

It seems you are using CategoryAxis. So, getting a final category is as easy as checking the last item in your data.

bossbelle commented 3 months ago

I'm using ValueAxis as the Y-axis. I need a way to get the maximum of the axis because the maximum of the axis of ValueAxis is always larger than the maximum of my data.

martynasma commented 3 months ago

Gotcha.

You can use private setting max for that. And you can watch for any changes:

yAxis2.onPrivate("max", function(max) {
  console.log(max)
});
bossbelle commented 3 months ago

Using the Legendary Hide() function Even if the maximum value of the y-axis changes yAxis2.getPrivate ("max") displays the same value.

Is the maximum value that changes to the Hide() function of the legend impossible to detect?

martynasma commented 3 months ago

If you need to find out max of the current zoom, you can use private setting selectionMax instead.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. It will be closed in 5 days unless a new comment is added.