Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Bar Graph X-Axis categories
akhilp
Hello,
we are planning to migrate existing Actuate e.report to birt. I have attached the Bar Graph image created using Actuate e.Report. is it possible to create the similar graph in birt.
note:secondary y-axis is same as the primary axis, just for ease of reading.
1. X-axis categories are displayed exactly look like in the image when -ve values exist.
2. the gap(gap ratio) between each category should be defined dynamically. here is the sample values for gap ratio. report has 2 series
a. if we have 5 categories then gap between each category should be 0.5
b. 4 categories gap is 1...etc..
please let me know if this can be done in birt?
I am using birt version 2.6.2. but not fixed at. we can go for higher version if required.
Find more posts tagged with
Comments
mwilliams
For x-axis values, are you talking about them being on two lines? If so, all you need to do is replace the '-' with "-\n". This will force a break after the '-'.
As for the spacing, you should be able to figure out how many bars there are in the afterDataSetFilled and change the spacing in the beforeGeneration.
akhilp
thank you.
1. x-axis categories in multiline using "\n". I did this, no issues
2. if you look the image, in graph, x- axis categories are displayed at the bottom. if i have -ve values, then x-axis categories position should be as per the image. I could not find a solution, how to place the categories as per image.
3. appreciated if you have any sample for the gap ration between each category.
mwilliams
Take a look at this. I use different inset values on the axis labels and the chart plot to get the labels where you want them and set the x-axis origin to 0. The spacing calculation can be seen in the script. I check the number of xaxis values, then change the spacing based on that value. Hope this helps. Let me know if you have questions.
akhilp
this looks great Michael.
this works excellent with with -ve values. we derive y-axis scale based on the series values. if we don't have -ve values, then the y-axis scale starts from 0(min value). do we have any direct method where we can set the insets dynamically.
2. how can i remove the space between X-Axis and secondary y-Axis.
akhilp
Michael,
I am able to set the insets dynamically.
var xAxis = chart.getAxes().get(0);
var lbl=xAxis.getLabel();
var ins=lbl.getInsets();
//var tp=ins.getTop();
ins.setTop(100)
2. but still struggling to remove the space between X-Axis and secondary Y-Axis. It may be simple, but not striking at this moment.
mwilliams
Can you explain the space you're seeing? It looks the same on both sides to me.
akhilp
Michael,
set the X-Axis Origin=value and Y-Axis1 origin=value, in this scenario both X-Axis and Y-Axis are start from the value. you will not see any space between X-Axis and Y-Axis1.
for Y-Axis2, if you set the origin=max, then there is a space between X-Axis and Y-Axis2. I am aking about this space.
mwilliams
Take a look at this. I set the yAxis2 origin setting to value, as well, then, in the beforeGeneration script, you'll see that I set the value based on the number of bars.
akhilp
awesome Michael.
its working fine. thank you so much.
mwilliams
Great! Let us know whenever you have questions!
akhilp
Michael,
how it works in the case of Line Graph? I applied the same logic but did not work
mwilliams
What doesn't work with this, with a line chart? If I change the chart from bar to line, in the example, it seems to work as expected. Let me know.
CaptainBob
<blockquote class='ipsBlockquote' data-author="'akhilp'" data-cid="108686" data-time="1345540228" data-date="21 August 2012 - 02:10 AM"><p>
Michael,<br />
<br />
2. but still struggling to remove the space between X-Axis and secondary Y-Axis. It may be simple, but not striking at this moment.<br /></p></blockquote>
<br />
I have a similar problem where there's extra space (+- 10pt font width) between the plot and the second Y-Axis. It appears if you set the X-Axis "Is category axis" = false. Set the X-Axis "Is category axis" = true and the space disappears.<br />
I'm using an area chart as the type with the second axis a line. BIRT 2.3.2.<br />
I've check every possible space setting on the chart and can't get rid of the space.
mwilliams
Did you take a look in the example up in post #9? It should help you out. If not, recreate your issue with the Classic Models sample database and post it in here.