Salut à tous,

J'ai des soucis d'affichage pour un graphique en bulle de la bibliothèque JFreeChart. Peut-être que qqn pourra m'aider.

Voici ce que j'obtiens



avec le code suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
private void plotBubbleChart(ResourceResponse response, Portefeuille portefeuille, String indiceReference, String portefeuilleReference) throws IOException{
		final MatrixSeriesCollection dataset = new MatrixSeriesCollection(perfVolatDataset(portefeuille,indiceReference,portefeuilleReference));
		final JFreeChart chart = ChartFactory.createBubbleChart("Croisement Perf / Volat sur un an glissant", "Volatilité", "Performance", dataset, PlotOrientation.VERTICAL, true, true, false);
		TextTitle subtitle = new TextTitle("La taille des points varie avec la proportion choisie pour votre portefeuille");
		subtitle.setFont(new Font("SansSerif", Font.ITALIC, 12));
                subtitle.setPosition(RectangleEdge.TOP);
                subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
                chart.addSubtitle(subtitle);
                chart.setBackgroundPaint(Color.white);
                final XYPlot plot =  chart.getXYPlot();
                plot.setForegroundAlpha(0.5f);
		final BufferedImage buf = chart.createBufferedImage(500, 300, null);
		final PngEncoder encoder = new PngEncoder(buf, false, 0, 9);
		response.getPortletOutputStream().write(encoder.pngEncode());
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
private NormalizedMatrixSeries perfVolatDataset(final Portefeuille portefeuille, String indiceReference, String portefeuilleReference) {
		final NormalizedMatrixSeries newSeries = new NormalizedMatrixSeries("Unités de compte", 100,100);
 
		for (final Uc uc : portefeuille.getListeUC()) {
			if ((uc.getVolatiliteUnAnGlissant() != null) && (uc.getPerfUnAnGlissant() != null)) {
				newSeries.update((int)Math.round(uc.getVolatiliteUnAnGlissant()*100), (int)Math.round(uc.getPerfUnAnGlissant()*100), uc.getRepartion()* 100);
			}
		}
		newSeries.update((int)Math.round(portefeuille.getVolatiliteUnAnGlissant()*100),(int)Math.round(portefeuille.getPerfUnAnGlissant()*100),1);
 
		return newSeries;
	}
uc.getVolatiliteUnAnGlissant(), uc.getPerfUnAnGlissant(), uc.getRepartion() et portefeuille.getVolatiliteUnAnGlissant(), portefeuille.getPerfUnAnGlissant() sont des doubles entre 0 et 1. Donc j'obtiens bien des entiers entre 0 et 100 pour les indice de newSeries. Je suis presque sur que les données que je passe au bubblechart sont correctes, je pense plutôt à un problème d'affichage des bulles, peut-être la couleur. Mais n'ayant fait aucun réglage sur ces bulles, je pense que les réglages par défauts de la bibliothèque permet de voir facilement quelque chose.

Merci pour votre aide.

Vanatou