Home
Analytics
Actual value and percentage
sumathra
<p>I had done a Report with chart so in that they was a parameter like Type...with value like Actual value and percentage...so to show a percentage i have wrote a script like </p><p> </p><p> </p><div><pre class="_prettyXprint">importPackage(Packages.org.eclipse.birt.chart.model.attribute);importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );function beforeDrawSeries( series, isr, icsc ){if(series.getSeriesIdentifier() == "Series 1"){labelType = icsc.getExternalContext().getScriptable().getParameterValue("Types");if(labelType == "Percentage"){series.getDataPoint().getComponents().get(0).setType(DataPointComponentType.PERCENTILE_ORTHOGONAL_VALUE_LITERAL);}}}</pre></div><div> </div><div> it had show value like in screenshot....but my requirement like the value is 75000,1015,1212,1352, it have to show in bar chart like 75%,25%,10%,7% ..how to change like this...</div>
Find more posts tagged with
Comments
sumathra
<p>if any body have some idea to this....?</p>
Jenkinsj5
<p>There is no enough information here for me to fully understand the data and the issue. But if you can build a table that has the all the numbers, then you should be able to build your graph using the table as a data source. Once the Graph is working you can hide the table.</p>
kclark
<p>In the onFetch() of my data set I calculated the total and stored it as a PGV to call later from the chart script.</p><pre class="_prettyXprint">var currentValue = row["AMOUNT"];var total = parseInt(reportContext.getPersistentGlobalVariable("total"))total += currentValue;reportContext.setPersistentGlobalVariable("total", total.toString())</pre><p>Then in my chart I made sure to display the value data so I could use it when calculating the percentages. Then I displayed them with the following</p><pre class="_prettyXprint">var currentValue = 0.0;var total = 0.0;function beforeDrawSeries( series, isr, icsc ){ total = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("total");}function beforeDrawDataPointLabel( dph, label, icsc ){ var stringValue = dph.getDisplayValue(); var currentValue = parseFloat(stringValue.replace(",","")); var percentage = (currentValue/total) * 100; label.getCaption().setValue((percentage).toFixed(2) + "%")}</pre>
vijayshankar245
<blockquote class="ipsBlockquote" data-author="kclark" data-cid="121747" data-time="1383587245">
<div>
<p> </p>
<p>In the onFetch() of my data set I calculated the total and stored it as a PGV to call later from the chart script.</p>
<pre class="_prettyXprint">
var currentValue = row["AMOUNT"];var total = parseInt(reportContext.getPersistentGlobalVariable("total"))total += currentValue;reportContext.setPersistentGlobalVariable("total", total.toString())</pre>
<p>Then in my chart I made sure to display the value data so I could use it when calculating the percentages. Then I displayed them with the following</p>
<pre class="_prettyXprint">
var currentValue = 0.0;var total = 0.0;function beforeDrawSeries( series, isr, icsc ){ total = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("total");}function beforeDrawDataPointLabel( dph, label, icsc ){ var stringValue = dph.getDisplayValue(); var currentValue = parseFloat(stringValue.replace(",","")); var percentage = (currentValue/total) * 100; label.getCaption().setValue((percentage).toFixed(2) + "%")}</pre>
</div>
</blockquote>
<p>Hi</p>
<p> </p>
<p>I have a similar requirement, Instead of dataset I'm using Data model in my report using .data</p>
<p> </p>
<p>Can you please explain how can i achieve the same using data model because the script feature is not enabled for model</p>
<p>As per your design we need to calculate total and assign it to PGV on OnFetch method of dataset.</p>
Clement Wong
<p>In iHub 16, there is a new feature where you can add computed measures into the Data Model.</p>
vijayshankar245
<blockquote class="ipsBlockquote" data-author="Clement Wong" data-cid="144162" data-time="1465233341">
<div>
<p>In iHub 16, there is a new feature where you can add computed measures into the Data Model.</p>
</div>
</blockquote>
<p>Thanks Wong ,</p>
<p> Since i am new in Actuate Could you please explain in Detail</p>
Clement Wong
<p>In iHub 16, users can create their own measures when using the iHub, but the (Data Model) architect can predefine ones in the Data Model.</p>
<p> </p>
<p><em>A measure uses an aggregation function to create a predefined summary of an expression. For example, a measure named SalesValue is the expression Price * Quantity and the aggregation function SUM and a measure named AverageSale is the expression SalesValue / LineCount. AverageSale is known as a derived measure because it uses the values of other measures. There is no difference in the usage of standard and derived measures. The data architect provides meaningful names for the measures so that report developers can easily understand the value that the measure provides.</em></p>
<p> </p>
<p><em>Using data model measures is a convenient way to access aggregated data in charts and cross tabs. Just drag the measure from the data model and drag it into the Y-axis of a chart or the summary area of a cross tab. No setting of aggregation functions is required. The measure is also available to create summary values for groups and grand totals in a cross tab.</em></p>