Applet Ternary plot / Triangular XYPlot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Loufa
Posts: 1
Joined: Wed Mar 04, 2015 7:46 pm
antibot: No, of course not.

Applet Ternary plot / Triangular XYPlot

Post by Loufa » Wed Mar 04, 2015 7:49 pm

Hello
I'm using jfreechart to create a ternary chart and run it as applet. the chart display correctly but when i exten it to an applet class and overwrite the paint function it open 5 different windows for the graph not sure why?

here is the code if you can help me.

Code: Select all

@Override
    public void paint(Graphics g) {
        DefaultXYDataset dataset = new DefaultXYDataset();
        dataset.addSeries("Red circles",new double[][]{{0, 1, 0.5,0.1, 0.6, 0.2, 0}, {1, 0, 0.5, 0.2, 0.3, 0.6, 0}});   
        XYPlot plot = new TriangularXYPlot();
        plot.setDataset(dataset);
        XYItemRenderer renderer = plot.getRenderer();
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesShape(0, new Ellipse2D.Double(-1, -1, 2, 2)); //point shape
        JFreeChart chart = new JFreeChart("Triangular Demo", new Font("Tahoma", 2, 18), plot, true);
        JFrame frame = new JFrame("XY Plot Demo");
        ChartPanel cPanel = new ChartPanel(chart);
        frame.getContentPane().add(cPanel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        cPanel.setPreferredSize(new java.awt.Dimension(1000, 540));
        frame.pack();
        frame.setVisible(true);
        chart.draw( (Graphics2D)g,getBounds()); 
    }

i wanted to clear that when i use code here: How can I run jfree chart as applet? http://stackoverflow.com/questions/1189 ... -as-appleti got a correct one window.

THE PROBLEM IS IN THIS LINES:

Code: Select all

JFrame frame = new JFrame("XY Plot Demo");
		ChartPanel cPanel = new ChartPanel(chart);
		frame.getContentPane().add(cPanel);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        cPanel.setPreferredSize(new java.awt.Dimension(1000, 540));
		frame.pack();
		frame.setVisible(true);

Locked