Home
Analytics
How to set marker color different from line color in chart?
entimo
Hallo,
I want to set different colors for the line series marker and the line color. I would like to have a series with a black line and empty (white) markers. I think to have set the colors but the effect is, that when I take color white, the marker is ok (filled white) but the line in invisible (white?). It is possible to have different colors for marker and line? It is possible to have different line styles for the line and the marker border, too? I had the problem that the border was dashed when the line was set to be dashed. I am using birt 2.5.2.
my code:
//
// create line series
//
final LineSeries lineSeries = (LineSeries) LineSeriesImpl.create();
lineSeries.setSeriesIdentifier(ident);
lineSeries.setCurve(false);
lineSeries.getLabel().getCaption().setValue(ident);
//
// set line attributes
//
final LineAttributes lineAttributes = lineSeries.getLineAttributes();
lineAttributes.setColor(lineColor);
lineAttributes.setStyle(lineStyle);
lineSeries.setPaletteLineColor(true);
//
// set marker attributes
//
final EList<Marker> markers = lineSeries.getMarkers();
final Marker marker = markers.get(0);
marker.getOutline().setStyle(LineStyle.SOLID_LITERAL); // funzt leider nicht!?
marker.setType(markerType);
marker.setFill(markerColor);
marker.setSize(fSizeMarker);
final Query lineQuery = createQueryDef(dataName);
lineSeries.getDataDefinition().add(lineQuery);
//
// series definition and palette
//
final SeriesDefinition lineSeriesDef = SeriesDefinitionImpl.create();
// final Palette seriesPalette = PaletteImpl.create(lineColor);
// seriesPalette.getEntries().add(markerColor);
// lineSeriesDef.setSeriesPalette(seriesPalette);
// lineSeriesDef.getSeriesPalette().shift(-fPrimAxisY.getSeriesDefinitions().size());
lineSeriesDef.getSeriesPalette().update(markerColor);
lineSeriesDef.getSeries().add(lineSeries);
lineSeriesDef.getQuery().setDefinition(BasicTool.dquote(ident));
fPrimAxisY.getSeriesDefinitions().add(lineSeriesDef);
Thanks in advance,
Bertram
Find more posts tagged with
Comments
mwilliams
Hi Bertram,
As far as I know, the line color is set by the series palette and if you change the fill color of the marker in the chart script, the line color doesn't change. So, if you set the first color in your chart palette to black and then in your chart script do:
beforeDrawDataPoint{
fill.set(255,255,255);
}
wizkid
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="76494" data-time="1304346244" data-date="02 May 2011 - 07:24 AM"><p>
Hi Bertram,<br />
<br />
As far as I know, the line color is set by the series palette and if you change the fill color of the marker in the chart script, the line color doesn't change. So, if you set the first color in your chart palette to black and then in your chart script do:<br />
<br />
beforeDrawDataPoint{<br />
fill.set(255,255,255);<br />
}<br /></p></blockquote>
<br />
Hi mwilliams,<br />
<br />
Do you happen to know how to do this in javascript? I mean the part where you change the Color of the line.<br />
<br />
I tried the below code but the problem is that I can't 'cast' in javascript and here above 'cast' is used. I tried to past it through the "javascript way of casting" but it doesn't recognize LineSeries.<br />
<br />
chart = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement(chartname);<br />
<br />
chartInst = chart.getReportItem().getProperty("chart.instance");<br />
xaxis = chartInst.getAxes().get(0);<br />
yaxis = xaxis.getAssociatedAxes().get(0);<br />
serie = yaxis.getSeriesDefinitions().get(0); <br />
ls = serie.getSeries().get(0);<br />
la = ls.getLineAttributes();<br />
la.setColor(255,255,255);//not available because of cast?<br />
<br />
Thanks in advance.
mwilliams
Where are you putting your script at? What exactly are you trying to do? Set the line color or set the fill color for the markers?
wizkid
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="78912" data-time="1308765743" data-date="22 June 2011 - 11:02 AM"><p>
Where are you putting your script at? What exactly are you trying to do? Set the line color or set the fill color for the markers?<br /></p></blockquote>
<br />
?'m tryig to set the line color, the script is in the beforeFactory event.<br />
Do you happen to know if Birt got documentation for javascript about changing line colors and dropping charts? Or even an api reference.
mwilliams
Here's a link to the documentation that is available:
http://www.birt-exchange.com/be/downloads/documentation/#currentdocs
Have you tried scripting in the chart script rather than the beforeFactory event?