tags:

views:

361

answers:

1

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?

+1  A: 

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
Just found this myself. CallingzedGraphControl.GraphPane.CurveList.Clear();Cleared all of the pie items.Thanks.
Zenox
@Zenox: Yes, but you can also remove a specific slice, if that's what you want. See the code I provided.
Dan Tao