2017-01-20 172 views
0

我做一個excel與epplus需要在像下面的圖片中所示的豎線產生兩個圖:更改訂單yAxys與EPPlus

enter image description here

正如你所看到的,在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"); 
    } 
+0

你能告訴我們你的代碼?所以我們可以看到有什麼問題 –

+0

你好,我剛剛添加了部分代碼 –

回答

1

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