Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
bluefrankey
hqchart
提交
fdb46a6b
hqchart
项目概览
bluefrankey
/
hqchart
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
hqchart
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fdb46a6b
编写于
7月 07, 2019
作者:
J
jones
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ver 6191
上级
2d2bee64
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
548 addition
and
186 deletion
+548
-186
umychart_python/umychart_complier_job.py
umychart_python/umychart_complier_job.py
+3
-3
umychart_python/umychart_complier_jscomplier.py
umychart_python/umychart_complier_jscomplier.py
+45
-18
umychart_python/umychart_complier_testcase.py
umychart_python/umychart_complier_testcase.py
+51
-6
umychart_python/umychart_webtemplate.py
umychart_python/umychart_webtemplate.py
+110
-0
vuehqchart/src/jscommon/umychart.complier.js
vuehqchart/src/jscommon/umychart.complier.js
+109
-53
vuehqchart/src/jscommon/umychart.js
vuehqchart/src/jscommon/umychart.js
+4
-0
webhqchart.demo/jscommon/umychart.complier.js
webhqchart.demo/jscommon/umychart.complier.js
+109
-53
webhqchart.demo/jscommon/umychart.js
webhqchart.demo/jscommon/umychart.js
+4
-0
webhqchart/umychart.complier.js
webhqchart/umychart.complier.js
+109
-53
webhqchart/umychart.js
webhqchart/umychart.js
+4
-0
未找到文件。
umychart_python/umychart_complier_job.py
浏览文件 @
fdb46a6b
...
...
@@ -161,13 +161,13 @@ class RequestOption :
self
.
MaxMinuteDayCount
=
maxMinuteDayCount
class
SymbolOption
:
def
__init__
(
self
,
symbol
=
'600000.sh'
,
hqDataType
=
HQ_DATA_TYPE
.
KLINE_ID
,
right
=
0
,
period
=
0
,
req
eu
st
=
RequestOption
(
maxDataCount
=
1000
,
maxMinuteDayCount
=
5
),
args
=
None
)
:
def
__init__
(
self
,
symbol
=
'600000.sh'
,
hqDataType
=
HQ_DATA_TYPE
.
KLINE_ID
,
right
=
0
,
period
=
0
,
req
ue
st
=
RequestOption
(
maxDataCount
=
1000
,
maxMinuteDayCount
=
5
),
args
=
None
)
:
self
.
HQDataType
=
hqDataType
# 数据类型
self
.
Symbol
=
symbol
# 股票代码
self
.
Right
=
right
# 复权
self
.
Period
=
period
# 周期
self
.
MaxRequestDataCount
=
req
eu
st
.
MaxDataCount
self
.
MaxRequestMinuteDayCount
=
req
eu
st
.
MaxMinuteDayCount
self
.
MaxRequestDataCount
=
req
ue
st
.
MaxDataCount
self
.
MaxRequestMinuteDayCount
=
req
ue
st
.
MaxMinuteDayCount
self
.
Arguments
=
args
# 指标参数
...
...
umychart_python/umychart_complier_jscomplier.py
浏览文件 @
fdb46a6b
...
...
@@ -13,6 +13,9 @@ from umychart_complier_help import Variant
#
#
##################################################################################################
class
JSComplier
:
@
staticmethod
# 词法分析
def
Tokenize
(
code
):
...
...
@@ -73,6 +76,28 @@ class ScriptIndexItem:
self
.
Script
=
script
#指标脚本
self
.
Arguments
=
args
#指标参数 ArgumentItem 数组
class
StockInfo
:
def
__init__
(
self
,
name
=
None
,
symbol
=
None
)
:
self
.
Name
=
name
self
.
Symbol
=
symbol
class
IndexResult
:
def
__init__
(
self
,
error
=
None
,
outVar
=
None
)
:
self
.
Error
=
error
self
.
OutVar
=
outVar
self
.
Stock
=
None
self
.
Date
=
None
self
.
Time
=
None
# 把返回的结果转换成json格式
def
ToJson
(
self
)
:
try
:
jsonData
=
json
.
dumps
(
self
,
default
=
lambda
obj
:
obj
.
__dict__
)
# ScriptIndexConsole.Serializable)
return
jsonData
# with open('data.txt','w') as file:
# file.write(jsonData)
except
BaseException
as
error
:
print
(
error
)
class
ScriptIndexConsole
:
def
__init__
(
self
,
obj
)
:
# obj = ScriptIndexItem()
...
...
@@ -92,40 +117,42 @@ class ScriptIndexConsole:
print
(
'[ScriptIndexConsole.ExecuteScript] parser finish.'
)
option
=
SymbolOption
(
symbol
=
obj
.
Symbol
,
hqDataType
=
obj
.
HQDataType
,
right
=
obj
.
Right
,
period
=
obj
.
Period
,
req
eu
st
=
RequestOption
(
maxDataCount
=
obj
.
MaxRequestDataCount
,
maxMinuteDayCount
=
obj
.
MaxRequestMinuteDayCount
),
req
ue
st
=
RequestOption
(
maxDataCount
=
obj
.
MaxRequestDataCount
,
maxMinuteDayCount
=
obj
.
MaxRequestMinuteDayCount
),
args
=
self
.
Arguments
if
obj
.
Arguments
==
None
else
obj
.
Arguments
)
# 个股指定指标参数优先使用
execute
=
JSExecute
(
ast
,
option
)
execute
.
JobList
=
parser
.
Node
.
GetDataJobList
()
result
=
Variant
()
result
.
Stock
=
Variant
()
result
.
Error
=
None
result
.
OutVar
=
execute
.
Execute
()
outVar
=
execute
.
Execute
()
print
(
'[ScriptIndexConsole.ExecuteScript] execute finish.'
)
# 股票信息
result
.
Stock
.
Name
=
execute
.
SymbolData
.
Name
result
.
Stock
.
Symbol
=
execute
.
SymbolData
.
Symbol
result
=
IndexResult
(
outVar
=
outVar
)
result
.
Stock
=
StockInfo
(
name
=
execute
.
SymbolData
.
Name
,
symbol
=
execute
.
SymbolData
.
Symbol
)
# 股票信息
result
.
Date
=
execute
.
SymbolData
.
Data
.
GetDate
()
# 数据对应的日期
if
(
obj
.
HQDataType
==
HQ_DATA_TYPE
.
KLINE_ID
and
obj
.
Period
>=
4
)
:
result
.
Time
=
execute
.
SymbolData
.
Data
.
GetTime
()
# 数据对应的时间
return
result
except
Error
as
error
:
ErrorInfo
=
Variant
()
ErrorInfo
.
Error
=
error
return
ErrorInfo
result
=
IndexResult
(
error
=
error
)
return
result
except
ValueError
as
error
:
ErrorInfo
=
Variant
()
ErrorInfo
.
Error
=
error
return
ErrorInfo
result
=
IndexResult
(
error
=
error
)
return
result
except
BaseException
as
error
:
ErrorInfo
=
Variant
()
ErrorInfo
.
Error
=
error
return
ErrorInfo
result
=
IndexResult
(
error
=
error
)
return
result
@
staticmethod
# 把返回的结果转换成json格式
def
ToJson
(
data
)
:
try
:
jsonData
=
json
.
dumps
(
data
,
default
=
lambda
obj
:
obj
.
__dict__
)
# ScriptIndexConsole.Serializable)
return
jsonData
# with open('data.txt','w') as file:
# file.write(jsonData)
except
BaseException
as
error
:
print
(
error
)
umychart_python/umychart_complier_testcase.py
浏览文件 @
fdb46a6b
# 开源项目 https://github.com/jones2000/HQChart
import
sys
import
codecs
import
webbrowser
from
umychart_complier_jscomplier
import
JSComplier
,
SymbolOption
,
HQ_DATA_TYPE
from
umychart_complier_jscomplier
import
ScriptIndexConsole
,
ScriptIndexItem
,
SymbolOption
,
RequestOption
,
HQ_DATA_TYPE
,
ArgumentItem
from
umychart_webtemplate
import
*
class
TestCase
:
def
__init__
(
self
,
code
,
option
=
SymbolOption
())
:
...
...
@@ -263,7 +266,7 @@ def Test_FINANCE(): # 财务数据测试
def
Test_ScriptIndexConsole
():
# 创建脚本, 及参数
scpritInfo
=
ScriptIndexItem
(
name
=
'
测试脚本
'
,
id
=
888888
,
scpritInfo
=
ScriptIndexItem
(
name
=
'
我的MA指标
'
,
id
=
888888
,
script
=
'MA1:MA(CLOSE,M1);
\n
'
# 指标脚本代码
'MA2:MA(CLOSE,M2);
\n
'
'MA3:MA(CLOSE,M3);'
,
...
...
@@ -275,14 +278,56 @@ def Test_ScriptIndexConsole():
option
=
SymbolOption
(
symbol
=
'000001.sz'
,
right
=
1
,
# 复权 0 不复权 1 前复权 2 后复权
period
=
0
# 周期 0=日线 1=周线 2=月线 3=年线 4=1分钟 5=5分钟 6=15分钟 7=30分钟 8=60分钟
period
=
0
,
# 周期 0=日线 1=周线 2=月线 3=年线 4=1分钟 5=5分钟 6=15分钟 7=30分钟 8=60分钟
request
=
RequestOption
(
maxDataCount
=
500
)
)
result
=
indexConsole
.
ExecuteScript
(
option
)
if
not
result
.
Error
:
print
(
'run successfully.'
)
if
result
.
Error
:
return
print
(
'run successfully.'
)
jsonData
=
result
.
ToJson
()
varName
=
'jsonData'
# 数据变量名字
HQChartOption
=
"""g_KLineOption={
Symbol:'%(symbol)s', //股票代码
Right:%(right)d, //复权
Period:%(period)d, //周期
Windows:
[
{ Modify:false,Change:false,
Local:
{
Data:%(varName)s, //py执行以后的json数据
Type:'LocalJsonDataIndex' ,
Name:'%(name)s', //指标名字
Args:[ //指标参数
{ Name: '%(arg1)s', Value: %(argvalue1)d },
{ Name: '%(arg2)s', Value: %(argvalue2)d },
{ Name: '%(arg3)s', Value: %(argvalue3)d }]
}
},
//{Index:"VOL", Modify:false,Change:false},
]
}
"""
%
{
"symbol"
:
option
.
Symbol
,
'right'
:
option
.
Right
,
'period'
:
option
.
Period
,
'varName'
:
varName
,
'name'
:
scpritInfo
.
Name
,
'arg1'
:
scpritInfo
.
Arguments
[
0
].
Name
,
'argvalue1'
:
scpritInfo
.
Arguments
[
0
].
Value
,
'arg2'
:
scpritInfo
.
Arguments
[
1
].
Name
,
'argvalue2'
:
scpritInfo
.
Arguments
[
1
].
Value
,
'arg3'
:
scpritInfo
.
Arguments
[
2
].
Name
,
'argvalue3'
:
scpritInfo
.
Arguments
[
2
].
Value
}
localJsonData
=
varName
+
'='
+
jsonData
+
'
\n
'
filePath
=
'data.html'
# 生成图形化页面
with
codecs
.
open
(
filePath
,
'w'
,
"utf-8"
)
as
file
:
file
.
write
(
HTML_PART1
)
file
.
write
(
localJsonData
)
file
.
write
(
HQChartOption
)
file
.
write
(
HTML_PART_END
)
file
.
close
()
webbrowser
.
open
(
filePath
,
new
=
1
)
#Test_Add()
...
...
umychart_python/umychart_webtemplate.py
0 → 100644
浏览文件 @
fdb46a6b
HTML_PART1
=
"""<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<meta name='viewport' content='width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<title>HQChart-Py可视化</title>
<!-- 加载资源 -->
<link rel='stylesheet' href='hqchart/content/css/tools.css' />
<link rel='stylesheet' href='hqchart/umychart.resource/font/iconfont.css' />
</head>
<body>
<div id='kline' style='width: 900px;height:400px;position: relative;'></div>
<script src='hqchart/content/js/jquery.min.js'></script>
<script src='hqchart/content/js/webfont.js'></script>
<script src='hqchart/umychart.js'></script> <!-- K线图形 -->
<script src='hqchart/umychart.complier.js'></script> <!-- 麦语言解析执行器 -->
<script src='hqchart/umychart.index.data.js'></script> <!-- 基础指标库 -->
<script src='hqchart/umychart.style.js'></script> <!-- 白色风格和黑色风格配置信息 -->
<script>
//简单的把K线控件封装下
function KLineChart(divKLine)
{
this.DivKLine=divKLine;
this.Chart=JSChart.Init(divKLine); //把K线图绑定到一个Div上
this.Barrage; //弹幕输出控制器
//K线配置信息
this.Option= {
Type:'历史K线图', //创建图形类型
//窗口指标
Windows:g_KLineOption.Windows,
Symbol:g_KLineOption.Symbol,
IsAutoUpdate:false, //是自动更新数据
IsShowRightMenu:false, //右键菜单
IsShowCorssCursorInfo:true, //是否显示十字光标的刻度信息
CorssCursorTouchEnd:false,
KLine: //K线设置
{
DragMode:1, //拖拽模式 0 禁止拖拽 1 数据拖拽 2 区间选择
Right:g_KLineOption.Right, //复权 0 不复权 1 前复权 2 后复权
Period:g_KLineOption.Period, //周期 0 日线 1 周线 2 月线 3 年线
MaxReqeustDataCount:1000, //数据个数
MaxRequestMinuteDayCount:10, //分钟数据取5天
PageSize:50, //一屏显示多少数据
//Info:["互动易","大宗交易",'龙虎榜',"调研","业绩预告","公告"], //信息地雷
IsShowTooltip:true, //是否显示K线提示信息
},
KLineTitle: //标题设置
{
IsShowName:true, //不显示股票名称
IsShowSettingInfo:true //不显示周期/复权
},
Border: //边框
{
Left:80, //左边间距
Right:80, //右边间距
Bottom:25, //底部间距
Top:25 //顶部间距
},
Frame: //子框架设置
[
{SplitCount:3,StringFormat:0, IsShowLeftText:true},
{SplitCount:2,StringFormat:0, IsShowLeftText:true},
{SplitCount:2,StringFormat:0, IsShowLeftText:true}
]
};
this.Create=function() //创建图形
{
var self=this;
$(window).resize(function() { self.OnSize(); }); //绑定窗口大小变化事件
this.OnSize(); //让K线全屏
this.Chart.SetOption(this.Option); //设置K线配置
}
this.OnSize=function() //自适应大小调整
{
var height= $(window).height();
var width = $(window).width();
this.DivKLine.style.top='px';
this.DivKLine.style.left='px';
this.DivKLine.style.width=width+'px';
this.DivKLine.style.height=height+'px';
this.Chart.OnSize();
}
}
$(function ()
{
WebFont.load({ custom: { families: ['iconfont'] } }); //预加载下iconfont资源
var klineControl=new KLineChart(document.getElementById('kline'));
klineControl.Create();
})
"""
HTML_PART_END
=
"""</script>
</body>
</html>"""
\ No newline at end of file
vuehqchart/src/jscommon/umychart.complier.js
浏览文件 @
fdb46a6b
...
...
@@ -9116,6 +9116,60 @@ function ScriptIndex(name,script,args,option)
return
true
;
}
//给一个默认的颜色
this
.
GetDefaultColor
=
function
(
id
)
{
let
COLOR_ARRAY
=
[
"
rgb(255,174,0)
"
,
"
rgb(25,199,255)
"
,
"
rgb(175,95,162)
"
,
"
rgb(236,105,65)
"
,
"
rgb(68,114,196)
"
,
"
rgb(229,0,79)
"
,
"
rgb(0,128,255)
"
,
"
rgb(252,96,154)
"
,
"
rgb(42,230,215)
"
,
"
rgb(24,71,178)
"
,
];
let
number
=
parseInt
(
id
);
return
COLOR_ARRAY
[
number
%
(
COLOR_ARRAY
.
length
-
1
)];
}
//获取颜色
this
.
GetColor
=
function
(
colorName
)
{
let
COLOR_MAP
=
new
Map
([
[
'
COLORBLACK
'
,
'
rgb(0,0,0)
'
],
[
'
COLORBLUE
'
,
'
rgb(18,95,216)
'
],
[
'
COLORGREEN
'
,
'
rgb(25,158,0)
'
],
[
'
COLORCYAN
'
,
'
rgb(0,255,198)
'
],
[
'
COLORRED
'
,
'
rgb(238,21,21)
'
],
[
'
COLORMAGENTA
'
,
'
rgb(255,0,222)
'
],
[
'
COLORBROWN
'
,
'
rgb(149,94,15)
'
],
[
'
COLORLIGRAY
'
,
'
rgb(218,218,218)
'
],
//画淡灰色
[
'
COLORGRAY
'
,
'
rgb(133,133,133)
'
],
//画深灰色
[
'
COLORLIBLUE
'
,
'
rgb(94,204,255)
'
],
//淡蓝色
[
'
COLORLIGREEN
'
,
'
rgb(183,255,190)
'
],
//淡绿色
[
'
COLORLICYAN
'
,
'
rgb(154,255,242)
'
],
//淡青色
[
'
COLORLIRED
'
,
'
rgb(255,172,172)
'
],
//淡红色
[
'
COLORLIMAGENTA
'
,
'
rgb(255,145,241)
'
],
//淡洋红色
[
'
COLORWHITE
'
,
'
rgb(255,255,255)
'
],
//白色
[
'
COLORYELLOW
'
,
'
rgb(255,198,0)
'
]
]);
if
(
COLOR_MAP
.
has
(
colorName
))
return
COLOR_MAP
.
get
(
colorName
);
//COLOR 自定义色
//格式为COLOR+“RRGGBB”:RR、GG、BB表示红色、绿色和蓝色的分量,每种颜色的取值范围是00-FF,采用了16进制。
//例如:MA5:MA(CLOSE,5),COLOR00FFFF 表示纯红色与纯绿色的混合色:COLOR808000表示淡蓝色和淡绿色的混合色。
if
(
colorName
.
indexOf
(
'
COLOR
'
)
==
0
)
return
'
#
'
+
colorName
.
substr
(
5
);
return
'
rgb(30,144,255)
'
;
}
}
//后台执行指标
...
...
@@ -9136,6 +9190,61 @@ function APIScriptIndex(name,script,args,option)
}
}
// 本地json数据指标
function
LocalJsonDataIndex
(
name
,
args
,
option
)
{
this
.
newMethod
=
ScriptIndex
;
//派生
this
.
newMethod
(
name
,
null
,
args
,
null
);
delete
this
.
newMethod
;
this
.
JsonData
;
//json格式数据
if
(
option
.
JsonData
)
this
.
JsonData
=
option
.
JsonData
;
this
.
RequestData
=
function
(
hqChart
,
windowIndex
,
hisData
)
{
if
(
!
this
.
JsonData
)
{
console
.
warn
(
"
[LocalJsonDataIndex::RequestData] JsonData is null
"
);
if
(
param
.
HQChart
.
ScriptErrorCallback
)
param
.
HQChart
.
ScriptErrorCallback
(
'
json 数据不能为空
'
);
return
;
}
this
.
OutVar
=
this
.
FittingData
(
this
.
JsonData
,
hisData
);
this
.
BindData
(
hqChart
,
windowIndex
,
hisData
);
}
this
.
FittingData
=
function
(
jsonData
,
hisData
)
{
outVar
=
jsonData
.
OutVar
;
date
=
jsonData
.
Date
;
result
=
[];
for
(
i
in
outVar
)
{
item
=
outVar
[
i
];
var
indexData
=
[];
outVarItem
=
{
Name
:
item
.
Name
,
Type
:
item
.
Type
}
for
(
j
in
item
.
Data
)
{
var
indexItem
=
new
SingleData
();
//单列指标数据
indexItem
.
Date
=
date
[
j
];
indexItem
.
Value
=
item
.
Data
[
j
];
indexData
.
push
(
indexItem
);
}
var
aryFittingData
=
hisData
.
GetFittingData
(
indexData
);
//数据和主图K线拟合
var
bindData
=
new
ChartData
();
bindData
.
Data
=
aryFittingData
;
outVarItem
.
Data
=
bindData
.
GetValue
();
result
.
push
(
outVarItem
)
}
return
result
;
}
}
////////////////////////////////////////////////////////////////////////
// 无UI指标执行
// obj: { Name:指标名字 , ID:指标ID , Script:指标脚本, Args:指标参数, ErrorCallback:错误回调 }
...
...
@@ -9214,59 +9323,6 @@ function ScriptIndexConsole(obj)
}
}
//给一个默认的颜色
ScriptIndex
.
prototype
.
GetDefaultColor
=
function
(
id
)
{
let
COLOR_ARRAY
=
[
"
rgb(255,174,0)
"
,
"
rgb(25,199,255)
"
,
"
rgb(175,95,162)
"
,
"
rgb(236,105,65)
"
,
"
rgb(68,114,196)
"
,
"
rgb(229,0,79)
"
,
"
rgb(0,128,255)
"
,
"
rgb(252,96,154)
"
,
"
rgb(42,230,215)
"
,
"
rgb(24,71,178)
"
,
];
let
number
=
parseInt
(
id
);
return
COLOR_ARRAY
[
number
%
(
COLOR_ARRAY
.
length
-
1
)];
}
//获取颜色
ScriptIndex
.
prototype
.
GetColor
=
function
(
colorName
)
{
let
COLOR_MAP
=
new
Map
([
[
'
COLORBLACK
'
,
'
rgb(0,0,0)
'
],
[
'
COLORBLUE
'
,
'
rgb(18,95,216)
'
],
[
'
COLORGREEN
'
,
'
rgb(25,158,0)
'
],
[
'
COLORCYAN
'
,
'
rgb(0,255,198)
'
],
[
'
COLORRED
'
,
'
rgb(238,21,21)
'
],
[
'
COLORMAGENTA
'
,
'
rgb(255,0,222)
'
],
[
'
COLORBROWN
'
,
'
rgb(149,94,15)
'
],
[
'
COLORLIGRAY
'
,
'
rgb(218,218,218)
'
],
//画淡灰色
[
'
COLORGRAY
'
,
'
rgb(133,133,133)
'
],
//画深灰色
[
'
COLORLIBLUE
'
,
'
rgb(94,204,255)
'
],
//淡蓝色
[
'
COLORLIGREEN
'
,
'
rgb(183,255,190)
'
],
//淡绿色
[
'
COLORLICYAN
'
,
'
rgb(154,255,242)
'
],
//淡青色
[
'
COLORLIRED
'
,
'
rgb(255,172,172)
'
],
//淡红色
[
'
COLORLIMAGENTA
'
,
'
rgb(255,145,241)
'
],
//淡洋红色
[
'
COLORWHITE
'
,
'
rgb(255,255,255)
'
],
//白色
[
'
COLORYELLOW
'
,
'
rgb(255,198,0)
'
]
]);
if
(
COLOR_MAP
.
has
(
colorName
))
return
COLOR_MAP
.
get
(
colorName
);
//COLOR 自定义色
//格式为COLOR+“RRGGBB”:RR、GG、BB表示红色、绿色和蓝色的分量,每种颜色的取值范围是00-FF,采用了16进制。
//例如:MA5:MA(CLOSE,5),COLOR00FFFF 表示纯红色与纯绿色的混合色:COLOR808000表示淡蓝色和淡绿色的混合色。
if
(
colorName
.
indexOf
(
'
COLOR
'
)
==
0
)
return
'
#
'
+
colorName
.
substr
(
5
);
return
'
rgb(30,144,255)
'
;
}
/* 测试例子
var code1='VARHIGH:IF(VAR1<=REF(HH,-1),REF(H,BARSLAST(VAR1>=REF(HH,1))),DRAWNULL),COLORYELLOW;';
...
...
vuehqchart/src/jscommon/umychart.js
浏览文件 @
fdb46a6b
...
...
@@ -218,6 +218,10 @@ function JSChart(divElement)
{
chart.WindowIndex[i]=new JsonDataIndex(item.Name,item.Script,item.Args,item); //脚本执行
}
else if (item.Local && item.Local.Data)
{
chart.WindowIndex[i]=new LocalJsonDataIndex(item.Local.Name,item.Local.Args,{JsonData:item.Local.Data});
}
else
{
let indexItem=JSIndexMap.Get(item.Index);
...
...
webhqchart.demo/jscommon/umychart.complier.js
浏览文件 @
fdb46a6b
...
...
@@ -9116,6 +9116,60 @@ function ScriptIndex(name,script,args,option)
return
true
;
}
//给一个默认的颜色
this
.
GetDefaultColor
=
function
(
id
)
{
let
COLOR_ARRAY
=
[
"
rgb(255,174,0)
"
,
"
rgb(25,199,255)
"
,
"
rgb(175,95,162)
"
,
"
rgb(236,105,65)
"
,
"
rgb(68,114,196)
"
,
"
rgb(229,0,79)
"
,
"
rgb(0,128,255)
"
,
"
rgb(252,96,154)
"
,
"
rgb(42,230,215)
"
,
"
rgb(24,71,178)
"
,
];
let
number
=
parseInt
(
id
);
return
COLOR_ARRAY
[
number
%
(
COLOR_ARRAY
.
length
-
1
)];
}
//获取颜色
this
.
GetColor
=
function
(
colorName
)
{
let
COLOR_MAP
=
new
Map
([
[
'
COLORBLACK
'
,
'
rgb(0,0,0)
'
],
[
'
COLORBLUE
'
,
'
rgb(18,95,216)
'
],
[
'
COLORGREEN
'
,
'
rgb(25,158,0)
'
],
[
'
COLORCYAN
'
,
'
rgb(0,255,198)
'
],
[
'
COLORRED
'
,
'
rgb(238,21,21)
'
],
[
'
COLORMAGENTA
'
,
'
rgb(255,0,222)
'
],
[
'
COLORBROWN
'
,
'
rgb(149,94,15)
'
],
[
'
COLORLIGRAY
'
,
'
rgb(218,218,218)
'
],
//画淡灰色
[
'
COLORGRAY
'
,
'
rgb(133,133,133)
'
],
//画深灰色
[
'
COLORLIBLUE
'
,
'
rgb(94,204,255)
'
],
//淡蓝色
[
'
COLORLIGREEN
'
,
'
rgb(183,255,190)
'
],
//淡绿色
[
'
COLORLICYAN
'
,
'
rgb(154,255,242)
'
],
//淡青色
[
'
COLORLIRED
'
,
'
rgb(255,172,172)
'
],
//淡红色
[
'
COLORLIMAGENTA
'
,
'
rgb(255,145,241)
'
],
//淡洋红色
[
'
COLORWHITE
'
,
'
rgb(255,255,255)
'
],
//白色
[
'
COLORYELLOW
'
,
'
rgb(255,198,0)
'
]
]);
if
(
COLOR_MAP
.
has
(
colorName
))
return
COLOR_MAP
.
get
(
colorName
);
//COLOR 自定义色
//格式为COLOR+“RRGGBB”:RR、GG、BB表示红色、绿色和蓝色的分量,每种颜色的取值范围是00-FF,采用了16进制。
//例如:MA5:MA(CLOSE,5),COLOR00FFFF 表示纯红色与纯绿色的混合色:COLOR808000表示淡蓝色和淡绿色的混合色。
if
(
colorName
.
indexOf
(
'
COLOR
'
)
==
0
)
return
'
#
'
+
colorName
.
substr
(
5
);
return
'
rgb(30,144,255)
'
;
}
}
//后台执行指标
...
...
@@ -9136,6 +9190,61 @@ function APIScriptIndex(name,script,args,option)
}
}
// 本地json数据指标
function
LocalJsonDataIndex
(
name
,
args
,
option
)
{
this
.
newMethod
=
ScriptIndex
;
//派生
this
.
newMethod
(
name
,
null
,
args
,
null
);
delete
this
.
newMethod
;
this
.
JsonData
;
//json格式数据
if
(
option
.
JsonData
)
this
.
JsonData
=
option
.
JsonData
;
this
.
RequestData
=
function
(
hqChart
,
windowIndex
,
hisData
)
{
if
(
!
this
.
JsonData
)
{
console
.
warn
(
"
[LocalJsonDataIndex::RequestData] JsonData is null
"
);
if
(
param
.
HQChart
.
ScriptErrorCallback
)
param
.
HQChart
.
ScriptErrorCallback
(
'
json 数据不能为空
'
);
return
;
}
this
.
OutVar
=
this
.
FittingData
(
this
.
JsonData
,
hisData
);
this
.
BindData
(
hqChart
,
windowIndex
,
hisData
);
}
this
.
FittingData
=
function
(
jsonData
,
hisData
)
{
outVar
=
jsonData
.
OutVar
;
date
=
jsonData
.
Date
;
result
=
[];
for
(
i
in
outVar
)
{
item
=
outVar
[
i
];
var
indexData
=
[];
outVarItem
=
{
Name
:
item
.
Name
,
Type
:
item
.
Type
}
for
(
j
in
item
.
Data
)
{
var
indexItem
=
new
SingleData
();
//单列指标数据
indexItem
.
Date
=
date
[
j
];
indexItem
.
Value
=
item
.
Data
[
j
];
indexData
.
push
(
indexItem
);
}
var
aryFittingData
=
hisData
.
GetFittingData
(
indexData
);
//数据和主图K线拟合
var
bindData
=
new
ChartData
();
bindData
.
Data
=
aryFittingData
;
outVarItem
.
Data
=
bindData
.
GetValue
();
result
.
push
(
outVarItem
)
}
return
result
;
}
}
////////////////////////////////////////////////////////////////////////
// 无UI指标执行
// obj: { Name:指标名字 , ID:指标ID , Script:指标脚本, Args:指标参数, ErrorCallback:错误回调 }
...
...
@@ -9214,59 +9323,6 @@ function ScriptIndexConsole(obj)
}
}
//给一个默认的颜色
ScriptIndex
.
prototype
.
GetDefaultColor
=
function
(
id
)
{
let
COLOR_ARRAY
=
[
"
rgb(255,174,0)
"
,
"
rgb(25,199,255)
"
,
"
rgb(175,95,162)
"
,
"
rgb(236,105,65)
"
,
"
rgb(68,114,196)
"
,
"
rgb(229,0,79)
"
,
"
rgb(0,128,255)
"
,
"
rgb(252,96,154)
"
,
"
rgb(42,230,215)
"
,
"
rgb(24,71,178)
"
,
];
let
number
=
parseInt
(
id
);
return
COLOR_ARRAY
[
number
%
(
COLOR_ARRAY
.
length
-
1
)];
}
//获取颜色
ScriptIndex
.
prototype
.
GetColor
=
function
(
colorName
)
{
let
COLOR_MAP
=
new
Map
([
[
'
COLORBLACK
'
,
'
rgb(0,0,0)
'
],
[
'
COLORBLUE
'
,
'
rgb(18,95,216)
'
],
[
'
COLORGREEN
'
,
'
rgb(25,158,0)
'
],
[
'
COLORCYAN
'
,
'
rgb(0,255,198)
'
],
[
'
COLORRED
'
,
'
rgb(238,21,21)
'
],
[
'
COLORMAGENTA
'
,
'
rgb(255,0,222)
'
],
[
'
COLORBROWN
'
,
'
rgb(149,94,15)
'
],
[
'
COLORLIGRAY
'
,
'
rgb(218,218,218)
'
],
//画淡灰色
[
'
COLORGRAY
'
,
'
rgb(133,133,133)
'
],
//画深灰色
[
'
COLORLIBLUE
'
,
'
rgb(94,204,255)
'
],
//淡蓝色
[
'
COLORLIGREEN
'
,
'
rgb(183,255,190)
'
],
//淡绿色
[
'
COLORLICYAN
'
,
'
rgb(154,255,242)
'
],
//淡青色
[
'
COLORLIRED
'
,
'
rgb(255,172,172)
'
],
//淡红色
[
'
COLORLIMAGENTA
'
,
'
rgb(255,145,241)
'
],
//淡洋红色
[
'
COLORWHITE
'
,
'
rgb(255,255,255)
'
],
//白色
[
'
COLORYELLOW
'
,
'
rgb(255,198,0)
'
]
]);
if
(
COLOR_MAP
.
has
(
colorName
))
return
COLOR_MAP
.
get
(
colorName
);
//COLOR 自定义色
//格式为COLOR+“RRGGBB”:RR、GG、BB表示红色、绿色和蓝色的分量,每种颜色的取值范围是00-FF,采用了16进制。
//例如:MA5:MA(CLOSE,5),COLOR00FFFF 表示纯红色与纯绿色的混合色:COLOR808000表示淡蓝色和淡绿色的混合色。
if
(
colorName
.
indexOf
(
'
COLOR
'
)
==
0
)
return
'
#
'
+
colorName
.
substr
(
5
);
return
'
rgb(30,144,255)
'
;
}
/* 测试例子
var code1='VARHIGH:IF(VAR1<=REF(HH,-1),REF(H,BARSLAST(VAR1>=REF(HH,1))),DRAWNULL),COLORYELLOW;';
...
...
webhqchart.demo/jscommon/umychart.js
浏览文件 @
fdb46a6b
...
...
@@ -218,6 +218,10 @@ function JSChart(divElement)
{
chart.WindowIndex[i]=new JsonDataIndex(item.Name,item.Script,item.Args,item); //脚本执行
}
else if (item.Local && item.Local.Data)
{
chart.WindowIndex[i]=new LocalJsonDataIndex(item.Local.Name,item.Local.Args,{JsonData:item.Local.Data});
}
else
{
let indexItem=JSIndexMap.Get(item.Index);
...
...
webhqchart/umychart.complier.js
浏览文件 @
fdb46a6b
...
...
@@ -9116,6 +9116,60 @@ function ScriptIndex(name,script,args,option)
return
true
;
}
//给一个默认的颜色
this
.
GetDefaultColor
=
function
(
id
)
{
let
COLOR_ARRAY
=
[
"
rgb(255,174,0)
"
,
"
rgb(25,199,255)
"
,
"
rgb(175,95,162)
"
,
"
rgb(236,105,65)
"
,
"
rgb(68,114,196)
"
,
"
rgb(229,0,79)
"
,
"
rgb(0,128,255)
"
,
"
rgb(252,96,154)
"
,
"
rgb(42,230,215)
"
,
"
rgb(24,71,178)
"
,
];
let
number
=
parseInt
(
id
);
return
COLOR_ARRAY
[
number
%
(
COLOR_ARRAY
.
length
-
1
)];
}
//获取颜色
this
.
GetColor
=
function
(
colorName
)
{
let
COLOR_MAP
=
new
Map
([
[
'
COLORBLACK
'
,
'
rgb(0,0,0)
'
],
[
'
COLORBLUE
'
,
'
rgb(18,95,216)
'
],
[
'
COLORGREEN
'
,
'
rgb(25,158,0)
'
],
[
'
COLORCYAN
'
,
'
rgb(0,255,198)
'
],
[
'
COLORRED
'
,
'
rgb(238,21,21)
'
],
[
'
COLORMAGENTA
'
,
'
rgb(255,0,222)
'
],
[
'
COLORBROWN
'
,
'
rgb(149,94,15)
'
],
[
'
COLORLIGRAY
'
,
'
rgb(218,218,218)
'
],
//画淡灰色
[
'
COLORGRAY
'
,
'
rgb(133,133,133)
'
],
//画深灰色
[
'
COLORLIBLUE
'
,
'
rgb(94,204,255)
'
],
//淡蓝色
[
'
COLORLIGREEN
'
,
'
rgb(183,255,190)
'
],
//淡绿色
[
'
COLORLICYAN
'
,
'
rgb(154,255,242)
'
],
//淡青色
[
'
COLORLIRED
'
,
'
rgb(255,172,172)
'
],
//淡红色
[
'
COLORLIMAGENTA
'
,
'
rgb(255,145,241)
'
],
//淡洋红色
[
'
COLORWHITE
'
,
'
rgb(255,255,255)
'
],
//白色
[
'
COLORYELLOW
'
,
'
rgb(255,198,0)
'
]
]);
if
(
COLOR_MAP
.
has
(
colorName
))
return
COLOR_MAP
.
get
(
colorName
);
//COLOR 自定义色
//格式为COLOR+“RRGGBB”:RR、GG、BB表示红色、绿色和蓝色的分量,每种颜色的取值范围是00-FF,采用了16进制。
//例如:MA5:MA(CLOSE,5),COLOR00FFFF 表示纯红色与纯绿色的混合色:COLOR808000表示淡蓝色和淡绿色的混合色。
if
(
colorName
.
indexOf
(
'
COLOR
'
)
==
0
)
return
'
#
'
+
colorName
.
substr
(
5
);
return
'
rgb(30,144,255)
'
;
}
}
//后台执行指标
...
...
@@ -9136,6 +9190,61 @@ function APIScriptIndex(name,script,args,option)
}
}
// 本地json数据指标
function
LocalJsonDataIndex
(
name
,
args
,
option
)
{
this
.
newMethod
=
ScriptIndex
;
//派生
this
.
newMethod
(
name
,
null
,
args
,
null
);
delete
this
.
newMethod
;
this
.
JsonData
;
//json格式数据
if
(
option
.
JsonData
)
this
.
JsonData
=
option
.
JsonData
;
this
.
RequestData
=
function
(
hqChart
,
windowIndex
,
hisData
)
{
if
(
!
this
.
JsonData
)
{
console
.
warn
(
"
[LocalJsonDataIndex::RequestData] JsonData is null
"
);
if
(
param
.
HQChart
.
ScriptErrorCallback
)
param
.
HQChart
.
ScriptErrorCallback
(
'
json 数据不能为空
'
);
return
;
}
this
.
OutVar
=
this
.
FittingData
(
this
.
JsonData
,
hisData
);
this
.
BindData
(
hqChart
,
windowIndex
,
hisData
);
}
this
.
FittingData
=
function
(
jsonData
,
hisData
)
{
outVar
=
jsonData
.
OutVar
;
date
=
jsonData
.
Date
;
result
=
[];
for
(
i
in
outVar
)
{
item
=
outVar
[
i
];
var
indexData
=
[];
outVarItem
=
{
Name
:
item
.
Name
,
Type
:
item
.
Type
}
for
(
j
in
item
.
Data
)
{
var
indexItem
=
new
SingleData
();
//单列指标数据
indexItem
.
Date
=
date
[
j
];
indexItem
.
Value
=
item
.
Data
[
j
];
indexData
.
push
(
indexItem
);
}
var
aryFittingData
=
hisData
.
GetFittingData
(
indexData
);
//数据和主图K线拟合
var
bindData
=
new
ChartData
();
bindData
.
Data
=
aryFittingData
;
outVarItem
.
Data
=
bindData
.
GetValue
();
result
.
push
(
outVarItem
)
}
return
result
;
}
}
////////////////////////////////////////////////////////////////////////
// 无UI指标执行
// obj: { Name:指标名字 , ID:指标ID , Script:指标脚本, Args:指标参数, ErrorCallback:错误回调 }
...
...
@@ -9214,59 +9323,6 @@ function ScriptIndexConsole(obj)
}
}
//给一个默认的颜色
ScriptIndex
.
prototype
.
GetDefaultColor
=
function
(
id
)
{
let
COLOR_ARRAY
=
[
"
rgb(255,174,0)
"
,
"
rgb(25,199,255)
"
,
"
rgb(175,95,162)
"
,
"
rgb(236,105,65)
"
,
"
rgb(68,114,196)
"
,
"
rgb(229,0,79)
"
,
"
rgb(0,128,255)
"
,
"
rgb(252,96,154)
"
,
"
rgb(42,230,215)
"
,
"
rgb(24,71,178)
"
,
];
let
number
=
parseInt
(
id
);
return
COLOR_ARRAY
[
number
%
(
COLOR_ARRAY
.
length
-
1
)];
}
//获取颜色
ScriptIndex
.
prototype
.
GetColor
=
function
(
colorName
)
{
let
COLOR_MAP
=
new
Map
([
[
'
COLORBLACK
'
,
'
rgb(0,0,0)
'
],
[
'
COLORBLUE
'
,
'
rgb(18,95,216)
'
],
[
'
COLORGREEN
'
,
'
rgb(25,158,0)
'
],
[
'
COLORCYAN
'
,
'
rgb(0,255,198)
'
],
[
'
COLORRED
'
,
'
rgb(238,21,21)
'
],
[
'
COLORMAGENTA
'
,
'
rgb(255,0,222)
'
],
[
'
COLORBROWN
'
,
'
rgb(149,94,15)
'
],
[
'
COLORLIGRAY
'
,
'
rgb(218,218,218)
'
],
//画淡灰色
[
'
COLORGRAY
'
,
'
rgb(133,133,133)
'
],
//画深灰色
[
'
COLORLIBLUE
'
,
'
rgb(94,204,255)
'
],
//淡蓝色
[
'
COLORLIGREEN
'
,
'
rgb(183,255,190)
'
],
//淡绿色
[
'
COLORLICYAN
'
,
'
rgb(154,255,242)
'
],
//淡青色
[
'
COLORLIRED
'
,
'
rgb(255,172,172)
'
],
//淡红色
[
'
COLORLIMAGENTA
'
,
'
rgb(255,145,241)
'
],
//淡洋红色
[
'
COLORWHITE
'
,
'
rgb(255,255,255)
'
],
//白色
[
'
COLORYELLOW
'
,
'
rgb(255,198,0)
'
]
]);
if
(
COLOR_MAP
.
has
(
colorName
))
return
COLOR_MAP
.
get
(
colorName
);
//COLOR 自定义色
//格式为COLOR+“RRGGBB”:RR、GG、BB表示红色、绿色和蓝色的分量,每种颜色的取值范围是00-FF,采用了16进制。
//例如:MA5:MA(CLOSE,5),COLOR00FFFF 表示纯红色与纯绿色的混合色:COLOR808000表示淡蓝色和淡绿色的混合色。
if
(
colorName
.
indexOf
(
'
COLOR
'
)
==
0
)
return
'
#
'
+
colorName
.
substr
(
5
);
return
'
rgb(30,144,255)
'
;
}
/* 测试例子
var code1='VARHIGH:IF(VAR1<=REF(HH,-1),REF(H,BARSLAST(VAR1>=REF(HH,1))),DRAWNULL),COLORYELLOW;';
...
...
webhqchart/umychart.js
浏览文件 @
fdb46a6b
...
...
@@ -218,6 +218,10 @@ function JSChart(divElement)
{
chart.WindowIndex[i]=new JsonDataIndex(item.Name,item.Script,item.Args,item); //脚本执行
}
else if (item.Local && item.Local.Data)
{
chart.WindowIndex[i]=new LocalJsonDataIndex(item.Local.Name,item.Local.Args,{JsonData:item.Local.Data});
}
else
{
let indexItem=JSIndexMap.Get(item.Index);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录