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
75
IRenderLabel and Composite Scatter Chart
posted

Hi,  I’m trying to implement  the  Y-axis  inversion  according to techniques suggested in this forum and  help documentation.  

I’m referring to  Winforms release 2010.2

The technique first suggests to change the sign of values (-1 *):  

no problem, of course.

Then –using IRenderLabel- reverse Y labels too. 

This should be done as follows:

1.      Set the appropriate FormatString property to a unique string value enclosed by "<" and ">" characters.

2.      Create a Hashtable with an entry containing that unique string value without the "<" and ">" characters, and an instance of an IRenderLabel implementation.

3.      Set the UltraChart.LabelHash property value to the Hashtable containing the IRenderLabel implementation.

 

This is my implementation,

1:  added to  the Form where is Ultrachart1

Public Class MyLabelRenderer

    Implements IrenderLabel

    Public Overloads Function ToString(ByVal context As Hashtable) _

      As String Implements IRenderLabel.ToString

        Dim itemLabel As Double = -1 * CDbl(context("REV_VALUE"))

        Return CStr(itemLabel)

    End Function

End Class

 

2.

I set up a  scatter chart with one chartArea and several layers

       ‘ … code setting up composite chart,  

       ‘ including <DATA_VALUE> default definition …

       ‘ up to

        myChartArea.Axes.Add(axisX)

        myChartArea.Axes.Add(axisY)

       ' +++++++++++++++++++++++++++++++++++++++++++

1      If bzCurv.grand = 4 Then

2          Dim yAxis As AxisItem = myChartArea.Axes(1)

3          yAxis.Labels.ItemFormat = AxisItemLabelFormat.Custom

4          yAxis.Labels.ItemFormatString = "<REV_VALUE:####0.>"

5      End If

 

6      Dim MyLabelHashTable As New Hashtable()

 

7      MyLabelHashTable.Add("REV_VALUE", New MyLabelRenderer())

8        Me.UltraChart1.LabelHash = MyLabelHashTable

       ' +++++++++++++++++++++++++++++++++++++++++++

 

This doesn’t work : the chart is replaced by the red cross

 

Since I didn’t  find  an example concerning  composite chart axis  I’m asking if you see where I make a mistake

I believe the  class MyLabelRenderer is correct. 

My doubts are about the code lines with line number.

·         this numbered code is placed in a Init.. method called by Form_Load

·         the test in line 1  tells the type of  chart where this inversion is needed

·         the following definitions are referred to the Y axis of myChartArea

·         6,7, 8 ?

 

Thanks in advance for any help

Best regards,  Marco Brazzelli