Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Stuck on changing legend labels
posted

Hi,

i'm trying to set/edit the legend labels of my UltraChart (Infragistics2.WebUI.UltraWebChart.v8.3 : Infragistics.WebUI.UltraWebChart) by using different techniques, but none of them seems to work.

The chart type i'm using is the StackColumnChart (2D).

I'm using the NumericDataPoint class to fill the chart (no dataset):

...

series.Points.Add(New NumericDataPoint(5.0, labelId, False))

chart.Series.Add(series)

 

 This results in a legend having the same labels that where set to the data points label.

I tried to set the label by using the DrawItemEvent:

 

         Dim handler As New Infragistics.UltraChart.Shared.Events.ChartDrawItemEventHandler(AddressOf DrawItem)
            AddHandler Chart.ChartDrawItem, handler

...

 Private Sub DrawItem(ByVal sender As Object, ByVal args As Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs)
            Dim _text As Text = TryCast(args.Primitive, Text)
            If Not _text Is Nothing AndAlso Not String.IsNullOrEmpty(_text.Path) AndAlso _text.Path.EndsWith("Legend") AndAlso Not _text.Column = -1 Then
                Dim labelIdAs Long = CLng(_text.Value)
                If _labelDictionary.ContainsKey(labelId) Then
                    _text.Value = _labelDictionary(labelId).Name
                End If
            End If
        End Sub

 

But the legend labels never appeared.

After that i tried to get it done by using the IRenderLabel interface:

 ....

            Dim labelRenderers As New Hashtable
            labelRenderers.Add("CUSTOM", New LabelRenderer(_labelDictionary))
            Chart.LabelHash = labelRenderers
            Chart.Legend.FormatString = "<CUSTOM>"

....

     Public Class LabelRenderer
        Implements Infragistics.UltraChart.Resources.IRenderLabel

        Private _labelDictionary As IDictionary(Of Long, NamedObject)

        Public Sub New(ByVal labels As IDictionary(Of Long, NamedObject))
            _labelDictionary = labels
        End Sub

        Public Function ToString1(ByVal context As System.Collections.Hashtable) As String Implements    Infragistics.UltraChart.Resources.IRenderLabel.ToString
            Dim label As String = Convert.ToString(context("ITEM_LABEL"))
            If Not String.IsNullOrEmpty(label) Then
                Dim labelId As Long = CLng(label)
                If _labelDictionary.ContainsKey(labelId) Then
                    label = _labelDictionary(labelId).Name
                End If
            End If
            Return label
        End Function
    End Class

 

but that did not work either. The labelRenderers ToString-Method never gets called in contrast to the DrawItem-Method which seems to work for everything else than the legend labels/primitives.

I'm totally stuck there.

Thanks in advance for any help.

Parents Reply Children
No Data