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

Maximum bar width in stacked bar chart

6 Answers 341 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Carl
Top achievements
Rank 1
Carl asked on 26 Oct 2009, 10:01 AM
Please could you let me know if there is a way to restrict the maximum bar width of a bar in the stacked bar chart? I have a variable number of items that need to be plotted, and if I only have one item on the x axis I would prefer the bar not to fill the width of the chart.

Thanks in anticipation, Carl

6 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 26 Oct 2009, 08:06 PM
I don't think RadChart actually allows for a set width for the bars. It basically just calculates the width it has to plot on, and spaces the bars out accordingly. An option would be to use series.Appearance.BarWidthPercent property which indicates how much spacing goes between each bar. Or you could play around with the plotarea margins depending on how many bars you anticipate having on a graph.
0
Dhananjay
Top achievements
Rank 1
answered on 30 Nov 2011, 12:38 AM
I've similar requirement wherein I'm plotting a horizontol bar chart. The number of records are variable and I need to keep the bar width constant so that it looks good whenever there are few records.
I tried playing with XAxis maxvalue property, still it's not helping.
Also, I wonder why the Chart.Height is not getting set in runtime, so that I get mostly constant bar width by playing around the BarWidthPercent and Height Property.
Looks like all my efforts are vain.
It will be really nice if the chart provides property like BarWidth and then the total Width or Height of Bar will expand depending upon the number of records.
Any suggestion how would I get the Height property set at runtime?
0
Peshito
Telerik team
answered on 02 Dec 2011, 11:41 AM
Hi Dhananjay,

You can wire to the BeforeLayout event in order to change the height in runtime for instance like this:
radChart.BeforeLayout += new EventHandler<EventArgs>(radChart_BeforeLayout);

void radChart_BeforeLayout(object sender, EventArgs e)
    {
        radChart.Height = radChart.Series.Count * 200;
    }


In order to have similar bar widths despite of their number, you need to set the AutoScale to false and then set your min, max and step values manually. This way you can control the number of items displayed on your axis, therefore your bar items width will be the same.

Best wishes,
Peshito
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Vivek
Top achievements
Rank 1
answered on 05 Dec 2011, 12:14 PM
Hi ,

I am working on a similar requirement and tried using BeforeLayout event, however for some reason this event is not available for my chart. Events that I could capture are : Disposed,NeedDataSource,ItemDataBinding,ItemDataBound and Error. Any suggestions?
0
Peshito
Telerik team
answered on 08 Dec 2011, 10:30 AM
Hello Vivek,

You could try using ItemDataBinding event, or you could create your chart programmatically in the report constructor and avoid events. More about that can be found here:
http://www.telerik.com/help/reporting/buildingprogrammaticcreate2.html

Kind regards,
Peshito
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Rob
Top achievements
Rank 1
answered on 05 Jan 2012, 11:41 PM
Tags
General Discussions
Asked by
Carl
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Dhananjay
Top achievements
Rank 1
Peshito
Telerik team
Vivek
Top achievements
Rank 1
Rob
Top achievements
Rank 1
Share this question
or