Home » Archived » BIRT » Error bar charts.
Error bar charts. [message #367032] |
Mon, 16 February 2009 14:16 |
Jeroen Van Goey Messages: 7 Registered: July 2009 |
Junior Member |
|
|
Hey,
I want to show bar charts with error bars in BIRT. Working from the
example package on
http://www.eclipse.org/articles/article.php?file=Article-BIR TChartEngine/index.html
I modified the buildYSeries() method in BarChartBuilder.java to the
following:
<code>
protected void buildYSeries() {
NumberDataSet orthoValuesDataSet1 =
NumberDataSetImpl.create(dataSet
.getTechnitians());
BarSeries bs1 = (BarSeries) BarSeriesImpl.create();
bs1.setDataSet(orthoValuesDataSet1);
bs1.setRiserOutline(null);
// Lower error bar series data set
StockDataSet dsStockValuesLower = StockDataSetImpl
.create(new StockEntry[] {
new StockEntry(7, 7, 8, 7),
new StockEntry(4, 4, 5, 4),
new StockEntry(3, 3, 4, 3),
new StockEntry(11, 11, 12, 11),
new StockEntry(1, 1, 2, 1),
new StockEntry(2, 2, 3, 2) });
// Upper error bar series data set
StockDataSet dsStockValuesUpper = StockDataSetImpl
.create(new StockEntry[] {
new StockEntry(9, 8, 9, 9),
new StockEntry(6, 5, 6, 6),
new StockEntry(5, 4, 5, 5),
new StockEntry(13, 12, 13, 13),
new StockEntry(3, 2, 3, 3),
new StockEntry(4, 3, 4, 4) });
// Create stock series
StockSeries ssl = (StockSeries) StockSeriesImpl.create();
ssl.getLineAttributes().setColor(ColorDefinitionImpl.BLUE()) ;
ssl.setDataSet(dsStockValuesLower);
StockSeries ssu = (StockSeries) StockSeriesImpl.create();
ssu.getLineAttributes().setColor(ColorDefinitionImpl.BLUE()) ;
ssu.setDataSet(dsStockValuesUpper);
// Create scatter series
ScatterSeries ss = (ScatterSeries) ScatterSeriesImpl.create();
ss.getMarker().setType(MarkerType.CIRCLE_LITERAL);
ss.setDataSet(orthoValuesDataSet1);
SeriesDefinition sdY1 = SeriesDefinitionImpl.create();
yAxis.getSeriesDefinitions().add(sdY1);
sdY1.getSeriesPalette().update(ColorDefinitionImpl.BLACK());
sdY1.getSeries().add(bs1);
sdY1.getSeries().add(ssl);
sdY1.getSeries().add(ssu);
sdY1.getSeries().add(ss);
}
</code>
So I misused a StockSeries and a ScatterSeries to create the following
effect: http://picasaweb.google.com/jeroen.vangoey/BIRT#530338995039 9700658
Three questions:
* The dot of the scatter series isn't always perfectly centered on the
vertical bar of my error bars (see for example the dots beloning to the
cities Bejing, Xian and Nanning in the picture). Is there a way to correct
this?
* I added my BarSeries to my SeriesDefinition ( sdY1.getSeries().add(bs1);
), but my bars aren't showing. Is there a way to make the bar chart
visible?
* If I remove the line "ss.setDataSet(orthoValuesDataSet1);" in the above
code, I get the bars from my bar chart, and the upper error bar I defined,
but my lower error bar end the dot from the scatter plot aren't showing
any more, see:
http://picasaweb.google.com/jeroen.vangoey/BIRT#530339478777 2763634
How do i get these back?
The last 2 questions are related. Essentially, the effect I'm trying to
achieve is to produce a bar chart, and centered on the top of each bar a
dot with two error bars extending from it, something like in this
photoshop mockup:
http://picasaweb.google.com/jeroen.vangoey/BIRT#530339751689 7454530
Of course I'm going to refactor my code to include a method which takes 2
parameters (the height of the bar and the standard deviation to draw the
error bars from) instead of the hardcoded numbers I have now, but any
other comments about how I would achieve this effect (possibly without
misusing stock- and scatterseries) would be appreciated.
Thanks in advance,
Jeroen Van Goey
|
|
| |
Re: Error bar charts. [message #529943 is a reply to message #529792] |
Tue, 27 April 2010 18:54 |
roadblock2thesun Messages: 14 Registered: April 2010 |
Junior Member |
|
|
This should be relatively easy from the eclipse report designer (this might depend on what version of BIRT you are using). Drag a chart onto your report layout. Select bar chart as your chart type. Go to 'select data' and add three series (one for bars, one for error bars, and one for the data point). Now go to 'format chart'. If it is not already selected, click on 'series' in the lefthand navigation pane. Next to each series you should see a drop down box (below the chart preview) that lists the series type. The first one should be greyed out and says 'bar series'. Change the second one to stock series and the third to line series (you will also have to go into the line series properties and set the line to not display). Then, go back to 'select data' and fill in all of your data the way you want it.
Let me know if you have anymore questions or if this doesn't work. I have not tried, but I have overlayed series of different types using a similar method.
RB
[Updated on: Tue, 27 April 2010 18:57] Report message to a moderator
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 01:24:17 GMT 2024
Powered by FUDForum. Page generated in 0.02848 seconds
|