Home
Analytics
Custom Sorting Order with Stacked Bar Chart
hcacace
Hi,
I'm new to the Actuate BIRT Report Designer tool, and I've got a question about the creation of a stacked bar chart.
Is there any way to specify a custom ordering of the grouping categories?
In my chart, each bar contains three groups, but unfortunately, the order that I want them to appear is not alphabetical. I tried adding a row number field to the data and sorting on that, but since the row number data doesn't appear in the chart, it doesn't appear in the Sort On dropdown box.
Any help would be greatly appreciated, and thanks in advance!
Hayden
Find more posts tagged with
Comments
mwilliams
Hi Hayden,
So, you want to sort the x-axis category based off a different column from your dataSet? How is your report set up? Is the chart a standalone chart, or is it inside a table footer or something?
hcacace
Yeah, if I was able to sort by a different column in the data set, that would achieve my goal.
My report is very simple, I just have 4 columns of data. One column is the Y axis of my chart, then each bar is a category from the second column. The third column has the three categories which is the grouping of each bar. The fourth column is the row number, which I would like to sort the grouping by. And yes, it is a standalone chart.
Thanks!
mwilliams
Hayden,
You should be able to click on the "expression builder" button next to the "sort on" box and choose the other column there. Let me know if you have more questions.
hcacace
I am still confused. Anything I do in the expression builder changes the expression that I am grouping by (currently, just the column I want to group by). I don't want to group by the row number, the row number just defines the ordering of the values of the column I do want to group by.
Can you clarify exactly what I should do within the expression builder?
mwilliams
Hayden,
I'm talking about when you select the "Edit Group and Sorting" button next to the X axis category box in the chart editor. You'll have the "Sort On" dropdown. You can click on the expression builder button next to that and look under the "Available Column Bindings" option.
If you can attach a small sample of data for me to set up a report with, that may help see if this works for your situation.
hcacace
I see. The problem is that the grouping I'm talking about is on the Y-Axis, under "Optional Y Series Grouping".
Here is an example of the data to give you a better idea...
ROW_NUM SCHOOL SKILL_LEVEL NUMBER
1 School A high 50
2 School A medium 32
3 School A low 10
4 School B high 13
5 School B medium 64
6 School B low 44
So I have NUMBER on the Y-Axis (Value (Y) Series).
SCHOOL is on the X-Axis (Category (X) Series).
and SKILL_LEVEL is under Optional Y Series Grouping.
The problem is that I want the bars to display high-medium-low in that order, but it that isn't the alphabetical order.
Hope this clarifies, and thanks so much for helping.
mwilliams
Hayden,<br />
<br />
If you create a computed column in your dataSet that is 3 for high, 2 for medium, and 1 for low, you can use that as your optional grouping. Then you can sort descending and use the following code in your chart script to replace the legend values.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawLegendItem( lerh, bounds, icsc )
{
temp = lerh.getLabel().getCaption().getValue();
if (temp == 3){
lerh.getLabel().getCaption().setValue("high");
}
else if (temp == 2){
lerh.getLabel().getCaption().setValue("medium");
}
else{
lerh.getLabel().getCaption().setValue("low");
}
}
</pre>
<br />
Hope this helps.
hcacace
That did it. Thank you very much!!!
mwilliams
You're welcome. Let us know whenever you have questions.