📄 cewolfohlc.jsp
字号:
<!--
Fig. 8.4_05: CewolfOHLC.jsp
功能: Cewolf 编程实例: 基于OHLCDataset数据集的图表
-->
<%@ page contentType="text/html;charset=GB2312"%>
<%@ taglib uri='/WEB-INF/cewolf.tld' prefix='cewolf' %>
<%@ page import="java.util.*"%>
<%@ page import="de.laures.cewolf.*"%>
<%@ page import="de.laures.cewolf.tooltips.*"%>
<%@ page import="de.laures.cewolf.links.*"%>
<%@ page import="org.jfree.data.*"%>
<%@ page import="org.jfree.data.time.*"%>
<%@ page import="org.jfree.data.gantt.*"%>
<%@ page import="org.jfree.chart.*"%>
<%@ page import="org.jfree.chart.plot.*"%>
<%@ page import="org.jfree.chart.renderer.*"%>
<%@ page import="org.jfree.data.category.*"%>
<%@ page import="org.jfree.data.general.*"%>
<%@ page import="org.jfree.data.xy.*"%>
<%!
String chartTitle = "Cewolf 编程实例: 基于OHLCDataset数据集的图表";
%>
<%
// 创建数据集
DatasetProducer hiloData = new DatasetProducer()
{
public Object produceDataset(Map params)
{
int itemCount = 60;
Date[]dates = new Date[itemCount];
double[]high = new double[itemCount];
double[]low = new double[itemCount];
double[]open = new double[itemCount];
double[]close = new double[itemCount];
double[]volume = new double[itemCount];
Calendar cal = new GregorianCalendar();
// 初始化第一组数据
high[0] = 27.0;
low[0] = 24.0;
open[0] = 24.0;
close[0] = 26.0;
dates[0] = cal.getTime();
volume[0] = 500.0 + Math.random() * 500;
for (int i = 1; i < itemCount; i++)
{
cal.roll(Calendar.MINUTE, 1);
dates[i] = cal.getTime();
high[i] = high[i - 1] + Math.random() * 5-2.5;
low[i] = high[i] - (Math.random() * 5);
open[i] = high[i] - (Math.random() * (high[i] - low[i]));
close[i] = low[i] + (Math.random() * (high[i] - open[i]));
volume[i] = 500.0 + Math.random() * 500;
}
OHLCDataset ds = new DefaultHighLowDataset(
"FatCat InfoTech Studio, Chongqing, P.R.China", dates, high, low, open,
close, volume);
return ds;
}
public String getProducerId()
{
return "HiLoDataProducer";
}
public boolean hasExpired(Map params, Date since)
{
return false;
}
};
pageContext.setAttribute("highLowData", hiloData);
%>
<HTML>
<HEAD>
<TITLE><%=chartTitle%></TITLE>
</HEAD>
<BODY>
<cewolf:chart
id="candleStick"
title="Cewolf 编程实例18: CandleStick 图表"
type="candleStick"
xaxislabel="交易时间"
yaxislabel="交易价格">
<cewolf:data>
<cewolf:producer id="highLowData" />
</cewolf:data>
</cewolf:chart>
<cewolf:img
chartid="candleStick"
renderer="/cewolf"
width="500"
height="375">
</cewolf:img>
<BR><BR>
<cewolf:chart
id="highLow"
title="Cewolf 编程实例19: HighLow 图表"
type="highLow"
xaxislabel="交易时间"
yaxislabel="交易价格">
<cewolf:data>
<cewolf:producer id="highLowData" />
</cewolf:data>
</cewolf:chart>
<cewolf:img
chartid="highLow"
renderer="/cewolf"
width="500"
height="375">
</cewolf:img>
</BODY>
</HTML>
<!--
/**************************************************************************
* (C) Copyright 2004-2005 by Jingkui Zhong(钟京馗) and Huan Tang(唐桓). *
* All Rights Reserved. *
* *
* DISCLAIMER: The authors of this code have used their *
* best efforts in preparing the code. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these codes. The authors *
* shall not be liable in any event for incidental or consequential *
* damages in connection with, or arising out of, the furnishing, *
* performance, or use of these programs. *
**************************************************************************/
-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -