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:ws.moor.bt.gui.charts.BlockDownload.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Downloaded Blocks", "Time", "Blocks", dataset, true, false, false);//w w w . j a v a 2s.co m chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }
From source file:net.sourceforge.jabm.view.TimeSeriesChart.java
public void initialiseGUI() { String name = chartTitle;//from ww w .j a v a 2 s.c o m if (name == null) { name = series.getName(); } computeVariableNames(); // series.initialise(null); JFreeChart chart = ChartFactory.createTimeSeriesChart(name, // chart // title "t", // domain axis label rangeAxisLabel, // range axis label this, // data true, // include legend true, // tooltips? false // URLs? ); chartPanel = new ChartPanel(chart, true); chartPanel.setPreferredSize(new Dimension(500, 270)); computeVariableNames(); series.addListener(this); }
From source file:net.sf.clichart.chart.TimeSeriesChartBuilder.java
protected JFreeChart getChartImpl(Options options) { return ChartFactory.createTimeSeriesChart(options.getChartTitle(), options.getChartXAxisTitle(), options.getChartYAxisTitle(), m_timeSeriesCollection, true, true, false); }
From source file:com.ace.capitalflows.ui.frame.chart.NianYdChart.java
/** * Creates a chart./*from www . ja va2 s . com*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("ZhongGuoGuoJiShouZhiPingHeBiao(NianDuCeSuan)", // title "NianYd", // x-axis label "YiMeiYuan", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM")); return chart; }
From source file:com.ace.capitalflows.ui.frame.chart.NianJdChart.java
/** * Creates a chart./*ww w . j av a 2 s . c o m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("ZhongGuoGuoJiShouZhiPingHeBiao(NianDuCeSuan)", // title "NianJd", // x-axis label "YiMeiYuan", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM")); return chart; }
From source file:compecon.dashboard.panel.MoneyPanel.java
protected ChartPanel createPriceIndicesPanel() { TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection(); for (Currency currency : Currency.values()) timeSeriesCollection.addSeries(ApplicationContext.getInstance().getModelRegistry() .getNationalEconomyModel(currency).priceIndexModel.getTimeSeries()); JFreeChart chart = ChartFactory.createTimeSeriesChart("Price Index", "Date", "Price Index", timeSeriesCollection, true, true, false); configureChart(chart);//from w ww. j a va2s . c om return new ChartPanel(chart); }
From source file:org.jfree.chart.demo.TimeSeriesDemo8.java
/** * Creates a chart./*w ww . j a v a 2s .com*/ * * @param dataset the dataset. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Time Series Demo 8", "Date", "Value", dataset, true, true, false); final XYItemRenderer renderer = chart.getXYPlot().getRenderer(); final StandardXYToolTipGenerator g = new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")); renderer.setToolTipGenerator(g); return chart; }
From source file:uk.co.moonsit.sockets.DualAxisDemo2.java
/** * A demonstration application showing how to create a time series chart with dual axes. * * @param title the frame title./*from w ww. j av a 2s .c om*/ */ public DualAxisDemo2(final String title) { super(title); // create a title... final String chartTitle = "Dual Axis Demo 2"; final XYDataset dataset = createDataset1(); final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Date", "Price Per Unit", dataset, true, true, false); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); final NumberAxis axis2 = new NumberAxis("Secondary"); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, createDataset2()); plot.mapDatasetToRangeAxis(1, 1); /*final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; //rr.setPlotShapes(true); rr.setShapesFilled(true); }*/ final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.black); //renderer2.setPlotShapes(true); //renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); plot.setRenderer(1, renderer2); final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:com.leonarduk.finance.chart.BollingerBars.java
public static void displayBollingerBars(final Stock stock) throws IOException { final TimeSeries series = TimeseriesUtils.getTimeSeries(stock, 1); /**// w ww . j a v a 2 s . com * Creating indicators */ // Close price final ClosePriceIndicator closePrice = new ClosePriceIndicator(series); // Bollinger bands final BollingerBandsMiddleIndicator middleBBand = new BollingerBandsMiddleIndicator(closePrice); final BollingerBandsLowerIndicator lowBBand = new BollingerBandsLowerIndicator(middleBBand, closePrice, Decimal.ONE); final BollingerBandsUpperIndicator upBBand = new BollingerBandsUpperIndicator(middleBBand, closePrice, Decimal.ONE); /** * Building chart dataset */ final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(BollingerBars.buildChartTimeSeries(series, closePrice, stock.getName() + ". (" + stock.getSymbol() + ") - " + stock.getStockExchange())); dataset.addSeries(BollingerBars.buildChartTimeSeries(series, lowBBand, "Low Bollinger Band")); dataset.addSeries(BollingerBars.buildChartTimeSeries(series, upBBand, "High Bollinger Band")); /** * Creating the chart */ final JFreeChart chart = ChartFactory.createTimeSeriesChart(stock.getName() + "Close Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); final XYPlot plot = (XYPlot) chart.getPlot(); final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd")); /** * Displaying the chart */ ChartDisplay.displayChartInFrame(chart, 500, 270, "Bollinger chart"); }
From source file:org.jfree.chart.demo.TimeSeriesDemo.java
/** * Creates a chart./*from w w w. ja v a2s .co m*/ * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", dataset, true, true, false); chart.setBackgroundPaint(Color.white); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); rr.setItemLabelsVisible(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }