Hi
I'm building a .net app with VB 2019.
With RadChartView, for some unknown reason, I can't change the Font on the Legend
Nor can I set the exact legend position when using following code
With myRadChartView
.ShowLegend = True
.ChartElement.LegendElement.Font = New Font("Arial", 12.0F, FontStyle.Regular)
.ChartElement.LegendPosition = LegendPosition.Float
.ChartElement.LegendOffset = New Point(1600, 300)
end with
NB: This was not working with previous release either.
Hi,
The feedback item is closed due to inactivity.
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Setting the LegendElement.TitleElement.Font property will affect the title's font. As to the legend's items, it is necessary to handle the LegendElement.VisualItemCreating event and apply the desire font for the respective visual legend element. I have prepared a sample code snippet for your reference. Please refer to the below code snippet.
Feel free to have a look at the following article demonstrating how to customize the legend:
https://docs.telerik.com/devtools/winforms/controls/chartview/features/legend#customize-legend
You can set the legend to float over the chart view. Here is how to set the legend to stay at position 1600, 300 over the chart area.
Sub New()
' This call is required by the designer.
InitializeComponent()
AddHandler Me.RadChartView1.ChartElement.LegendElement.VisualItemCreating, AddressOf LegendElement_VisualItemCreating
Dim barSeries As New Telerik.WinControls.UI.BarSeries("Performance", "RepresentativeName")
barSeries.LegendTitle = "Q1"
barSeries.DataPoints.Add(New CategoricalDataPoint(177, "Harley"))
barSeries.DataPoints.Add(New CategoricalDataPoint(128, "White"))
barSeries.DataPoints.Add(New CategoricalDataPoint(143, "Smith"))
barSeries.DataPoints.Add(New CategoricalDataPoint(111, "Jones"))
barSeries.DataPoints.Add(New CategoricalDataPoint(118, "Marshall"))
Me.RadChartView1.Series.Add(barSeries)
Dim barSeries2 As New Telerik.WinControls.UI.BarSeries("Performance", "RepresentativeName")
barSeries2.LegendTitle = "Q2"
barSeries2.DataPoints.Add(New CategoricalDataPoint(153, "Harley"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(141, "White"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(130, "Smith"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(88, "Jones"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(109, "Marshall"))
Me.RadChartView1.Series.Add(barSeries2)
Me.RadChartView1.ShowLegend = True
Me.RadChartView1.LegendTitle = "Legend"
Me.RadChartView1.ChartElement.LegendPosition = LegendPosition.Float
Me.RadChartView1.ChartElement.LegendOffset = New Point(1600, 300)
Me.RadChartView1.ChartElement.LegendElement.TitleElement.Font = f
End Sub
Dim f As New Font("Arial", 12.0F, FontStyle.Regular)
Private Sub LegendElement_VisualItemCreating(sender As Object, e As LegendItemElementCreatingEventArgs)
e.ItemElement = New LegendItemElement(e.LegendItem)
e.ItemElement.TitleElement.Font = f
End Sub
Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.