This is a migrated thread and some comments may be shown as answers.

Specifying legend text at runtime

1 Answer 161 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
drodriguez
Top achievements
Rank 1
drodriguez asked on 11 Jul 2007, 05:06 PM
I would like to know how do I specify legend item text at runtime. When I bind a data object to a chart, it automatically binds the wrong data to the legend. I would like to have control over this.

1 Answer, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 12 Jul 2007, 02:52 PM
Hi drodriguez,

To add a custom legend item you can use the following code snippet:

            Dim customLegendItem As Telerik.Charting.LabelItem 
        customLegendItem = New Telerik.Charting.LabelItem() 
        customLegendItem.TextBlock.Appearance.TextProperties.Font = New Font("Arial", 8) 
        customLegendItem.Marker.Appearance.FillStyle.MainColor = Color.Blue 
        customLegendItem.Marker.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid 
        customLegendItem.Marker.Appearance.Figure = "Diamond" 
        customLegendItem.Marker.Appearance.Visible = True 
        customLegendItem.TextBlock.Text = "  Custom Legend Item" 


Eventually if the series name appears in the legend you have to set the LegendDisplayMode property of the series to Nothing. For example:

    Me.chart1.Series(0).Appearance.LegendDisplayMode =     Telerik.Charting.ChartSeriesLegendDisplayMode.Nothing

Greetings,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
drodriguez
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Share this question
or