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

Problem with Bar graph

1 Answer 129 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jiraphat
Top achievements
Rank 1
Jiraphat asked on 27 Oct 2010, 06:03 AM
Hi Telerik team,

I got a problem with bar graph customization in Telerik report version Q2 2009. My customer requirement is they want to fixed the length size of each bar graph to "Millimeter" unit. For example, if data count is 12 items, each bar's width must be 2 mm. But if data count is 3 items, each bar's width must be 8 mm (make it bigger).
Is it possible to do that? I see the graph usually adjust the width of each bar by automatic based on amount of item and graph area.

Regards,
Jiraphat Jokdee

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 28 Oct 2010, 05:49 PM
Hi Jiraphat,

The chart does not support setting directly the bar width in pixels. However, knowing how the chart calculates the bar width you can affect that calculation. Here is how it works: the chart has its width. Then you can configure the plot area margins. You can set them in percents or in pixels. This leaves a fixed and known space for the plot area.

Let us consider an example -- 300px available for the PlotArea. If there are 12 items, there will be 12 slots 25 pixels each. The chart.Appearance.BarWidthPercent property defines what part of that space will be occupied by the bar. Its default value is 80, so 80% or these 25 pixels will be taken by the bar -> 20 pixels wide. So, configuring the plot area margins and the BarWidthPercent you can influence the bar width.

In addition, you can set the XAxis.AutoScale property to false and configure the axis manually by calling the AddRange(min, max, step) method. This way you have complete control over the number of items in X axis, so you can calculate the BarWidthPercent according to the desired value for bar width.

Sincerely,
Ves
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
Tags
General Discussions
Asked by
Jiraphat
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or