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)
Text in middle of pie
shamo
<p>I have these two reports with same scripts. when I run in version 11.0.4 build id 20121023, I get image on right with both text and number fitting as I want it but when I run in version 4.2.3 build id v20131216, I get image on left. Any help to get them both as on the right with number up text below.</p>
Find more posts tagged with
Comments
Matthew L.
<p>This can happen because of a few properties that have changed between v11 and iHub3 versions.</p>
<p>I believe the reason is because of the "Explode Slice When" feature.</p>
<p>In the "Format Chart" tab of the chart editor, select "Value Series" then find "Explode Slice When" and set its value to "true" (without double quotes).</p>
<p>I believe this will correct the issue.</p>
<p>If not, then check the "Chart Area" menu option and verify that "Coverage" is set to 100%.</p>
<p>You can also check to see if the value in "By Distance" in the "Value Series" menu option to see if this changes the behavior.</p>
<p> </p>
<p>*by the way, great color scheme.</p>
shamo
<p>Thanks Matthew. Unfortunately i can't get he iHub to show both as i the v11. Do you have any sample you can share for me to look at?</p>
shamo
<p>Anyone with a workaround sample to the mentioned problem above?</p>
Clement Wong
<p>Please attach a sample design with your script.</p>
shamo
<p>This is a sample report from classic models</p>
Clement Wong
<p>You can do this easier without using all those PGVs, and overriding the <em>onCreate </em>and <em>beforeRender </em>events.</p>
<p> </p>
<p>Attached is a revised design.</p>
<p> </p>
<p>In the <em>beforeRendering </em>of the chart, we do the following to save the values and update the Title text (should be self explanatory since you are familiar with the HTML5 scripting). Add a <strong>debugger;</strong> if you want to walk through.</p>
<pre class="_prettyXprint">
beforeGeneration: function(options)
{
for (var i=0; i < options.series[0].data.length; i++ ) {
if (options.series[0].data[i].name == options.title.text)
{
var displayAmount = options.series[0].data[i].y;
var chartTitle = options.title.text;
}
}
//You can change options here.
options.title =
{
useHTML: true,
verticalAlign: 'middle',
text: '<div>' + displayAmount + '</div><div style="color:#ffffff;font-size:12pt;font-family:Arial;font-weight:400;font-style:normal">' + chartTitle + '</div>'
},
options.plotOptions =
{
pie: {
size: "85%"
}
},
options.chart =
{
spacingLeft: 0,
spacingRight:0,
spacingBottom:0,
spacingTop:0,
}
},
</pre>
shamo
<p>Clement, Thank you for the solution. It worked but my requirement is such that the pie values aren't going to be same as the table and that is why I needed the table and scripts to work also output isn't always going to be HTML. When run in pdf, only pie shows no values. Could you tweak my sample for me? Your script sample works but still not serving my purpose. How do I add a break <br> between the options.title and the options.subtible? I believe if I'm able to do that then the subtitle will be below the title. Thank you for you help.</p>
Clement Wong
<p>
If you must save variables, you can either:<br><br>
1. Create Report Variables to save the values. In the Chart, you can use this.getReportVariable("variableNameHere") to retrieve the value.<br>
a. For your report, I did this for "Shipped". In your original onCreate event, we comment the PGV and add:</p>
<pre class="_prettyXprint">
//reportContext.setPersistentGlobalVariable("Shipped", (row["Aggregation"]).toString());
vars["Shipped"] = row["Aggregation"].toString();
</pre>
<p>
b. The code in the beforeRendering event is not needed:</p>
<pre class="_prettyXprint">
//var chart1 = rr.designHandle.getDesignHandle().findElement("Chart1");
//chart1.getReportItem().getProperty("chart.instance").getTitle().getLabel().getCaption().setValue(reportContext.getPersistentGlobalVariable("Shipped"));
</pre>
<p>
2. Use a Text Report Item as HTML. Save the values you want in a JavaScript variable.<br>
a. For your report, I did this for "Cancelled". In your original onCreate event, we comment the PGV:<br>
</p>
<pre class="_prettyXprint">
//reportContext.setPersistentGlobalVariable("Cancelled", (row["Aggregation_1"]).toString());
</pre>
<p>
b. We add a Report Item anywhere that you have column binding available for your value. I added a Text Report Item in the top Cancelled box/section.<br>
</p>
<pre class="_prettyXprint">
<script>
theCancelledValue = '<VALUE-OF>row["Aggregation_1"]</VALUE-OF>';
</script>
</pre>
<p>
c. The code in the beforeRendering event is not needed:<br>
</p>
<pre class="_prettyXprint">
//var chart2 = rr.designHandle.getDesignHandle().findElement("Chart2");
//chart2.getReportItem().getProperty("chart.instance").getTitle().getLabel().getCaption().setValue(reportContext.getPersistentGlobalVariable("Cancelled"));
</pre>
<p>
Then in the Chart when setting the title, you can reference the value with option 1:</p>
<pre class="_prettyXprint">
options.title =
{
useHTML: true,
verticalAlign: 'middle',
text: '<div>' + this.getReportVariable("Shipped") + '</div><div style="color:#ffffff;font-size:12pt;font-family:Arial;font-weight:400;font-style:normal">' + options.title.text + '</div>'
};
</pre>
<p> <br>
Or with option 2:</p>
<pre class="_prettyXprint">
options.title =
{
useHTML: true,
verticalAlign: 'middle',
text: '<div>' + theCancelledValue + '</div><div style="color:#ffffff;font-size:12pt;font-family:Arial;font-weight:400;font-style:normal">' + options.title.text + '</div>'
};
</pre>
<p>As to what the difference is with 11 SP4, I'm not sure at this time, but you can open a Support case and have them log a ticket to investigate further and log a ticket with Engineering to address. Also, in my investigation, I was not able to use title.y (<a data-ipb='nomediaparse' href='
http://api.highcharts.com/highcharts#title.y'>http://api.highcharts.com/highcharts#title.y</a>)
or subtitle.y <a>(
http://api.highcharts.com/highcharts#subtitle.y)</a>
; to move the title or subtitle. </p>
<p> </p>
<p>Attached is a revised sample based on your requirement that demonstrates the two options of the report variable and JavaScript variable so you can use in the title.</p>
shamo
<p>Clement, thanks for all the help you are offering me. unfortunately, the attached report doesn't work these are attached pictures of results in both web/html and pdf</p>
shamo
<p>Hello Clement,</p>
<p>thank you very much for the help. I got it working by adding these to the options.title =</p>
<p>{</p>
<p>verticalAlign: 'middle',</p>
<p>floating: true,</p>
<p>y: 30,},</p>
<p>options.subtitle=</p>
<p>{</p>
<p>text: 'Shipped',</p>
<p>verticlaAlign: 'middle',</p>
<p>floating: true,</p>
<p>y: 35,</p>
<p>style:{ .....}</p>
<p>},</p>
<p> </p>
<p> </p>
<p>Now my problem is how to break the subtitles if it is too long. Any help?</p>
shamo
<p>Found the solution. inserted the <br> between the text for the break</p>
Clement Wong
<p>Cool. So simple! Thanks for the update.</p>