0
votes

With Fusion Charts, there is a click event that can toggle the visibility of the legend. Is this same functionality available for MSchart, Rgraph, and Telrik? I haven't been able to figure out how to do this.

1

1 Answers

0
votes

I can only answer for MS Chart.

If you are using the Windows Forms version built in to the .NET 4 Framework, you can programmatically remove the legend(s) by clearing the Chart.Legends collection:

_chart.Legends.Clear();

This will remove any Legend object from the chart, so if you want to switch between displaying and not displaying the legend, you would need to save the Legend object locally and Add it to the collection when you want to display it again.
(Alternatively, it is also possible to remove the Legend object from the Legends collection directly in the designer.)

If you are using the WPF version available in the WPF Toolkit, probably the most convenient way to hide the legend is to set the Width and the Height in the Chart.LegendStyle to zero in XAML:

<chartingToolkit:Chart.LegendStyle>
    <Style TargetType="Control">
        <Setter Property="Width" Value="0"/>
        <Setter Property="Height" Value="0"/>
    </Style>
</chartingToolkit:Chart.LegendStyle>

In order to re-display, the Width and Height need to be set to non-zero values. In contrast to the Windows Forms chart, you need not re-define the Legend object with this approach.