Completed
Last Updated: 02 Jul 2018 09:36 by Dimitar
ADMIN
Dimitar
Created on: 20 Jun 2018 11:29
Category: ChartView
Type: Bug Report
0
FIX. RadChartView - point is selected when clicking outside of its rectangle in a polar chart.
To reproduce:
- Add a polar chart with a selection controller.
- Click near the bottom right corner of the point (10 pixels away)
- The point is selected.

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


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

    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 null;
    }
}



0 comments