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)
add text on chart
spulapalli
hello,
how to add dynamic text on chart in birt report. I have attached the screen shot for the same.
X Red:0.327
Blue
Tgt:.3
Red,Green and tgt are series names and values are data points(last) for that corresponding series.
X is a symbol. this is added based on conditions, we have add the symbols like X,O..etc.
I have done this report in erdpro, but struggling in birt. can you please let me know how can we do this in birt.
Thanks,
Suresh
Find more posts tagged with
Comments
spulapalli
any help on this.
mwilliams
You could try doing something like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
mmax = 0;
importPackage( Packages.org.eclipse.birt.chart.util);
importPackage( Packages.org.eclipse.birt.chart.model.data.impl);
function afterDataSetFilled(series, dataSet, icsc){
ps = PluginSettings.instance( );
if (series.getSeriesIdentifier() == "Series 1"){
dsp = ps.getDataSetProcessor(series.getClass());
//dataset max
mmax = dsp.getMaximum(dataSet);
}
}
function beforeDrawMarkerLine( axis, markerLine, icsc )
{
markerLine.setValue(NumberDataElementImpl.create(mmax))
markerLine.getLabel().getCaption().setValue("The new display value is \n" + mmax.toString())
}
</pre>
<br />
I added a markerline to the y-axis of the chart and made the line not visible and the label visible. This script then finds the max value of the chart, so the marker line value will be changed to move it to the top of the chart and the label can then be changed to whatever values you want. Let me know if you have questions.
spulapalli
thank you for the quick reply.
need more info
1. the X shown on the graph is a svg image created in existing report. I wanted to add the same svg on this graph in birt. i wanted to create svg images like X,O...etc based on some condition. can we do this?
here is the complete requirement.
I have three series on chart blue, red and target and category x-axis has months. the text should be displayed on chart in following scenarios.
1. blue series last datapoint value < target series last datapoint
then we should display as shown in image attached in previous conversations. X(color red) blue:last datapoint of target series
2. blue series last datapoint value > target series last datapoint
then we should display as shown in image attached in previous conversations. triange symbol(color green) blue:last datapoint of target series
i should display this on top of the graph.
Thanks
Suresh
mwilliams
I have doubts that you'll be able to do an image the way I showed above. The only thing I can think of for the image might be a background image. As for the text, you'd be able to change your text to what you want based on the dataset values in the AfterDataSetFilled function. You should be able to check the last value in each series' dataset. Then, change your marker text accordingly. Hope this helps.