Here's my sample code, called after InitializeComponent. It seems to have no effect, as the legend text is always the series name. How do I change the legend text? Is this a bug? Any workaround? It's a line graph only.
Hashtable labelHash = new Hashtable(); labelHash.Add("CURRENTVALUE", new LineChartCurrentValueRenderer(this)); mChart.LabelHash = labelHash; mChart.Legend.FormatString = "<CURRENTVALUE>";
I realise this is an old thread, but I've hit the same problem, and a solution here would have saved a lot of time!
It appears to be a bug. If the chart is bound to a series collection, then FormatString doesn't work for the legend. It's OK if you bind to a datasource.
Additionally, the ChartDrawitem event does get called OK for the legend labels, but there's no indication of what they refer to (no series, column etc. fields are completed) Thus it's hard to know you're dealing with a label, if you want to attempt do some reformatting in that draw event.
i'm not sure what would cause this. are you sure this isn't a composite chart (ChartType = Composite)? could you post a sample project?
Yeah it wasn't getting called at all. In fact, when I modified just the FormatString (not a custom renderer), it didn't even change what was shown in the legend text. It seems to be getting ignored.
that code looks good to me. is your LineChartCurrentValueRenderer's ToString method not getting called?