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
| import org.jCharts.axisChart.*;
import org.jCharts.test.*;
import org.jCharts.types.*;
import org.jCharts.chartData.*;
import org.jCharts.nonAxisChart.*;
import org.jCharts.properties.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MonPanel extends JPanel
{
// CHAMPS
AxisChart axisChart;
// Constructeur :
public MonPanel()
{
super(true);
setBackground(Color.black);
}
//**********************************************************************
public void construireUnAxisChart() throws ChartDataException, PropertyException
{
// -----------------------------------------------------------------------------
String[] xAxisLabels= { "A", "B", "C", "D", "E", "F", "G", "H", "I" };
String xAxisTitle= "Temps";
String yAxisTitle= "Rendement";
String title= "Joli graphe";
DataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle, yAxisTitle, title );
double[][] data= new double[][]{ { 250, 45, 136, 66, 145, 80, 55, 34, 98 },
{ 50, 145, 6, 166, 105, 105, 85, 78, 80 } };
String[] legendLabels= { "Bugs", "FUD Towards Gnu/Linux" };
Paint[] paints= new Paint[] { new Color( 255, 0, 18 ,100 ), //new Color( 153, 0, 255 ,100 ),
new Color( 255,138, 0, 150 ) };//new Color( 204,0,255, 150 ) };
AreaChartProperties areaChartProperties= new AreaChartProperties();
AxisChartDataSet axisChartDataSet= new AxisChartDataSet( data, legendLabels,
paints, ChartType.AREA,
areaChartProperties );
dataSeries.addIAxisPlotDataSet( axisChartDataSet );
ChartProperties chartProperties = new ChartProperties();
AxisProperties axisProperties = new AxisProperties();
LegendProperties legendProperties = new LegendProperties();
axisChart= new AxisChart( dataSeries, chartProperties,
axisProperties, legendProperties,
500, 350 );
Graphics g = this.getGraphics();
Graphics2D g2 = (Graphics2D) g;
axisChart.setGraphics2D( g2) ;
}
//**********************************************************************
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
axisChart.setGraphics2D( g2) ;
try {
axisChart.render();
}
catch (ChartDataException cde)
{
System.out.println( cde.toString() );
}
catch (PropertyException pe)
{
System.out.println( pe.toString() );
}
}
//**********************************************************************
} |