I got a dual vertical axis chart with different unit for each axis.
(see in image below). double_axis_chart.PNG (40.1 KB)
My issue is that left and right axis are not sync.
I mean that the duration curve line must be in “touch” with the top of “Total” stacked column (as they have both same value).
Instead it’s very dependant of the value in table.
I want to scale right axis max value according to left axis max value, but I’m unable to found out the max value for left axis.
Your input Excel file (if any) containing data source for the chart.
Your output Excel file containing your undesired chart by Aspose.Cells API.
Your complete runnable sample code to generate the (undesired) chart in 2).
A sample Excel file containing your desired chart in it, you may create the chart manually in MS Excel.
You may try to first call Chart.calculate() method before retrieving values from those attributes if it works. Please note, if those major unit scale and maximum values are set “Automatic” in axis formats, then you cannot get values for those attributes precisely.
// Divide total duration in seconds by number of seconds in 1 day
const percentToDurationRatio =
columnStackedChartDetails.curveTotalDuration / 86400;
// Pre render chart to get axis values
chart.calculate();
// Set secondary axis min value according to primary axis min value
chart
.getSecondValueAxis()
.setMinValue(
chart.getValueAxis().getMinValue() * percentToDurationRatio
);
// Set secondary axis max value according to primary axis max value
chart
.getSecondValueAxis()
.setMaxValue(
chart.getValueAxis().getMaxValue() * percentToDurationRatio
);
Good to know that your issue is sorted out by the suggested line of code. Feel free to write us back if you have further queries or issue, we will be happy to assist you soon.