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

X-Axis Label off the screen

3 Answers 46 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Fransiscus
Top achievements
Rank 1
Fransiscus asked on 18 May 2011, 12:49 PM
Hi All,

1. I have an issue where the chart x-axis label is off the screen. The X-Axis is coming dynamically from database
-Screenshot Attached

-Code
  RebindChartReport(radChartReport);
  radChartReport.ItemsSource = e.Result;
  radChartReport.DefaultView.ChartArea.SmartLabelsEnabled = true;
  radChartReport.DefaultView.ChartArea.AxisX.AxisStyles.ItemLabelStyle = this.Resources["AxisLabelStyle"] as Style;
 
private void RebindChartReport(RadChart radChart, bool isBar = false)
{
            radChart.SeriesMappings.Clear();
            SeriesMapping seriesMapping = new SeriesMapping();
            if (isBar)
            { seriesMapping.SeriesDefinition = new BarSeriesDefinition(); }
            else
            {
                seriesMapping.SeriesDefinition = new LineSeriesDefinition();
            }
            seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("YAxisLegendName"));
            seriesMapping.ItemMappings.Add(new ItemMapping("XYValue", DataPointMember.YValue));
            seriesMapping.ItemMappings.Add(new ItemMapping("XAxisName", DataPointMember.XCategory));
            radChart.SeriesMappings.Add(seriesMapping);
            radChart.DefaultView.ChartArea.AxisX.AutoRange = true;
}

-Xaml of AxisLabel Style
<Style x:Key="AxisLabelStyle" TargetType="TextBlock">
          <Setter Property="TextWrapping"  Value="Wrap" />
          <Setter Property="Width" Value="100" />
          <Setter Property="Padding" Value="10" />
          <Setter Property="Margin" Value="10" />
          <Setter Property="FontSize" Value="11" />
          <Setter Property="TextAlignment" Value="Center" />
      </Style>

2.How do you put an offset to the beginning of the chart - Image attached

Any help will be appreciated

Cheers

3 Answers, 1 is accepted

Sort by
0
Fransiscus
Top achievements
Rank 1
answered on 19 May 2011, 07:55 AM
Any thought guys?Telerik support?

Cheers
0
Accepted
Missing User
answered on 20 May 2011, 01:15 PM
Hi Fransiscus,

You can change the AxisLayoutMode so that the labels will be between the ticks. For example:
radChart.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Between;

The default AxisLayoutMode is Normal and in Line Charts the ticks match labels. Thus you need to use different mode to position the labels as expected. More information about AxisLayoutMode can be found here.

I hope this helps.

Regards,
Polina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Fransiscus
Top achievements
Rank 1
answered on 20 May 2011, 01:50 PM
Thank you Polina, really appreciate it

Cheers
Tags
Chart
Asked by
Fransiscus
Top achievements
Rank 1
Answers by
Fransiscus
Top achievements
Rank 1
Missing User
Share this question
or