List of usage examples for org.jfree.chart ChartFactory createXYLineChart
public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:ubic.gemma.visualization.ExpressionDataMatrixVisualizationServiceImpl.java
@Override @Deprecated/*w ww.jav a 2 s . c om*/ public JFreeChart createXYLineChart(String title, Collection<double[]> dataCol, int numProfiles) { if (dataCol == null) throw new RuntimeException("dataCol cannot be " + null); if (dataCol.size() < numProfiles) { log.info("Collection smaller than number of elements. Will display first " + NUM_PROFILES_TO_DISPLAY + " profiles."); numProfiles = NUM_PROFILES_TO_DISPLAY; } XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); Iterator<double[]> iter = dataCol.iterator(); for (int j = 0; j < numProfiles; j++) { double[] data = iter.next(); XYSeries series = new XYSeries(j, true, true); for (int i = 0; i < data.length; i++) { series.add(i, data[i]); } xySeriesCollection.addSeries(series); } JFreeChart chart = ChartFactory.createXYLineChart(title, "Platform", "Expression Value", xySeriesCollection, PlotOrientation.VERTICAL, false, false, false); chart.addSubtitle(new TextTitle("(Raw data values)", new Font("SansSerif", Font.BOLD, 14))); return chart; }
From source file:org.jls.toolbox.math.chart.XYLineChart.java
/** * Permet de crer le graphique partir des paramtres spcifis. */// www.j a v a2 s . c om private void createChart() { this.chart = ChartFactory.createXYLineChart(this.title, // Titre du // graphique this.xTitle, // Titre de l'axe des abscisses this.yTitle, // Titre de l'axe des ordonnes this.dataset, // Valeurs de la courbe PlotOrientation.VERTICAL, // Orientation du graphique this.isLegendVisible, // Affichage de la lgende this.isTooltipsVisible, // Affichage des tooltips this.isUrlVisible); // Affichage des urls this.plot = (XYPlot) this.chart.getPlot(); if (this.chart.getLegend() != null) { this.chart.getLegend().setBackgroundPaint(new JPanel().getBackground()); this.chart.getLegend().setItemPaint(new JLabel().getForeground()); } }
From source file:org.rdv.viz.spectrum.SpectrumAnalyzerPanel.java
/** * Initializes the chart./*from w ww. ja v a 2s.c o m*/ */ private void initChart() { xySeries = new SpectrumXYSeries("", false, false); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); xySeriesCollection.addSeries(xySeries); chart = ChartFactory.createXYLineChart(null, "Frequency (Hz)", null, xySeriesCollection, PlotOrientation.VERTICAL, false, true, false); chart.setAntiAlias(false); XYPlot xyPlot = (XYPlot) chart.getPlot(); NumberAxis xAxis = (NumberAxis) xyPlot.getDomainAxis(); xAxis.setRange(0, sampleRate / 2); setChart(chart); }
From source file:org.yooreeka.util.gui.XyGui.java
public XyGui(String title, double[] x, double[] y) { super(title); errMsg = new StringBuilder(); setLoopInt(x.length);/* ww w . jav a2 s .c o m*/ if (checkX(x) && checkY(x.length, y)) { XYSeries xydata = new XYSeries(title); for (int i = 0; i < loopInt; i++) { xydata.add(x[i], y[i]); } xycollection = new XYSeriesCollection(xydata); final JFreeChart chart = ChartFactory.createXYLineChart(title + " (XY Plot)", "X", "Y", xycollection, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); final NumberAxis domainAxis = new NumberAxis("x"); plot.setDomainAxis(domainAxis); final NumberAxis rangeAxis = new NumberAxis("y"); plot.setRangeAxis(rangeAxis); chart.setBackgroundPaint(Color.white); plot.setOutlinePaint(Color.black); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); } else { System.err.println(errMsg.toString()); } }
From source file:DynamiskDemo2.java
/** * Creates a sample chart.// w ww . ja v a 2 s. c o m * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createXYLineChart("Dynamic Data Demo", "Time", "Value", dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = result.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60000.0); // 60 seconds axis = plot.getRangeAxis(); axis.setRange(-0.5, 1.5); return result; }
From source file:edu.uic.cs.compbio.DyNSPK.DynamicEntropy.java
public String makeChart(Map<Double, Double> data, String filename, String Title, String XAxis, String YAxis) { //Time series XYSeries dSeries = ChartUtils.createXYSeries(data, Title); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(dSeries);/*from w ww. j a v a 2 s . co m*/ JFreeChart chart = ChartFactory.createXYLineChart(Title, XAxis, YAxis, dataset, PlotOrientation.HORIZONTAL, true, false, false); chart.removeLegend(); ChartUtils.decorateChart(chart); ChartUtils.scaleChart(chart, dSeries, false); String degreeImageFile = ChartUtils.renderChart(chart, filename); return degreeImageFile; }
From source file:com.bdb.weather.display.summary.HighLowMedianTempPanel.java
/** * Constructor./* w w w .j a v a2s . c o m*/ * * @param interval The interval for which this graph is being used. Intervals are typically day, week, month or year. * @param launcher A class that is used to launch sub-views when a data item is double-clicked * @param supporter A class that aids in the generalization of this graph */ @SuppressWarnings("LeakingThisInConstructor") public HighLowMedianTempPanel(SummaryInterval interval, ViewLauncher launcher, SummarySupporter supporter) { this.setPrefSize(500, 300); this.interval = interval; tableHeadings = getTableColumnLabels(); chart = ChartFactory.createXYLineChart("", "", "", null, PlotOrientation.VERTICAL, true, true, true); plot = (XYPlot) chart.getPlot(); viewLauncher = launcher; this.supporter = supporter; StandardXYToolTipGenerator ttgen = new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, interval.getLegacyFormat(), Temperature.getDefaultFormatter()); diffRenderer.setBaseToolTipGenerator(ttgen); plot.setRenderer(LOW_DATASET, diffRenderer); plot.setRenderer(HIGH_DATASET, diffRenderer); plot.setRenderer(MEDIAN_DATASET, diffRenderer); valueAxis.setAutoRangeIncludesZero(false); plot.setRangeCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(true); plot.setDomainCrosshairVisible(true); plot.setRangeAxis(valueAxis); dateAxis = new DateAxis("Date"); dateAxis.setDateFormatOverride(interval.getLegacyFormat()); dateAxis.setVerticalTickLabels(true); //dateAxis.setTickUnit(interval.getDateTickUnit()); plot.setDomainAxis(dateAxis); chartViewer = new ChartViewer(chart); chartViewer.setPrefSize(500, 300); chartViewer.addChartMouseListener(this); dataTable = new TableView(); for (int i = 0; i < tableHeadings.length; i++) { TableColumn col = new TableColumn(); //col.setHeaderValue(tableHeadings[i]); //col.setModelIndex(i); //colModel.addColumn(col); } this.setTabContents(chartViewer, dataTable); }
From source file:cmsc105_mp2.Panels.java
public void createGraph(Data d, float window, Double threshold) { XYSeries data = new XYSeries("data"); double max = Double.MIN_VALUE; for (double num : d.plots) { if (max < num) max = num;/* w w w . jav a 2 s . c o m*/ } max += 1; ArrayList<XYSeries> xy = new ArrayList(); ArrayList<Integer> points = new ArrayList(); for (int j = (int) (window / 2); j < d.plots.length - (window / 2); j++) { data.add(j, d.plots[j]); //System.out.println(points.size()); if (d.plots[j] > threshold) { points.add(j); } else { if (points.size() >= window) { //System.out.println("MIN!"); XYSeries series = new XYSeries("trend"); for (int n : points) { series.add(n, max); } xy.add(series); } points = new ArrayList(); } } if (points.size() >= window) { XYSeries series = new XYSeries("trend"); for (int n : points) { series.add(n, max); } xy.add(series); } XYSeriesCollection my_data_series = new XYSeriesCollection(); my_data_series.addSeries(data); for (XYSeries x : xy) { my_data_series.addSeries(x); } XYSeries thresh = new XYSeries("threshold"); for (int j = 0; j < d.plots.length; j++) { thresh.add(j, threshold); } my_data_series.addSeries(thresh); //System.out.println(d.name); JFreeChart XYLineChart = ChartFactory.createXYLineChart(d.name, "Position", "Average", my_data_series, PlotOrientation.VERTICAL, true, true, false); bImage1 = (BufferedImage) XYLineChart.createBufferedImage(690, 337); imageIcon = new ImageIcon(bImage1); jLabel1.setIcon(imageIcon); jLabel1.revalidate(); jLabel1.repaint(); jButton1.setText("Save as PNG"); jButton1.repaint(); jButton1.revalidate(); jButton1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File("Documents")); int retrival = chooser.showSaveDialog(null); if (retrival == JFileChooser.APPROVE_OPTION) { try { ImageIO.write(bImage1, "png", new File(chooser.getSelectedFile() + ".png")); } catch (IOException ex) { System.out.println("Unable to Print!"); } } } }); }
From source file:de.laures.cewolf.taglib.CewolfChartFactory.java
public static JFreeChart getChartInstance(String chartType, String title, String xAxisLabel, String yAxisLabel, Dataset data) throws ChartValidationException { // first check the dynamically registered chart types CewolfChartFactory factory = (CewolfChartFactory) factories.get(chartType); if (factory != null) { // custom factory found, use it return factory.getChartInstance(title, xAxisLabel, yAxisLabel, data); }// w w w .j a v a 2s . c om switch (getChartTypeConstant(chartType)) { case XY: check(data, XYDataset.class, chartType); return ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, (XYDataset) data, PlotOrientation.VERTICAL, true, true, true); case PIE: check(data, PieDataset.class, chartType); return ChartFactory.createPieChart(title, (PieDataset) data, true, true, true); case AREA_XY: check(data, XYDataset.class, chartType); return ChartFactory.createXYAreaChart(title, xAxisLabel, yAxisLabel, (XYDataset) data, PlotOrientation.VERTICAL, true, false, false); case SCATTER: check(data, XYDataset.class, chartType); return ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, (XYDataset) data, PlotOrientation.VERTICAL, true, false, false); case AREA: check(data, CategoryDataset.class, chartType); return ChartFactory.createAreaChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.VERTICAL, true, false, false); case HORIZONTAL_BAR: check(data, CategoryDataset.class, chartType); return ChartFactory.createBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.HORIZONTAL, true, false, false); case HORIZONTAL_BAR_3D: check(data, CategoryDataset.class, chartType); return ChartFactory.createBarChart3D(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.HORIZONTAL, true, false, false); case LINE: check(data, CategoryDataset.class, chartType); return ChartFactory.createLineChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.VERTICAL, true, false, false); case STACKED_HORIZONTAL_BAR: check(data, CategoryDataset.class, chartType); return ChartFactory.createStackedBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.HORIZONTAL, true, false, false); case STACKED_VERTICAL_BAR: check(data, CategoryDataset.class, chartType); return ChartFactory.createStackedBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.VERTICAL, true, false, false); case STACKED_VERTICAL_BAR_3D: check(data, CategoryDataset.class, chartType); return ChartFactory.createStackedBarChart3D(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.VERTICAL, true, false, false); case VERTICAL_BAR: check(data, CategoryDataset.class, chartType); return ChartFactory.createBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.VERTICAL, true, false, false); case VERTICAL_BAR_3D: check(data, CategoryDataset.class, chartType); return ChartFactory.createBarChart3D(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.VERTICAL, true, false, false); case TIME_SERIES: check(data, XYDataset.class, chartType); return ChartFactory.createTimeSeriesChart(title, xAxisLabel, yAxisLabel, (XYDataset) data, true, false, false); case CANDLE_STICK: check(data, OHLCDataset.class, chartType); return ChartFactory.createCandlestickChart(title, xAxisLabel, yAxisLabel, (OHLCDataset) data, true); case HIGH_LOW: check(data, OHLCDataset.class, chartType); return ChartFactory.createHighLowChart(title, xAxisLabel, yAxisLabel, (OHLCDataset) data, true); case GANTT: check(data, IntervalCategoryDataset.class, chartType); return ChartFactory.createGanttChart(title, xAxisLabel, yAxisLabel, (IntervalCategoryDataset) data, true, false, false); case WIND: check(data, WindDataset.class, chartType); return ChartFactory.createWindPlot(title, xAxisLabel, yAxisLabel, (WindDataset) data, true, false, false); //case SIGNAL : // check(data, SignalsDataset.class, chartType); // return ChartFactory.createSignalChart(title, xAxisLabel, yAxisLabel, (SignalsDataset) data, true); case VERRTICAL_XY_BAR: check(data, IntervalXYDataset.class, chartType); return ChartFactory.createXYBarChart(title, xAxisLabel, true, yAxisLabel, (IntervalXYDataset) data, PlotOrientation.VERTICAL, true, false, false); case PIE_3D: check(data, PieDataset.class, chartType); return ChartFactory.createPieChart3D(title, (PieDataset) data, true, false, false); case METER: check(data, ValueDataset.class, chartType); MeterPlot plot = new MeterPlot((ValueDataset) data); JFreeChart chart = new JFreeChart(title, plot); return chart; case STACKED_AREA: check(data, CategoryDataset.class, chartType); return ChartFactory.createStackedAreaChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data, PlotOrientation.VERTICAL, true, false, false); case BUBBLE: check(data, XYZDataset.class, chartType); return ChartFactory.createBubbleChart(title, xAxisLabel, yAxisLabel, (XYZDataset) data, PlotOrientation.VERTICAL, true, false, false); case AUSTER_CICLOS: check(data, IntervalCategoryDataset.class, chartType); return ChartFactory.createAusterCiclosChart((IntervalCategoryDataset) data); default: throw new UnsupportedChartTypeException(chartType + " is not supported."); } }
From source file:edu.ucla.stat.SOCR.chart.demo.QQNormalPlotDemo.java
/** * Creates a chart.// ww w .ja v a 2s .com * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, //"Normal Q-Q plot", // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // 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... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setShapesVisible(true); renderer.setBaseShapesFilled(true); // renderer.setLinesVisible(false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. //setQQSummary(dataset); // very confusing return chart; }