I have a lot of charts i am graphing and for some i need to give each X value a custom color and have that item in the legend as well. The following code achieves this but on the legend there is always the first default value which is now pointless. How would i remove/hide/clear that original default legend item? Just for reference the chartColors array is just an array of colors to cycle through.
mainChart.Legends.Add(new Legend("legend"));
mainChart.Legends["legend"].Docking = Docking.Bottom;
foreach (Series ser in mainChart.Series)
{
int i = 0;
foreach (DataPoint point in ser.Points)
{
point.Color = chartColors[i % chartColors.Count()];
mainChart.Legends["legend"].CustomItems.Add(point.Color,point.AxisLabel);
i++;
}
}
According to http://msdn.microsoft.com/en-us/library/vstudio/dd456659(v=vs.100).aspx
"Legend items in this collection are always attached to the end of other legend items in the legend. "
so to maybe clarify my question, how do i remove the "other legend items"
edit: I found this answer but it is for winforms and im not sure how to call the function they add