List of usage examples for org.jfree.chart ChartFactory createCandlestickChart
public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend)
From source file:net.sf.smbt.ui.btc.views.AbstractBTCMarketView.java
public void addCharts(Composite folder) { chart = ChartFactory.createCandlestickChart("BTC Price / Volume", "Time", "Price", new DefaultHighLowDataset("Test", new Date[0], new double[0], new double[0], new double[0], new double[0], new double[0]), true);/* ww w . j ava 2 s. com*/ chart.setBackgroundPaint(new java.awt.Color(66, 66, 66)); chart.getPlot().setBackgroundPaint(new java.awt.Color(66, 66, 66)); chartComposite = new ChartComposite(folder, SWT.NONE, chart, true); }
From source file:compecon.dashboard.panel.IndustriesPanel.java
protected ChartPanel createPriceTimeSeriesChartPanel(Currency currency, GoodType goodType) { JFreeChart priceChart = ChartFactory.createCandlestickChart(goodType + " Prices", "Time", "Price in " + currency.getIso4217Code(), this.getDefaultHighLowDataset(currency, goodType), false); ChartPanel chartPanel = new ChartPanel(priceChart); chartPanel.setDomainZoomable(true);//from w ww.j a v a 2 s . c o m chartPanel.setPreferredSize(new java.awt.Dimension(800, 400)); return chartPanel; }
From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java
public static JFreeChart createChartWithXYDataSet(ChartData chartData) { XYDataset dataset = (XYDataset) chartData.getDatasource(); String type = chartData.getType(); String xAxis = chartData.getXlabel(); String yAxis = chartData.getYlabel(); boolean legend = chartData.isLegend(); JFreeChart chart = null;//from w w w. j a v a 2s .com PlotOrientation plotOrientation = ChartUtils.getPlotOrientation(chartData.getOrientation()); if (type.equalsIgnoreCase("timeseries")) { chart = ChartFactory.createTimeSeriesChart("", xAxis, yAxis, dataset, legend, true, false); } else if (type.equalsIgnoreCase("xyline")) { chart = ChartFactory.createXYLineChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false); } else if (type.equalsIgnoreCase("polar")) { chart = ChartFactory.createPolarChart("", dataset, legend, true, false); } else if (type.equalsIgnoreCase("scatter")) { chart = ChartFactory.createScatterPlot("", xAxis, yAxis, dataset, plotOrientation, legend, true, false); } else if (type.equalsIgnoreCase("xyarea")) { chart = ChartFactory.createXYAreaChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false); } else if (type.equalsIgnoreCase("xysteparea")) { chart = ChartFactory.createXYStepAreaChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false); } else if (type.equalsIgnoreCase("xystep")) { chart = ChartFactory.createXYStepChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false); } else if (type.equalsIgnoreCase("bubble")) { chart = ChartFactory.createBubbleChart("", xAxis, yAxis, (XYZDataset) dataset, plotOrientation, legend, true, false); } else if (type.equalsIgnoreCase("candlestick")) { chart = ChartFactory.createCandlestickChart("", xAxis, yAxis, (OHLCDataset) dataset, legend); } else if (type.equalsIgnoreCase("boxandwhisker")) { chart = ChartFactory.createBoxAndWhiskerChart("", xAxis, yAxis, (BoxAndWhiskerXYDataset) dataset, legend); } else if (type.equalsIgnoreCase("highlow")) { chart = ChartFactory.createHighLowChart("", xAxis, yAxis, (OHLCDataset) dataset, legend); } else if (type.equalsIgnoreCase("histogram")) { chart = ChartFactory.createHistogram("", xAxis, yAxis, (IntervalXYDataset) dataset, plotOrientation, legend, true, false); } else if (type.equalsIgnoreCase("wind")) { chart = ChartFactory.createWindPlot("", xAxis, yAxis, (WindDataset) dataset, legend, true, false); } if (chart.getPlot() instanceof XYPlot) { chart.getXYPlot().setDomainGridlinesVisible(chartData.isDomainGridLines()); chart.getXYPlot().setRangeGridlinesVisible(chartData.isRangeGridLines()); if (chartData.getGenerateMap() != null) chart.getXYPlot().getRenderer().setURLGenerator(new StandardXYURLGenerator("")); } setXYSeriesColors(chart, chartData); setXYExtensions(chart, chartData); return chart; }
From source file:compecon.dashboard.panel.HouseholdsPanel.java
protected ChartPanel createPriceTimeSeriesChartPanel(Currency currency) { JFreeChart priceChart = ChartFactory.createCandlestickChart(GoodType.LABOURHOUR + " Prices", "Time", "Price in " + currency.getIso4217Code(), this.getDefaultHighLowDataset(currency), false); ChartPanel chartPanel = new ChartPanel(priceChart); chartPanel.setDomainZoomable(true);/*from w w w. j a va 2 s . co m*/ chartPanel.setPreferredSize(new java.awt.Dimension(800, 400)); return chartPanel; }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates a candlestick chart./* www. j av a2s . c o m*/ * * @return a candlestick chart. */ public JFreeChart createCandlestickChart() { // create a default chart based on some sample data... final String title = this.resources.getString("timeseries.candlestick.title"); final String domain = this.resources.getString("timeseries.candlestick.domain"); final String range = this.resources.getString("timeseries.candlestick.range"); final String subtitleStr = this.resources.getString("timeseries.candlestick.subtitle"); final DefaultHighLowDataset data = DemoDatasetFactory.createHighLowDataset(); final JFreeChart chart = ChartFactory.createCandlestickChart(title, domain, range, data, false); // then customise it a little... final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12)); chart.addSubtitle(subtitle); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.green)); return chart; }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
/** * * @param evaluation/*from ww w. j ava 2 s.c o m*/ * @throws net.sf.fspdfs.engine.JRException */ protected JFreeChart createCandlestickChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createCandlestickChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRCandlestickPlot) getPlot()).getTimeAxisLabelExpression()), (String) evaluateExpression(((JRCandlestickPlot) getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset) getDataset(), isShowLegend()); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRCandlestickPlot candlestickPlot = (JRCandlestickPlot) getPlot(); CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer(); boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume().booleanValue(); candlestickRenderer.setDrawVolume(isShowVolume); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(), candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(), candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(), candlestickPlot.getOwnTimeAxisLineColor(), false, (Comparable) evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(), candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(), candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(), candlestickPlot.getOwnValueAxisLineColor(), true, (Comparable) evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
/** * * @param evaluation/*w ww. j a v a 2s .c o m*/ * @throws net.sf.fspdfs.engine.JRException */ protected JFreeChart createCandlestickChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createCandlestickChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRCandlestickPlot) getPlot()).getTimeAxisLabelExpression()), (String) evaluateExpression(((JRCandlestickPlot) getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset) getDataset(), isShowLegend()); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRCandlestickPlot candlestickPlot = (JRCandlestickPlot) getPlot(); CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer(); boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume().booleanValue(); candlestickRenderer.setDrawVolume(isShowVolume); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(), candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(), candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(), candlestickPlot.getOwnTimeAxisLineColor(), getDomainAxisSettings(), (Comparable) evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(), candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(), candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(), candlestickPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable) evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
/** * *///from w w w . j a v a2 s.com protected JFreeChart createCandlestickChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createCandlestickChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRCandlestickPlot) getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRCandlestickPlot) getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset) getDataset(), isShowLegend()); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRCandlestickPlot candlestickPlot = (JRCandlestickPlot) getPlot(); CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer(); boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume(); candlestickRenderer.setDrawVolume(isShowVolume); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(), candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(), candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(), candlestickPlot.getOwnTimeAxisLineColor(), false, (Comparable<?>) evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(), candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(), candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(), candlestickPlot.getOwnValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * *///from w ww .jav a2 s . co m protected JFreeChart createCandlestickChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createCandlestickChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRCandlestickPlot) getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRCandlestickPlot) getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset) getDataset(), isShowLegend()); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRCandlestickPlot candlestickPlot = (JRCandlestickPlot) getPlot(); CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer(); boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume(); candlestickRenderer.setDrawVolume(isShowVolume); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(), candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(), candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(), candlestickPlot.getOwnTimeAxisLineColor(), getDomainAxisSettings(), (Comparable<?>) evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(), candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(), candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(), candlestickPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>) evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * */// w w w . j a v a 2s . c o m protected JFreeChart createCandlestickChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createCandlestickChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRCandlestickPlot) getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRCandlestickPlot) getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset) getDataset(), isShowLegend()); configureChart(jfreeChart); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRCandlestickPlot candlestickPlot = (JRCandlestickPlot) getPlot(); CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer(); boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume(); candlestickRenderer.setDrawVolume(isShowVolume); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(), candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(), candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(), candlestickPlot.getTimeAxisLineColor(), false, (Comparable<?>) evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(), candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(), candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(), candlestickPlot.getValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }