📄 cewolfxy4.jsp
字号:
<!--
Fig. 8.4_04_04: CewolfXY4.jsp
功能: Cewolf 编程实例16: 基于XYDataset的时序图及移动平均线
-->
<%@ page contentType="text/html;charset=GB2312"%>
<%@ include file="CewolfXYDataset.jsp" %>
<%
// 创建数据集
DatasetProducer timeData = new DatasetProducer()
{
public Object produceDataset(Map params)
{
TimeSeries tsc = new TimeSeries("2004年国际原油价格");
double value = 35;
Day day = new Day(1, 1, 2004);
for (int i = 0; i < 360; i++)
{
// 生成原油价格
double flag = Math.random();
if (flag > 0.5)
{
value += Math.random() * 1.5;
}
else
{
value -= Math.random() * 1.5;
}
tsc.add(day, value);
day = (Day)day.next();
}
TimeSeriesCollection dataset = new TimeSeriesCollection();
// 创建移动平均线数据集对象
TimeSeries mav =
MovingAverage.createMovingAverage(tsc, "30天油价移动平均价", 30, 30);
dataset.addSeries(tsc);
dataset.addSeries(mav);
return dataset;
}
public String getProducerId()
{
return "TimeDataProducer";
}
public boolean hasExpired(Map params, Date since)
{
return false;
}
};
pageContext.setAttribute("timeData", timeData);
%>
<HTML>
<HEAD>
<TITLE>Cewolf 编程实例16: 时序图及移动平均线</TITLE>
</HEAD>
<BODY>
<cewolf:chart
id="timeChart"
title="Cewolf 编程实例16: 时序图及移动平均线"
type="timeseries">
<cewolf:colorpaint color="#CCCCFF"/>
<cewolf:data>
<cewolf:producer id="timeData"/>
</cewolf:data>
</cewolf:chart>
<cewolf:img
chartid="timeChart"
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 + -