Home
Analytics
Bar-Chart's Bar-width?
Azad Singh
Is there a way to handle the bar chart's bar width? I want the script or some formula to define the bar's width.
I put efforts to search the handle on this, but I found the handle on Bar Chart Unit Spacing... Which is entirely different than what I need.
Please reply if have any Idea.
Thanks in advance.
Find more posts tagged with
Comments
mwilliams
The unit space is what controls the width of the bar. Take a look at this post, from the devShare. It might help you out, depending on what you're trying to do.
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1584-adjust-chart-unit-spacing-to-keep-consistent-bar-width/
Let me know more about what you're trying to do, if this doesn't help.
Azad Singh
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="114099" data-time="1360561402" data-date="10 February 2013 - 10:43 PM"><p>
The unit space is what controls the width of the bar. Take a look at this post, from the devShare. It might help you out, depending on what you're trying to do.<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1584-adjust-chart-unit-spacing-to-keep-consistent-bar-width/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/1584-adjust-chart-unit-spacing-to-keep-consistent-bar-width/</a><br
/>
<br />
Let me know more about what you're trying to do, if this doesn't help.<br /></p></blockquote>
<br />
Hi Williams, I am trying to create a bar chart where the bar's width is unique for any no. of data-points(If the no. of data-points are bellow to a threashold, as I know the width have to be adjusted to a lower value if no. of data-points are greater than a certain threshold, Say for me the threshold on Data-Points is 15.).<br />
<br />
What I mean is that if no. of Data-Points in Bar-Chart are less than 15, then the width of the bar should be same. Even if there is a single Data-Point is there.<br />
<br />
What happens by default when I define the unit spacing to some value (say '70') is : It is fine if no. of Data-Points >4 and no. of Data-Points < 15. But if no. of Data-Points == 1 || no. of Data-Points == 2, Then the Bar is too much thick.<br />
<br />
I think you know what I mean. <br />
I will try to check with the link you forwarded. <br />
<br />
Thanks for such a quick response.
mwilliams
Yeah. The example I linked you should definitely help you come up with a solution for that. Let me know if you run into issues.
Azad Singh
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="114145" data-time="1360705346" data-date="12 February 2013 - 02:42 PM"><p>
Yeah. The example I linked you should definitely help you come up with a solution for that. Let me know if you run into issues.<br /></p></blockquote>
<br />
<br />
Williams, I am OK with the example you send to me, It helps me to somehow handle with the bar's width. Though I wanted to consider 'Chart width' also to be considered in the formula.<br />
<br />
I hope you understand what I mean. Because what i feel is, the chart width also have a part in deciding the chart width.<br />
<br />
Thanks!
mwilliams
I understand what you're saying, but are you changing the width of the chart? This script is definitely chart specific. If you wanted to be able to copy and paste it to any chart, you'd definitely need to come up with a formula that takes the width into consideration. Let me know if you need help with this.
Azad Singh
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="114153" data-time="1360731403" data-date="12 February 2013 - 09:56 PM"><p>
I understand what you're saying, but are you changing the width of the chart? This script is definitely chart specific. If you wanted to be able to copy and paste it to any chart, you'd definitely need to come up with a formula that takes the width into consideration. Let me know if you need help with this.<br /></p></blockquote>
<br />
<br />
Williams, I want it for Bar chart only, but for every bar chart I will use the same script, and want to consider the chart width into that, I don't know a formula which involves the science to adjust the bar's width.
mwilliams
This is how you get the width of the chart, in the beforeGeneration:
chartWidth = chart.getBlock().getBounds().getWidth();
It'll probably be tough to get a great formula to keep them perfect. I tried for a bit without getting anything perfect. I didn't look in the source code to see how this value is used. That might help in creating a formula.
jain
Hi,
I have checked the example which is attached, the bar width is set based on the unit-spacing. But I want to set the width of the bar dynamically based on the number of bars in the chart without using unit-spacing, let say if the of no of bars >=1 and no. of bars<= 3, then width of the bars should be 0.80 inch. the same if its >=4 and <= 7 then bar width should be 0.45 like that., Is there a way to set the bar width dynamically?
Thanks,
Jain
mwilliams
Unfortunately, the unit spacing is how a chart determines the width of the bar. If I find a way to set the exact width, I'll let you know. You could always file an enhancement request in the bugzilla at eclipse.org/birt to be able to easily set the width of the bars to a specific width. If there's a workaround, they might be able to tell you.
jain
Thanks Michael, sure I will file an enhancement request in the bugzilla. Also can you please let me know how to set the bar width in inches?
mwilliams
The bar width is determined by the unit spacing, like discussed above. Are you meaning chart?
jain
Actually have set the bar width using unit spacing in inches, chart.setUnitSpacing(0.5) but bar width is not exactly same. so how do I set the bar width in inches?
Thanks,
Jain
mwilliams
What I'm trying to say is that there isn't a setting for setting the bar width in inches. Just the unit spacing setting. You could probably come up with a calculation to make the bar width a certain width, depending on the number of bars and the chart's width.
jain
Thanks Michael, let me try it out with some calculation using unitspacing for bar width.
Thanks,
Jain