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

How to draw on the chartview

2 Answers 56 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 08 Apr 2015, 06:50 PM

I'm trying to have a range of my chart. The range as a slope of y = ax+b, plus a tolerance for the width of the band.

I know that I can draw a line with 2 points, but I'm trying to achieve something like the picture attached knowing that the user will be able to change the slope and tolerance via two spineditor.

 

Thanks

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 09 Apr 2015, 04:22 PM
Hi Vincent,

Thank you for contacting us.

The easiest way to achieve this is to add an additional RangeSeries to the chart. For example:
public RadForm1()
{
    InitializeComponent();
    LineSeries lineSeries = new LineSeries();
    lineSeries.DataPoints.Add(new CategoricalDataPoint(20, 30));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(22, 40));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(12, 50));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(19, 60));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(6, 70));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(35, 80));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(60, 90));
    lineSeries.PointSize = new SizeF(10f,10f);
    lineSeries.BorderColor = Color.Transparent;
    this.radChartView1.Series.Add(lineSeries);
 
    this.radChartView1.Series.Add(BuildRange());
}
double tolernace = 10;
public RangeSeries BuildRange()
{
    var series = radChartView1.Series[0];
 
    RangeSeries rangeSeries = new RangeSeries();
 
    for (int i = 0; i < series.DataPoints.Count; i++)
    {
        CategoricalDataPoint point = series.DataPoints[i] as CategoricalDataPoint;
 
        rangeSeries.DataPoints.Add(new RangeDataPoint((double)point.Value + tolernace, (double)point.Value - tolernace,point.Category));
    }
    return rangeSeries;
}

The result is shown in the attached image.

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Vincent
Top achievements
Rank 1
answered on 10 Apr 2015, 02:56 PM
Thanks for the help, it's working!
Tags
ChartView
Asked by
Vincent
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Vincent
Top achievements
Rank 1
Share this question
or