How to Hide Series 2 Legend in the Chart

vijayshankar245
edited February 11, 2022 in Analytics #1
<p><span style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Hi</span></p>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">I have a report where I have two series Bar and line in the same chart. I'm showing total count against each application for the last 7 weeks.</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> </div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">The first 3 application names,we are showing in bar chart and the last 3 application names in line series like below.</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> </div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">//bar series</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">if (dataSetRow["Application"] == 'A1')</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">{</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> row["Count"]</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">}</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">else if (dataSetRow["Application"] == 'A2')</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">{</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> row["Count"]</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">}</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">else if (dataSetRow["Application"] == 'A3')</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">{</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> row["Count"]</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">}</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> </div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">//line series</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">if (dataSetRow["Application"] == 'A4')</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">{</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> row["Count"]</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">}</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">else if (dataSetRow["Application"] == 'A5')</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">{</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> row["Count"]</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">}</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">else if (dataSetRow["Application"] == 'A6')</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">{</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> row["Count"]</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">}</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> </div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">But the legend values are showing for all the application names as below</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 1 - A1</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 1 - A2</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 1 - A3</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 1 - A4</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 1 - A5</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 1 - A6</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> </div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 2 - A1</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 2 - A2</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 2 - A3</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 2 - A4</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 2 - A5</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Series 2 - A6</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> </div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">I want series 1 to display only the first 3 application names and series 2 to display only the last 3 applications.</div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);"> </div>
<div style="background-color:rgb(255,255,255);color:rgb(38,39,43);">Please help if anyone has worked on the above scenario.</div>

Comments

  • <p>Hi,</p>
    <p> </p>
    <p>what version of BIRT are you using ?</p>
    <p>Can you upload a flat file (csv) with basic sample datas ?</p>
    Warning No formatter is installed for the format ipb
  • vijayshankar245
    edited March 16, 2016 #3
    <blockquote class="ipsBlockquote" data-author="GLO_FR" data-cid="142852" data-time="1458054039">
    <div>
    <p>Hi,</p>
    <p> </p>
    <p>what version of BIRT are you using ?</p>
    <p>Can you upload a flat file (csv) with basic sample datas ?</p>
    </div>
    </blockquote>
    <p>Hi GLO_FR</p>
    <p> </p>
    <p>The release version of BIRT Actuate is Version : 4.4.0</p>
    <p> I have attached the output ,report the excel datasource. Please help if you know how to show the corresponding legend values based on the Y series.</p>
    <p> </p>
    <p>I have written the code for each series as below,</p>
    <p>//line series</p>
    <p>if (dataSetRow["Application"] == 'App_01')<br>
    {<br>
     row["Count"]<br>
    }<br>
    else if (dataSetRow["Application"] == 'App_02')<br>
    {<br>
     row["Count"]<br>
    }<br>
    else if (dataSetRow["Application"] == 'App_03')<br>
    {<br>
     row["Count"]<br>
    }</p>
    <p> </p>
    <p> //bar series</p>
    <p>if (dataSetRow["Application"] == 'App_04')<br>
    {<br>
     row["Count"]<br>
    }<br>
    else if (dataSetRow["Application"] == 'App_05')<br>
    {<br>
     row["Count"]<br>
    }<br>
    else if (dataSetRow["Application"] == 'App_06')<br>
    {<br>
     row["Count"]<br>
    }</p>
    <p> </p>
    <p>But the data for the remaining apps are showing in the line series as 0. but i want only 3 apps to be shown in line and the other 3 in bar.</p>
    <p> </p>
    <p>I have also tried having a seperate total number column for both BAR and LINE as below</p>
    <p> </p>
    <p><b>if</b> (row["Count_Bar"] != <b>null</b>) { row["Count_Bar"];} </p>
    <p> </p>
    <p> </p>
    <p><b>if</b>(row["Count_Line"] != <b>null</b>) { row["Count_Line"];}</p>
    <p> </p>
    <p>Kindly help if you know how to limit the entries for each chart. I guess the problem lies here since all the apps are showing for both the series, the legends are displaying all. If we could change the above logic, the issue will be resolved.</p>
    <p> </p>
    <p>Kindly help if anyone has written any script to hide the zero values in the series.</p>
  • <p>Hi,</p>
    <p> </p>
    <p>the easiest way can be to simply add some script to hide the serie.</p>
    <pre class="_prettyXprint _lang-">
    beforeRendering: function(options, chart) {
    for (i=0;i<options.series.length; i++) {
    if (i<3 || i>8) {
    options.series[i].showInLegend = true;
    } else {
    options.series[i].showInLegend = false;
    }
    }
    } </pre>
    <p>example attached</p>
    <p> </p>
    <p> </p>
    Warning No formatter is installed for the format ipb
  • <blockquote class="ipsBlockquote" data-author="GLO_FR" data-cid="142874" data-time="1458133434"><br><div><br><p>Hi,</p>
    <p> </p>
    <p>the easiest way can be to simply add some script to hide the serie.</p>
    <pre class="_prettyXprint _lang-">
    beforeRendering: function(options, chart) {
    for (i=0;i<options.series.length; i++) {
    if (i<3 || i>8) {
    options.series[i].showInLegend = true;
    } else {
    options.series[i].showInLegend = false;
    }
    }
    } </pre>
    <p>example attached</p>
    </div>
    </blockquote>
    <p>Thanks</p>
    <p> </p>
    <p>But the main issue we found in the report now is the list of values showing for each charts.</p>
    <p> </p>
    <p>I want only APP_01,APP_02,APP_03 to show as line series and APP_04,APP_05,APP_06 as Bar.</p>
    <p> </p>
    <p>Attached the report and the excel source.</p>
    <p> </p>
    <p>The error is all the apps are showing in the Bar and line with values as zero.</p>
  • <blockquote class="ipsBlockquote" data-author="GLO_FR" data-cid="142874" data-time="1458133434">
    <div>
    <p>Hi,</p>
    <p> </p>
    <p>the easiest way can be to simply add some script to hide the serie.</p>
    <pre class="_prettyXprint _lang-">
    beforeRendering: function(options, chart) {
    for (i=0;i<options.series.length; i++) {
    if (i<3 || i>8) {
    options.series[i].showInLegend = true;
    } else {
    options.series[i].showInLegend = false;
    }
    }
    } </pre>
    <p>example attached</p>
    </div>
    </blockquote>
    <p>Thanks a ton.</p>
    <p>The above solution worked with our excel datasource.</p>
    <p> </p>
    <p>But we actually use JDBC data source, the script column in the chart doesnt show any functions. Is it because of the data source? kindly help</p>
  • <p>Mmmm strange. </p>
    <p>In the Chart wizard window, did you choose <strong>HTML5 </strong>chart on the "Select Chart type" sheet</p>
    Warning No formatter is installed for the format ipb
  • <p>You can also do it that way (serie renamed dynamicaly with script).</p>
    <p>In that case no "ghost" series with 0/null value</p>
    <p> </p>
    Warning No formatter is installed for the format ipb
  • <blockquote class="ipsBlockquote" data-author="GLO_FR" data-cid="142878" data-time="1458135301">
    <div>
    <p>Mmmm strange. </p>
    <p>In the Chart wizard window, did you choose <strong>HTML5 </strong>chart on the "Select Chart type" sheet</p>
    </div>
    </blockquote>
    <p>I also faced the similar issue. The chart type selected was "HTML5". but no script function can be written inside the chart script editor.</p>
    <p>Instead wrote the script in the main page script editor but it didnt render the desired results. could we test/debug how the script works?</p>
  • Warning No formatter is installed for the format ipb
  • <blockquote class="ipsBlockquote" data-author="GLO_FR" data-cid="142881" data-time="1458136470">
    <div>
    <p>You can also do it that way (serie renamed dynamicaly with script).</p>
    <p>In that case no "ghost" series with 0/null value</p>
    </div>
    </blockquote>
    <p>Hi Guillaume</p>
    <p> </p>
    <p>I have a similar requirement but in your example you have used incremental logic to the series since it is increasing with numbers.</p>
    <p> </p>
    <p>But my scenario is little different, I have the series as string values and I want to show first 2 in Bar and the remaining in Line.</p>
    <p> </p>
    <p>I have attached the flat file and the same barchart you have modified. Kindly help.</p>