0

I am trying to use the ZedGraphControl to create a pie chart. I am able to add pie slices by using the

zedGraphControl.GraphPane.AddPieSlice (30, Color.Red, Color.White, 45f, .0, "Data");

Method, but there does not seem to be any

RemovePieSlice

Or any remove object at all methods. Am I missing something simple, or does this library not allow for the removal of slices?

Kyle
  • 17,317
  • 32
  • 140
  • 246

1 Answers1

1

AddPieSlice returns a PieItem object; the PieItem class inherits from CurveItem. This means you can remove the PieItem via the CurveList property (which is a collection of CurveItem objects).

To remove just one PieItem object:

Dim zgc As ZedGraph.ZedGraphControl = Me.ZedGraphControl1

Dim zgPane As ZedGraph.GraphPane = zgc.GraphPane

Dim zgPieItem As ZedGraph.PieItem = zgPane.CurveList("PieItemLabel")
zgPane.CurveList.Remove(zgPieItem)

To remove all PieItem objects:

Dim zgc As ZedGraph.ZedGraphControl = Me.ZedGraphControl1

Dim zgPane As ZedGraph.GraphPane = zgc.GraphPane

zgPane.CurveList.Clear()
Dan Tao
  • 125,917
  • 54
  • 300
  • 447
  • Just found this myself. Calling zedGraphControl.GraphPane.CurveList.Clear(); Cleared all of the pie items. Thanks. – Kyle Sep 18 '09 at 15:16
  • @Zenox: Yes, but you can also remove a specific slice, if that's what you want. See the code I provided. – Dan Tao Sep 18 '09 at 15:27