This is a migrated thread and some comments may be shown as answers.

Chart labels inside chart area

1 Answer 152 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 14 Apr 2015, 10:49 AM

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?

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 17 Apr 2015, 08:27 AM
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. 
 
Regards,
Dimitar
Telerik
 

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

 
Tags
ChartView
Asked by
Barry
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or