Completed
Last Updated: 27 Sep 2022 13:31 by ADMIN
Release R3 2022
Dimitrios
Created on: 20 Jul 2022 08:23
Category: ChartView
Type: Bug Report
0
RadChartView: Visual PolarPointElement is not correctly associated with the PolarDataPoint

Please refer to the attached sample project. Try to select a point.

Expected result: the clicked point should be colored in red.

Actual result: a random point is colored in red even though the label is colored correctly. The attached gif file illustrates the observed result.


1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 27 Sep 2022 13:26

Hi,

The possible workaround until a fix is provided is to use the following custom rendering:

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

        public class CustomPolarRenderer : PolarRenderer
        {
            public CustomPolarRenderer(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 CustomPolarPointSeriesDrawPart((PolarPointSeries)linePart.Element, this);
                    }
                }
            }

        }

        public class CustomPolarPointSeriesDrawPart : PolarPointSeriesDrawPart
        {
            public CustomPolarPointSeriesDrawPart(PolarPointSeries series, IChartRenderer renderer) : base(series, renderer)
            {
            }

            protected override void DrawPoints()
            {
                PointF[] points = this.GetPointsPositionsArray();

                if (points == null)
                {
                    return;
                }

                RadGdiGraphics radGraphics = new RadGdiGraphics(this.Renderer.Surface as Graphics);
                List<DataPointElement> pointElements = new List<DataPointElement>();
                DataPointElementLayoutSlotComparer comparer = new DataPointElementLayoutSlotComparer();

                if (this.Renderer is CartesianRenderer)
                {
                    comparer.Vertical = ((CartesianRenderer)this.Renderer).Area.Orientation == Orientation.Vertical;
                }

                comparer.Collection = this.Element.DataPoints; 

                for (int i = 0; i < this.Element.Children.Count; i++)
                {
                    DataPointElement childElement = this.Element.Children[i] as DataPointElement;

                    if (childElement == null || !childElement.IsVisible || childElement.PointSize.Width < 1f || childElement.PointSize.Height < 1f)
                    {
                        continue;
                    }

                    SizeF pointSize = childElement.PointSize;
                    PointF pointLocation = points[i];

                    RectangleF ptRect = new RectangleF(pointLocation, pointSize);
                    ptRect.Offset(pointSize.Width / -2f, pointSize.Height / -2f);

                    if (childElement.BackgroundShape != null)
                    {
                        childElement.BackgroundShape.Paint((Graphics)radGraphics.UnderlayGraphics, ptRect);
                    }

                    GraphicsPath pointPath = null;

                    if (childElement.Shape != null)
                    {
                        pointPath = childElement.Shape.CreatePath(ptRect);
                    }
                    else
                    {
                        pointPath = new GraphicsPath();
                        pointPath.AddEllipse(ptRect);
                    }

                    if (pointPath != null)
                    {
                        Telerik.WinControls.Primitives.FillPrimitiveImpl pointFill = new Telerik.WinControls.Primitives.FillPrimitiveImpl(childElement, null);
                        pointFill.PaintFill(radGraphics, pointPath, ptRect);

                        Telerik.WinControls.Primitives.BorderPrimitiveImpl pointBorder = new Telerik.WinControls.Primitives.BorderPrimitiveImpl(childElement, null);
                        pointBorder.PaintBorder(radGraphics, null, pointPath, ptRect);

                        if (childElement.Image != null)
                        {
                            Telerik.WinControls.Primitives.ImagePrimitiveImpl pointImage = new Telerik.WinControls.Primitives.ImagePrimitiveImpl(childElement);
                            pointImage.PaintImage(radGraphics, childElement.Image, ptRect, childElement.ImageLayout, childElement.ImageAlignment, childElement.ImageOpacity, false);
                        }

                        pointPath.Dispose();
                    }
                }
            }
        }

I hope this information helps. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.