Completed
Last Updated: 23 Jul 2015 12:59 by ADMIN
ADMIN
Hristo
Created on: 23 Jun 2015 08:27
Category: ChartView
Type: Bug Report
0
FIX. RadChartView - clip region in ChartSeriesDrawPart not restored in the Draw method
Workaround: create a custom BarSeriesDrawPart  and override the Draw method

public class CustomBarSeriesDrawPart : BarSeriesDrawPart
{
    public CustomBarSeriesDrawPart(BarSeries series, IChartRenderer renderer)
        : base(series, renderer)
    { }

    public override void Draw()
    {
        bool shouldDraw = IsElementValid();
        if (shouldDraw)
        {
            Graphics graphics = this.Renderer.Surface as Graphics;
            GraphicsState state = graphics.Save();
            Region clipRegion = graphics.Clip;

            CartesianSeries cartesianSeries = this.Element as CartesianSeries;
           

            if (cartesianSeries != null)
            {
                FieldInfo fi = cartesianSeries.GetType().GetField("area", BindingFlags.NonPublic | BindingFlags.Instance);
                CartesianArea  area = fi.GetValue(cartesianSeries) as CartesianArea;
                MethodInfo mi = area.GetType().GetMethod("GetCartesianClipRect", BindingFlags.NonPublic | BindingFlags.Instance);
                mi.Invoke(area, null);

                RectangleF clipRect = (RectangleF)mi.Invoke(area, null); 
                graphics.Clip = new Region(clipRect);
            }

            DrawSeriesParts();

            graphics.Clip = clipRegion;
            graphics.Restore(state);
        }
    }
}
0 comments