我正在用 epplus 做一个 excel,它需要在垂直条中生成两个图形,如下图所示:
如您所见,在 Y 轴上,标签显得杂乱无章,从 P6 开始,到 P1 结束。我想得到相反的效果。从 P1 开始,在 P6 结束
有没有可以更改订单的属性?或者我应该用某种排序算法订购它?
这是与生成图表相关的功能
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");
}