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)
How to display the total number on a stacked bar?
knlgetter
the chart below is a type of stacked bar and we have optional Y series grouping. If I check "show series label", the chart would give me the detail number of each of the groupings. But I really want to have a total number instead shown on the chart. How do I do that? Thanks.<br />
<br />
<img src='
http://3.bp.blogspot.com/_2YQMPJPq75s/TGmeihHp_7I/AAAAAAAAALE/PwgF1CQW91c/s1600/stackedbar.png'
alt='Posted Image' class='bbc_img' />
Find more posts tagged with
Comments
thuston
I can't find my sample code, however you should be able to do this with Script.
Loop through the data and sum all the values for each category (may even be directly available.
As you go through, set the point label to "" except for the last one. Reset the last (top) label to be the summed value for the category bar.
knlgetter
Sorry, the last (top) label you referred to is the label setting here:<br />
<img src='
http://1.bp.blogspot.com/_2YQMPJPq75s/TGnIQAuVcYI/AAAAAAAAALM/7bLhzyyipFw/s1600/label1.jpg'
alt='Posted Image' class='bbc_img' /><br />
<br />
or somewhere else? Appreciated!
thuston
Yes. You must first turn on the Labels.
Check that box. Then configure the label format by clicking the Labels button.
Set the labels to be Outside and you will see the top series has a label just above the Bar. That is the label you want to keep and modify when scripting to blank out the others.
knlgetter
Hmmm... not sure I understand how to blank out the numbers of the optional y group while still have the groupings show up in my chart:<br />
<br />
Here is my logic in Fetch in the dataset used by our chart:<br />
<br />
<em class='bbc'>if (index == chartWorkItems.length) {<br />
return false;<br />
}<br />
var obj = chartWorkItems[index];<br />
<br />
row["TEAM_AREA_NAME"] = obj.teamAreaName;<br />
row["STORY_POINTS"] = obj.storyPoints;<br />
row["ITERATION_NAME"] = obj.iterationName;<br />
row["STATE_NAME"] = states[obj.stateName];<br />
<br />
<br />
index++;<br />
return true;</em><br />
<br />
Also here is our chart design using the same dataset:<br />
<img src='
http://4.bp.blogspot.com/_2YQMPJPq75s/TGqiqeqyAoI/AAAAAAAAAL0/8y7MmsM52_I/s1600/chart.jpg'
alt='Posted Image' class='bbc_img' /><br />
<br />
My question really goes to if I blank out the numbers for the Option Y series grouping, the stacked groupings would be all gone? How do I keep the groupings while printing a total number above the bar? <br />
<br />
I guess I don't understand your logic
Could you elaborate a little bit more? Thanks.
thuston
I was talking about Scripting the Chart's OnRender.<br />
<br />
Below is method I had that hide 0 or else custom formats the label values.<br />
I have not had time to look at how you would get the Bar total and how to know when you were at the topmost series section, but I hope it helps.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var series1;
var series2;
/**
* Called before rendering the label for each datapoint.
*
*
@param
dph
* DataPointHints
*
@param
label
* Label
*
@param
icsc
* IChartScriptContext
*/
function beforeDrawDataPointLabel( dph, label, icsc )
{
if (dph.getSeriesDisplayValue() == "Series 1") {
if (dph.getOrthogonalValue() == 0)
label.setVisible(false);
else {
myLabel = (100 * (series2[dph.getIndex()] * -1)) + "";
myLabel += (myLabel.indexOf(".") > 0) ? "%" : ".0%";
label.getCaption().setValue(myLabel);
}
}
else {
if (series1[dph.getIndex()] != 0)
label.setVisible(false);
}
}</pre>
knlgetter
Hmm... OnRender, I see. Let me try a little bit then. Thanks.