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
1365
Show data value of single point
posted

Dear experts,

I've followed the following example from this forum (because i'm learning to use the UltraChart):

this.ultraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.ScatterChart;

XYSeries series1 = new XYSeries();

series1.Points.Add(new XYDataPoint(1, 0.1, "", false));

series1.Points.Add(new XYDataPoint(2, 0.2, "", false));

XYSeries series2 = new XYSeries();

series2.Points.Add(new XYDataPoint(3, 0.2, "", false));

series2.Points.Add(new XYDataPoint(4, 0.3, "", false));

this.ultraChart1.Series.Add(series1);

this.ultraChart1.Series.Add(series2);

Works fine. In the wizard you can check that you want to "Show data value on chart". This will show ALL data values per point in the chart. But for a real world problem of mine I would like to show the 'data value'  of a single point of 1 serie on the chart.

So for example in the above code, if I would like to show the data value of the 2nd point in series 1. How would I do that?

Thank you very much in advance for answering.

Parents
No Data
Reply
  • 5118
    Verified Answer
    posted

    Hi,

    I would probably just add a text primitive to the chart and position it over that point.  Something like this:

    private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
            {
    
                SceneGraph scene = e.SceneGraph;
                PointSet ps = null;
                for (int i = scene.Count - 1; i >= 0; i--)
                {
                    ps = scene[i] as PointSet;
                    if (ps != null && ps.Series.Key == "series2")
                    {
                        DataPoint dp = ps.points[1];
                        Point p = dp.point;
                        p.Offset(-4, 0);
                        Infragistics.UltraChart.Core.Primitives.Text tprim = new Text(p, ((object[]) dp.Value)[0].ToString());
                        
                        e.SceneGraph.Add(tprim);
                    }
                }
            }
Children