OWC控件问题,关于股价图

hdg_sy 2003-05-05 03:03:55
利用OWC中的chart对象产生股票图,不知道如何对“涨柱线格式”“跌柱线格式”设置颜色?
谢谢!
...全文
68 8 打赏 收藏 举报
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
hdg_sy 2003-06-09
OWC9.0中直接就能出现不同的颜色,而在OWC10.0中就没有,怎么设置?还是一个Bug?
  • 打赏
  • 举报
回复
hdg_sy 2003-05-09
但是我还是没有找到股价图的相关设置
  • 打赏
  • 举报
回复
wsj 2003-05-07
vml sample from MSDN:

<html>
<!-- TOOLBAR_START --><!-- TOOLBAR_EXEMPT --><!-- TOOLBAR_END -->
<head>
<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v"/>
<style>
v\:* { behavior:url(#default#VML);}
</style>

<XML id="Stock" src="stockdata.xml">
</XML>

</head>

<body style="font-family: verdana" onload="getData('AADV')">

<h2>Graphing</h2>

<br>

<script>

function getQuoteRange() {
rs = Stock.recordset;
return rs;
}


function createLineWithDOM(p, color, width, fx, fy, tx, ty) {
var l, d, i;

l = document.createElement("v:line");
l.strokeweight = width+"pt";
l.strokecolor = color;
l.from = fx + "px, " + fy + "px";
l.to = tx + "px, " + ty + "px";
p.insertBefore(l, null);

}

function getData() {
buildGraph(document.body);
}

function scalePoint(p, tMin, tMax, MaxHeight, MarginTop, MaxHeight11) {

// do conversions
p -= tMin;
// divide by max - min
p /= (tMax - tMin);
// multiply by max scale
p *= MaxHeight;
// add margin
p += MarginTop;
// invert
p = (MaxHeight11) - p;

return p
}


function buildGraph(insertParent, quote) {
var rs, count, i, ly;
var tMax, tMin, cMax, cMin, pDiv;
var MarginLeft, MarginTop;

var increment, vIncrement;
var MaxWidth = document.body.clientWidth * 0.75;
var MaxHeight = document.body.clientHeight * 0.6;
var MaxHeight11 = MaxHeight * 1.1;
var MaxWidth11 = MaxWidth * 1.1;
var DateSpace = 50;
var TitleText;

pDiv = document.createElement("DIV");
pDiv.id = "Graph1";
pDiv.style.width = MaxWidth11;
MarginLeft = MaxWidth * 0.05;
pDiv.style.height = MaxHeight11;
MarginTop = MaxHeight * 0.05;
pDiv.style.border = "1px black solid";
pDiv.style.position = "absolute";
pDiv.style.top = 70;
pDiv.style.left = 10;
insertParent.insertBefore(pDiv, null);

rs = getQuoteRange();
TitleText = "Price History for ";

count = rs.recordcount;
if (count == 0)
return;
rs.moveFirst();
tMax = -1;
tMin = 100000;

// create graph title
var s, t;
s = document.createElement("span");
t = document.createTextNode(TitleText + rs.fields("symbol").value);
s.style.fontFamily = "verdana";
s.style.fontSize = 20;
s.style.fontWeight = "bold";
s.insertBefore(t, null);
s.style.position = "absolute";
pDiv.insertBefore(s, null);

// get min/max for scaling calculation
for (i=0; i<count; i++) {
cMax = rs.fields("quotehigh").value;
tMax = Math.max(cMax, tMax);
cMin = rs.fields("quotelow").value;
tMin = Math.min(cMin, tMin);

rs.movenext();
}

// adjust min/max for buffer
tMax = tMax + (tMax * 0.1);
tMin = tMin - (tMin * 0.1);

increment = MaxWidth / count;
vIncrement = 10;

// create vertical scale
var sMX = (MaxWidth11) - 10;

var lowPrice = tMin;
var highPrice = tMax;
var pIncrement = (highPrice - lowPrice) / 10;

for (i=lowPrice; i<=highPrice; i+=pIncrement) {
tl = i;
tl = scalePoint(tl, tMin, tMax, MaxHeight, MarginTop, MaxHeight11);

createLineWithDOM(pDiv, "black", 1, MaxWidth11, tl , sMX, tl);

value = Math.round(i*100);
value = value / 100;
value = toMoney(value, 2);

d = document.createElement("DIV");
d.style.position = "absolute";
d.style.top = tl - 5;
d.style.left = (MaxWidth * 1.1) + 5;
d.style.fontFamily = "Verdana";
d.style.fontSize = 14;
d.style.fontWeight = "bold";
t = document.createTextNode(value);
d.insertBefore(t, null);
pDiv.insertBefore(d, null);


}

// draw high low bars, as well as horizontal scale and date gradations
rs.moveFirst();
var lastLeft = -1000;
var tempDate;
var tm, td, ty;
var dateString;
var strokeWidth;

for (i=0; i<count; i++) {
// get high/low points from bo
tl = rs.fields("quotelow").value;
th = rs.fields("quotehigh").value;

// scale them to fit in the graph
tl = scalePoint(tl, tMin, tMax, MaxHeight, MarginTop, MaxHeight11);

th = scalePoint(th, tMin, tMax, MaxHeight, MarginTop, MaxHeight11);

createLineWithDOM(pDiv, "blue", 1, i*increment+MarginLeft, tl, i*increment + MarginLeft, th);

// if there is enough space to print the date, do it, else skip to the next line
currLeft = i*increment+MarginLeft;
strokewidth = 1;
if ((lastLeft + DateSpace) < currLeft) {
strokewidth = 2;
d = document.createElement("DIV");
d.style.position = "absolute";
d.style.top = MaxHeight11+10;
d.style.left = i*increment+MarginLeft;
d.style.fontFamily = "Verdana";
d.style.fontSize = 8;
tempDate = new Date(rs.fields("quotedate").value);

tm = (tempDate.getMonth())+1
td = tempDate.getDate();
ty = tempDate.getYear();
dateString = tm+"/"+td+"/"+ty;

t = document.createTextNode(dateString);
d.insertBefore(t, null);
pDiv.insertBefore(d, null);
lastLeft = i*increment+MarginLeft;
}

// draw date lines
createLineWithDOM(pDiv, "black", strokewidth, i*increment+MarginLeft, (MaxHeight * 1.1) - 1, i*increment + MarginLeft, (MaxHeight * 1.1) - 10);

rs.movenext();
}

// draw running close line

rs.moveFirst();
var ly = rs.fields("quoteclose").value;
rs.movenext();
for (i=1; i<count; i++) {
ly = scalePoint(ly, tMin, tMax, MaxHeight, MarginTop, MaxHeight11);

lc = rs.fields("quoteclose").value;

lc = scalePoint(lc, tMin, tMax, MaxHeight, MarginTop, MaxHeight11);

createLineWithDOM(pDiv, "red", 1, (i-1)*increment + MarginLeft, ly, i*increment + MarginLeft, lc);
ly = rs.fields("quoteclose").value;

rs.movenext();
}

}

function toMoney(value, decimalPlaces) {
var moneyString;
var decimal, c, i, currPlaces;

moneyString = "$"+value;

decimal = -1;
for (i=moneyString.length - 1; i>=0; i--) {
c = moneyString.charAt(i);
if (c == ".") {
decimal = i;
}
}

if (decimal == -1) {
decimalString = ".";
for (i=0; i<decimalPlaces; i++) {
decimalString += "0";
}
moneyString = moneyString + decimalString;
} else {
currPlaces = moneyString.length - decimal - 1;
if (currPlaces <= decimalPlaces) {
for (i=0; i< decimalPlaces - currPlaces; i++) {
moneyString += "0";
}
}
}
return moneyString;
}

</script>

</body>

</html>
  • 打赏
  • 举报
回复
hdg_sy 2003-05-07
高手,请赐教!
  • 打赏
  • 举报
回复
online 2003-05-07
http://www.csdn.net/develop/read_article.asp?id=16421
http://www.ourfly.com演示
  • 打赏
  • 举报
回复
hdg_sy 2003-05-07
谢谢你,但是这也没有用到OWC控件,这修都是script的代码,不是我所要的
  • 打赏
  • 举报
回复
hdg_sy 2003-05-06
google中没有找到,才来问各位高手的。
  • 打赏
  • 举报
回复
linuxap 2003-05-05
在google中搜索一下就行了!
  • 打赏
  • 举报
回复
发帖
ASP

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
帖子事件
创建了帖子
2003-05-05 03:03
社区公告
暂无公告