This is a migrated thread and some comments may be shown as answers.

ScatterLineSeries Point Labels

2 Answers 193 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Adam asked on 24 Jul 2019, 05:28 PM


Is it possible to add labels to points in a ScatterLineSeries? I've been able to add labels to CategoricalDataPoints but not ScatterDataPoints. I noticed that on there are labels for Line, Spline, Area, and SplineArea series, but not for Bar or Scatter.

I added a custom LabelFormatting event that gets called when I use a LineSeries with CategoricalDataPoints, but it doesn't run when I use a ScatterLineSeries with ScatterDataPoints. Here's some sample code I tested (in OpenEdge) and a screenshot of my results:

LabelFormatting method:

METHOD PRIVATE VOID myLabelFormatting(INPUT sender AS System.Object, INPUT e AS ChartViewLabelFormattingEventArgs):
   e:LabelElement:BackColor = System.Drawing.Color:White.
   e:LabelElement:ForeColor = System.Drawing.Color:Black.
   e:LabelElement:BorderColor = System.Drawing.Color:Black.
   e:LabelElement:Font = NEW Font("Segoe Script", 12, FontStyle:Regular).
   DEFINE VARIABLE element AS CartesianLinePointElement NO-UNDO.
   MESSAGE "Casting element..." VIEW-AS ALERT-BOX.
   element = CAST(e:LabelElement:Parent, CartesianLinePointElement).
   DEFINE VARIABLE dataPoint AS ScatterDataPoint NO-UNDO.
   MESSAGE "Casting point..." VIEW-AS ALERT-BOX.
   dataPoint = CAST(element:DataPoint, ScatterDataPoint).
   e:LabelElement:Text = STRING(dataPoint:XValue) + ", " + STRING(dataPoint:YValue).


Sample code:

DEFINE VARIABLE lineSeries AS ScatterLineSeries NO-UNDO.
lineSeries = NEW ScatterLineSeries().
lineSeries:DataPoints:Add(NEW ScatterDataPoint(1, 10)).
lineSeries:DataPoints:Add(NEW ScatterDataPoint(15, 15)).
lineSeries:DataPoints:Add(NEW ScatterDataPoint(5, 20)).
lineSeries:PointSize = NEW SizeF(8, 8).
lineSeries:ShowLabels = TRUE.
radChartView1:BackColor = System.Drawing.Color:LightGray.
radChartView1:ShowLegend = TRUE.




2 Answers, 1 is accepted

Sort by
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Jul 2019, 08:30 AM
Hello, Adam,   

In order to show labels for the ScatterLineSeries, make sure that you set the Label for each ScatterDataPoint. Please refer to the following code snippet:

public RadForm1()
    this.radChartView1.LabelFormatting += radChartView1_LabelFormatting;
    ScatterLineSeries scatterSeries = new ScatterLineSeries();
    scatterSeries.DataPoints.Add(new ScatterDataPoint(15, 19) { Label = "15, 19" });
    scatterSeries.DataPoints.Add(new ScatterDataPoint(18, 10) { Label = "18, 10" });
    scatterSeries.DataPoints.Add(new ScatterDataPoint(13, 15) { Label = "13, 15" });
    scatterSeries.DataPoints.Add(new ScatterDataPoint(10, 8) { Label = "10, 8" });
    scatterSeries.DataPoints.Add(new ScatterDataPoint(5, 2) { Label = "5, 2" });
    scatterSeries.PointSize = new SizeF(8, 8);
    scatterSeries.ShowLabels = true;
private void radChartView1_LabelFormatting(object sender, ChartViewLabelFormattingEventArgs e)
    e.LabelElement.ForeColor = Color.Red;

Note that most of the forum threads are reviewed by Telerik representatives and sometimes we address the questions asked by our customers in the forums as well. However, a post in the forum doesn't guarantee you a response from the Telerik support team. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread. Thank you for your understanding.

I hope this information helps.

Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Top achievements
Rank 1
answered on 25 Jul 2019, 05:16 PM
Thank you! Setting the label for each point fixed my issue.
Asked by
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Top achievements
Rank 1
Share this question