How to change data label position in EPPlus?

帅比萌擦擦* 提交于 2021-01-29 04:21:00

问题


So here is my successfully generated chart. However for some reason on this chart only it decides the date times should show up at the top of the chart instead of the bottom. Here is my code and what I've tried. Notice the text is neither bold nor is at showing where it should. I've also tried giving the chart a ton of area to work with and it still does this. Any help in the right direction would be greatly appreciated.

ExcelChart paintDewChart = overview.Drawings.AddChart(w.Name + "Dew", OfficeOpenXml.Drawing.Chart.eChartType.LineMarkersStacked);
paintDewChart.Title.Text = "Paint Dew";
paintDewChart.SetPosition(24, 0, 0, 0);
paintDewChart.SetSize(1550, 400);
paintDewChart.Legend.Position = eLegendPosition.Bottom;

var dser1 = (ExcelLineChartSerie)(paintDewChart.Series.Add(w2.Cells["C4:C" + water.Count.ToString()], w1.Cells["A4:A" + water.Count.ToString()]));
var dser2 = (ExcelLineChartSerie)(paintDewChart.Series.Add(w2.Cells["D4:D" + water.Count.ToString()], w1.Cells["A4:A" + water.Count.ToString()]));

dser1.Header = "PC2 Dew";
dser2.Header = "B Dew";

dser1.DataLabel.Position = eLabelPosition.Bottom;
dser2.DataLabel.Position = eLabelPosition.Bottom;

dser1.DataLabel.Font.Bold = true;
dser2.DataLabel.Font.Bold = true;

EDIT:

I figured out I can flip the orientation with this, however labels still overlay on the graph instead of below it.

paintDewChart.YAxis.Orientation = eAxisOrientation.MaxMin;

回答1:


Here is the correct code I need for my situation.

paintDewChart.YAxis.Orientation = eAxisOrientation.MaxMin;
paintDewChart.XAxis.LabelPosition = eTickLabelPosition.High;
paintDewChart.XAxis.TickLabelPosition = eTickLabelPosition.High;

EDIT: Also depending on minimum and maximum value ranges going from positive to negative, you may need this.

paintDewChart.XAxis.Crosses = eCrosses.Max;


来源:https://stackoverflow.com/questions/41576082/how-to-change-data-label-position-in-epplus

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!