本文整理匯總了Java中org.jfree.chart.ChartFactory.createCandlestickChart方法的典型用法代碼示例。如果您正苦於以下問題:Java ChartFactory.createCandlestickChart方法的具體用法?Java ChartFactory.createCandlestickChart怎麽用?Java ChartFactory.createCandlestickChart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jfree.chart.ChartFactory
的用法示例。
在下文中一共展示了ChartFactory.createCandlestickChart方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
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);
}