List of usage examples for org.jfree.chart ChartFactory createTimeSeriesChart
public static JFreeChart createTimeSeriesChart(String title, String timeAxisLabel, String valueAxisLabel, XYDataset dataset, boolean legend, boolean tooltips, boolean urls)
From source file:org.mwc.debrief.sensorfusion.views.DataSupport.java
/** * Creates a chart./* w w w .jav a 2s .com*/ * * @param dataset * a dataset. * * @return A chart. */ public static JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Bearing Management", // title "Time", // x-axis label "Bearing", // y-axis label dataset, // data false, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setOrientation(PlotOrientation.HORIZONTAL); final XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm.ss")); return chart; }
From source file:finalproject.GraphData.java
/** * Creates a chart with the data that is graphed vs time * @param data/*from www. j a v a 2 s .c o m*/ * @param names * @return */ public JFreeChart graphVsTime(String[][] data, String[] names) { TimeSeries mySeries = new TimeSeries("Data"); for (int i = 0; i < data.length; i++) { if (data[i][0] != null && data[i][1] != null) mySeries.add(new Hour(convertTime(data[i][0]), day), Integer.parseInt(data[i][1])); } TimeSeriesCollection collection = new TimeSeriesCollection(mySeries); XYDataset dataset = collection; JFreeChart chart = ChartFactory.createTimeSeriesChart("Blood Glucose vs Time", names[0], names[1], dataset, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); return chart; }
From source file:net.sourceforge.processdash.ev.ui.chart.AbstractEVTimeSeriesChart.java
@Override protected JFreeChart getXYChartObject(XYDataset data) { return ChartFactory.createTimeSeriesChart(null, null, null, data, true, true, false); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.ScatterPlotChartExpression.java
protected JFreeChart computeXYChart(final XYDataset xyDataset) { final JFreeChart chart; if (xyDataset instanceof TimeSeriesCollection) { chart = ChartFactory.createTimeSeriesChart(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, isShowLegend(), false, false); final XYPlot xyPlot = chart.getXYPlot(); final XYLineAndShapeRenderer itemRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer(); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(itemRenderer.getBaseToolTipGenerator()); renderer.setURLGenerator(itemRenderer.getURLGenerator()); xyPlot.setRenderer(renderer);/*from ww w .ja v a 2 s. c o m*/ } else { final PlotOrientation orientation = computePlotOrientation(); chart = ChartFactory.createScatterPlot(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset, orientation, isShowLegend(), false, false); } chart.getXYPlot().setRenderer(new XYDotRenderer()); configureLogarithmicAxis(chart.getXYPlot()); return chart; }
From source file:com.sigma.applet.GraphsApplet.java
public void init() { final JTabbedPane tabs = new JTabbedPane(); XYDataset data1 = createTimeSeriesCollection1(1.1); JFreeChart chart1 = ChartFactory.createTimeSeriesChart("Time Series", "Date", "Rate", data1, true, true, false);/* ww w .j av a 2s. c om*/ ChartPanel panel1 = new ChartPanel(chart1, 400, 300, 200, 100, 400, 200, true, false, false, false, true, true); tabs.add("Chart 1", panel1); XYDataset data2 = createTimeSeriesCollection1(0.8); JFreeChart chart2 = ChartFactory.createTimeSeriesChart("Time Series", "Date", "Rate", data2, true, true, false); ChartPanel panel2 = new ChartPanel(chart2, 400, 300, 200, 100, 400, 200, true, false, false, false, true, true); tabs.add("Chart 2", panel2); this.getContentPane().add(tabs); }
From source file:com.charts.IntradayChart.java
public IntradayChart(YStockQuote currentStock) { TimeSeries series = new TimeSeries(currentStock.get_name()); ArrayList<String> fiveDayData = currentStock.get_one_day_data(); int length = fiveDayData.size(); for (int i = 17; i < length; i++) { String[] data = fiveDayData.get(i).split(","); Date time = new Date((long) Integer.parseInt(data[0]) * 1000); DateFormat df = new SimpleDateFormat("MM-dd-yyyy-h-m"); series.addOrUpdate(new Minute(time), Double.parseDouble(data[1])); }// www . j a v a 2 s . c om TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createTimeSeriesChart( currentStock.get_name() + "(" + currentStock.get_symbol() + ")" + " Intraday", "Date", "Price", dataset, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); ValueAxis yAxis = (ValueAxis) plot.getRangeAxis(); DateAxis xAxis = (DateAxis) plot.getDomainAxis(); xAxis.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); xAxis.setDateFormatOverride(new SimpleDateFormat("h:m a")); xAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); //xAxis.setVerticalTickLabels(true); chartPanel = new ChartPanel(chart); chart.setBackgroundPaint(chartPanel.getBackground()); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); chartPanel.setVisible(true); chartPanel.revalidate(); chartPanel.repaint(); }
From source file:org.apache.qpid.disttest.charting.chartbuilder.TimeSeriesLineChartBuilder.java
@Override public JFreeChart createChartImpl(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) { JFreeChart chart = ChartFactory.createTimeSeriesChart(title, xAxisTitle, yAxisTitle, (XYDataset) dataset, showLegend, showToolTips, showUrls); return chart; }
From source file:networkanalyzer.DynamicPing.java
public JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createTimeSeriesChart("Ping Chart", //title "Time", //x-axis "Ping", //y-axis dataset, false, false, false); final XYPlot plot = result.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); ValueAxis xaxis = plot.getDomainAxis(); xaxis.setAutoRange(true);/*ww w. java2s .com*/ xaxis.setFixedAutoRange(60000.0); xaxis.setVerticalTickLabels(true); ValueAxis yaxis = plot.getRangeAxis(); yaxis.setAutoRange(true); return result; }
From source file:com.testmax.framework.CreateGraph.java
protected void createChart(double timeout) { TimeSeriesCollection dataset = new TimeSeriesCollection(ts); this.chart = ChartFactory.createTimeSeriesChart(this.graphName, this.xName, this.yName, dataset, true, true, false);// w w w. j a va 2 s . co m final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(timeout * 1000.0); JFrame frame = new JFrame(this.graphName); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ChartPanel label = new ChartPanel(chart); frame.getContentPane().add(label); //Suppose I add combo boxes and buttons here later frame.pack(); if (ConfigLoader.getConfig("SHOW_GRAPH_RUNTIME").equalsIgnoreCase("yes")) { frame.setVisible(true); } else { frame.setVisible(false); } }
From source file:cv.mikusher.freechart.TimeSeries_AWT.java
private JFreeChart createChart(final XYDataset dataset) { return ChartFactory.createTimeSeriesChart("Computing Test", "Seconds", "Value", dataset, false, false, false);/*from ww w. j a v a 2s .c om*/ }