Bonjour
j'ai essayé d'intégrer une charte avec Java dans un rapport Birt, j'utilise Birt2.6
La charte a pour source d'information un DataSet deja existant ,donc voila j'ai deux problèmes :
voici mon code :
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| OdaDataSetHandle dataSet = fact.newOdaDataSet("chartDataSet","org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet");
try {
dataSet.setDataSource("DataBase");
dataSet.setQueryText("select * from tab1;");
designHandle.getDataSets().add(dataSet);
} catch (SemanticException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
ExtendedItemHandle EX=null;
ChartWithAxes chart=ChartWithAxesImpl.create();
chart.getBlock().setBackground(ColorDefinitionImpl.YELLOW());
chart.getBlock().getOutline().setVisible(true);
chart.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL);
// customize the plot
Plot p = chart.getPlot();
p.getClientArea().setBackground(ColorDefinitionImpl.create(255, 255, 225));
p.getOutline().setVisible(false);
chart.getTitle().getLabel().getCaption().setValue("Simple Bar Chart");
// customize the legend
Legend lg = chart.getLegend();
lg.getOutline( ).setVisible( false );
lg.getText().getFont().setSize(16);
lg.getInsets().set(10, 5, 0, 0);
lg.setAnchor(Anchor.NORTH_LITERAL);
// customize the X-axis
Axis[] axa = chart.getPrimaryBaseAxes();
Axis xAxisPrimary=axa[0];
xAxisPrimary.setType(AxisType.TEXT_LITERAL);
xAxisPrimary.setCategoryAxis(true);
xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
xAxisPrimary.getOrigin().setType(IntersectionType.VALUE_LITERAL);
xAxisPrimary.getTitle().setVisible(true);
// customize the Y-axis
Axis yAxisPrimary = chart.getPrimaryOrthogonalAxis(xAxisPrimary);
yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
yAxisPrimary.setType(AxisType.LINEAR_LITERAL);
yAxisPrimary.getLabel().getCaption().getFont().setRotation(90);
// create the category base series
Query query =QueryImpl.create("row[\"nom\"]");
Series Category = SeriesImpl.create();
Category.getDataDefinition().add(query);
Category.setSeriesIdentifier(query);
// create the value orthogonal series
Query Q1=QueryImpl.create("row[\"num1\"]");
Series bs1 = (LineSeries) LineSeriesImpl.create();
bs1.getDataDefinition().add(Q1);
bs1.setSeriesIdentifier(Q1);
bs1.getLabel().setVisible(true);
bs1.setLabelPosition(Position.INSIDE_LITERAL);
// wrap the base series in the X-axis series definition
SeriesDefinition sdX = SeriesDefinitionImpl.create();
sdX.getSeriesPalette().update(0);
xAxisPrimary.getSeriesDefinitions().add(sdX);
// wrap the orthogonal series in the X-axis series definition
SeriesDefinition sdY = SeriesDefinitionImpl.create();
sdY.getSeriesPalette().update(0);
sdY.getSeries().add(bs1);
yAxisPrimary.getSeriesDefinitions().add(sdY);
sdY.getSeries().add(bs1);
sdX.getSeries().add(Category);
try {
EX=fact.newExtendedItem(null,"Chart");
try {
EX.setProperty(ExtendedItemHandle.DATA_SET_PROP,"Data Set");
EX.setDataSet(dataSet);
EX.setHeight("250pt");
EX.setWidth("250pt");
EX.getReportItem( ).setProperty( "chart.instance", chart );
designHandle.getBody().add(EX);
}
catch (SemanticException e1) {e1.printStackTrace();}
}
catch (ClassCastException e){e.getMessage();} |

le premier c'est que la charte ne retrouve pas les données du DataSet meme si dans la propietée "Binding" de la charte on trouve ma DataSet.
Le deuxième c'est quand j'essai d'acceder à "Edit chart" dans la vue design ben j'ai ce problème dans l'image.
Merci pour votre aide.