Is it possible to combine TimeSeries data and HighLow data in the same chart?
Also, I have an array of price data where each element has a time code (e.g. L1, L3 or M1) and a price. This I would like to turn into a HighLow chart with a vertical bar for each time code. I've got a method to convert the time code to a time string "HH:mm". The same time code can occur multiple times. Do I first need to trim this data to exclude multiple values? What is the best DataSet to do this?
HighLowDataset and TimeSeries
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: HighLowDataset and TimeSeries
Yes, you can add a secondary dataset and renderer to a time series chart - the secondary renderer can be a HighLowRenderer.Markus wrote:Is it possible to combine TimeSeries data and HighLow data in the same chart?
The HighLowRenderer expects a dataset that conforms to the HighLowDataset interface. Your best option is probably to write a class that wraps your data array and implements the HighLowRenderer interface.Markus wrote:... What is the best DataSet to do this?
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
found a solution
My solution
---------------------------------
HighLowDataset dataset = pgraph.createhighlowdataset();
TimeSeriesCollection dataset2 = new TimeSeriesCollection();
dataset2.addSeries(lmme2fi);
JFreeChart chart = ChartFactory.createCandlestickChart("Candlestick Demo",
"Time", "Value",
dataset, true);
StandardLegend legend = (StandardLegend) chart.getLegend();
legend.setDisplaySeriesShapes(true);
XYPlot plot = chart.getXYPlot();
NumberAxis axis2 = new VerticalNumberAxis("F Ind");
axis2.setAutoRangeIncludesZero(true);
plot.setSecondaryRangeAxis(axis2);
plot.setSecondaryDataset(dataset2);
XYToolTipGenerator tooltipGenerator = null;
XYURLGenerator urlGenerator = null;
plot.setSecondaryRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES, tooltipGenerator, urlGenerator));
plot.setSecondaryDataset(dataset2);
---------
Well, i'm looking for the samething, but just with a single Axis..
like a CandlestickChart with two average ??
Any solution ???
thanks ...
---------------------------------
HighLowDataset dataset = pgraph.createhighlowdataset();
TimeSeriesCollection dataset2 = new TimeSeriesCollection();
dataset2.addSeries(lmme2fi);
JFreeChart chart = ChartFactory.createCandlestickChart("Candlestick Demo",
"Time", "Value",
dataset, true);
StandardLegend legend = (StandardLegend) chart.getLegend();
legend.setDisplaySeriesShapes(true);
XYPlot plot = chart.getXYPlot();
NumberAxis axis2 = new VerticalNumberAxis("F Ind");
axis2.setAutoRangeIncludesZero(true);
plot.setSecondaryRangeAxis(axis2);
plot.setSecondaryDataset(dataset2);
XYToolTipGenerator tooltipGenerator = null;
XYURLGenerator urlGenerator = null;
plot.setSecondaryRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES, tooltipGenerator, urlGenerator));
plot.setSecondaryDataset(dataset2);
---------
Well, i'm looking for the samething, but just with a single Axis..
like a CandlestickChart with two average ??
Any solution ???
thanks ...