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)
Hiding a (sub-)Series Based Upon SeriesIdentifier
sweaver
<p>Hi All,</p>
<p>I am trying to make a chart, under the following scenario.</p>
<p> </p>
<p>I have a SQL datasource with the following columns:</p>
<ul><li>Name - used for grouping the Y-values</li>
<li>Value - the Y Values</li>
<li>Datetime - the X values</li>
</ul><p>However, the data is gappy - there are periods that will have no data. When added to a chart the gaps are closed and the X axis values simply jump from say, April 25 to May 22.</p>
<p> </p>
<p>I have another, scripted, datasource - that has a single Column - DateTime - that contains an entry for every day between the first and last entry of the first datasource.</p>
<p> </p>
<p>My tentative solution was to create a joint dataset, doing an outer join on datetime. So, now, this dataset has an entry for every date, but for the gaps the name and value rows are null. </p>
<p> </p>
<p>The chart now displays correctly and has an appropriate x-axis and there's no gaps. However, now there's a phantom (sub-)series for the dates that lack a name or value, which is only visible in the legend.</p>
<p> </p>
<p>So, my question is twofold:</p>
<ol><li>Is there a better/BIRTier way to deal with this situation?</li>
<li>Is there an easy way to remove the phantom series from the legend?</li>
</ol><p>I assume there is as my searching revealed people doing similar things with the onRender/beforeGenerate functions but all the examples I could find were using properties that don't appear to exist anymore for the BIRT chart class.</p>
<p> </p>
<p>I assume that it will ultimately rest upon checking whether the SeriesIdentifier is null and setting visible to false if so.</p>
<p> </p>
<p>EDIT: Also, is there a similar way to limit the number of series for a chart or is that best handled via the SQL query used to populate the dataset? The former would be more useful as the dataset would be reusable. </p>
<p> </p>
<p>EDIT2: I've tried a few things along the lines below. But it doesn't work - likely because I am misunderstanding what is being returned or how "for each ... in" works (some of my troubleshooting has counted some 130 entries so I think I have overlooked something far more straightforward.</p>
<pre class="_prettyXprint _lang-js">
function beforeGeneration( chart, icsc )
{
seriesSet = chart.getSeriesForLegend();
for each (a in seriesSet){
for each (s in a){
if ( !s.getSeriesIdentifer() ){
s.visible = false;
}
}
}
}
</pre>
<p>Many thanks. </p>
Find more posts tagged with
Comments
GLO_FR
<p>Hi,</p>
<p> </p>
<p>what version of BIRT are you using ?</p>
<p>can you upload an example based on a scripted datasource or flat file or classic model db ?</p>