org.jfree.data.xy.DefaultHighLowDataset Java Examples
The following examples show how to use
org.jfree.data.xy.DefaultHighLowDataset.
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: TaChart.java From TAcharting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Builds a JFreeChart OHLC dataset from a ta4j time series. * @param series a time series * @return an Open-High-Low-Close dataset */ private static OHLCDataset createOHLCDataset(BarSeries series) { final int nbBars = series.getBarCount(); Date[] dates = new Date[nbBars]; double[] opens = new double[nbBars]; double[] highs = new double[nbBars]; double[] lows = new double[nbBars]; double[] closes = new double[nbBars]; double[] volumes = new double[nbBars]; for (int i = 0; i < nbBars; i++) { Bar Bar = series.getBar(i); dates[i] = new Date(Bar.getEndTime().toEpochSecond() * 1000); opens[i] = Bar.getOpenPrice().doubleValue(); highs[i] = Bar.getHighPrice().doubleValue(); lows[i] = Bar.getLowPrice().doubleValue(); closes[i] = Bar.getClosePrice().doubleValue(); volumes[i] = Bar.getVolume().doubleValue(); } return new DefaultHighLowDataset(series.getName(), dates, highs, lows, opens, closes, volumes); }
Example #2
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 #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: CandlestickChart.java From ta4j-origins with MIT License | 6 votes |
/** * Builds a JFreeChart OHLC dataset from a ta4j time series. * @param series a time series * @return an Open-High-Low-Close dataset */ private static OHLCDataset createOHLCDataset(TimeSeries series) { final int nbTicks = series.getTickCount(); Date[] dates = new Date[nbTicks]; double[] opens = new double[nbTicks]; double[] highs = new double[nbTicks]; double[] lows = new double[nbTicks]; double[] closes = new double[nbTicks]; double[] volumes = new double[nbTicks]; for (int i = 0; i < nbTicks; i++) { Tick tick = series.getTick(i); dates[i] = new Date(tick.getEndTime().toEpochSecond() * 1000); opens[i] = tick.getOpenPrice().toDouble(); highs[i] = tick.getMaxPrice().toDouble(); lows[i] = tick.getMinPrice().toDouble(); closes[i] = tick.getClosePrice().toDouble(); volumes[i] = tick.getVolume().toDouble(); } OHLCDataset dataset = new DefaultHighLowDataset("btc", dates, highs, lows, opens, closes, volumes); return dataset; }
Example #5
Source File: JRFillHighLowDataset.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Dataset getCustomDataset() { int size = elements.size(); if (size > 0) { Date[] dateArray = new Date[size]; double[] highArray = new double[size]; double[] lowArray = new double[size]; double[] openArray = new double[size]; double[] closeArray = new double[size]; double[] volumeArray = new double[size]; for (int i = 0; i < elements.size(); i++) { HighLowElement bean = elements.get(i); dateArray[i] = new Date(bean.getDate().getTime()); highArray[i] = bean.getHigh().doubleValue(); lowArray[i] = bean.getLow().doubleValue(); openArray[i] = bean.getOpen().doubleValue(); closeArray[i] = bean.getClose().doubleValue(); volumeArray[i] = bean.getVolume().doubleValue(); } return new DefaultHighLowDataset(series, dateArray, highArray, lowArray, openArray, closeArray, volumeArray); } return null; }
Example #6
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 #7
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 #8
Source File: DefaultHighLowDatasetTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[0], new double[0], new double[0], new double[0], new double[0], new double[0]); assertTrue(d1 instanceof PublicCloneable); }
Example #9
Source File: IndustriesPanel.java From computational-economy with GNU General Public License v3.0 | 5 votes |
protected DefaultHighLowDataset getDefaultHighLowDataset(final Currency currency, final GoodType goodType) { final PricesModel pricesModel = ApplicationContext.getInstance().getModelRegistry() .getNationalEconomyModel(currency).pricesModel; final Map<GoodType, PriceModel> priceModelsForGoodType = pricesModel.getPriceModelsForGoodTypes(); final PriceModel priceModel = priceModelsForGoodType.get(goodType); if (priceModel != null) { return new DefaultHighLowDataset("", priceModel.getDate(), priceModel.getHigh(), priceModel.getLow(), priceModel.getOpen(), priceModel.getClose(), priceModel.getVolume()); } return null; }
Example #10
Source File: HouseholdsPanel.java From computational-economy with GNU General Public License v3.0 | 5 votes |
protected DefaultHighLowDataset getDefaultHighLowDataset(final Currency currency) { final PricesModel pricesModel = ApplicationContext.getInstance().getModelRegistry() .getNationalEconomyModel(currency).pricesModel; final Map<GoodType, PriceModel> priceModelsForGoodType = pricesModel.getPriceModelsForGoodTypes(); final PriceModel priceModel = priceModelsForGoodType.get(GoodType.LABOURHOUR); if (priceModel != null) { return new DefaultHighLowDataset("", priceModel.getDate(), priceModel.getHigh(), priceModel.getLow(), priceModel.getOpen(), priceModel.getClose(), priceModel.getVolume()); } return null; }
Example #11
Source File: BanksPanel.java From computational-economy with GNU General Public License v3.0 | 5 votes |
protected DefaultHighLowDataset getDefaultHighLowDataset(final Currency currency, final Currency commodityCurrency) { final PricesModel pricesModel = ApplicationContext.getInstance().getModelRegistry() .getNationalEconomyModel(currency).pricesModel; final Map<Currency, PriceModel> priceModelsForCurrencies = pricesModel.getPriceModelsForCurrencies(); final PriceModel priceModel = priceModelsForCurrencies.get(commodityCurrency); if (priceModel != null) { return new DefaultHighLowDataset("", priceModel.getDate(), priceModel.getHigh(), priceModel.getLow(), priceModel.getOpen(), priceModel.getClose(), priceModel.getVolume()); } return null; }
Example #12
Source File: DefaultChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected JFreeChart createHighLowChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createHighLowChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot(); HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer(); boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks(); boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false : highLowPlot.getShowCloseTicks(); hlRenderer.setDrawOpenTicks(isShowOpenTicks); hlRenderer.setDrawCloseTicks(isShowCloseTicks); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(), highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(), highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisVerticalTickLabels(), highLowPlot.getTimeAxisLineColor(), false, (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(), highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(), highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisVerticalTickLabels(), highLowPlot.getValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
Example #13
Source File: GenericChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected JFreeChart createHighLowChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createHighLowChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot(); HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer(); boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks(); boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false : highLowPlot.getShowCloseTicks(); hlRenderer.setDrawOpenTicks(isShowOpenTicks); hlRenderer.setDrawCloseTicks(isShowCloseTicks); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(), highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(), highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisVerticalTickLabels(), highLowPlot.getOwnTimeAxisLineColor(), false, (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(), highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(), highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisVerticalTickLabels(), highLowPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
Example #14
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 #15
Source File: SimpleChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected JFreeChart createHighLowChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createHighLowChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot(); HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer(); boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks(); boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false : highLowPlot.getShowCloseTicks(); hlRenderer.setDrawOpenTicks(isShowOpenTicks); hlRenderer.setDrawCloseTicks(isShowCloseTicks); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(), highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(), highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisVerticalTickLabels(), highLowPlot.getOwnTimeAxisLineColor(), getDomainAxisSettings(), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression()) ); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(), highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(), highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisVerticalTickLabels(), highLowPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMaxValueExpression()) ); return jfreeChart; }