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)
Stacked Bar Chart: Suppress labels based on section height
just1joe
<p>I have a multi-page report which generates multiple stacked bar charts. I am trying to see if there is a way to suppress the labels on a section when the section height is below a certain height of the whole bar. One chart may have 6 sections and 5 bars where one bar has a total of 500 and another has 50 and another may have totals 1000 and 5000. Some of the labels overlap and are unreadable when the sections are too small.</p>
<p> </p>
<p>I have used the following scripts depending on if the chart is a count or a percentage of total. </p>
<p> </p>
<div>function beforeDrawDataPointLabel( dph, label, icsc )</div>
<div>{</div>
<div>var myVal = label.getCaption().getValue();</div>
<div>if( </div>
<div>myVal < 250 ){</div>
<div>label.setVisible(false);</div>
<div>}else{</div>
<div>label.setVisible(true);</div>
<div>}</div>
<div>}</div>
<div> </div>
<div>
<div>function beforeDrawDataPointLabel( dph, label, icsc )</div>
<div>{</div>
<div>var myVal = label.getCaption().getValue();</div>
<div>if( </div>
<div>Number(parseInt(myVal)) < 8 ){</div>
<div>label.setVisible(false);</div>
<div>}else{</div>
<div>label.setVisible(true);</div>
<div>}</div>
<div>} </div>
<div> </div>
<div>But these set a value across all of the charts generated and even though there is room to display the label, nothing is printed.</div>
<div> </div>
<div>I used the following script but it does not set the value based on the section height:</div>
<div> </div>
<div>
<div>function beforeDrawDataPointLabel( dph, label, icsc )</div>
<div>{</div>
<div>if(dph.getOrthogonalValue() < .15){</div>
<div>label.setVisible(false);</div>
<div>
<div>}else{</div>
<div>label.setVisible(true);</div>
</div>
<div>}</div>
<div>}</div>
</div>
</div>
<p> </p>
<p>Is there a script available to display the labels only when they would not overlap?</p>
Find more posts tagged with
Comments
JFreeman
<p>Which version of BIRT are you using?</p>
<p> </p>
<p>You can try using dph.getPercentileOrthogonalValue() instead.</p>