0

I'm doing an excel with epplus that requires generating two graphs in vertical bars like those shown in the following image:

enter image description here

As you can see, on the Y-axis, the labels appear disordered, starting with P6 and ending with P1. I want to get the opposite effect. Start at P1 and end at P6

Is there any property with which I can change the order? Or should I order it with some sort of sort algorithm?

This is the function related to generate the chart

public void dibujarGrafica6Periodos(ExcelWorksheet ws, CultureInfo idioma)
    {
        CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
        TextInfo textinfo = cultureInfo.TextInfo;
        var chart = ws.Drawings.AddChart("barChart2", OfficeOpenXml.Drawing.Chart.eChartType.BarClustered);
        chart.SetPosition(34, 0, 10, 10);
        chart.SetSize(940, 20*14);
        var serie1 = chart.Series.Add(ws.Cells["E36:E41"], ws.Cells["A36:A41"]);
        var serie2 =chart.Series.Add(ws.Cells["C36:C41"], ws.Cells["A36:A41"]);
        chart.Title.Text = "Consumo por Periodos - " + textinfo.ToUpper(DateTime.Now.ToString("MMMM", idioma));
        chart.Title.Font.Color = System.Drawing.ColorTranslator.FromHtml("#4F81BD");
        chart.Border.Fill.Style = eFillStyle.NoFill;
        chart.Title.Font.Size = 6;
        chart.YAxis.Font.Size = 5;
        chart.XAxis.Font.Size = 5;
        chart.Legend.Font.Size = 5;
        chart.Legend.Font.Color = System.Drawing.ColorTranslator.FromHtml("#4F81BD");
        chart.YAxis.Font.Color = System.Drawing.ColorTranslator.FromHtml("#4F81BD");
        chart.XAxis.Font.Color = System.Drawing.ColorTranslator.FromHtml("#4F81BD");
        chart.Legend.Position = OfficeOpenXml.Drawing.Chart.eLegendPosition.Bottom;
        chart.Style = OfficeOpenXml.Drawing.Chart.eChartStyle.Style10;
        serie1.Header = DateTime.Now.ToString("yyyy");
        serie2.Header = DateTime.Now.AddYears(-1).ToString("yyyy");
    }

1 Answers1

1

Resolved with:

 chart.XAxis.Orientation = OfficeOpenXml.Drawing.Chart.eAxisOrientation.MaxMin;