X-Axis Label off the screen

4 posts, 1 answers
  1. Fransiscus
    Fransiscus avatar
    7 posts
    Member since:
    May 2011

    Posted 18 May 2011 Link to this post

    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
  2. Fransiscus
    Fransiscus avatar
    7 posts
    Member since:
    May 2011

    Posted 19 May 2011 Link to this post

    Any thought guys?Telerik support?

    Cheers
  3. Answer
    Missing user
    Missing user avatar

    Posted 20 May 2011 Link to this post

    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
  4. Fransiscus
    Fransiscus avatar
    7 posts
    Member since:
    May 2011

    Posted 20 May 2011 Link to this post

    Thank you Polina, really appreciate it

    Cheers
Back to Top