如何更改 EPPlus 中的数据标签位置?
How to change data label position in EPPlus?
这是我成功生成的图表。然而,出于某种原因,在此图表上,它只决定日期时间应显示在图表的顶部而不是底部。这是我的代码和我尝试过的。请注意,文本既不是粗体也没有显示它应该在哪里。我也试过给图表提供大量的工作区域,但它仍然这样做。任何正确方向的帮助将不胜感激。
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;
编辑:
我发现我可以用这个翻转方向,但是标签仍然覆盖在图表上而不是下面。
paintDewChart.YAxis.Orientation = eAxisOrientation.MaxMin;
这是我需要的正确代码。
paintDewChart.YAxis.Orientation = eAxisOrientation.MaxMin;
paintDewChart.XAxis.LabelPosition = eTickLabelPosition.High;
paintDewChart.XAxis.TickLabelPosition = eTickLabelPosition.High;
编辑:还取决于从正到负的最小值和最大值范围,您可能需要这个。
paintDewChart.XAxis.Crosses = eCrosses.Max;
这是我成功生成的图表。然而,出于某种原因,在此图表上,它只决定日期时间应显示在图表的顶部而不是底部。这是我的代码和我尝试过的。请注意,文本既不是粗体也没有显示它应该在哪里。我也试过给图表提供大量的工作区域,但它仍然这样做。任何正确方向的帮助将不胜感激。
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;
编辑:
我发现我可以用这个翻转方向,但是标签仍然覆盖在图表上而不是下面。
paintDewChart.YAxis.Orientation = eAxisOrientation.MaxMin;
这是我需要的正确代码。
paintDewChart.YAxis.Orientation = eAxisOrientation.MaxMin;
paintDewChart.XAxis.LabelPosition = eTickLabelPosition.High;
paintDewChart.XAxis.TickLabelPosition = eTickLabelPosition.High;
编辑:还取决于从正到负的最小值和最大值范围,您可能需要这个。
paintDewChart.XAxis.Crosses = eCrosses.Max;