Completed
Last Updated: 03 Jun 2015 10:01 by ADMIN
ADMIN
Dimitar
Created on: 02 Jun 2015 06:26
Category: ChartView
Type: Bug Report
0
FIX. RadChartView - the step-line series is not rendered correctly when only two data points are added.
To reproduce
- Add step-line series with two data points.

Workaround:
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++)
        {
            SteplineDrawPart linePart = this.DrawParts[i] as SteplineDrawPart;
            if (linePart != null)
            {
                this.DrawParts[i] = new CustomDrawPart((SteplineSeries)linePart.Element, this);
            }
        }
    }
}

public class CustomDrawPart : SteplineDrawPart
{
    public CustomDrawPart(LineSeriesBase series, IChartRenderer renderer)
        : base(series, renderer)
    {
    }
    protected override System.Drawing.Drawing2D.GraphicsPath GetLinePaths(PointF[] points)
    {
        //return base.GetLinePaths(points);
        GraphicsPath path = new GraphicsPath();

         if (points.Length > 1)
        {
            if (this.Element is LineSeries && ((LineSeries)this.Element).Spline)
            {
                path.AddCurve(points, ((LineSeries)this.Element).SplineTension);
            }
            else
            {
                bool isVertical = this.Element.View.GetArea<CartesianArea>().Orientation == System.Windows.Forms.Orientation.Vertical;

                for (int i = 1; i < points.Length; i++)
                {
                    PointF x = points[i - 1];
                    PointF y = points[i];

                    if (isVertical)
                    {
                        path.AddLine(x.X, x.Y, y.X, x.Y);
                        path.AddLine(y.X, x.Y, y.X, y.Y);
                    }
                    else
                    {
                        path.AddLine(x.X, x.Y, x.X, y.Y);
                        path.AddLine(x.X, y.Y, y.X, y.Y);
                    }
                }
            }
        }
        else
        {
            return null;
        }

        return path;
    }
}
//change like this
void radChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e)
{
    e.Renderer = new CustomCartesianRenderer((CartesianArea)e.Area);
}
 
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments