List of usage examples for org.jfree.data.xy XYSeries XYSeries
public XYSeries(Comparable key)
From source file:GUI.PlotHere.java
/** * Creates new form PlotHere/*from w w w . ja v a 2 s. c o m*/ */ public PlotHere(String Title) { initComponents(); XYSeries Input00 = new XYSeries("Input 00"); XYSeries Input01 = new XYSeries("Input 01"); XYSeries Input02 = new XYSeries("Input 02"); XYSeriesCollection data = new XYSeriesCollection(Input00); data.addSeries(Input01); data.addSeries(Input02); JFreeChart chart = ChartFactory.createXYLineChart(Title, "Angle", "Voltage", data, PlotOrientation.VERTICAL, true, true, false); ChartPanel chartpanel = new ChartPanel(chart); //chartpanel.setDomainZoomable(true); chartpanel.setPreferredSize(new java.awt.Dimension(200, 200)); //JPanel jPanel4 = new JPanel(); Component[] a = GraphHerePanel.getComponents(); if (a.length == 0) { GraphHerePanel.setLayout(new BorderLayout()); GraphHerePanel.add(chartpanel); } this.revalidate(); this.repaint(); }
From source file:JchartTest.GetChartAction.java
@Override public String execute() throws Exception { ValueAxis xAxis = new NumberAxis("Input Increase"); ValueAxis yAxis = new NumberAxis("Production"); XYSeries xySeries = new XYSeries(new Integer(1)); xySeries.add(0, 200);// w ww . j av a 2 s . co m xySeries.add(1, 300); xySeries.add(2, 500); xySeries.add(3, 700); xySeries.add(4, 700); xySeries.add(5, 900); XYSeriesCollection xyDataset = new XYSeriesCollection(xySeries); // create XYPlot XYPlot xyPlot = new XYPlot(xyDataset, xAxis, yAxis, new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES)); chart = new JFreeChart(xyPlot); return SUCCESS; }
From source file:DATA.Grafica.java
public void crearSerie(double[] datos, String nombre) { XYSeries serie = new XYSeries(nombre); // leemos los datos for (int x = 0; x < datos.length; x++) { serie.add(x, datos[x]);//from w ww . ja va 2s . co m } // agregamoss la serie a la coleccion this.coleccion.addSeries(serie); }
From source file:org.jfree.chart.demo.XYLine3DRendererDemo1.java
private static XYDataset createDataset() { XYSeries xyseries = new XYSeries("Series 1"); xyseries.add(1.0D, 3.2999999999999998D); xyseries.add(2D, 4.4000000000000004D); xyseries.add(3D, 1.7D);//from w w w. j a v a2 s . com XYSeries xyseries1 = new XYSeries("Series 2"); xyseries1.add(1.0D, 7.2999999999999998D); xyseries1.add(2D, 0.0D); xyseries1.add(3D, 9.5999999999999996D); xyseries1.add(4D, 5.5999999999999996D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); xyseriescollection.addSeries(xyseries1); return xyseriescollection; }
From source file:at.ac.tuwien.dsg.utility.DesignChart.java
public void chart(LinkedList<String> xValue, LinkedList<String> yValue) throws Exception { XYSeries series = new XYSeries("Sensory Data"); final JFreeChart chart; //data assignment in the chart {//from www .ja v a 2 s .c o m for (int i = 0; i < xValue.size(); i++) { series.add(Double.parseDouble(xValue.get(i)), Double.parseDouble(yValue.get(i))); } final XYSeriesCollection data = new XYSeriesCollection(series); chart = ChartFactory.createXYLineChart("Graph Visualization", "collection_time", "collection_data", data, PlotOrientation.VERTICAL, true, true, false); } //design the plot of the chart { XYPlot xyPlot = chart.getXYPlot(); NumberAxis xAxis = (NumberAxis) xyPlot.getDomainAxis(); NumberAxis yAxis = (NumberAxis) xyPlot.getRangeAxis(); xAxis.setRange(20, 120); xAxis.setTickUnit(new NumberTickUnit(15)); yAxis.setRange(947, 950); yAxis.setTickUnit(new NumberTickUnit(0.5)); } //generation of the image { try { BufferedImage img = chart.createBufferedImage(300, 200); //File outputfile = new File("./example/Sample.png"); File outputfile = new File( "/Users/dsg/Documents/phd/Big Demo/CloudLyra/Utils/JBPMEngine/example/Sample.png"); ImageIO.write(img, "png", outputfile); } catch (Exception e) { System.out.println("exception occured in tomcat: " + e); } } }
From source file:AppPackage.HumidityGraph.java
/** * *///from w w w . j a v a 2 s . c o m public HumidityGraph() { try { JFrame window = new JFrame(); window.setSize(1000, 615); window.setBackground(Color.blue); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - window.getWidth()) / 2); int y = (int) ((dimension.getHeight() - window.getHeight()) / 2); window.setLocation(x, y); XYSeries series = new XYSeries("Humidity "); XYSeriesCollection dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createXYLineChart("Humidity against Time", "Time(seconds)", "Humidity(percentage)", dataset); window.add(new ChartPanel(chart), BorderLayout.CENTER); window.setVisible(true); } catch (Exception e) { System.out.print("Chart exception:" + e); } initComponents(); }
From source file:cpsControllers.LineChartController.java
/** * Method for create line chart./*w ww .j a v a 2s . c om*/ * * @param t * @param values * @return */ public JFreeChart printChart(ArrayList<Integer> t, ArrayList<Double> values) { // Prepare the data set XYSeries xySeries = new XYSeries("Number & Square Chart"); double[] val = new double[values.size()]; for (int i = 0; i < val.length; i++) { xySeries.add(i, values.get(i)); } XYDataset xyDataset = new XYSeriesCollection(xySeries); //Create the chart JFreeChart chart = ChartFactory.createXYLineChart("Wykres liniowy", "Czas (t)", "Aplituda (A)", xyDataset, PlotOrientation.VERTICAL, false, true, false); // //Render the frame // ChartFrame chartFrame = new ChartFrame("Wykres sygnalu ", chart); // chartFrame.setVisible(true); // chartFrame.setSize(800, 600); return chart; }
From source file:com.raghav.plot.XYSeriesDemo.java
/** * A demonstration application showing an XY series containing a null value. * * @param title the frame title./* www . java 2 s. c o m*/ */ public XYSeriesDemo(final String title) { super(title); final XYSeries series = new XYSeries("Random Data"); // float x=1; // float y=(float)((Math.sqrt(2))*x); // for (int i = 1; i < 200000; i++) { double x = (((double) (i)) / 1000); System.out.print("x = " + x); double xdb = 10 * (Math.log10(x)); System.out.print("\t 10logx=" + xdb); double y = Erf.erfc(Math.sqrt(x)); System.out.print("\t y=" + y); System.out.println("----------------------"); series.add(xdb, y); } final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart("XY Series Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:frequencyassignment.charts.Charts.java
public static void displayScatterPlot(String name, HashMap<Double, Double> values) { XYSeries xyData = new XYSeries(name); for (Map.Entry<Double, Double> entry : values.entrySet()) { xyData.add(entry.getKey(), entry.getValue()); }// w w w .j ava2 s .c om XYSeriesCollection xySeriesCollection = new XYSeriesCollection(xyData); JFreeChart chart = ChartFactory.createScatterPlot(name, "X", "Y", (XYDataset) xySeriesCollection); ChartFrame frame = new ChartFrame(name, chart); frame.pack(); frame.setVisible(true); }
From source file:org.rhwlab.ace3d.SegmentationLinePlot.java
public void setTree(BHCTree tree) { XYSeriesCollection collect = new XYSeriesCollection(); XYSeries series = new XYSeries(""); collect.addSeries(series);/*from w w w. j a va 2s.c o m*/ TreeMap<Integer, TreeSet<NucleusLogNode>> map = tree.allTreeCuts(500); for (Integer i : map.keySet()) { TreeSet<NucleusLogNode> nodes = map.get(i); double lnP = nodes.first().getLogPosterior(); series.add((double) i, Math.exp(lnP)); } int t = tree.getTime(); int nu = tree.getNu(); JFreeChart chart = ChartFactory.createXYLineChart( String.format("Time=%d,nu=%d,alpha=%e", tree.getTime(), tree.getNu(), tree.getAlpha()), "Index", "Probability", collect, PlotOrientation.VERTICAL, false, true, true); XYPlot plot = (XYPlot) chart.getPlot(); ChartPanel panel = new ChartPanel(chart); this.add(panel); }