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

Are StepLine charts supported with the Winforms ChartView control

1 Answer 20 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Krisztian
Top achievements
Rank 1
Krisztian asked on 26 Nov 2013, 03:34 PM
I was wondering if steplines are supported in this control. Thanks in advance, Krisztian

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Nov 2013, 12:17 PM
Hello Krisztian,

Thank you for contacting Telerik Support.

The Step Line chart type is currently not supported. However, this is a quite reasonable request and therefore I have it in our Public Issue Tracking System - PITS. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - PITS item.

I have also updated your Telerik points for the co-operation. 

Currently, a possible solution that I can propose is use custom CartesianRenderer:
public Form1()
{
    InitializeComponent();
 
    this.radChartView1.CreateRenderer += radChartView1_CreateRenderer;
 
    LineSeries lineSeries = new LineSeries();
    lineSeries.BorderColor = Color.Black;
    lineSeries.DataPoints.Add(new CategoricalDataPoint(20, "Jan"));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(42, "Apr"));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(34, "Jul"));
    lineSeries.DataPoints.Add(new CategoricalDataPoint(25, "Oct"));
    this.radChartView1.Series.Add(lineSeries);
 
    LineSeries lineSeries2 = new LineSeries();
    lineSeries2.BorderColor = Color.Red;
    lineSeries2.DataPoints.Add(new CategoricalDataPoint(18, "Jan"));
    lineSeries2.DataPoints.Add(new CategoricalDataPoint(5, "Apr"));
    lineSeries2.DataPoints.Add(new CategoricalDataPoint(13, "Jul"));
    lineSeries2.DataPoints.Add(new CategoricalDataPoint(20, "Oct"));
    this.radChartView1.Series.Add(lineSeries2);
}

private void radChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e)
{
    e.Renderer = new CustomCartesianRenderer((CartesianArea)e.Area);
}
 
public class CustomCartesianRenderer : CartesianRenderer
{
    public CustomCartesianRenderer(CartesianArea area) : base(area)
    {
    }
 
    protected override void Initialize()
    {
        base.Initialize();
 
        for (int i = 0; i < this.DrawParts.Count; i++)
        {
            LineSeriesDrawPart drawPart = this.DrawParts[i] as LineSeriesDrawPart;
            if (drawPart != null)
            {
                this.DrawParts[i] = new CustomLineDrawPart((LineSeries)drawPart.Element, this);
            }
        }
    }
}
 
public class CustomLineDrawPart : LineSeriesDrawPart
{
    public CustomLineDrawPart(LineSeriesBase series, IChartRenderer renderer) : base(series, renderer)
    {
    }
     
    protected override System.Drawing.Drawing2D.GraphicsPath GetLinePath()
    {
        PointF[] points = GetPointsPositionsArray();
        GraphicsPath path = new GraphicsPath();
        PointF x;
        PointF y;
 
        if (points.Length > 1)
        {
            for (int i = 1; i < points.Length; i++)
            {
                x = points[i - 1];
                y = points[i];
                path.AddLine(x.X, x.Y, y.X, x.Y);
                path.AddLine(y.X, x.Y, y.X, y.Y);
            }
        }
        else
        {
            return null;
        }
 
        return path;
    }
}

You can find more information about custom rendering in RadChartView in the referred help article.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ChartView
Asked by
Krisztian
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or