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)
Chart with one data point does not show anything
jmuthuku
Hi,<br />
I have a chart (an area graph showing a trend) and it works fine if I have more than one data point. But if there is only one data point it doesn't show anything. Is this a known bug. While searching online I found this <a class='bbc_url' href='
http://publib.boulder.ibm.com/infocenter/tivihelp/v24r1/index.jsp?topic=/com.ibm.itcamt.doc/rt/ss_miscellaneous/viewingtrendswithbirtreports.html'>link</a>
; explaining that it is a known issue. Just wanted to confirm and find out if there is a workaround.<br />
<br />
- J
Find more posts tagged with
Comments
mwilliams
Is this any chart with just one point? Can you post an example that shows this, using the sample database?
jmuthuku
Hi Micheal,
Thanks for the quick reply. I am attaching the rptdesign file here. Please have a look, i am able to reproduce this issue.
- J
mwilliams
Sorry. I skipped right over the word "area". What are you wanting to show when you have a single point area chart? Just a point?
mwilliams
If showing the single point, with a marker is acceptable for when you only have one point, you could put a script like this, in your chart's onRender:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var markerVisibility = false;
function afterDataSetFilled( series, dataSet, icsc )
{
if(series.getSeriesIdentifier() == "Series 1"){
if(dataSet.getValues().length == 1){
markerVisibility = true;
}
}
}
function beforeDrawMarker( marker, dph, icsc )
{
marker.setVisible(markerVisibility);
}
</pre>
<br />
Let me know.
jmuthuku
Thanks again Micheal. Using the code snippet you sent I am able to render a marker when there is only one data point. Will it be possible to render just a vertical line representing the single data point. Since I am not using markers in general it looks a bit odd to show the marker. I'd appreciate if you could let me know. Thanks a lot.
- J
mwilliams
Try this.<br />
<br />
Add a second series to your chart, with the same expression as the first. Then, in the format chart tab, go to the series section and make Series 2 a bar series. You can make the bar skinny by going to the general properties button, in the chart area section, and setting the unit spacing to 99. Finally, use the following script:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var barSeriesVisibility = false;
function afterDataSetFilled( series, dataSet, icsc )
{
if(series.getSeriesIdentifier() == "Series 1"){
if(dataSet.getValues().length == 1){
barSeriesVisibility = true;
}
}
}
function beforeGeneration( chart, icsc )
{
xAxis = chart.getAxes().get(0);
yAxis = xAxis.getAssociatedAxes().get(0);
if(barSeriesVisibility){
yAxis.getSeriesDefinitions().remove(yAxis.getSeriesDefinitions().get(0)); //drop area series
}
else{
yAxis.getSeriesDefinitions().remove(yAxis.getSeriesDefinitions().get(1)); // drop bar series
}
}
</pre>
<br />
This will check the number of points in the chart. If there is only 1, the area series is dropped and the bar series is shown. If there is more than one point, the opposite happens.
jmuthuku
Beautiful !!
I am amazed by your expertise :-) It works like a charm.
Thanks a lot again.
- J
mwilliams
You're very welcome! Let us know whenever you have questions!