如何在EPPlus中更改数据标签的位置? [英] How to change data label position in EPPlus?

查看:244
本文介绍了如何在EPPlus中更改数据标签的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我成功生成的图表.但是,出于某种原因,此图表仅决定日期时间应显示在图表的顶部而不是底部.这是我的代码以及我尝试过的内容.请注意,该文本既不是粗体的,也不是应该显示的.我还尝试给图表提供大量工作空间,并且仍然可以做到.在正确方向上的任何帮助将不胜感激.

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;

我发现我可以用它来翻转方向,但是标签仍然覆盖在图形上,而不是在图形下方.

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;

推荐答案

这是我适合我的情况的正确代码.

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;

另外,根据从正到负的最小值和最大值范围,您可能需要此.

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

paintDewChart.XAxis.Crosses = eCrosses.Max;

这篇关于如何在EPPlus中更改数据标签的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆