JFreeC,股票走勢圖 hart制作股票走勢圖

  生成圖形:

import org.jstockchart.model.TimeseriesItem;

3,股票.jcommon,JFreeC.所以當生成了JFreeChart實例後

//設定顯示中線

jfreechart,股票市場.所以當生成了JFreeChart實例後

new Double(lastPrice), new Range(

* 由于JFreeChart具有高度的可定制性,通過PriceArea類,炒股票新手入門.都必須在"同一天"内。股票市場.

logicDateAxis.addDateTick(“10:30″);

priceArea.setPriceColor(new Color(0x));

* SegmentedTimeline.MINUTE_SEGMENT_SIZE);

LogicDateAxis logicDateAxis = new LogicDateAxis(baseDate,

* 如,都必須在"同一天"内。hart制作股票走勢圖.

* @date: 2009-3-24

TimeseriesArea timeseriesArea = new TimeseriesArea(priceArea,

logicDateAxis.addDateTick(“13:30″);

import org.jstockchart.axis.logic.LogicDateAxis;

if (!images.exists()) {

timeline.setStartTime(SegmentedTimeline.firstMondayAfter1900() + 780

* @time: 下午08:21:10

logicDateAxis.addDateTick(“13:00″, TickAlignment.START);

priceArea.setBackgroudColor(new Color(0xFFFFCC));

logicDateAxis.addDateTick(“14:00″);

logicDateAxis.addDateTick(“15:00″, TickAlignment.END);

import java.text.SimpleDateFormat;

import org.jstockchart.util.DateUtils;

int v = (int)(Math.random()*1000);

CentralValueAxis logicPriceAxis = new CentralValueAxis(

volumeArea, createlogicDateAxis(DateUtils.createDate(2008, 1, 1)));

import org.jfree.data.Range;

VolumeArea volumeArea = new VolumeArea(logicVolumeAxis);

//注意:所有的數據,股市.顯示9個坐标值,并且不生成圖例(legend)。炒股票新手入門.

priceArea.setCentralPriceColor(new Color(0x0000FF));

//創建邏輯價格坐标軸。指定中間價爲lastPrice,jfreec.并且不生成圖例(legend)。炒股票新手入門.

long leTime = endDate.getTime();

final int type, final int step){

volumeArea.setVolumeColor(new Color(0x3366FF));

@SuppressWarnings(“unchecked")

import org.jfree.chart.plot.XYPlot;

//創建價格區域

plot.setBackgroundAlpha(0.618f);

Date startTime = DateUtils.createDate(2008, 1, 1, 9, 30, 0);

return list;

XYPlot plot = (XYPlot)jfreechart.getPlot();

.doubleValue()), 5, new DecimalFormat(“0″));

import org.jstockchart.axis.logic.LogicNumberAxis;

logicDateAxis.addDateTick(“10:00″);

* @author: Daniel Cao

//通過JStockChartFactory的工廠方法生成JFreeChart實例。股票市場.

List data = makeTimeseriesItem(lastPrice,startTime, endTime,Calendar.MINUTE, 1);

//指定了該圖的标題爲"Timeseries Chart Demo",股票市場.測試代碼:股票走勢圖.

import org.jfree.chart.ChartUtilities;

//創建時序圖區域

logicDateAxis.addDateTick(“14:30″);

SegmentedTimeline timeline = new SegmentedTimeline(

2,表示時間區間"09:30-11:30,13:00-15:00″。股票.

priceArea.setMarkCentralValue(true);

//設定價格區占的權重

JFreeChart jfreechart = JStockChartFactory.createTimeseriesChart(

import org.jstockchart.axis.logic.CentralValueAxis;

images.mkdir();

//創建SegmentedTimeline實例,股票行情查詢.時間間隔爲1分鍾。

import org.jstockchart.JStockChartFactory;

private static LogicDateAxis createlogicDateAxis(Date baseDate) {

timeline, false);

return logicDateAxis;

import org.jstockchart.axis.TickAlignment;

//創建TimeseriesDataset實例,如何買股票新手入門.在創建JStockChart的XXXArea對象時,股票.然後再定制它們的屬性。炒股票新手入門.

//設定量圖的顔色

new DecimalFormat(“.00″));

* 均線的顔色(PriceArea.setAverageColor);

ChartUtilities.saveChartAsPNG(new File(imageFile), jfreechart, 545, 300);

public static void main(String[] args) throws IOException {

//随機生成數據

//創建一個包含TimeseriesItem的List實例。JFreeC.

public class JFreeChartTest {

for(long l = lsTime; l <= leTime; l += 1*60*1000L){

* 詳細信息請參見JFreeChart的站點和論壇。股票.

//指定時期坐标軸中的邏輯坐标。

//設定中線顔色

priceArea.setAverageVisible(false);

import java.util.ArrayList;

//不顯示均價線

import java.text.DecimalFormat;

import org.jstockchart.dataset.TimeseriesDataset;

import java.util.Date;

import org.jstockchart.area.VolumeArea;

TimeseriesItem ti = new TimeseriesItem(d,price,v);

PriceArea priceArea = new PriceArea(logicPriceAxis);

* 是否顯示漲跌幅(PriceArea.setRateVisible);…。股票走勢圖.

String imageDir = “E:/images";

private static List<TimeseriesItem> makeTimeseriesItem(final double lastPrice,final Date startTime, final Date endDate,

import org.jstockchart.area.TimeseriesArea;

import java.util.List;

File images = new File(imageDir);

* 另外,hart制作股票走勢圖.如Plot,股票行情.寬爲300。股票入門.

import java.io.File;

* 你可以從中獲取圖表中的各個元素,hart.長爲545,制作.主要使用jar:

//創建圖像文件。圖像格式爲PNG,主要使用jar:

volumeArea.setBackgroudColor(new Color(0xFFFFCC));

Date d = new Date(l);

//背景色

import java.io.IOException;

logicDateAxis.addDateTick(“11:30″, TickAlignment.END);

“實時走勢圖", dataset, timeline, timeseriesArea, false);

LogicNumberAxis logicVolumeAxis = new LogicNumberAxis(new Range(dataset

dataset.addDataItems(data);

new SimpleDateFormat(“HH:mm"));

logicDateAxis.addDateTick(“09:30″, TickAlignment.START);

SegmentedTimeline.MINUTE_SEGMENT_SIZE, 1351, 89);

//設定價格線的顔色

// 創建量區域

timeseriesArea.setPriceWeight(3);

List<TimeseriesItem> list = new ArrayList<TimeseriesItem>();

logicDateAxis.addDateTick(“11:00″);

import java.awt.Color;

import java.util.Calendar;

.getMaxPrice().doubleValue()), 9,

package test;

import org.jfree.data.time.Minute;

list.add(ti);

long lsTime = startTime.getTime();

//向dataset中加入TimeseriesItem的List

TimeseriesDataset dataset = new TimeseriesDataset(Minute.class, 1,

Date endTime = DateUtils.createDate(2008, 1, 1, 15, 0, 0);

import org.jfree.chart.axis.SegmentedTimeline;

//設定價格區背景色

1,坐标值的格式爲"0″。

dataset.getMinPrice().doubleValue(), dataset

import org.jfree.chart.JFreeChart;

//創建邏輯量坐标軸。顯示5個坐标值,
* 詳細信息請參見JStockChart的API文檔

double price = lastPrice + (Math.random()-0.5)*4.5;

import org.jstockchart.area.PriceArea;

double lastPrice = 23.50;

.getMinVolume().doubleValue(), dataset.getMaxVolume()

String imageFile = imageDir + “/jstockchart-timeseries.png";

* 是否顯示均線(PriceArea.setAverageVisible);