Completed
Last Updated: 04 Jan 2017 19:14 by ADMIN
ADMIN
Dimitar
Created on: 21 Dec 2016 11:11
Category: ChartView
Type: Bug Report
1
FIX. RadChartView - the selection controller does not work with polar series.
To reproduce:
- Add polar series and selection controller


Workaround:

private void RadChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e)
{
    e.Renderer = new MyPolarRenderer(e.Area as PolarArea);
}

class MyPolarRenderer : PolarRenderer
{
    public MyPolarRenderer(PolarArea area) : base(area)
    { }

    public override DataPoint HitTest(int x, int y)
    {
        for (int i = 0; i < this.DrawParts.Count; i++)
        {
            DataPoint dataPoint = this.DrawParts[i].HitTest(new Point(x, y));
            if (dataPoint != null)
            {
                return dataPoint;
            }
        }

        return base.HitTest(x, y);
    }
    protected override void Initialize()
    {
        base.Initialize();
        for (int i = 0; i < this.DrawParts.Count; i++)
        {
            PolarPointSeriesDrawPart linePart = this.DrawParts[i] as PolarPointSeriesDrawPart;
            if (linePart != null)
            {
                this.DrawParts[i] = new MyDrawpart((PolarPointSeries)linePart.Element, this);
            }
        }
    }

}
class MyDrawpart : PolarPointSeriesDrawPart
{
    public MyDrawpart(PolarPointSeries series, IChartRenderer renderer) : base(series, renderer)
    { }
    public override DataPoint HitTest(Point location)
    {
        if (this.Element.PointSize.Width == 0 || this.Element.PointSize.Height == 0)
        {
            return null;
        }

        for (int i = 0; i < this.Element.DataPoints.Count; i++)
        {
            RadRect slot = this.Element.DataPoints[i].LayoutSlot;
            float pointHalfWidth = this.Element.PointSize.Width / 2;
            float pointHalfHeight = this.Element.PointSize.Height / 2;

            RectangleF dataPointBounds = new RectangleF((float)(slot.X - pointHalfWidth), (float)(slot.Y - pointHalfHeight), this.Element.PointSize.Width, this.Element.PointSize.Height);

            if (dataPointBounds.Contains(location.X, location.Y))
            {
                return this.Element.DataPoints[i];
            }
        }

        return base.HitTest(location);
    }
}
0 comments