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
No Data
Reply
  • 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.

Children