Chart labels inside chart area

2 posts, 0 answers
  1. Barry
    Barry avatar
    2 posts
    Member since:
    Jun 2011

    Posted 14 Apr 2015 Link to this post

    Telerik v2013 "UI for Winforms"

    .Net 3.5

    Visual Studio 2008

    We have a .Net desktop application built using Visual Studio with Telerik UI for WinForms integrated.  We are using the Chartview feature to show user some charts.  However they are not displaying correctly and we cannot identify why.

    When we create a chart using the radChartView control, the labels for the bars of the chart sometimes extend outside of the chart frame area (e.g. see fig1).  We want the bar labels to always being contained within the chart frame and never extend outside of this.

    To demonstrate better what we require, we have made a mockup using MSChart control to show what we are aiming for (see fig2).

    Please advise how we can create what we require using radChartView control?

  2. Dimitar
    Dimitar avatar
    1321 posts

    Posted 17 Apr 2015 Link to this post

    Hi Barry,

    Thank you for writing.

    One way to solve this is to set bigger maximum for the vertical axis. Another possibility is to manually set the label position:
    void radChartView1_LabelFormatting(object sender, ChartViewLabelFormattingEventArgs e)
        BarLabelElement el = e.LabelElement as BarLabelElement;
        CategoricalPointElement element = (CategoricalPointElement)e.LabelElement.Parent;
        CategoricalDataPoint dataPoint = (CategoricalDataPoint)element.DataPoint;
        LinearAxis myAxis = (LinearAxis)radChartView1.Axes[1];
        double doubleValue = Convert.ToDouble(dataPoint.Value);
        if (doubleValue+5 > myAxis.ActualRange.Maximum)
            el.PositionOffset = new PointF(0,25);

    Please let me know if there is something else I can help you with. 

    See What's Next in App Development. Register for TelerikNEXT.

  3. DevCraft R3 2016 release webinar banner
Back to Top