Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
[BIRT 2.6.2] Stacked bar chart layout issue
rsenden
<p>Please see the attached barchart.rptdesign for an example.</p><p> </p><p>I have a data set with columns CATEGORY_NAME, CATEGORY_ORDER, FOLDER_NAME, and COUNT. I want to display this data in a stacked bar chart, with CATEGORY_NAME on the X-axis, COUNT on the Y-axis, and FOLDER_NAME as Y-axis grouping.</p><p> </p><p>This is no problem, except that I want to sort the X-axis by CATEGORY_ORDER. In the attached example, the correct order would be Cat2, Cat1, Cat3.</p><p> </p><p>Since BIRT doesn't allow to order on anything else than the X-axis value, I have implemented a work-around where I prepend CATEGORY_ORDER (with leading zeros) to CATEGORY_NAME for the X-axis value, and then use beforeDrawAxisLabel to remove the leading zeros and CATEGORY_ORDER again.</p><p> </p><p>This works fine; the X-axis is sorted by CATEGORY_ORDER, and it shows CATEGORY_NAME as the X-axis caption. However, BIRT reserves space for the full X-axis value (leading zeros, CATEGORY_ORDER and CATEGORY_NAME), resulting in a lot of white space between the bar chart and the legend.</p><p> </p><p>Any ideas on good ways to solve this layout issue, i.e. to have BIRT automatically reserve the correct amount of space based on the actual CATEGORY_NAME values?</p>
Find more posts tagged with
Comments
rsenden
<p>I already found a solution for this myself; instead of removing the prefix in the beforeDrawAxisLabel() event handler, I now remove the prefix in the afterDataSetFilled() event handler. This event handler is apparently called after the data set has been sorted, but before the layout is computed. See the attached barchart.rptdesign for an example.</p>