Chart and bar width

2 posts, 0 answers
  1. Mattias
    Mattias avatar
    6 posts
    Member since:
    Aug 2009

    Posted 01 Oct 2009 Link to this post


    I have a categorical 2D bar chart where I would like the bars to be a specific width (about 20) or at least minwidth 20 for the bars. Then I want the chart so expand it's width in case there are a lot of bars or categories. Basically take the space it needs.

    Right now it seems like even if I don't set a width or only a min width the chart tries to cramp everything together instead of just expanding its width.

    So the question is, how do i do that?

    This is my current template:
    <ControlTemplate TargetType="telerik:Bar"
          <Rectangle x:Name="PART_DefiningGeometry" 
                     Height="{TemplateBinding ItemActualHeight}" 
                     Style="{TemplateBinding ItemStyle}" /> 

    I attached a image that shows how it looks at the moment.
  2. Vladimir Milev
    Vladimir Milev avatar
    1061 posts

    Posted 07 Oct 2009 Link to this post

    Hello Mattias,

    This behavior is by design. The chart control does not try to accommodate the bar width. It will space out the bars as much as it can when the values allow it.

    What you can do (as a work-around) is try to manually set the range of your axis to accommodate the appropriate width. You need to set the AutoRange property to false and set Min, Max and Step values.

    Vladimir Milev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top