Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# chart epplus axis reverse order

I do an export in Excel and draw charts using Epplus:

var chart = (ExcelChart)wksh.Drawings.AddChart("Chart", eChartType.Line);
chart.SetSize(500, 300);
chart.SetPosition(5, 800);
chart.Title.Text = "myChart";
chart.Series.Add(ExcelRange.GetAddress(2, 26, rowIndex, 26), ExcelRange.GetAddress(2, 25, rowIndex, 25));

And get the chart from left to right by default:

enter image description here

How do I get the chart from right to left??

enter image description here

For example, in excel in properties there is a parameter "categories in reverse order":

how it is done in the Epplus?.

like image 779
Lilia Semenov Avatar asked Jun 17 '26 15:06

Lilia Semenov


1 Answers

I had a similar problem in which I wanted to flip my y axis, which I fixed with

chart.YAxis.Orientation = eAxisOrientation.MaxMin;

If you wanted to do x then the same thing (but with x) should work

chart.XAxis.Orientation = eAxisOrientation.MaxMin;

You may also want to set

chart.XAxis.MinValue 
chart.XAxis.MaxValue 
chart.XAxis.Crosses

If your formatting looks wonky

like image 164
Lyco Avatar answered Jun 19 '26 11:06

Lyco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!