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
630
Obtaining the X value and Y value in an IRenderLabel for a composite scatter chart.
posted

I have a composite scatterchart that produces several lines (ConnectWithLines=true) series. I have created a single X Axis to use on each of thes series and added an IRenderLabel class to this axis:

MyLabelHashTable.Add("X_LABEL",XAxisRenderer);

xAxisLine.Labels.ItemFormat = AxisItemLabelFormat.Custom

xAxisLine.Labels.ItemFormatString = "<X_Label>";

 

My input Dataseries is an XYSeries:

 

 

ChartLayerAppearance

 

CL_Line = new ChartLayerAppearance();

 

 

XYSeries thisSeries = new XYSeries();

 

thisSeries.Data.DataSource = dataseries;

thisSeries.Data.ValueXColumn = ValueXColumn;

thisSeries.Data.ValueYColumn = ValueYColumn;

thisSeries.Data.LabelColumn = labelColumn;

thisSeries.Label = dataseries.TableName;

thisSeries.DataBind();

mychart.Series.Add(thisSeries);

CL_Line.ChartType =

ChartType.ScatterChart;

 

In my XLabelRender class I see 12 items in my context array in the ToString(). 1 is the data_value. However I would like to get both the X value and Y value to format my X label string but cannot not seem to find them. I would expect to see an X value and Y Value since its a scatterchart type. Am I missing something?

Parents
  • 2406
    posted

    Hi,

    I'm not sure what exactly you want to achieve. If you set an IRenderLabel object to an axis Labels, you have access only to the axis values which depends on the axis type. If you want to access both X value and the Y value, you could do it only in the data points labels, i.e. when setting the ChartText ItemFormatString to an IRenderLabel object:

    this.UltraChart1.ScatterChart.ChartText[0].Visible = true;
    this.UltraChart1.ScatterChart.ChartText[0].Column = -2;
    this.UltraChart1.ScatterChart.ChartText[0].Row = -2;
    this.UltraChart1.ScatterChart.ChartText[0].ItemFormatString = "<MY_VALUE>";

    Hashtable MyLabelHashTable = new Hashtable();
    MyLabelHashTable.Add("MY_VALUE", new MyLabelRenderer());
    this.UltraChart1.LabelHash = MyLabelHashTable;

    Here is a sample IRenderLabel class declaration:

        public class MyLabelRenderer : IRenderLabel
        {
            public string ToString(Hashtable context)
            {  
                string xValue = context["DATA_VALUE_X"].ToString();
                string yValue = context["DATA_VALUE_Y"].ToString();
                return xValue.ToString() + " x " + yValue.ToString();
            }
        }

    Let me know if you have further questions.

  • 630
    Offline posted in reply to [Infragistics] Sandman

    Hi Petia,

    I am trying another way to obtain/calulate the value that I need and this might be simpilier.

    What I am trying to accomplish is very similar to this post:

    https://es.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/20848/text-labels-on-the-x-axis-in-a-scatter-chart/113800#113800

    This chart has 5 XYSeries with  with its  ScatterChartAppearance .ConnectWithLines=true.

    The XYSeries has its Data.ValueXColumn and Data.ValueYColumn set to the columns containing the points, which works as expected. I also set the Data.LabelColumn = the date Column in the DataTable (which I was trying to obatain using both the X and Y datapoints).

    I have been using an IRenderLabel class to customize the spacing and text of the XAxis. Each of my 5 ChartLayerAppearances use the same X Axis which has the IRenderLabel class: xAxisLine.Labels.ItemFormatString = "<X_LABEL>"

    In my ToString() method I was expecting to see the value of the series LabelColumn in the Context[ITEM_LABEL] but it is null.

    I tried to set my ChartText ItemFormatString to use the IRenderLabel Class like you suggested but it never called the ToString() method.

    By the Way- the time you see on the chart: 11:03 is just a placeholder (the current time) until I can get the correct value.

Reply Children