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)
How to format bar series label in HTML5 charts?
BIRT User
<p>Hi,</p>
<p>I have requirement where i have to format the negative series values in HTML5 bar chart.</p>
<p>If the value is negative, then i have to display it like below over/under the bars.</p>
<p>Eg. -34.78 should be displayed like <span style="color:#ff0000;">(34.78). </span>And the positive value should displayed as it in black font color. </p>
<p> </p>
<p>The negative sign should be replaced with round brackets and the font color should be 'Red'.</p>
<p> </p>
<p>Please help me on how to implement this in HTML5 bar chart.</p>
<p> </p>
<p>Note: I am using BDPro designer. </p>
<p> </p>
<p>Thanks,</p>
<p>Ragu</p>
Find more posts tagged with
Comments
Clement Wong
<p>You can use the series dataLabels formatter (@ <a data-ipb='nomediaparse' href='
http://api.highcharts.com/highcharts#plotOptions.series.dataLabels.formatter'>http://api.highcharts.com/highcharts#plotOptions.series.dataLabels.formatter</a>)
to change label text and color.</p>
<pre class="_prettyXprint">
beforeGeneration: function(options)
{
options.series[0].dataLabels.formatter = function () {
if (this.y < 0)
return '<span style="fill: red;">(' + (-1 * this.y) + ')</span>';
else
return this.y;
};
},
</pre>
<p>Attached is an example.</p>
<p> </p>
BIRT User
<p>Thanks Wong!!. It solved my issue. </p>
Neojet
<p>Hello,</p>
<p> </p>
<p>I think my problem, is not so far this script.</p>
<p>It's about, when i got a value = 0, the datalabel go inside the negative bar. (<span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">Attached is an example).</span></p>
<p>Is it possible to just rise up the datalabel in this case ?</p>
<p> </p>
<p> </p>
<p> </p>
<p>P.S : Since i use the second type of bar chart, I already use in my script :</p>
<blockquote class="ipsBlockquote">
<p> </p>
<p>beforeDrawSeries: function(series, seriesOptions, chart, seriesIndex)</p>
<div>{</div>
<div>//You can change seriesOptions here.</div>
<div>seriesOptions.dataLabels.inside=false;</div>
<div>},</div>
</blockquote>
<p> </p>
<p> </p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">Thank you very much for your help.</span></p>
Clement Wong
<p>Please attach a sample report.</p>
Neojet
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">Please see a sample of my report with the source.</span></p>
<p> </p>
<p>In fact, i just wanna the label of serie1 (only positive value) are above the x axis and the labels of serie2 (only negative value) under the x axis.</p>
<p> </p>
<p>Thank you</p>
<p> </p>
<p> </p>
<p> </p>
Clement Wong
<p>Try this:</p>
<pre class="_prettyXprint _lang-">
beforeDrawDataPoint: function(point, pointOptions, chart, seriesIndex, pointIndex)
{
pointOptions.dataLabels = {
formatter: function() {
if (this.series.index == 0) {
if (this.y >= 0) return null;
else return this.y;
}
else {
if (this.y <= 0) return null;
else return this.y;
}
}
}
},
</pre>