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

Chart and bar width

1 Answer 92 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 01 Oct 2009, 08:51 AM
Hi,

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"
   <Canvas> 
      <Rectangle x:Name="PART_DefiningGeometry" 
                 Height="{TemplateBinding ItemActualHeight}" 
                 RadiusX="2" 
                 RadiusY="2" 
                 Stroke="Transparent" 
                 StrokeThickness="1" 
                 MinWidth="20" 
                 Style="{TemplateBinding ItemStyle}" /> 
   </Canvas> 
</ControlTemplate> 

I attached a image that shows how it looks at the moment.

1 Answer, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 07 Oct 2009, 11:45 AM
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.

Greetings,
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.
Tags
Chart
Asked by
Mattias
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
Share this question
or