C1FlexChart - How to hide major grid lines from the plot area where there is co

Posted by: digiptechnologies on 19 June 2019, 12:30 am EST

  • Posted 19 June 2019, 12:30 am EST

    Hello,

    We want to hide the grid lines inside the column/bar. So the grid lines would be visible throughout the chart but just hide in Column/bar area.

    Please let me know how could we achieve that.

    Thanks,
    Parthiv
  • Replied 19 June 2019, 9:17 pm EST

    Hi Parthiv,

    From what I understand, you wish to prevent the GridLines from rendering over the series data.
    If that's correct then I am researching more over it and discussing about the same with the developer [ID:385382]

    Thanks,
    Ruchir
  • Replied 19 June 2019, 10:25 pm EST

    Hello Ruchir,

    Yes, that's correct. Looking forward to hearing back from you.

    Thanks,
    Parthiv
  • Replied 7 July 2019, 11:05 pm EST

    Hello Ruchir,

    Just checking in, if you have any update.

    Thanks,
    Parthiv
  • Replied 8 July 2019, 4:05 pm EST

    Hello Parthiv,

    There are no updates on this as of now. I have asked the developer to share an update on this case?
    I'll get back to you as soon as there is some information.

    Thanks,
    Ruchir
  • Replied 20 August 2019, 9:58 pm EST

    Hi Parthiv,

    To prevent grid lines from rendering over column/bar, it's possible to move columns to the front after rendering the chart. For this, one should handle the Rendered event and inside invoke SetZIndex method, as follows:
    private void chart_Rendered(object sender, C1.WPF.Chart.RenderEventArgs e)
    {
    // find render canvas
    var cnv = chart.FindFirstChild<C1.WPF.Chart.RenderCanvas>();
    foreach (var item in cnv.Children)
    {
    var rect = item as System.Windows.Shapes.Rectangle;
    if (rect != null)
    {
    // move to the front
    Canvas.SetZIndex(rect, 1);
    //Use opaque fill
    rect.Fill = rect.Stroke;
    }
    }
    }


    ColumnChart.zip

    Best wishes,
    Ruchir
  • Replied 25 August 2019, 4:29 pm EST

    Hello Ruchir,

    Thanks for the solution. But this is not working when I set the chart's render mode to "Direct2D".

    Let me know how can we solve in that case.

    Thanks,
    Parthiv
  • Replied 26 August 2019, 6:21 pm EST

    Hi Parthiv,

    I can see it happening at my end too.
    The reason is, our code to set the ZIndex does not get triggered as the RenderCanvas has child of runtime type when RenderMode is set to Default2D.
    So, I am re-discussing the case with the developer and will let you know as there is any information.

    Thanks,
    Ruchir
  • Marked as Answer

    Replied 29 August 2019, 8:23 pm EST

    Hello Parthiv,

    Developer has shared a solution that uses Chart's Rendered and SymbolRendered events. The approach seems to be working, even with Direct2D RenderMode.
    You're requested to verify the same using the attached sample.

    Best wishes,
    Ruchir
    ColumnChart-Direct2D.zip
  • Replied 1 September 2019, 8:47 pm EST

    Hi Ruchir,

    Thanks for the reply. I have tried the solution you provided but not working.

    I am getting "fld" as null in the below line.

    var fld = chart.GetType().GetField("_chartRenderer", BindingFlags.Instance | BindingFlags.NonPublic);

    Can you tell me why that can come to null or am I missing anything?

    Thanks,
    Parthiv
  • Replied 2 September 2019, 10:27 am EST

    Hello Ruchir,

    Actually that has fixed the issue. We have the custom control which is derived from the C1FlexChart and hence I have to change the above code a little bit and that seems working now.

    Thanks,
    Parthiv
  • Replied 2 September 2019, 7:32 pm EST

    Hi Parthiv,

    Thank you for confirming that the issue is resolved with the solution we shared.
    Let us know, if you face any trouble in future.

    Best regards,
    Ruchir
  • Replied 9 September 2019, 7:32 pm EST

    Hi Ruchir,

    Sorry to bother you again. The solution provided is working with bar and column charts but we have a chart with the type "Area" and this fix is not working for that.

    I am attaching the sample project to highlight that.

    Would you please review it and let me know what changes need to be made.

    Thanks,
    ParthivColumnChart.zip
  • Replied 11 September 2019, 10:04 pm EST

    Apologies Parthiv. I can observe that the workaround fails for Area type charts.
    We are researching further to provide you a solution that works with Area type charts too. I'll come back to you once we have a solution/workaround.

    Thanks,
    Ruchir
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels