簡體   English   中英

從ZedGraph餅圖中刪除標簽行

[英]Removing label lines from ZedGraph pie-chart

我正在使用ZedGraph創建一個餅圖,並使用AddPieSlice()方法向其添加項目,所有重載都需要label參數。 我為此傳遞null,因為我不想要段的任何標簽。 然而,圖表仍然從每個段中划出一條線,我認為它應該將它加入到它不存在的標簽中。

有沒有辦法刪除這些線?

提前致謝!

除了分配標簽的任何值(包括null)之外,您還應該使用PieItem.LabelType = PieLabelType.None

例如:

GraphPane myPane = zedGraphControl1.GraphPane;

PieItem pieSlice1 = myPane.AddPieSlice(10, Color.Blue, 0F, "Label1");
PieItem pieSlice2 = myPane.AddPieSlice(15, Color.Orange, 0F, "Label2");
PieItem pieSlice3 = myPane.AddPieSlice(35, Color.Green, 0F, "Label3");
PieItem pieSlice4 = myPane.AddPieSlice(40, Color.DarkGray, 0F, "Label4");

// optional depending on whether you want labels within the graph legend
myPane.Legend.IsVisible = false;

pieSlice1.LabelType = PieLabelType.None;
pieSlice2.LabelType = PieLabelType.None;
pieSlice3.LabelType = PieLabelType.None;
pieSlice4.LabelType = PieLabelType.None;

zedGraphControl1.AxisChange();
zedGraphControl1.Invalidate();


highLine.Symbol.Type = SymbolType.Circle;
highLine.Symbol.Fill.IsVisible = false;
highLine.Symbol.Border.Width = 2F;
highLine.Symbol.Size = 16F;

zedGraphControl1.AxisChange();
zedGraphControl1.Invalidate();

以下是生成的餅圖:

餅圖沒有標簽

以下是一些ZedGraph參考:

最近遇到了類似的問題。 以下是我如何解決它:

GraphPane myPane = zedGraphControl1.GraphPane;

myPane.AddPieSlices(new double[] { 10, 25, 25, 40 }, new[] { "1", "2", "3", "4" });
myPane.Legend.IsVisible = false;
foreach (var x in myPane.CurveList.OfType<PieItem>())
    x.LabelType = PieLabelType.None; 

zedGraphControl1.AxisChange();
zedGraphControl1.Invalidate();

您可以在循環中方便地更改值。

對不起我的英語不好

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM