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 83 84 85 86 87 88 89
   |  
 
public class Graphique extends JPanel {
 
	public Graphique(double cpm1, int temps1, double cpm2,
			double temps2, double cpm3, double temps3, double cpm4,
			double temps4) {
 
 
		final XYDataset dataset = createDataset(cpm1, temps1,
				cpm2, temps2, cpm3, temps4, cpm4,
				temps4);
		final JFreeChart chart = createChart(dataset);
		final ChartPanel chartPanel = new ChartPanel(chart){
 
                @Override
                public Dimension getPreferredSize() {
                    return new Dimension(501, 190);
                }
            };
		chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
		add(chartPanel);
 
 
		final XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(Color.lightGray);
 
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
 
        final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setSeriesLinesVisible(1, false);
        renderer.setSeriesShapesVisible(1, false);
        plot.setRenderer(renderer);
 
	}
 
	public XYDataset createDataset(double cpm1, int temps1, double cpm2,
			double temps2, double cpm3, double temps3, double cpm4,
			double temps4) {
		final XYSeries series1 = new XYSeries("log cpm net");
		series1.add(temps1, cpm1);
		series1.add(temps2, cpm2);
		series1.add(temps3, cpm3);
		series1.add(temps4, cpm4);
		final XYSeriesCollection dataset = new XYSeriesCollection();
		dataset.addSeries(series1);
		return dataset;
 
	}
 
	private JFreeChart createChart(final XYDataset dataset) {
		final JFreeChart chart = ChartFactory.createXYLineChart("log Chart", // chart
																				// title
				"temps", // x axis label
				"log CPM", // y axis label
				dataset, // data
				PlotOrientation.VERTICAL, true, // include legend
				true, // tooltips
				false // urls
				);
		return chart;
 
        }
 
	}
/**
        public static void main(final String[] args) {
                Graphique v = new Graphique(Math.log(819), 90, Math.log(687),
          110,
            Math.log(580), 130,
               Math.log(482), 150);
                JFrame F = new JFrame ();
                F.add(v);
                F.setVisible(true);
                // window parameters
                F.setSize(800, 900);
        
                java.lang.Number tabx[] = { 90,110, 130, 150 };
                java.lang.Number taby[] = { Math.log10(819), Math.log10(687),
                                Math.log10(580), Math.log10(482) };
                double[] x = Statistics.getLinearFit(tabx, taby);
                for (int i = 0; i < 2; i++) {
                         System.out.println(x[i]);
                        float p1 = (float) (x[0]);
                        float p2 = (float) (x[1]);}
                }
        
*/ | 
Partager