本文整理汇总了Java中org.jfree.data.xy.OHLCDataset类的典型用法代码示例。如果您正苦于以下问题:Java OHLCDataset类的具体用法?Java OHLCDataset怎么用?Java OHLCDataset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OHLCDataset类属于org.jfree.data.xy包,在下文中一共展示了OHLCDataset类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getOHLCDataset
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
private OHLCDataset getOHLCDataset(List<Candle> chartDatas) {
final int size = chartDatas.size();
Date[] date = new Date[size];
double[] high = new double[size];
double[] low = new double[size];
double[] open = new double[size];
double[] close = new double[size];
double[] volume = new double[size];
int i = 0;
for(Candle chartData : chartDatas) {
date[i] = new Date(chartData.getStartTimeStamp());
high[i] = chartData.getHigh();
low[i] = chartData.getLow();
open[i] = chartData.getOpen();
close[i] = chartData.getClose();
volume[i] = chartData.getVolume();
i++;
}
return new DefaultHighLowDataset("Price", date, high, low, open, close, volume);
}
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:25,代码来源:ChartJDialog.java
示例2: createOHLCDataset
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* 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;
}
开发者ID:ta4j,项目名称:ta4j,代码行数:30,代码来源:CandlestickChart.java
示例3: createCandlestickChart
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* 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;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:ChartFactory.java
示例4: createHighLowChart
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* Creates and returns a default instance of a high-low-open-close 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 high-low-open-close chart.
*/
public static JFreeChart createHighLowChart(String title,
String timeAxisLabel,
String valueAxisLabel,
OHLCDataset dataset,
boolean legend) {
ValueAxis timeAxis = new DateAxis(timeAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
HighLowRenderer renderer = new HighLowRenderer();
renderer.setToolTipGenerator(new HighLowItemLabelGenerator());
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
return chart;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:ChartFactory.java
示例5: createCandlestickChart
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* 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;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:ChartFactory.java
示例6: createHighLowChart
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* Creates and returns a default instance of a high-low-open-close 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 high-low-open-close chart.
*/
public static JFreeChart createHighLowChart(String title,
String timeAxisLabel,
String valueAxisLabel,
OHLCDataset dataset,
boolean legend) {
ValueAxis timeAxis = new DateAxis(timeAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
HighLowRenderer renderer = new HighLowRenderer();
renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
return chart;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:ChartFactory.java
示例7: createHighLowChart
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* Creates and returns a default instance of a high-low-open-close 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 high-low-open-close chart.
*/
public static JFreeChart createHighLowChart(String title,
String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
boolean legend) {
ValueAxis timeAxis = new DateAxis(timeAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
HighLowRenderer renderer = new HighLowRenderer();
renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
currentTheme.apply(chart);
return chart;
}
开发者ID:mdzio,项目名称:ccu-historian,代码行数:29,代码来源:ChartFactory.java
示例8: createHighLowChart
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* Creates and returns a default instance of a high-low-open-close chart.
*
* @param title the chart title ({@code null} permitted).
* @param timeAxisLabel a label for the time axis ({@code null}
* permitted).
* @param valueAxisLabel a label for the value axis ({@code null}
* permitted).
* @param dataset the dataset for the chart ({@code null} permitted).
* @param legend a flag specifying whether or not a legend is required.
*
* @return A high-low-open-close chart.
*/
public static JFreeChart createHighLowChart(String title,
String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
boolean legend) {
ValueAxis timeAxis = new DateAxis(timeAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
HighLowRenderer renderer = new HighLowRenderer();
renderer.setDefaultToolTipGenerator(new HighLowItemLabelGenerator());
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
currentTheme.apply(chart);
return chart;
}
开发者ID:jfree,项目名称:jfreechart,代码行数:29,代码来源:ChartFactory.java
示例9: createCandlestickChart
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* 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;
}
开发者ID:SOCR,项目名称:HTML5_WebSite,代码行数:30,代码来源:ChartFactory.java
示例10: createHighLowChart
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* Creates and returns a default instance of a high-low-open-close 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 high-low-open-close chart.
*/
public static JFreeChart createHighLowChart(String title,
String timeAxisLabel,
String valueAxisLabel,
OHLCDataset dataset,
boolean legend) {
ValueAxis timeAxis = new DateAxis(timeAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
HighLowRenderer renderer = new HighLowRenderer();
renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
currentTheme.apply(chart);
return chart;
}
开发者ID:SOCR,项目名称:HTML5_WebSite,代码行数:31,代码来源:ChartFactory.java
示例11: createCandlestickChart
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
private JFreeChart createCandlestickChart(OHLCDataset priceOHLCDataset) {
final String title = "Chart";
final ValueAxis timeAxis = new DateAxis("Date");
final NumberAxis valueAxis = new NumberAxis("Price");
valueAxis.setAutoRangeIncludesZero(false);
valueAxis.setUpperMargin(0.0);
valueAxis.setLowerMargin(0.0);
XYPlot plot = new XYPlot(priceOHLCDataset, timeAxis, valueAxis, null);
final CandlestickRenderer candlestickRenderer = new CandlestickRenderer();
plot.setRenderer(candlestickRenderer);
//plot.getRangeAxis().setAutoRange(true);
// Give good width when zoom in, but too slow in calculation.
((CandlestickRenderer)plot.getRenderer()).setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(timeAxis);
cplot.add(plot, 3);
cplot.setGap(8.0);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, cplot, true);
applyChartTheme(chart);
// Handle zooming event.
chart.addChangeListener(this.getChartChangeListner());
return chart;
}
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:32,代码来源:ChartJDialog.java
示例12: getLowestLow
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
private double getLowestLow(OHLCDataset dataset, int start, int end){
double lowest;
lowest = dataset.getLowValue(0,start);
for(int i=1;i<=end;i++){
if(dataset.getLowValue(0,i) < lowest){
lowest = dataset.getLowValue(0,i);
}
}
return lowest;
}
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:12,代码来源:ChartScrollBar.java
示例13: getHighestHigh
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
private double getHighestHigh(OHLCDataset dataset, int start, int end){
double highest;
highest = dataset.getHighValue(0,start);
for(int i=1;i<=end;i++){
if(dataset.getLowValue(0,i) > highest){
highest = dataset.getHighValue(0,i);
}
}
return highest;
}
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:12,代码来源:ChartScrollBar.java
示例14: initialise
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* Initialises the renderer then returns the number of 'passes' through the data that the
* renderer will require (usually just one). This method will be called before the first
* item is rendered, giving the renderer an opportunity to initialise any
* state information it wants to maintain. The renderer can do nothing if it chooses.
*
* @param g2 the graphics device.
* @param dataArea the area inside the axes.
* @param plot the plot.
* @param dataset the data.
* @param info an optional info collection object to return data back to the caller.
*
* @return The number of passes the renderer requires.
*/
public XYItemRendererState initialise(Graphics2D g2,
Rectangle2D dataArea,
XYPlot plot,
XYDataset dataset,
PlotRenderingInfo info) {
// calculate the maximum allowed candle width from the axis...
ValueAxis axis = plot.getDomainAxis();
double x1 = axis.getLowerBound();
double x2 = x1 + this.maxCandleWidthInMilliseconds;
RectangleEdge edge = plot.getDomainAxisEdge();
double xx1 = axis.valueToJava2D(x1, dataArea, edge);
double xx2 = axis.valueToJava2D(x2, dataArea, edge);
this.maxCandleWidth = Math.abs(xx2 - xx1); // Absolute value, since the relative x
// positions are reversed for horizontal orientation
// calculate the highest volume in the dataset...
if (this.drawVolume) {
OHLCDataset highLowDataset = (OHLCDataset) dataset;
this.maxVolume = 0.0;
for (int series = 0; series < highLowDataset.getSeriesCount(); series++) {
for (int item = 0; item < highLowDataset.getItemCount(series); item++) {
double volume = highLowDataset.getVolumeValue(series, item);
if (volume > this.maxVolume) {
this.maxVolume = volume;
}
}
}
}
return new XYItemRendererState(info);
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:48,代码来源:CandlestickRenderer.java
示例15: generateToolTip
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* Generates a tooltip text item for a particular item within a series.
*
* @param dataset the dataset.
* @param series the series (zero-based index).
* @param item the item (zero-based index).
*
* @return the tooltip text.
*/
public String generateToolTip(XYDataset dataset, int series, int item) {
String result = null;
if (dataset instanceof OHLCDataset) {
OHLCDataset d = (OHLCDataset) dataset;
Number high = d.getHigh(series, item);
Number low = d.getLow(series, item);
Number open = d.getOpen(series, item);
Number close = d.getClose(series, item);
Number x = d.getX(series, item);
result = d.getSeriesName(series);
if (x != null) {
Date date = new Date(x.longValue());
result = result + "--> Date=" + this.dateFormatter.format(date);
if (high != null) {
result = result + " High=" + this.numberFormatter.format(high.doubleValue());
}
if (low != null) {
result = result + " Low=" + this.numberFormatter.format(low.doubleValue());
}
if (open != null) {
result = result + " Open=" + this.numberFormatter.format(open.doubleValue());
}
if (close != null) {
result = result + " Close=" + this.numberFormatter.format(close.doubleValue());
}
}
}
return result;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:46,代码来源:HighLowItemLabelGenerator.java
示例16: iterateXYRangeExtent
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* Iterates over the data item of the xy dataset to find
* the range extent.
*
* @param dataset the dataset (<code>null</code> not permitted).
*
* @return The range (possibly <code>null</code>).
*/
public static Range iterateXYRangeExtent(XYDataset dataset) {
double minimum = Double.POSITIVE_INFINITY;
double maximum = Double.NEGATIVE_INFINITY;
int seriesCount = dataset.getSeriesCount();
for (int series = 0; series < seriesCount; series++) {
int itemCount = dataset.getItemCount(series);
for (int item = 0; item < itemCount; item++) {
double lvalue;
double uvalue;
if (dataset instanceof IntervalXYDataset) {
IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset;
lvalue = intervalXYData.getStartYValue(series, item);
uvalue = intervalXYData.getEndYValue(series, item);
}
else if (dataset instanceof OHLCDataset) {
OHLCDataset highLowData = (OHLCDataset) dataset;
lvalue = highLowData.getLowValue(series, item);
uvalue = highLowData.getHighValue(series, item);
}
else {
lvalue = dataset.getYValue(series, item);
uvalue = lvalue;
}
if (!Double.isNaN(lvalue)) {
minimum = Math.min(minimum, lvalue);
}
if (!Double.isNaN(uvalue)) {
maximum = Math.max(maximum, uvalue);
}
}
}
if (minimum == Double.POSITIVE_INFINITY) {
return null;
}
else {
return new Range(minimum, maximum);
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:47,代码来源:DatasetUtilities.java
示例17: initialise
import org.jfree.data.xy.OHLCDataset; //导入依赖的package包/类
/**
* Initialises the renderer then returns the number of 'passes' through the
* data that the renderer will require (usually just one). This method
* will be called before the first item is rendered, giving the renderer
* an opportunity to initialise any state information it wants to maintain.
* The renderer can do nothing if it chooses.
*
* @param g2 the graphics device.
* @param dataArea the area inside the axes.
* @param plot the plot.
* @param dataset the data.
* @param info an optional info collection object to return data back to
* the caller.
*
* @return The number of passes the renderer requires.
*/
public XYItemRendererState initialise(Graphics2D g2,
Rectangle2D dataArea,
XYPlot plot,
XYDataset dataset,
PlotRenderingInfo info) {
// calculate the maximum allowed candle width from the axis...
ValueAxis axis = plot.getDomainAxis();
double x1 = axis.getLowerBound();
double x2 = x1 + this.maxCandleWidthInMilliseconds;
RectangleEdge edge = plot.getDomainAxisEdge();
double xx1 = axis.valueToJava2D(x1, dataArea, edge);
double xx2 = axis.valueToJava2D(x2, dataArea, edge);
this.maxCandleWidth = Math.abs(xx2 - xx1);
// Absolute value, since the relative x
// positions are reversed for horizontal orientation
// calculate the highest volume in the dataset...
if (this.drawVolume) {
OHLCDataset highLowDataset = (OHLCDataset) dataset;
this.maxVolume = 0.0;
for (int series = 0; series < highLowDataset.getSeriesCount();
series++) {
for (int item = 0; item < highLowDataset.getItemCount(series);
item++) {
double volume = highLowDataset.getVolumeValue(series, item);
if (volume > this.maxVolume) {
this.maxVolume = volume;
}
}
}
}
return new XYItemRendererState(info);
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:53,代码来源:CandlestickRenderer.java
注:本文中的org.jfree.data.xy.OHLCDataset类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论