org.jfree.chart.renderer.xy.CandlestickRenderer Java Examples
The following examples show how to use
org.jfree.chart.renderer.xy.CandlestickRenderer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EyeCandySixtiesChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected JFreeChart createCandlestickChart() throws JRException { JFreeChart jfreeChart = super.createCandlestickChart(); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); CandlestickRenderer renderer = (CandlestickRenderer)xyPlot.getRenderer(); DefaultHighLowDataset dataset = (DefaultHighLowDataset)xyPlot.getDataset(); if (dataset != null) { for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i)); renderer.setSeriesPaint(i, Color.DARK_GRAY); } } return jfreeChart; }
Example #2
Source File: ChartFactory.java From opensim-gui with Apache License 2.0 | 6 votes |
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
Example #3
Source File: AegeanChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected JFreeChart createCandlestickChart() throws JRException { JFreeChart jfreeChart = super.createCandlestickChart(); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); CandlestickRenderer renderer = (CandlestickRenderer)xyPlot.getRenderer(); DefaultHighLowDataset dataset = (DefaultHighLowDataset)xyPlot.getDataset(); @SuppressWarnings("unchecked") List<Paint> seriesPaints = (List<Paint>)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS); for(int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesFillPaint(i, seriesPaints.get(i)); renderer.setSeriesPaint(i, Color.DARK_GRAY); } return jfreeChart; }
Example #4
Source File: ChartFactory.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
Example #5
Source File: CandlestickRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { CandlestickRenderer r1 = new CandlestickRenderer(); CandlestickRenderer r2 = new CandlestickRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
Example #6
Source File: ChartFactory.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example #7
Source File: ChartFactory.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example #8
Source File: CandlestickRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { CandlestickRenderer r1 = new CandlestickRenderer(); CandlestickRenderer r2 = new CandlestickRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
Example #9
Source File: CandlestickRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the constructor. */ public void testConstructor() { CandlestickRenderer r1 = new CandlestickRenderer(); // check defaults assertEquals(Color.green, r1.getUpPaint()); assertEquals(Color.red, r1.getDownPaint()); assertFalse(r1.getUseOutlinePaint()); assertTrue(r1.getDrawVolume()); assertEquals(Color.gray, r1.getVolumePaint()); assertEquals(-1.0, r1.getCandleWidth(), EPSILON); }
Example #10
Source File: ChartFactory.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example #11
Source File: ChartFactory.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example #12
Source File: CandlestickRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the constructor. */ public void testConstructor() { CandlestickRenderer r1 = new CandlestickRenderer(); // check defaults assertEquals(Color.green, r1.getUpPaint()); assertEquals(Color.red, r1.getDownPaint()); assertFalse(r1.getUseOutlinePaint()); assertTrue(r1.getDrawVolume()); assertEquals(Color.gray, r1.getVolumePaint()); assertEquals(-1.0, r1.getCandleWidth(), EPSILON); }
Example #13
Source File: ChartFactory.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example #14
Source File: ChartFactory.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example #15
Source File: GenericChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ 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; }
Example #16
Source File: DefaultChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ 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; }
Example #17
Source File: ChartFactory.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (<code>null</code> permitted). * @param timeAxisLabel a label for the time axis (<code>null</code> * permitted). * @param valueAxisLabel a label for the value axis (<code>null</code> * permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example #18
Source File: CandlestickRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { CandlestickRenderer r1 = new CandlestickRenderer(); CandlestickRenderer r2 = new CandlestickRenderer(); assertEquals(r1, r2); // upPaint r1.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertFalse(r1.equals(r2)); r2.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertTrue(r1.equals(r2)); // downPaint r1.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, Color.yellow)); assertFalse(r1.equals(r2)); r2.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, Color.yellow)); assertTrue(r1.equals(r2)); // drawVolume r1.setDrawVolume(false); assertFalse(r1.equals(r2)); r2.setDrawVolume(false); assertTrue(r1.equals(r2)); // candleWidth r1.setCandleWidth(3.3); assertFalse(r1.equals(r2)); r2.setCandleWidth(3.3); assertTrue(r1.equals(r2)); // maxCandleWidthInMilliseconds r1.setMaxCandleWidthInMilliseconds(123); assertFalse(r1.equals(r2)); r2.setMaxCandleWidthInMilliseconds(123); assertTrue(r1.equals(r2)); // autoWidthMethod r1.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); assertFalse(r1.equals(r2)); r2.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); assertTrue(r1.equals(r2)); // autoWidthFactor r1.setAutoWidthFactor(0.22); assertFalse(r1.equals(r2)); r2.setAutoWidthFactor(0.22); assertTrue(r1.equals(r2)); // autoWidthGap r1.setAutoWidthGap(1.1); assertFalse(r1.equals(r2)); r2.setAutoWidthGap(1.1); assertTrue(r1.equals(r2)); r1.setUseOutlinePaint(true); assertFalse(r1.equals(r2)); r2.setUseOutlinePaint(true); assertTrue(r1.equals(r2)); r1.setVolumePaint(Color.blue); assertFalse(r1.equals(r2)); r2.setVolumePaint(Color.blue); assertTrue(r1.equals(r2)); }
Example #19
Source File: CandlestickRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { CandlestickRenderer r1 = new CandlestickRenderer(); assertTrue(r1 instanceof PublicCloneable); }
Example #20
Source File: CandlestickRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { CandlestickRenderer r1 = new CandlestickRenderer(); CandlestickRenderer r2 = new CandlestickRenderer(); assertEquals(r1, r2); // upPaint r1.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertFalse(r1.equals(r2)); r2.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertTrue(r1.equals(r2)); // downPaint r1.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, Color.yellow)); assertFalse(r1.equals(r2)); r2.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, Color.yellow)); assertTrue(r1.equals(r2)); // drawVolume r1.setDrawVolume(false); assertFalse(r1.equals(r2)); r2.setDrawVolume(false); assertTrue(r1.equals(r2)); // candleWidth r1.setCandleWidth(3.3); assertFalse(r1.equals(r2)); r2.setCandleWidth(3.3); assertTrue(r1.equals(r2)); // maxCandleWidthInMilliseconds r1.setMaxCandleWidthInMilliseconds(123); assertFalse(r1.equals(r2)); r2.setMaxCandleWidthInMilliseconds(123); assertTrue(r1.equals(r2)); // autoWidthMethod r1.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); assertFalse(r1.equals(r2)); r2.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); assertTrue(r1.equals(r2)); // autoWidthFactor r1.setAutoWidthFactor(0.22); assertFalse(r1.equals(r2)); r2.setAutoWidthFactor(0.22); assertTrue(r1.equals(r2)); // autoWidthGap r1.setAutoWidthGap(1.1); assertFalse(r1.equals(r2)); r2.setAutoWidthGap(1.1); assertTrue(r1.equals(r2)); r1.setUseOutlinePaint(true); assertFalse(r1.equals(r2)); r2.setUseOutlinePaint(true); assertTrue(r1.equals(r2)); r1.setVolumePaint(Color.blue); assertFalse(r1.equals(r2)); r2.setVolumePaint(Color.blue); assertTrue(r1.equals(r2)); }
Example #21
Source File: SimpleChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ 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; }
Example #22
Source File: CandlestickChart.java From ta4j-origins with MIT License | 4 votes |
public static void main(String[] args) { /** * Getting time series */ TimeSeries series = CsvTradesLoader.loadBitstampSeries(); /** * Creating the OHLC dataset */ OHLCDataset ohlcDataset = createOHLCDataset(series); /** * Creating the additional dataset */ TimeSeriesCollection xyDataset = createAdditionalDataset(series); /** * Creating the chart */ JFreeChart chart = ChartFactory.createCandlestickChart( "Bitstamp BTC price", "Time", "USD", ohlcDataset, true); // Candlestick rendering CandlestickRenderer renderer = new CandlestickRenderer(); renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); XYPlot plot = chart.getXYPlot(); plot.setRenderer(renderer); // Additional dataset int index = 1; plot.setDataset(index, xyDataset); plot.mapDatasetToRangeAxis(index, 0); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); renderer2.setSeriesPaint(index, Color.blue); plot.setRenderer(index, renderer2); // Misc plot.setRangeGridlinePaint(Color.lightGray); plot.setBackgroundPaint(Color.white); NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); numberAxis.setAutoRangeIncludesZero(false); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); /** * Displaying the chart */ displayChart(chart); }