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)
Different line types in Y-series grouping
mogwai
<p>I would like to use both full and dashed lines types for different Y series when using Y-series grouping in a line chart. </p>
<p> </p>
<p>Y-series groups that contain the string "Control" should be dashed. Others should be full.</p>
<p>The GUI doesn't allow this.</p>
<p> </p>
<p>I found code to change the series type but I don't know how to modify this to change the line type:</p>
<p> </p>
<p><span style="color:rgb(51,51,51);font-family:'Source Sans Pro', Arial;">importPackage(Packages.org.eclipse.birt.chart.model.data.impl); importPackage(Packages.org.eclipse.birt.chart.model.type.impl); function beforeGeneration( chart, icsc ) { yAxis = chart.getAxes()[0].getAssociatedAxes()[0]; seriesDef = yAxis.getSeriesDefinitions()[0]; for(i=0;i<seriesDef.getSeries().size();i++){ if(seriesDef.getSeries()
.getSeriesIdentifier() == "Vintage Cars"){ ds = seriesDef.getSeries()
.getDataSet(); } } ns = BarSeriesImpl.create(); ns.setDataSet(ds); ns.setSeriesIdentifier("Vintage Cars"); seriesDef.getSeries().add(ns); }</span></p>
<p> </p>
<p><span style="color:rgb(51,51,51);font-family:'Source Sans Pro', Arial;">This code changes the series for "Vintage Cars" to a bar series. I am looking for the code that will change the line type to dashed for series containing "Control".</span></p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>You need to dynamically change the LineAttribute of the series, as shown here:</p>
<pre class="_prettyXprint">
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.type.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
function beforeGeneration( chart, icsc ) {
yAxis = chart.getAxes()[0].getAssociatedAxes()[0];
seriesDef = yAxis.getSeriesDefinitions()[0];
for(i=0; i<seriesDef.getSeries().size(); i++){
if(seriesDef.getSeries()[i].getSeriesIdentifier() == "Vintage Cars"){
la = seriesDef.getSeries()[i].getLineAttributes();
la.setStyle(LineStyle.DOTTED_LITERAL);
ds = seriesDef.getSeries()[i].getDataSet();
}
}
}
</pre>
<p>Attached is the modified version of your report.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
mogwai
<p>Thanks Pierre. This is exactly what I needed. I used <span>LineStyle</span><span>.</span><span>DASHED_LITERAL instead of <span>LineStyle</span><span>.</span><span>DOTTED_LITERAL to get the dashed lines.</span></span></p>