Chart Bar Width / Chart Whitespace

4 posts, 0 answers
  1. Drew
    Drew avatar
    2 posts
    Member since:
    Aug 2010

    Posted 12 Aug 2010 Link to this post

    Is it possible to control the width of the bars drawn in a bar graph?  The bars being drawn in my application are more narrow than I would like them to be.  The result is a lot more whitespace than I would prefer.

    My chart is populated by setting the ItemsSource property to an ObservableCollection<Activity>.  (Activity is just a simple object I've defined with several properties, including a string property with the name of Priority.)

    My mappings are set up with the following code:

    <code>
    SeriesMapping seriesMapping = new SeriesMapping();
    seriesMapping.SeriesDefinition = new BarSeriesDefinition();

    seriesMapping.ItemMappings.Add(new ItemMapping("Priority", DataPointMember.XCategory));

    ItemMapping yItem = new ItemMapping();
    yItem.AggregateFunction = ChartAggregateFunction.Count;
    yItem.DataPointMember = DataPointMember.YValue;
    seriesMapping.ItemMappings.Add(yItem);

    seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Priority"));

    chartControl.SeriesMappings.Clear();
    chartControl.SeriesMappings.Add(seriesMapping);
    </code>

    I have attached a screenshot of the resulting graph.  I would like the bars to be thicker and take up more of the whitespace of the graph.  If possible, I would also like the bars to be centered over the labels underneath each category.
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 18 Aug 2010 Link to this post

    Hi Drew,

    You can use the ItemWidthPercent property to control this behavior:

    Chart.DefaultView.ChartArea.ItemWidthPercent = 10;

    The bigger the value, the wider the bars will be.

    Sincerely yours,
    Yavor
    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
  3. Drew
    Drew avatar
    2 posts
    Member since:
    Aug 2010

    Posted 23 Aug 2010 Link to this post

    Hi Yavor,

    Unfortunately, I have experimented with the ItemWidthPercent property but I have not had success with the results.  The bars are slightly larger at 100% but they still leave the majority of the graph as whitespace (picture attached).  I can make them larger by exceeding 100% but this forces some bars to be drawn outside the bounds of the chart container, making them invisible.  Is there another way to make the bar size larger?

    Thanks,
    Drew
  4. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 24 Aug 2010 Link to this post

    Hi Drew,

    I double- tested the approach on my end, and it worked as expected. I suspect that there may be another setting/style which may be influencing the behavior of the bars at your end. However, based on the supplied information, it is hard to pinpoint the cause. If the issue persists, you can open a formal support ticket, and send us a small working project, demonstrating your settings, and the resulting layout, for additional review and testing.

    Best wishes,
    Yavor
    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
Back to Top