List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries
public void addSeries(XYSeries series)
From source file:utils.Graficos_old.java
public static JFreeChart GraficoLinhas(List<CarCapContas> pagar, List<CarCapContas> receber, String titulo) { XYSeries series1 = new XYSeries("Pagar"); // CarCapContas contasPagar = new CarCapContas(); for (CarCapContas contasPagar : pagar) { series1.add(contasPagar.getContaValorTotal(), contasPagar.getContaDataEmissao().getMonth()); }/*from w w w . j av a 2 s . c o m*/ XYSeries series2 = new XYSeries("Receber"); for (CarCapContas contasReceber : receber) { series2.add(contasReceber.getContaValorTotal(), contasReceber.getContaDataEmissao().getMonth()); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); JFreeChart chart = ChartFactory.createXYLineChart(titulo, // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:MainWindowLogic.java
static void drawXYChart(JPanel panelWhenInside, JTable pointsCollector) { panelWhenInside.removeAll();//from www .jav a 2 s. c om panelWhenInside.setLayout(new java.awt.BorderLayout()); //TODO XYSeries seriersAllPoints = new XYSeries("All points"); addPointsToSeries(seriersAllPoints, pointsCollector); // Add the seriersAllPoints to your data set XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(seriersAllPoints); // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart(null, // Title null, // x-axis Label null, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend false, // Use tooltips false // Configure chart to generate URLs? ); final XYPlot plot = chart.getXYPlot(); ChartPanel chartPanel = new ChartPanel(chart); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); plot.setRenderer(renderer); panelWhenInside.add(chartPanel, BorderLayout.CENTER); panelWhenInside.validate(); }
From source file:org.jfree.chart.demo.PolarChartDemo1.java
private static XYDataset createDataset() { XYSeriesCollection xyseriescollection = new XYSeriesCollection(); XYSeries xyseries = new XYSeries("Series 1"); xyseries.add(0.0D, 2D);/*from w w w . j ava2 s . co m*/ xyseries.add(90D, 13D); xyseries.add(180D, 9D); xyseries.add(270D, 8D); xyseriescollection.addSeries(xyseries); XYSeries xyseries1 = new XYSeries("Series 2"); xyseries1.add(90D, -11.199999999999999D); xyseries1.add(180D, 21.399999999999999D); xyseries1.add(250D, 17.300000000000001D); xyseries1.add(355D, 10.9D); xyseriescollection.addSeries(xyseries1); return xyseriescollection; }
From source file:eu.cassandra.csn.gui.Stats.java
/** * /*from w ww.jav a 2 s . c om*/ * @param instInfo */ public static void updateTableModelSelected(Vector<InstallationInfo> instInfos) { for (int i = tableModelSelected.getRowCount() - 1; i >= 0; i--) { tableModelSelected.removeRow(i); } for (int i = 0; i < instInfos.size(); i++) { InstallationInfo instInfo = instInfos.get(i); String[] rowData = new String[5]; rowData[0] = (instInfo.getInstallationName() != null ? instInfo.getInstallationName() : ""); rowData[1] = (instInfo.getInstallationType() != null ? instInfo.getInstallationType() : ""); rowData[2] = String.valueOf( (instInfo.getTotalConsumption() != 0.0 ? instInfo.getTotalConsumption() : "")) + " kWh"; rowData[3] = String .valueOf((instInfo.getPeakComsumption() != 0.0 ? instInfo.getPeakComsumption() : "") + " W"); rowData[4] = String .valueOf((instInfo.getAvgConsumption() != 0.0 ? instInfo.getAvgConsumption() : "") + " W"); tableModelSelected.addRow(rowData); } Double[] data; if (instInfos.size() == 1) { String inst_id = instInfos.get(0).getID(); data = MongoQueries.getInstallationResults(inst_id); } else { data = new Double[0]; } XYSeries series1 = new XYSeries("First"); for (int i = 0; i < data.length / 15; i++) { double d = 0; for (int j = 0; j < 60; j++) { d += data[j * 60 + i]; } series1.add(i, d); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); chartPanel.getChart().getXYPlot().setDataset(dataset); }
From source file:com.javafxpert.neuralnetviz.scenario.PlotUtil.java
private static XYDataset createDataSetTrain(INDArray features, INDArray labels) { int nRows = features.rows(); int nClasses = labels.columns(); XYSeries[] series = new XYSeries[nClasses]; for (int i = 0; i < series.length; i++) series[i] = new XYSeries("Class " + String.valueOf(i)); INDArray argMax = Nd4j.getExecutioner().exec(new IAMax(labels), 1); for (int i = 0; i < nRows; i++) { int classIdx = (int) argMax.getDouble(i); series[classIdx].add(features.getDouble(i, 0), features.getDouble(i, 1)); }/*from w w w .jav a 2 s. c o m*/ XYSeriesCollection c = new XYSeriesCollection(); for (XYSeries s : series) c.addSeries(s); return c; }
From source file:projects.tgas.exec.HrDiagram.java
/** * Plot the HR diagram chart from the given data. * @param series// w ww.j av a 2 s. c o m * A {@link XYSeries} containing the HR diagram data. * @return * A {@link JFreeChart} containing the plot. */ private static JFreeChart getHrChart(XYSeries series) { XYSeriesCollection hrData = new XYSeriesCollection(); hrData.addSeries(series); // Set up the renderer XYLineAndShapeRenderer hrRenderer = new XYLineAndShapeRenderer(); hrRenderer.setSeriesLinesVisible(0, false); hrRenderer.setSeriesShapesVisible(0, true); hrRenderer.setSeriesShape(0, new Ellipse2D.Double(-0.5, -0.5, 1, 1)); // Configure axes NumberAxis xAxis = new NumberAxis("B - V [mag]"); xAxis.setRange(-0.5, 2.25); NumberAxis yAxis = new NumberAxis("G [mag]"); yAxis.setInverted(true); yAxis.setRange(-5, 13); // Configure plot XYPlot xyplot = new XYPlot(hrData, xAxis, yAxis, hrRenderer); xyplot.setBackgroundPaint(Color.white); JFreeChart hrChart = new JFreeChart("HR diagram of TGAS stars", xyplot); hrChart.removeLegend(); hrChart.setBackgroundPaint(Color.white); return hrChart; }
From source file:com.javafxpert.neuralnetviz.scenario.PlotUtil.java
private static XYDataset createDataSetTest(INDArray features, INDArray labels, INDArray predicted) { int nRows = features.rows(); int nClasses = labels.columns(); XYSeries[] series = new XYSeries[nClasses * nClasses]; //new XYSeries("Data"); for (int i = 0; i < nClasses * nClasses; i++) { int trueClass = i / nClasses; int predClass = i % nClasses; String label = "actual=" + trueClass + ", pred=" + predClass; series[i] = new XYSeries(label); }// w w w . j av a 2 s . c o m INDArray actualIdx = Nd4j.getExecutioner().exec(new IAMax(labels), 1); INDArray predictedIdx = Nd4j.getExecutioner().exec(new IAMax(predicted), 1); for (int i = 0; i < nRows; i++) { int classIdx = (int) actualIdx.getDouble(i); int predIdx = (int) predictedIdx.getDouble(i); int idx = classIdx * nClasses + predIdx; series[idx].add(features.getDouble(i, 0), features.getDouble(i, 1)); } XYSeriesCollection c = new XYSeriesCollection(); for (XYSeries s : series) c.addSeries(s); return c; }
From source file:e3fraud.gui.GraphingTool.java
public static JFreeChart generateGraph(E3Model model, Resource need, int startValue, int endValue, boolean expected) { //Get list of actors Set<Resource> actors = model.getActors(); //generate a series Map<Resource, XYSeries> actorSeriesMap = model.getTotalForActors(need, startValue, endValue, expected); //for each actor XYSeriesCollection line_chart_dataset = new XYSeriesCollection(); for (Resource actor : actors) { //add it's series to the chart XYSeries series = actorSeriesMap.get(actor); line_chart_dataset.addSeries(series); double slope; if (series.getItemCount() > 1) { slope = (series.getY(0).doubleValue() - series.getY(1).doubleValue()) / (series.getX(0).doubleValue() - series.getX(1).doubleValue()); } else {//from w w w.ja va 2 s. co m slope = 0; } DecimalFormat df = new DecimalFormat("#.##"); series.setKey(series.getKey() + "\nAvg.\t = \t" + df.format(model.getLastKnownAverages().get(actor)) + "\nSlope\t = \t" + df.format(slope)); } /* Step -2:Define the JFreeChart object to create line chart */ JFreeChart lineChartObject; if (expected) { lineChartObject = ChartFactory.createScatterPlot( "(Ideal) Profit Vs Occurences of \"" + need.getProperty(E3value.e3_has_name).getString() + " \"", "Occurences of \"" + need.getProperty(E3value.e3_has_name).getString() + " \"", "Profit (in Euro)", line_chart_dataset, PlotOrientation.VERTICAL, true, true, false); } else { lineChartObject = ChartFactory.createScatterPlot( "(Non-ideal) Profit Vs Occurences of \"" + need.getProperty(E3value.e3_has_name).getString() + " \"", "Occurences of \"" + need.getProperty(E3value.e3_has_name).getString() + " \"", "Profit (in Euro)", line_chart_dataset, PlotOrientation.VERTICAL, true, true, false); } return lineChartObject; }
From source file:stratego.neural.net.RandomSampleTest.java
private static void plotDataSet(List<double[]> data) { XYSeriesCollection plotData = new XYSeriesCollection(); for (double[] ds : data) { XYSeries series = new XYSeries("Winrate"); for (int i = 0; i < ds.length; i++) { series.add((double) i, ds[i]); }// w w w .j ava 2 s . c om plotData.addSeries(series); } String title = "Simulating Random Samples"; String xAxisLabel = "Matches"; String yAxisLabel = "Winrate"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean legend = false; // might wanna set this to true at some point, but research the library boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, plotData, orientation, legend, tooltips, urls); JPanel panel = new ChartPanel(chart); JFrame f = new JFrame(); f.add(panel); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); f.pack(); f.setTitle("Random test simulation"); f.setVisible(true); }
From source file:de.hs.mannheim.modUro.controller.diagram.SimulationDiagramController.java
/** * Creates Dataset./*from www .ja va2s . c om*/ * * @return */ private static XYDataset createDataset(String simulationName, double[][] fitnessArray) { XYSeries xySerie = new XYSeries(simulationName); double x; double y; for (int i = 0; i < fitnessArray.length; i++) { x = fitnessArray[i][0]; y = fitnessArray[i][1]; xySerie.add(x, y); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(xySerie); return dataset; }