Free Support Forum -

How to set the value ranges and interval in the axis in excel chart

I am facing a simple issue and below are the scenarios.
1. On x-axis, the data range is from 1.0 to 9.0. I am using below code to set this. But, they are coming simple 1, 2,3,4,…, 9. Don’t know how to get decimals.

chart.ValueAxis.MinValue = 1.0;
chart.ValueAxis.MaxValue = 9.0;
2. On the chart type RADAR, is there any way to set the interval between the lines? My requirement is axis values should start from 4.0 and ends at 9.0. And the interval should be 1. So that it will be 4.0, 5.0, 6.0, 7.0, 8.0, 9.0. But, right now they are coming 4.0, 4.5, 5.0…8.5, 9.0.

These are very urgent for me as I completed all, these are for I am waiting to complete the work. So, any help is greatly appreciated.



1) I think you may try to use TickLabels.NumberFormat attribute:
chart.ValueAxis.TickLabels.NumberFormat = “0.0”;

2) To set interval, you may try to use MajorUnit and MinorUnit attributes of Axis class.
chart.ValueAxis.TickLabels.NumberFormat = “0.0”;
chart.ValueAxis.MinValue = 4.0;
chart.ValueAxis.MaxValue = 9.0;
chart.ValueAxis.MinorUnit = 1.0;

Thank you.

Thanks for the solution.
But, it is not working for the chart type Bar3D100PercentStacked.
I have percentages needs to be shown. it is starting from 0 and ending at 100, the interval is 20, But, I need the interval to be 10.
This is the code used for it.
chart.ValueAxis.IsAutomaticMaxValue = false;
chart.ValueAxis.IsAutomaticMinValue = false;
chart.ValueAxis.MinValue = 0;
chart.ValueAxis.MaxValue = 100;
chart.ValueAxis.MinorUnit = 10;
chart.ValueAxis.TickLabels.NumberFormat = “0%”;

What could be the problem?


I think you might be using lots of data in the series and your chart size might not be having enough width to render the interval correctly or completely, so it might use 20 as interval. I think you may try to extend the chart’s width or chart’s size, you may do it while adding the chart, e.g

int chartIndex = worksheet.Charts.Add(ChartType.Bar3D100PercentStacked, 1, 1, 30, 20);

Thank you.