本文整理匯總了Java中org.jfree.chart.ChartFactory.createTimeSeriesChart方法的典型用法代碼示例。如果您正苦於以下問題:Java ChartFactory.createTimeSeriesChart方法的具體用法?Java ChartFactory.createTimeSeriesChart怎麽用?Java ChartFactory.createTimeSeriesChart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jfree.chart.ChartFactory
的用法示例。
在下文中一共展示了ChartFactory.createTimeSeriesChart方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TimeSeriesChartTab
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
* Constructor
* @param model The data model for this time series
*/
public TimeSeriesChartTab(TimeSeriesDataModel model, TimeSeriesChartEditorJPanel parent){
super(ChartFactory.createTimeSeriesChart(
model.getTimeSeriesOntologyModel().getChartSettings().getChartTitle(),
model.getTimeSeriesOntologyModel().getChartSettings().getXAxisLabel(),
model.getTimeSeriesOntologyModel().getChartSettings().getYAxisLabel(),
model.getTimeSeriesChartModel().getTimeSeriesCollection(),
true, false, false
), parent);
this.dataModel = model;
applySettings();
model.getChartModel().addObserver(this);
}
示例2: createChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
* Create a horizontal bar chart with sample data in the range -3 to +3.
*
* @return The chart.
*/
private static JFreeChart createChart() {
// create a dataset...
XYSeries series1 = new XYSeries("Series 1");
series1.add(1.0, 1.0);
series1.add(2.0, 2.0);
series1.add(3.0, 3.0);
XYDataset dataset = new XYSeriesCollection(series1);
// create the chart...
return ChartFactory.createTimeSeriesChart(
"XY Line Chart", // chart title
"Domain",
"Range",
dataset, // data
true, // include legend
true, // tooltips
true // urls
);
}
示例3: paintPanel
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public JPanel paintPanel()
{
String titre = "Historique du point strat�gique";
String titre_x = "Periode";
String titre_y = "LED";
XYDataset dataset = createDataset();
JFreeChart chart = ChartFactory.createTimeSeriesChart(titre, titre_x, titre_y, dataset);
return new ChartPanel(chart);
}
示例4: TimeSeriesChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public TimeSeriesChart() {
XYDataset xydataset = createDataset();
JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General單位信托基金價格", "日期", "價格", xydataset, true, true, true);
XYPlot xyplot = (XYPlot) jfreechart.getPlot();
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
frame1 = new ChartPanel(jfreechart, true);
dateaxis.setLabelFont(new Font("黑體", Font.BOLD, 14)); //水平底部標題
dateaxis.setTickLabelFont(new Font("宋體", Font.BOLD, 12)); //垂直標題
ValueAxis rangeAxis = xyplot.getRangeAxis();//獲取柱狀
rangeAxis.setLabelFont(new Font("黑體", Font.BOLD, 15));
jfreechart.getLegend().setItemFont(new Font("黑體", Font.BOLD, 15));
jfreechart.getTitle().setFont(new Font("宋體", Font.BOLD, 20));//設置標題字體
}
示例5: getChartPanel
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public ChartPanel getChartPanel(List<String> industrys) {
XYDataset xydataset = createDataset(industrys);
JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("行業資金流入流出", "日期(日/單位)", "價格(億/單位)", xydataset, true, true, true);
XYPlot xyplot = (XYPlot) jfreechart.getPlot();
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
dateaxis.setLabelFont(new Font("黑體", Font.BOLD, 14)); //水平底部標題
dateaxis.setTickLabelFont(new Font("宋體", Font.BOLD, 12)); //垂直標題
ValueAxis rangeAxis = xyplot.getRangeAxis();//獲取柱狀
rangeAxis.setLabelFont(new Font("黑體", Font.BOLD, 15));
jfreechart.getLegend().setItemFont(new Font("黑體", Font.BOLD, 15));
jfreechart.getTitle().setFont(new Font("宋體", Font.BOLD, 20));//設置標題字體
ChartPanel frame1 = new ChartPanel(jfreechart, true);
return frame1;
}
示例6: getChartPanel
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public ChartPanel getChartPanel(List<String> industrys) {
XYDataset xydataset = createDataset(industrys);
JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("行業漲跌", "日期(日/單位)", "價格(%/單位)", xydataset, true, true, true);
XYPlot xyplot = (XYPlot) jfreechart.getPlot();
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
dateaxis.setLabelFont(new Font("黑體", Font.BOLD, 14)); //水平底部標題
dateaxis.setTickLabelFont(new Font("宋體", Font.BOLD, 12)); //垂直標題
ValueAxis rangeAxis = xyplot.getRangeAxis();//獲取柱狀
rangeAxis.setLabelFont(new Font("黑體", Font.BOLD, 15));
jfreechart.getLegend().setItemFont(new Font("黑體", Font.BOLD, 15));
jfreechart.getTitle().setFont(new Font("宋體", Font.BOLD, 20));//設置標題字體
ChartPanel frame1 = new ChartPanel(jfreechart, true);
return frame1;
}
示例7: main
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void main(String[] args) {
// Getting the time series
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
// Building the trading strategy
Strategy strategy = MovingMomentumStrategy.buildStrategy(series);
/**
* Building chart datasets
*/
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(buildChartTimeSeries(series, new ClosePriceIndicator(series), "Bitstamp Bitcoin (BTC)"));
/**
* Creating the chart
*/
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Bitstamp BTC", // title
"Date", // x-axis label
"Price", // y-axis label
dataset, // data
true, // create legend?
true, // generate tooltips?
false // generate URLs?
);
XYPlot plot = (XYPlot) chart.getPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MM-dd HH:mm"));
/**
* Running the strategy and adding the buy and sell signals to plot
*/
addBuySellSignals(series, strategy, plot);
/**
* Displaying the chart
*/
displayChart(chart);
}
示例8: createChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Legal & General Unit Trust Prices", // title
"Date", // x-axis label
"Price Per Unit", // y-axis label
dataset, // data
true, // create legend?
true, // generate tooltips?
false // generate URLs?
);
chart.setBackgroundPaint(Color.white);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setBaseShapesVisible(true);
renderer.setBaseShapesFilled(true);
renderer.setDrawSeriesLineAsPath(true);
}
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
return chart;
}
示例9: showChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public void showChart() {
/**
* Building chart datasets
*/
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(
buildChartTimeSeries(timeSeries, new ClosePriceIndicator(timeSeries), symbol));
dataset.addSeries(
buildChartTimeSeries(timeSeries, new EMAIndicator(new ClosePriceIndicator(timeSeries), 5), "EMA5"));
dataset.addSeries(
buildChartTimeSeries(timeSeries, new EMAIndicator(new ClosePriceIndicator(timeSeries), 10), "EMA10"));
dataset.addSeries(
buildChartTimeSeries(timeSeries, new EMAIndicator(new ClosePriceIndicator(timeSeries), 40), "EMA40"));
/**
* Creating the chart
*/
JFreeChart chart = ChartFactory.createTimeSeriesChart("BTC", // title
"Date", // x-axis label
"Price", // y-axis label
dataset, // data
true, // create legend?
true, // generate tooltips?
false // generate URLs?
);
XYPlot plot = (XYPlot) chart.getPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MM-dd-yyyy HH:mm"));
addBuySellSignals(timeSeries, strategy, plot);
displayChart(chart);
}
示例10: createChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Legal & General Unit Trust Prices", // title
"Date", // x-axis label
"Price Per Unit", // y-axis label
dataset, // data
true, // create legend?
true, // generate tooltips?
false // generate URLs?
);
chart.setBackgroundPaint(Color.white);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setBaseShapesVisible(true);
renderer.setBaseShapesFilled(true);
}
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
return chart;
}
示例11: createChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public JFreeChart createChart(final XYDataset dataset) {
return ChartFactory.createTimeSeriesChart(
feature,
"Timestamp",
"Value",
dataset,
true,
false,
false);
}
示例12: createChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"International Coffee Organisation : Coffee Prices", // title
null, // x-axis label
"US cents/lb", // y-axis label
dataset);
String fontName = "Palatino";
chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14)));
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(false);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
plot.getDomainAxis().setLowerMargin(0.0);
plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
chart.getLegend().setFrame(BlockBorder.NONE);
chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setDefaultShapesVisible(false);
renderer.setDrawSeriesLineAsPath(true);
// set the default stroke for all series
renderer.setAutoPopulateSeriesStroke(false);
renderer.setDefaultStroke(new BasicStroke(3.0f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesPaint(1, new Color(24, 123, 58));
renderer.setSeriesPaint(2, new Color(149, 201, 136));
renderer.setSeriesPaint(3, new Color(1, 62, 29));
renderer.setSeriesPaint(4, new Color(81, 176, 86));
renderer.setSeriesPaint(5, new Color(0, 55, 122));
renderer.setSeriesPaint(6, new Color(0, 92, 165));
renderer.setDefaultLegendTextFont(new Font(fontName, Font.PLAIN, 14));
}
return chart;
}
示例13: createChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"International Coffee Organisation : Coffee Prices", // title
null, // x-axis label
"US cents/lb", // y-axis label
dataset);
String fontName = "Palatino";
chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf",
new Font(fontName, Font.PLAIN, 14)));
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(true);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
plot.getDomainAxis().setLowerMargin(0.0);
plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
chart.getLegend().setFrame(BlockBorder.NONE);
chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setDefaultShapesVisible(false);
renderer.setDrawSeriesLineAsPath(true);
// set the default stroke for all series
renderer.setAutoPopulateSeriesStroke(false);
renderer.setDefaultStroke(new BasicStroke(3.0f));
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesPaint(1, new Color(24, 123, 58));
renderer.setSeriesPaint(2, new Color(149, 201, 136));
renderer.setSeriesPaint(3, new Color(1, 62, 29));
renderer.setSeriesPaint(4, new Color(81, 176, 86));
renderer.setSeriesPaint(5, new Color(0, 55, 122));
renderer.setSeriesPaint(6, new Color(0, 92, 165));
}
return chart;
}
示例14: main
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void main(String[] args) {
// Getting the time series
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
// Building the trading strategy
Strategy strategy = MovingMomentumStrategy.buildStrategy(series);
// Running the strategy
TimeSeriesManager seriesManager = new TimeSeriesManager(series);
TradingRecord tradingRecord = seriesManager.run(strategy);
// Getting the cash flow of the resulting trades
CashFlow cashFlow = new CashFlow(series, tradingRecord);
/**
* Building chart datasets
*/
TimeSeriesCollection datasetAxis1 = new TimeSeriesCollection();
datasetAxis1.addSeries(buildChartTimeSeries(series, new ClosePriceIndicator(series), "Bitstamp Bitcoin (BTC)"));
TimeSeriesCollection datasetAxis2 = new TimeSeriesCollection();
datasetAxis2.addSeries(buildChartTimeSeries(series, cashFlow, "Cash Flow"));
/**
* Creating the chart
*/
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Bitstamp BTC", // title
"Date", // x-axis label
"Price", // y-axis label
datasetAxis1, // data
true, // create legend?
true, // generate tooltips?
false // generate URLs?
);
XYPlot plot = (XYPlot) chart.getPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MM-dd HH:mm"));
/**
* Adding the cash flow axis (on the right)
*/
addCashFlowAxis(plot, datasetAxis2);
/**
* Displaying the chart
*/
displayChart(chart);
}
示例15: main
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void main(String[] args) {
/**
* Getting time series
*/
TimeSeries series = CsvTicksLoader.loadAppleIncSeries();
/**
* Creating indicators
*/
// Close price
ClosePriceIndicator closePrice = new ClosePriceIndicator(series);
EMAIndicator avg14 = new EMAIndicator(closePrice, 14);
StandardDeviationIndicator sd14 = new StandardDeviationIndicator(closePrice, 14);
// Bollinger bands
BollingerBandsMiddleIndicator middleBBand = new BollingerBandsMiddleIndicator(avg14);
BollingerBandsLowerIndicator lowBBand = new BollingerBandsLowerIndicator(middleBBand, sd14);
BollingerBandsUpperIndicator upBBand = new BollingerBandsUpperIndicator(middleBBand, sd14);
/**
* Building chart dataset
*/
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(buildChartTimeSeries(series, closePrice, "Apple Inc. (AAPL) - NASDAQ GS"));
dataset.addSeries(buildChartTimeSeries(series, lowBBand, "Low Bollinger Band"));
dataset.addSeries(buildChartTimeSeries(series, upBBand, "High Bollinger Band"));
/**
* Creating the chart
*/
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Apple Inc. 2013 Close Prices", // title
"Date", // x-axis label
"Price Per Unit", // y-axis label
dataset, // data
true, // create legend?
true, // generate tooltips?
false // generate URLs?
);
XYPlot plot = (XYPlot) chart.getPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
/**
* Displaying the chart
*/
displayChart(chart);
}