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)
Hide dynamically a Pie Chart depending on series value
Stéphane
<p>Hi,</p>
<p> </p>
<p>It is forbidden - because impossible in the real world - to show a negative value in a Pie Chart.</p>
<p> </p>
<p>So I am looking for a solution to hide a Pie Chart if it has a negative series. And replace it by a Bar Chart.</p>
<p> </p>
<p>So I need to test each series value and if one is negative, hide the graph. </p>
<p> </p>
<p>I searched on the forum all the day and I did not find. </p>
<p> </p>
<p>Could you please help me?</p>
<p> </p>
<p>(My idea is to have the 2 graphs - one Pie and one Bar - and show the right one depending on the data).</p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>Because you need to test the series value before the pie chart is generated, you best option is to create a the chart inside a table and bind the chart to the container's data.</p>
<p> </p>
<p>In the attached example, the sample data set will return negative values for product lines when the buyprice is subtracted from 50. (You can subtract from 80 if you want to get only positive values and test the display of the pie chart).</p>
<p> </p>
<p>The table is grouped on product line and contains an aggregation that sums up the price column per product line (you can look at the binding for the table to find the aggregation definition)</p>
<p> </p>
<p>The table has only a table footer that contains a pie chart and a bar chart. The Visibility attribute of the bar chart is set to hide the chart when the aggregation is never negative. The Visibility attribute of the pie chart is set to hide the chart when the aggregation is negative.</p>
<p> </p>
<p>There are probably other ways to do it depending on your business case, but right now, you have an option!</p>
<p> </p>
<p>P.</p>
Stéphane
<p>Hi,</p>
<p> </p>
<p>Excellent, thank you,</p>
<p> </p>
<p>Best regards,</p>
<p> </p>
<p>Stéphane.</p>
Stéphane
<p>Hi, </p>
<p> </p>
<p>It did not work with my code, I searched and in fact your tip does not work neither.</p>
<p> </p>
<p>If you filter in the DataSet the PRODUCTLINE <em>Motorcycles</em>, you will have only one group with a negative value: <em>Trucks and Buses</em>, and the Pie Chart appears.</p>
<p> </p>
<p>In fact, your example works because the first group - <em>Motorcycles</em> - is negative, if the first group is positive, that does not work.</p>
<p> </p>
<p>Stéphane.</p>
pricher
<p>Sorry about that... Here's one that should work. I have added a new aggregation at the table level to find the minimum value of the already computed aggregation. The test for visibility on the charts is now based on that new aggregation, i.e. if the minimum value is negative, don't show the pie chart.</p>
<p> </p>
<p>P.</p>
Stéphane
<p>Hi,</p>
<p> </p>
<p>Of course that works, a huge thank you,</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>Stéphane</p>