-
Notifications
You must be signed in to change notification settings - Fork 725
/
kline_MULTI_SVGICON.html
316 lines (241 loc) · 11.1 KB
/
kline_MULTI_SVGICON.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!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 name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>页面行情(K线图)</title>
<!-- 加载资源 -->
<link rel="stylesheet" href="../jscommon/umychart.resource/css/tools.css" />
<link rel="stylesheet" href="../jscommon/umychart.resource/font/iconfont.css" />
<link rel="stylesheet" href="./localdata/MULTI_SVGICON_iconfont.css" />
</head>
<body>
<div id="kline" >
</div>
<div>
</div>
<script src="../jscommon/umychart.resource/js/jquery.min.js"></script>
<script src="../jscommon/umychart.resource/js/webfont.js"></script>
<script src='../jscommon/umychart.console.js'></script> <!-- 日志输出 -->
<script src="../jscommon/umychart.network.js"></script> <!-- 网络请求分装 -->
<script src="../jscommon/umychart.js"></script> <!-- K线图形 -->
<script src="../jscommon/umychart.complier.js"></script> <!-- 麦语言解析执行器 -->
<script src="../jscommon/umychart.index.data.js"></script> <!-- 基础指标库 -->
<script src="../jscommon/umychart.style.js"></script> <!-- 白色风格和黑色风格配置信息 -->
<script src="../jscommon/umychart.NetworkFilterTest.js"></script>
<script>
MARKET_SUFFIX_NAME.GetMarketStatus = function (symbol) { return 2; }
//简单的把K线控件封装下
function KLineChart(divKLine)
{
this.DivKLine=divKLine;
this.Chart=JSChart.Init(divKLine); //把K线图绑定到一个Div上
//K线配置信息
this.Option= {
Type:'历史K线图', //创建图形类型
//Type:'历史K线图横屏',
//EnableBorderDrag:false,
Windows: //窗口指标
[
{
Index:'SVG图标标记',
API:
{
Name:'SVG图标标记',
Script:null,
Args:null,
Url:'http://local'
}
},
],
OverlayIndex:
[
], //叠加指标
OverlayIndexFrameWidth:1,
//DragDownload: { Day:{ Enable:true } , Minute:{ Enable:true }},
EnableYDrag:
{
Right:true,
Left:true,
},
Symbol:"000001.sz",
IsAutoUpdate:false, //是自动更新数据
AutoUpdateFrequency:10000, //数据更新频率
//TradeIndex: {Index:'交易系统-BIAS'}, //交易系统
SplashTitle:'加载数据中......',
IsShowRightMenu:true, //右键菜单
//CorssCursorTouchEnd:true,
//IsClickShowCorssCursor:true,
//IsCorssOnlyDrawKLine:true,
CorssCursorInfo: { Right:2, DateFormatType:3, HPenType:1, VPenType:1 ,VLineType:0,RightButton:{ Enable:true }, IsShowCorss:true, PriceFormatType:0, DataFormatType:0 },
EnableZoomIndexWindow:true,
KLine: //K线设置
{
DragMode:1, //拖拽模式 0 禁止拖拽 1 数据拖拽 2 区间选择
Right:0, //复权 0 不复权 1 前复权 2 后复权
Period:0, //周期 0 日线 1 周线 2 月线 3 年线
MaxRequestDataCount:5000, //数据个数
MaxRequestMinuteDayCount:5, //分钟数据获取几天数据 默认取5天数据
PageSize:30, //一屏显示多少数据
//Info:["互动易","大宗交易",'龙虎榜',"调研","业绩预告","公告"], //信息地雷
//Info:["公告"],
IsShowTooltip:true, //是否显示K线提示信息
DrawType:0, //K线类型 0=实心K线柱子 1=收盘价线 2=美国线 3=空心K线柱子 4=收盘价面积图
//FirstShowDate:20161201,
KLineDoubleClick:false, //禁止双击弹框
RightSpaceCount:5,
ZoomType:0,
//DataWidth:5
ShowKLine:true,
IsShowTooltip:true,
},
StepPixel:0,
IsDrawPictureXY:true,
SelectedChart:{ EnableSelected: true, EnableMoveOn:true },
EnableIndexChartDrag:true,
KLineTitle: //标题设置
{
IsShowName:true, //不显示股票名称
IsShowSettingInfo:true //不显示周期/复权
},
Border: //边框
{
Left:50, //左边间距
Right:50, //右边间距
Bottom:25, //底部间距
Top:25, //顶部间距
AutoLeft:{ Blank:10, MinWidth:30 },
AutoRight:{ Blank:5, MinWidth:40 },
},
Frame: //子框架设置
[
],
Overlay:
[
],
};
this.Create=function() //创建图形
{
var self=this;
//$(window).resize(function() { self.OnSize( {Type:1} ); }); //绑定窗口大小变化事件
$(window).resize(function() { self.OnSize( ); }); //绑定窗口大小变化事件
var blackStyle=HQChartStyle.GetStyleConfig(STYLE_TYPE_ID.BLACK_ID); //读取黑色风格配置
JSChart.SetStyle(blackStyle);
this.DivKLine.style.backgroundColor=blackStyle.BGColor; //设置最外面的div背景
this.OnSize(); //让K线全屏
this.Option.NetworkFilter=(data, callback)=>{ this.NetworkFilter(data, callback); }
this.Chart.SetOption(this.Option); //设置K线配置
}
this.NetworkFilter=function(data, callback)
{
console.log('[NetworkFilter] data', data);
switch(data.Name)
{
case "APIScriptIndex::ExecuteScript":
return this.GetExecuteScript(data, callback);
default:
HQData.NetworkFilter(data, callback);
break;
}
}
this.GetExecuteScript=function(data, callback)
{
var request=data.Request;
if (request.Data.indexname=='SVG图标标记')
this.Index_MULTI_SVGICON(data, callback)
}
this.Index_MULTI_SVGICON=function(data, callback)
{
var hqchart=data.HQChart;
var kData=hqchart.ChartPaint[0].Data;
data.PreventDefault=true;
var closeLine={ name:'收盘价线', type:0, data:kData.GetClose() };
var iconData=
{
name:'MULTI_SVGICON', type:1,
Draw:
{
DrawType:'MULTI_SVGICON',
DrawData:
{
Family:'js-iconfont',
Icon:
[
//{ Date:20190916, Value:"High", Symbol:'\ue611', Color:'rgb(240,0,0)', Baseline:2 , YMove:-5}, //0 居中 1 上 2 下
//{ Date:20190919, Value:15.3, Symbol:'\ue615', Color:'rgb(240,240,0)', Baseline:2 },
//{ Date:20190909, Value:15.4, Symbol:'\ue615', Color:'rgb(240,100,30)'}
]
}
} //绘制图标数组
};
var TEST_ICON_SYMBOL=['\ue611', '\ue615', "\ue610"];
var TEST_ICON_COLOR=["'rgb(240,0,0)", "rgb(240,100,30)", "rgb(138,43, 226)", "rgb(151,255,255)", "rgb(255, 20, 147)"];
for(var i=0, j=0;i<kData.Data.length;++i)
{
var item=kData.Data[i];
if (i%10!=3) continue;
var iconIndex=Math.ceil(Math.random()*10) % TEST_ICON_SYMBOL.length;
var colorIndex=Math.ceil(Math.random()*10) % TEST_ICON_COLOR.length;
var iconItem=
{
Date:item.Date, Time:item.Time,
Value:item.High,
Symbol:TEST_ICON_SYMBOL[iconIndex],
Color:TEST_ICON_COLOR[colorIndex],
Baseline:2,
YMove:-5,
};
iconData.Draw.DrawData.Icon.push(iconItem);
++j;
}
var apiData=
{
code:0,
stock:{ name:hqchart.Name, symbol:hqchart.Symbol },
outdata: { date:kData.GetDate() , outvar:[iconData] }
};
console.log('[KLineChart::Index_MULTI_SVGICON] apiData ', apiData);
callback(apiData);
}
this.OnSize=function(option) //自适应大小调整
{
var height= $(window).height()-50;
var width = $(window).width();
//width=50000;
this.DivKLine.style.top='0px';
this.DivKLine.style.left='0px';
this.DivKLine.style.width=width+'px';
this.DivKLine.style.height=height+'px';
this.Chart.OnSize(option);
}
this.ChangeSymbol=function(symbol)
{
this.Chart.ChangeSymbol(symbol);
}
}
$(function ()
{
WebFont.load({ custom: { families: ['iconfont'] } }); //预加载下iconfont资源
var klineControl=new KLineChart(document.getElementById('kline'));
klineControl.Create();
})
</script>
</body>
</html>
<style>
#kline
{
width: 900px;
height:400px;
position: relative;
/*margin-top: 100px;*/
}
.btn-style
{
padding: 3px 8px;
border: 1px solid #ececec;
border-radius: 5px;
background-color: #f5f5f5;
cursor: pointer;
}
</style>