Hi,
I have recently started using the UltraWinChart (Line Chart) for my project and we have a client requirement as follows.
We have multiple lines on a line Chart and legends corresponding to each on.
The user should be allowed to turn on/off a perticular line by clicking on the corresponding Legend.
Example: suppose i have two line on the line chart and two legends (one for each line), now if i click on legend-,1 line-1 should disappear and legend color fades and click back again brings up the line and Legend shows an active color.
Could you please suggest how this can be done in UltraWinChart?
Thanks & regards,
Kshitiz Pandey
Try setting e.Primitive.Value = 0.0 in your ChartDrawItem handler.
I'm not quite sure because it looks like you're using version 6.2 ... but I think you also need to set the Layer property of the Legend primitives. you might need to do this using the FillSceneGraph event instead of ChartDrawItem, because the best way to set the layer property is:
legendPrimitive.Layer = e.ChartCore.GetChartLayer();
I tried the suggested method to make the legends clickable, how ever am facing an issue. Here is what I did.
private void uChartViewData_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e) {
if (e.Primitive.Path != null && e.Primitive.Path.IndexOf("Legend") != -1) {
e.Primitive.Caps |= PCaps.HitTest|PCaps.Tooltip;
if (e.Primitive.Row == -1 && e.Primitive.Column == -1) {
e.Primitive.Row = e.Primitive.Column = 0;
}
e.Primitive.Chart = uChartViewData.ChartType;
Now whenever I point to legend i get an exception of "Null Reference Exception" and my application restarts.
Exception Source: "Infragistics2.Win.UltraWinChart.v6.2"
Stack Trace: @ at Infragistics.UltraChart.Core.ChartCore.GetChartInfoFromPrimitive(Primitive prim)
I also tried to assign value to the Primitive [Legend]
e.Primitive.Value = new object();
in which case the exception does not arise but Legend does not become click-able. i.e on clicking the Legend the breakpoint @ uChartViewData_ChartDataClicked()................ does not get hit.
Could you please suggest incase I am making a mistake somewhere.
I need this fix urgently. thanks in advance.
Regards,
Hi Kshitiz,
You could find a similar scenarios in the following threads:
http://community.infragistics.com/forums/p/1736/13413.aspx#13413
http://community.infragistics.com/forums/p/41045/228994.aspx#228994
Let me know if this helps.