This is a migrated thread and some comments may be shown as answers.
ChartView Line Chart Label position to Offset in to the left
2 Answers 25 Views
This is a migrated thread and some comments may be shown as answers.
Dominic
Top achievements
Rank 1
Dominic asked on 20 May 2020, 07:13 AM

How for I offset ChartView Line Chart Label position more to the left of the datapoint ?

Meaning how do I move the label further left of the datapoint ?

 

2 Answers, 1 is accepted

Sort by
0
Nadya
Telerik team
answered on 21 May 2020, 01:58 PM

Hello Dominic,

In order to achieve this, you can subscribe to the LabelFormatting event and in the handler manually move the label to the left. This can be done by setting a proper value to the PointLabelElement.PosittionOffset property. Please refer to the following example that uses LineSeries to plot the data points:

 public RadForm1()
 {
     InitializeComponent();

     LineSeries lineSeries = new LineSeries();
     lineSeries.DataPoints.Add(new CategoricalDataPoint(21, "Jan"));
     lineSeries.DataPoints.Add(new CategoricalDataPoint(22, "Apr"));
     lineSeries.DataPoints.Add(new CategoricalDataPoint(12, "Jul"));
     lineSeries.DataPoints.Add(new CategoricalDataPoint(15, "Oct"));
     this.radChartView1.Series.Add(lineSeries);
     LineSeries lineSeries2 = new LineSeries();
     lineSeries2.DataPoints.Add(new CategoricalDataPoint(18, "Feb"));
     lineSeries2.DataPoints.Add(new CategoricalDataPoint(15, "Apr"));
     lineSeries2.DataPoints.Add(new CategoricalDataPoint(17, "Jul"));
     lineSeries2.DataPoints.Add(new CategoricalDataPoint(22, "Oct"));
     lineSeries2.DataPoints.Add(new CategoricalDataPoint(30, "Nov"));
     this.radChartView1.Series.Add(lineSeries2);
     lineSeries.ShowLabels = true;
     lineSeries2.ShowLabels = true;

     this.radChartView1.LabelFormatting += this.RadChartView1_LabelFormatting;
 }

 private void RadChartView1_LabelFormatting(object sender, ChartViewLabelFormattingEventArgs e)
 {
     PointLabelElement pointLabel = e.LabelElement as PointLabelElement;
     if (pointLabel != null)
     {
         pointLabel.PositionOffset = new PointF(-10, 0);
         pointLabel.DataPointElement.PointSize = new SizeF(10, 10);
     }
 }

I hope this helps. Should you have other questions do not hesitate to ask.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Dominic
Top achievements
Rank 1
answered on 01 Jun 2020, 03:16 AM
Ok thanks for your reply :)
Asked by
Dominic
Top achievements
Rank 1
Answers by
Nadya
Telerik team
Dominic
Top achievements
Rank 1
Share this question
or