hqchart 1.1.15438 → 1.1.15446
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/umychart.vue.js +184 -156
- package/package.json +1 -1
- package/src/jscommon/umychart.StatusBar.js +1069 -0
- package/src/jscommon/umychart.StockInfo.js +0 -6
- package/src/jscommon/umychart.js +304 -2
- package/src/jscommon/umychart.resource/font/iconfont.css +11 -3
- package/src/jscommon/umychart.resource/font/iconfont.ttf +0 -0
- package/src/jscommon/umychart.resource/font/iconfont.woff +0 -0
- package/src/jscommon/umychart.resource/font/iconfont.woff2 +0 -0
- package/src/jscommon/umychart.style.js +42 -0
- package/src/jscommon/umychart.uniapp.h5/umychart.uniapp.h5.js +347 -3
- package/src/jscommon/umychart.version.js +1 -1
- package/src/jscommon/umychart.vue/umychart.vue.js +347 -3
|
@@ -0,0 +1,1069 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2018 jones
|
|
3
|
+
|
|
4
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
|
|
6
|
+
开源项目 https://github.com/jones2000/HQChart
|
|
7
|
+
|
|
8
|
+
jones_2000@163.com
|
|
9
|
+
|
|
10
|
+
底部状态栏 (H5版本)
|
|
11
|
+
不提供内置测试数据
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function JSStatusBarChart(divElement)
|
|
15
|
+
{
|
|
16
|
+
this.DivElement=divElement;
|
|
17
|
+
this.JSChartContainer; //表格控件
|
|
18
|
+
this.ResizeListener; //大小变动监听
|
|
19
|
+
|
|
20
|
+
//h5 canvas
|
|
21
|
+
this.CanvasElement=document.createElement("canvas");
|
|
22
|
+
this.CanvasElement.className='jsstatusbar-drawing';
|
|
23
|
+
this.CanvasElement.id=Guid();
|
|
24
|
+
this.CanvasElement.setAttribute("tabindex",0);
|
|
25
|
+
if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
|
|
26
|
+
if(divElement.hasChildNodes())
|
|
27
|
+
{
|
|
28
|
+
JSConsole.Chart.Log("[JSStatusBarChart::JSStatusBarChart] divElement hasChildNodes", divElement.childNodes);
|
|
29
|
+
}
|
|
30
|
+
divElement.appendChild(this.CanvasElement);
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
this.OnSize=function()
|
|
34
|
+
{
|
|
35
|
+
//画布大小通过div获取 如果有style里的大小 使用style里的
|
|
36
|
+
var height=this.DivElement.offsetHeight;
|
|
37
|
+
var width=this.DivElement.offsetWidth;
|
|
38
|
+
if (this.DivElement.style.height && this.DivElement.style.width)
|
|
39
|
+
{
|
|
40
|
+
if (this.DivElement.style.height.includes("px"))
|
|
41
|
+
height=parseInt(this.DivElement.style.height.replace("px",""));
|
|
42
|
+
if (this.DivElement.style.width.includes("px"))
|
|
43
|
+
width=parseInt(this.DivElement.style.width.replace("px",""));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.CanvasElement.height=height;
|
|
47
|
+
this.CanvasElement.width=width;
|
|
48
|
+
this.CanvasElement.style.width=this.CanvasElement.width+'px';
|
|
49
|
+
this.CanvasElement.style.height=this.CanvasElement.height+'px';
|
|
50
|
+
|
|
51
|
+
var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
|
|
52
|
+
this.CanvasElement.height*=pixelTatio;
|
|
53
|
+
this.CanvasElement.width*=pixelTatio;
|
|
54
|
+
|
|
55
|
+
JSConsole.Chart.Log(`[JSStatusBarChart::OnSize] devicePixelRatio=${window.devicePixelRatio}, height=${this.CanvasElement.height}, width=${this.CanvasElement.width}`);
|
|
56
|
+
|
|
57
|
+
if (this.JSChartContainer && this.JSChartContainer.OnSize)
|
|
58
|
+
{
|
|
59
|
+
this.JSChartContainer.OnSize();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.SetOption=function(option)
|
|
64
|
+
{
|
|
65
|
+
var chart=this.CreateJSStatusBarChartContainer(option);
|
|
66
|
+
|
|
67
|
+
if (!chart) return false;
|
|
68
|
+
|
|
69
|
+
if (option.OnCreatedCallback) option.OnCreatedCallback(chart);
|
|
70
|
+
|
|
71
|
+
this.JSChartContainer=chart;
|
|
72
|
+
this.DivElement.JSChart=this; //div中保存一份
|
|
73
|
+
|
|
74
|
+
if (option.EnableResize==true) this.CreateResizeListener();
|
|
75
|
+
|
|
76
|
+
chart.Draw();
|
|
77
|
+
chart.RequestData();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.CreateResizeListener=function()
|
|
81
|
+
{
|
|
82
|
+
this.ResizeListener = new ResizeObserver((entries)=>{ this.OnDivResize(entries); });
|
|
83
|
+
this.ResizeListener.observe(this.DivElement);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.OnDivResize=function(entries)
|
|
87
|
+
{
|
|
88
|
+
JSConsole.Chart.Log("[JSStatusBarChart::OnDivResize] entries=", entries);
|
|
89
|
+
|
|
90
|
+
this.OnSize();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this.CreateJSStatusBarChartContainer=function(option)
|
|
94
|
+
{
|
|
95
|
+
var chart=new JSStatusBarChartContainer(this.CanvasElement);
|
|
96
|
+
chart.Create(option);
|
|
97
|
+
|
|
98
|
+
this.SetChartBorder(chart, option);
|
|
99
|
+
|
|
100
|
+
if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) chart.SetColumn(option.Column);
|
|
101
|
+
if (option.RightToolbar) chart.SetRightToolbar(option.RightToolbar);
|
|
102
|
+
|
|
103
|
+
//是否自动更新
|
|
104
|
+
if (option.NetworkFilter) chart.NetworkFilter=option.NetworkFilter;
|
|
105
|
+
|
|
106
|
+
if (option.IsAutoUpdate!=null) chart.IsAutoUpdate=option.IsAutoUpdate;
|
|
107
|
+
if (option.AutoUpdateFrequency>0) chart.AutoUpdateFrequency=option.AutoUpdateFrequency;
|
|
108
|
+
|
|
109
|
+
//注册事件
|
|
110
|
+
if (option.EventCallback)
|
|
111
|
+
{
|
|
112
|
+
for(var i=0;i<option.EventCallback.length;++i)
|
|
113
|
+
{
|
|
114
|
+
var item=option.EventCallback[i];
|
|
115
|
+
chart.AddEventCallback(item);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return chart;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.SetChartBorder=function(chart, option)
|
|
123
|
+
{
|
|
124
|
+
if (!option.Border) return;
|
|
125
|
+
|
|
126
|
+
var item=option.Border;
|
|
127
|
+
if (IFrameSplitOperator.IsNumber(option.Border.Left)) chart.Frame.ChartBorder.Left=option.Border.Left;
|
|
128
|
+
if (IFrameSplitOperator.IsNumber(option.Border.Right)) chart.Frame.ChartBorder.Right=option.Border.Right;
|
|
129
|
+
if (IFrameSplitOperator.IsNumber(option.Border.Top)) chart.Frame.ChartBorder.Top=option.Border.Top;
|
|
130
|
+
if (IFrameSplitOperator.IsNumber(option.Border.Bottom)) chart.Frame.ChartBorder.Bottom=option.Border.Bottom;
|
|
131
|
+
|
|
132
|
+
var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
|
|
133
|
+
chart.Frame.ChartBorder.Left*=pixelTatio;
|
|
134
|
+
chart.Frame.ChartBorder.Right*=pixelTatio;
|
|
135
|
+
chart.Frame.ChartBorder.Top*=pixelTatio;
|
|
136
|
+
chart.Frame.ChartBorder.Bottom*=pixelTatio;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
//事件回调
|
|
140
|
+
this.AddEventCallback=function(obj)
|
|
141
|
+
{
|
|
142
|
+
if(this.JSChartContainer && typeof(this.JSChartContainer.AddEventCallback)=='function')
|
|
143
|
+
{
|
|
144
|
+
JSConsole.Chart.Log('[JSStatusBarChart:AddEventCallback] obj=', obj);
|
|
145
|
+
this.JSChartContainer.AddEventCallback(obj);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//重新加载配置
|
|
150
|
+
this.ReloadResource=function(option)
|
|
151
|
+
{
|
|
152
|
+
if(this.JSChartContainer && typeof(this.JSChartContainer.ReloadResource)=='function')
|
|
153
|
+
{
|
|
154
|
+
JSConsole.Chart.Log('[JSStatusBarChart:ReloadResource] ');
|
|
155
|
+
this.JSChartContainer.ReloadResource(option);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
this.ChartDestroy=function()
|
|
160
|
+
{
|
|
161
|
+
if (this.JSChartContainer && typeof (this.JSChartContainer.ChartDestroy) == 'function')
|
|
162
|
+
{
|
|
163
|
+
this.JSChartContainer.ChartDestroy();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
this.Draw=function()
|
|
168
|
+
{
|
|
169
|
+
if(this.JSChartContainer && typeof(this.JSChartContainer.Draw)=='function')
|
|
170
|
+
{
|
|
171
|
+
JSConsole.Chart.Log('[JSStatusBarChart:Draw] ');
|
|
172
|
+
this.JSChartContainer.Draw();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
JSStatusBarChart.Init=function(divElement)
|
|
178
|
+
{
|
|
179
|
+
var jsChartControl=new JSStatusBarChart(divElement);
|
|
180
|
+
jsChartControl.OnSize();
|
|
181
|
+
|
|
182
|
+
return jsChartControl;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//自定义风格
|
|
186
|
+
JSStatusBarChart.SetStyle=function(option)
|
|
187
|
+
{
|
|
188
|
+
if (option) g_JSChartResource.SetStyle(option);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//获取颜色配置 (JSStatusBarChart.Init()之前)
|
|
192
|
+
JSStatusBarChart.GetResource=function()
|
|
193
|
+
{
|
|
194
|
+
return g_JSChartResource;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
JSStatusBarChart.GetfloatPrecision=function(symbol)
|
|
198
|
+
{
|
|
199
|
+
return GetfloatPrecision(symbol);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
function JSStatusBarChartContainer(uielement)
|
|
204
|
+
{
|
|
205
|
+
this.ClassName='JSStatusBarChartContainer';
|
|
206
|
+
this.Frame; //框架画法
|
|
207
|
+
this.ChartPaint=[]; //图形画法
|
|
208
|
+
|
|
209
|
+
this.Canvas=uielement.getContext("2d"); //画布
|
|
210
|
+
|
|
211
|
+
this.NetworkFilter; //数据回调接口
|
|
212
|
+
this.Data=
|
|
213
|
+
{
|
|
214
|
+
MapSymbol:new Map(), //key=symbol, { Value:, Text:, } 股票数据
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
//事件回调
|
|
218
|
+
this.mapEvent=new Map(); //通知外部调用 key:JSCHART_EVENT_ID value:{ Callback:回调,}
|
|
219
|
+
|
|
220
|
+
this.AutoUpdateTimer=null;
|
|
221
|
+
this.AutoUpdateFrequency=15000; //15秒更新一次数据
|
|
222
|
+
|
|
223
|
+
this.ToolbarTimer=null;
|
|
224
|
+
|
|
225
|
+
this.UIElement=uielement;
|
|
226
|
+
|
|
227
|
+
this.IsDestroy=false; //是否已经销毁了
|
|
228
|
+
|
|
229
|
+
this.ChartDestroy=function() //销毁
|
|
230
|
+
{
|
|
231
|
+
this.IsDestroy=true;
|
|
232
|
+
this.StopAutoUpdate();
|
|
233
|
+
|
|
234
|
+
if (this.ToolbarTimer)
|
|
235
|
+
{
|
|
236
|
+
clearInterval(this.ToolbarTimer);
|
|
237
|
+
this.ToolbarTimer=null;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
//设置事件回调
|
|
242
|
+
//{event:事件id, callback:回调函数}
|
|
243
|
+
this.AddEventCallback=function(object)
|
|
244
|
+
{
|
|
245
|
+
if (!object || !object.event || !object.callback) return;
|
|
246
|
+
|
|
247
|
+
var data={Callback:object.callback, Source:object};
|
|
248
|
+
this.mapEvent.set(object.event,data);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
this.RemoveEventCallback=function(eventid)
|
|
252
|
+
{
|
|
253
|
+
if (!this.mapEvent.has(eventid)) return;
|
|
254
|
+
|
|
255
|
+
this.mapEvent.delete(eventid);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
this.GetEventCallback=function(id) //获取事件回调
|
|
259
|
+
{
|
|
260
|
+
if (!this.mapEvent.has(id)) return null;
|
|
261
|
+
var item=this.mapEvent.get(id);
|
|
262
|
+
return item;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
this.ClearData=function()
|
|
266
|
+
{
|
|
267
|
+
this.Data.MapSymbol=new Map();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
this.RequestData=function(option)
|
|
271
|
+
{
|
|
272
|
+
this.CancelAutoUpdate();
|
|
273
|
+
this.ClearData();
|
|
274
|
+
|
|
275
|
+
if (option)
|
|
276
|
+
{
|
|
277
|
+
if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) this.SetColumn(option.Column);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
this.Draw();
|
|
281
|
+
this.RequestStockData();
|
|
282
|
+
|
|
283
|
+
if (this.IsAutoUpdate)
|
|
284
|
+
{
|
|
285
|
+
var frequency=this.AutoUpdateFrequency;
|
|
286
|
+
setInterval(()=>
|
|
287
|
+
{
|
|
288
|
+
var marketStatus=MARKET_SUFFIX_NAME.GetMarketStatus(this.Symbol);
|
|
289
|
+
if (marketStatus==0 || marketStatus==3) //闭市,盘后
|
|
290
|
+
return;
|
|
291
|
+
|
|
292
|
+
this.RequestStockData();
|
|
293
|
+
}, frequency)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
this.CancelAutoUpdate=function() //关闭停止更新
|
|
298
|
+
{
|
|
299
|
+
if (this.AutoUpdateTimer)
|
|
300
|
+
{
|
|
301
|
+
clearInterval(this.AutoUpdateTimer);
|
|
302
|
+
this.AutoUpdateTimer = null;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
this.StopAutoUpdate=function()
|
|
307
|
+
{
|
|
308
|
+
this.CancelAutoUpdate();
|
|
309
|
+
if (!this.IsAutoUpdate) return;
|
|
310
|
+
this.IsAutoUpdate=false;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
this.RequestStockData=function()
|
|
314
|
+
{
|
|
315
|
+
if (!this.NetworkFilter) return;
|
|
316
|
+
|
|
317
|
+
var chart=this.ChartPaint[0];
|
|
318
|
+
if (!chart) return;
|
|
319
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(chart.Column)) return;
|
|
320
|
+
|
|
321
|
+
var arySymbol=[];
|
|
322
|
+
for(var i=0;i<chart.Column.length;++i)
|
|
323
|
+
{
|
|
324
|
+
var item=chart.Column[i];
|
|
325
|
+
var newItem={ Symbol:item.Symbol, Fields:[] };
|
|
326
|
+
arySymbol.push(newItem);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
var obj=
|
|
330
|
+
{
|
|
331
|
+
Name:'JSStatusBarChartContainer::RequestStockData', //类名::函数名
|
|
332
|
+
Explain:'工具栏股票数据',
|
|
333
|
+
Request: { Data:{ stocks:arySymbol } },
|
|
334
|
+
Self:this,
|
|
335
|
+
PreventDefault:false
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
this.NetworkFilter(obj, (data)=>
|
|
339
|
+
{
|
|
340
|
+
this.RecvStockData(data);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
if (obj.PreventDefault==true) return; //已被上层替换,不调用默认的网络请求
|
|
344
|
+
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
this.RecvStockData=function(recv)
|
|
348
|
+
{
|
|
349
|
+
if (!recv) return;
|
|
350
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(recv.data)) return;
|
|
351
|
+
|
|
352
|
+
for(var i=0;i<recv.data.length;++i)
|
|
353
|
+
{
|
|
354
|
+
var item=recv.data[i];
|
|
355
|
+
if (!item.Symbol) continue;
|
|
356
|
+
|
|
357
|
+
var stockItem=null;
|
|
358
|
+
if (this.Data.MapSymbol.has(item.Symbol))
|
|
359
|
+
{
|
|
360
|
+
stockItem=this.Data.MapSymbol.get(item.Symbol);
|
|
361
|
+
}
|
|
362
|
+
else
|
|
363
|
+
{
|
|
364
|
+
stockItem={ Symbol:item.Symbol, MapData:new Map() };
|
|
365
|
+
stockItem.YClose=item.YClose;
|
|
366
|
+
if (IFrameSplitOperator.IsNumber(item.FYClose)) stockItem.YClose=item.FYClose;
|
|
367
|
+
this.Data.MapSymbol.set(item.Symbol,stockItem);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
for(var j=0;j<item.Data.length;++j)
|
|
371
|
+
{
|
|
372
|
+
var itemData=item.Data[j];
|
|
373
|
+
stockItem.MapData.set(itemData.Key,itemData.Value);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (!this.ToolbarTimer) this.Draw();
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
//创建
|
|
381
|
+
this.Create=function(option)
|
|
382
|
+
{
|
|
383
|
+
this.UIElement.JSChartContainer=this;
|
|
384
|
+
|
|
385
|
+
//创建框架
|
|
386
|
+
this.Frame=new JSStatusBarFrame();
|
|
387
|
+
this.Frame.ChartBorder=new ChartBorder();
|
|
388
|
+
this.Frame.ChartBorder.UIElement=this.UIElement;
|
|
389
|
+
this.Frame.ChartBorder.Top=30;
|
|
390
|
+
this.Frame.ChartBorder.Left=5;
|
|
391
|
+
this.Frame.ChartBorder.Bottom=20;
|
|
392
|
+
this.Frame.Canvas=this.Canvas;
|
|
393
|
+
|
|
394
|
+
//创建表格
|
|
395
|
+
var chart=new ChartStatusBarStockData();
|
|
396
|
+
chart.Frame=this.Frame;
|
|
397
|
+
chart.ChartBorder=this.Frame.ChartBorder;
|
|
398
|
+
chart.Canvas=this.Canvas;
|
|
399
|
+
chart.UIElement=this.UIElement;
|
|
400
|
+
chart.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
|
|
401
|
+
chart.Data=this.Data;
|
|
402
|
+
chart.BorderData=this.BorderData;
|
|
403
|
+
chart.GlobalOption=this.GlobalOption;
|
|
404
|
+
chart.FixedRowData=this.FixedRowData;
|
|
405
|
+
chart.SortInfo=this.SortInfo;
|
|
406
|
+
this.ChartPaint[0]=chart;
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
if (option)
|
|
410
|
+
{
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
this.UIElement.onmousedown=(e)=> { this.UIOnMouseDown(e); }
|
|
415
|
+
|
|
416
|
+
/*
|
|
417
|
+
this.UIElement.ondblclick=(e)=>{ this.UIOnDblClick(e); }
|
|
418
|
+
this.UIElement.onmousedown=(e)=> { this.UIOnMouseDown(e); }
|
|
419
|
+
this.UIElement.onmousemove=(e)=>{ this.UIOnMouseMove(e);}
|
|
420
|
+
this.UIElement.onmouseout=(e)=>{ this.UIOnMounseOut(e); }
|
|
421
|
+
this.UIElement.onmouseleave=(e)=>{ this.UIOnMouseleave(e); }
|
|
422
|
+
this.UIElement.oncontextmenu=(e)=> { this.UIOnContextMenu(e); }
|
|
423
|
+
*/
|
|
424
|
+
|
|
425
|
+
var frequency=500;
|
|
426
|
+
this.ToolbarTimer=setInterval(()=>
|
|
427
|
+
{
|
|
428
|
+
this.Draw();
|
|
429
|
+
}, frequency)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
this.UIOnMouseDown=function(e)
|
|
433
|
+
{
|
|
434
|
+
var pixelTatio = GetDevicePixelRatio();
|
|
435
|
+
this.ClickDownPoint={ X:e.clientX, Y:e.clientY };
|
|
436
|
+
var x = (e.clientX-this.UIElement.getBoundingClientRect().left)*pixelTatio;
|
|
437
|
+
var y = (e.clientY-this.UIElement.getBoundingClientRect().top)*pixelTatio;
|
|
438
|
+
|
|
439
|
+
var ptClick={ X:this.ClickDownPoint.X, Y:this.ClickDownPoint.Y };
|
|
440
|
+
this.TryClickPaintEvent(JSCHART_EVENT_ID.ON_CLICK_STATUSBAR_ITEM, ptClick, e);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
this.TryClickPaintEvent=function(eventID, ptClick, e)
|
|
444
|
+
{
|
|
445
|
+
var event=this.GetEventCallback(eventID);
|
|
446
|
+
if (!event) return false;
|
|
447
|
+
|
|
448
|
+
if (ptClick.X==e.clientX && ptClick.Y==e.clientY)
|
|
449
|
+
{
|
|
450
|
+
var pixelTatio = GetDevicePixelRatio();
|
|
451
|
+
var x = (e.clientX-uielement.getBoundingClientRect().left)*pixelTatio;
|
|
452
|
+
var y = (e.clientY-uielement.getBoundingClientRect().top)*pixelTatio;
|
|
453
|
+
|
|
454
|
+
var toolTip=new TooltipData();
|
|
455
|
+
for(var i=0;i<this.ChartPaint.length;++i)
|
|
456
|
+
{
|
|
457
|
+
var item=this.ChartPaint[i];
|
|
458
|
+
if (item.GetTooltipData(x,y,toolTip))
|
|
459
|
+
{
|
|
460
|
+
if (toolTip.Data)
|
|
461
|
+
{
|
|
462
|
+
var data= { X:e.clientX, Y:e.clientY, Tooltip:toolTip };
|
|
463
|
+
event.Callback(event, data, this);
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
this.Draw=function()
|
|
474
|
+
{
|
|
475
|
+
if (this.UIElement.width<=0 || this.UIElement.height<=0) return;
|
|
476
|
+
|
|
477
|
+
this.Canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);
|
|
478
|
+
var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
|
|
479
|
+
this.Canvas.lineWidth=pixelTatio; //手机端需要根据分辨率比调整线段宽度
|
|
480
|
+
|
|
481
|
+
this.Frame.Draw();
|
|
482
|
+
this.Frame.DrawLogo();
|
|
483
|
+
|
|
484
|
+
//框架内图形
|
|
485
|
+
for(var i=0;i<this.ChartPaint.length;++i)
|
|
486
|
+
{
|
|
487
|
+
var item=this.ChartPaint[i];
|
|
488
|
+
item.Draw();
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
this.OnSize=function()
|
|
493
|
+
{
|
|
494
|
+
if (!this.Frame) return;
|
|
495
|
+
|
|
496
|
+
this.SetSizeChange(true);
|
|
497
|
+
this.Draw();
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
this.SetSizeChange=function(bChanged)
|
|
501
|
+
{
|
|
502
|
+
for(var i=0;i<this.ChartPaint.length;++i)
|
|
503
|
+
{
|
|
504
|
+
var chart=this.ChartPaint[i];
|
|
505
|
+
if (chart) chart.SizeChange=bChanged;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
this.ReloadResource=function(option)
|
|
510
|
+
{
|
|
511
|
+
this.Frame.ReloadResource(option);
|
|
512
|
+
|
|
513
|
+
for(var i=0;i<this.ChartPaint.length;++i)
|
|
514
|
+
{
|
|
515
|
+
var item=this.ChartPaint[i];
|
|
516
|
+
if (item.ReloadResource) item.ReloadResource(option);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (option && (option.Redraw || option.Draw))
|
|
520
|
+
{
|
|
521
|
+
this.SetSizeChange(true);
|
|
522
|
+
this.Draw();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
this.SetColumn=function(aryColunm, option)
|
|
527
|
+
{
|
|
528
|
+
var chart=this.ChartPaint[0];
|
|
529
|
+
if (!chart) return;
|
|
530
|
+
|
|
531
|
+
chart.SetColumn(aryColunm);
|
|
532
|
+
chart.SizeChange=true;
|
|
533
|
+
|
|
534
|
+
if (option && option.Redraw) this.Draw();
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
this.SetRightToolbar=function(toolbar, option)
|
|
538
|
+
{
|
|
539
|
+
var chart=this.ChartPaint[0];
|
|
540
|
+
if (!chart) return;
|
|
541
|
+
|
|
542
|
+
chart.SetRightToolbar(toolbar);
|
|
543
|
+
chart.SizeChange=true;
|
|
544
|
+
|
|
545
|
+
if (option && option.Redraw) this.Draw();
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function JSStatusBarFrame()
|
|
550
|
+
{
|
|
551
|
+
this.ChartBorder;
|
|
552
|
+
this.Canvas; //画布
|
|
553
|
+
|
|
554
|
+
this.BorderLine=null; //1=上 2=下 4=左 8=右
|
|
555
|
+
this.ClassName="JSStatusBarFrame";
|
|
556
|
+
|
|
557
|
+
this.BorderColor=g_JSChartResource.StatusBar.BorderColor; //边框线
|
|
558
|
+
|
|
559
|
+
this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
|
|
560
|
+
this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
|
|
561
|
+
|
|
562
|
+
this.ReloadResource=function(resource)
|
|
563
|
+
{
|
|
564
|
+
this.BorderColor=g_JSChartResource.StatusBar.BorderColor; //边框线
|
|
565
|
+
this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
|
|
566
|
+
this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
this.Draw=function()
|
|
570
|
+
{
|
|
571
|
+
var left=ToFixedPoint(this.ChartBorder.GetLeft());
|
|
572
|
+
var top=ToFixedPoint(this.ChartBorder.GetTop());
|
|
573
|
+
var right=ToFixedPoint(this.ChartBorder.GetRight());
|
|
574
|
+
var bottom=ToFixedPoint(this.ChartBorder.GetBottom());
|
|
575
|
+
var width=right-left;
|
|
576
|
+
var height=bottom-top;
|
|
577
|
+
|
|
578
|
+
if (!IFrameSplitOperator.IsNumber(this.BorderLine))
|
|
579
|
+
{
|
|
580
|
+
this.Canvas.strokeStyle=this.BorderColor;
|
|
581
|
+
this.Canvas.strokeRect(left,top,width,height);
|
|
582
|
+
}
|
|
583
|
+
else
|
|
584
|
+
{
|
|
585
|
+
this.Canvas.strokeStyle=this.BorderColor;
|
|
586
|
+
this.Canvas.beginPath();
|
|
587
|
+
|
|
588
|
+
if ((this.BorderLine&1)>0) //上
|
|
589
|
+
{
|
|
590
|
+
this.Canvas.moveTo(left,top);
|
|
591
|
+
this.Canvas.lineTo(right,top);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if ((this.BorderLine&2)>0) //下
|
|
595
|
+
{
|
|
596
|
+
this.Canvas.moveTo(left,bottom);
|
|
597
|
+
this.Canvas.lineTo(right,bottom);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
if ((this.BorderLine&4)>0) //左
|
|
601
|
+
{
|
|
602
|
+
this.Canvas.moveTo(left,top);
|
|
603
|
+
this.Canvas.lineTo(left,bottom);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if ((this.BorderLine&8)>0) //右
|
|
607
|
+
{
|
|
608
|
+
this.Canvas.moveTo(right,top);
|
|
609
|
+
this.Canvas.lineTo(right,bottom);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
this.Canvas.stroke();
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
this.DrawLogo=function()
|
|
617
|
+
{
|
|
618
|
+
/*
|
|
619
|
+
var text=g_JSChartResource.FrameLogo.Text;
|
|
620
|
+
if (!IFrameSplitOperator.IsString(text)) return;
|
|
621
|
+
|
|
622
|
+
this.Canvas.fillStyle=this.LogoTextColor;
|
|
623
|
+
this.Canvas.font=this.LogoTextFont;
|
|
624
|
+
this.Canvas.textAlign = 'right';
|
|
625
|
+
this.Canvas.textBaseline = 'bottom';
|
|
626
|
+
|
|
627
|
+
var x=this.ChartBorder.GetRight()-30;
|
|
628
|
+
var y=this.ChartBorder.GetBottom()-5;
|
|
629
|
+
this.Canvas.fillText(text,x,y);
|
|
630
|
+
*/
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
function ChartStatusBarStockData()
|
|
636
|
+
{
|
|
637
|
+
this.Canvas; //画布
|
|
638
|
+
this.ChartBorder; //边框信息
|
|
639
|
+
this.ChartFrame; //框架画法
|
|
640
|
+
this.Name; //名称
|
|
641
|
+
this.ClassName='ChartStatusBarStockData'; //类名
|
|
642
|
+
this.UIElement;
|
|
643
|
+
this.GetEventCallback; //获取事件
|
|
644
|
+
this.Data; //数据
|
|
645
|
+
this.SizeChange=true;
|
|
646
|
+
|
|
647
|
+
this.UpColor=g_JSChartResource.StatusBar.UpTextColor;
|
|
648
|
+
this.DownColor=g_JSChartResource.StatusBar.DownTextColor;
|
|
649
|
+
this.UnchangeColor=g_JSChartResource.StatusBar.UnchangeTextColor;
|
|
650
|
+
|
|
651
|
+
this.TableConfig=CloneData(g_JSChartResource.StatusBar.Table);
|
|
652
|
+
this.DateTimeConfig=CloneData(g_JSChartResource.StatusBar.DateTime);
|
|
653
|
+
|
|
654
|
+
//显示的字段
|
|
655
|
+
this.Column=
|
|
656
|
+
[
|
|
657
|
+
{
|
|
658
|
+
Symbol:"000001.sh",
|
|
659
|
+
Column:
|
|
660
|
+
[
|
|
661
|
+
{ Name:"名称", Key:"Name", Text:"000001", },
|
|
662
|
+
{ Name:"现价", Key:"Price", ColorType:3, FloatPrecision:-1, MaxText:"88888.88" },
|
|
663
|
+
{ Name:"涨幅", Key:"Increase", ColorType:1, FloatPrecision:2, StringFormat:"{Value}%", MaxText:"888.88%" },
|
|
664
|
+
{ Name:"涨跌", Key:"UpDown",ColorType:1, FloatPrecision:-1 },
|
|
665
|
+
{ Name:"总额", Key:"Amount", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 }, ColorID:1 }
|
|
666
|
+
]
|
|
667
|
+
},
|
|
668
|
+
|
|
669
|
+
{
|
|
670
|
+
Symbol:"600000.sh",
|
|
671
|
+
Column:
|
|
672
|
+
[
|
|
673
|
+
{ Name:"名称", Key:"Name", Text:"600000", },
|
|
674
|
+
{ Name:"现价", Key:"Price", ColorType:3, FloatPrecision:-1 },
|
|
675
|
+
{ Name:"涨幅", Key:"Increase", ColorType:1, FloatPrecision:2, StringFormat:"{Value}%" },
|
|
676
|
+
{ Name:"涨跌", Key:"UpDown",ColorType:1, FloatPrecision:-1 },
|
|
677
|
+
{ Name:"总额", Key:"Amount", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }
|
|
678
|
+
]
|
|
679
|
+
}
|
|
680
|
+
]
|
|
681
|
+
|
|
682
|
+
this.RightToolbarConfig=CloneData(g_JSChartResource.StatusBar.RightToolbar);
|
|
683
|
+
this.MapToolbarFlash=new Map(); //key=id, Value:{ Counter:, Enable: }
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
//右侧工具栏
|
|
687
|
+
this.RightToolbar=
|
|
688
|
+
{
|
|
689
|
+
/*
|
|
690
|
+
AryButton:
|
|
691
|
+
[
|
|
692
|
+
{ ID:2, Type:1, Icon:[{ Symbol:"\ue609", Color:"rgb(180,180,180)"} ] },
|
|
693
|
+
|
|
694
|
+
{
|
|
695
|
+
ID:1, Type:2, Icon:[{ Symbol:"\ue6d0", Color:"rgb(180,180,180)"} ],
|
|
696
|
+
Flash:
|
|
697
|
+
{
|
|
698
|
+
AryIcon:
|
|
699
|
+
[
|
|
700
|
+
[{ Symbol:"\ue6cb", Color:"rgb(0,191,255)"}],
|
|
701
|
+
[{ Symbol:"\ue6cb", Color:"rgb(255,165,0)"}],
|
|
702
|
+
[{ Symbol:"\ue6cb", Color:"rgb(255,215,0)"}],
|
|
703
|
+
]
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
]
|
|
707
|
+
*/
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
this.AryRectCell=[];
|
|
711
|
+
this.AryRectButton=[];
|
|
712
|
+
|
|
713
|
+
this.ReloadResource=function(resource)
|
|
714
|
+
{
|
|
715
|
+
this.UpColor=g_JSChartResource.StatusBar.UpTextColor;
|
|
716
|
+
this.DownColor=g_JSChartResource.StatusBar.DownTextColor;
|
|
717
|
+
this.UnchangeColor=g_JSChartResource.StatusBar.UnchangeTextColor;
|
|
718
|
+
|
|
719
|
+
this.TableConfig=CloneData(g_JSChartResource.StatusBar.Table);
|
|
720
|
+
this.DateTimeConfig=CloneData(g_JSChartResource.StatusBar.DateTime);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
this.SetColumn=function(aryColumn)
|
|
724
|
+
{
|
|
725
|
+
this.Column=[];
|
|
726
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(aryColumn)) return;
|
|
727
|
+
|
|
728
|
+
for(var i=0;i<aryColumn.length;++i)
|
|
729
|
+
{
|
|
730
|
+
var item=aryColumn[i];
|
|
731
|
+
if (!item) continue;
|
|
732
|
+
this.Column.push(CloneData(item));
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
this.SetRightToolbar=function(toolbar, option)
|
|
737
|
+
{
|
|
738
|
+
if (IFrameSplitOperator.IsNonEmptyArray(toolbar.AryButton))
|
|
739
|
+
{
|
|
740
|
+
this.RightToolbar.AryButton=toolbar.AryButton.slice();
|
|
741
|
+
for(var i=0;i<this.RightToolbar.AryButton.length;++i)
|
|
742
|
+
{
|
|
743
|
+
var item=this.RightToolbar.AryButton[i];
|
|
744
|
+
if (item.Type===2)
|
|
745
|
+
{
|
|
746
|
+
var value={ Counter:1, Enable:true };
|
|
747
|
+
if (IFrameSplitOperator.IsBool(item.Enable)) value.Enable=item.Enable;
|
|
748
|
+
this.MapToolbarFlash.set(item.ID, value)
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
this.Draw=function()
|
|
758
|
+
{
|
|
759
|
+
this.AryRectCell=[];
|
|
760
|
+
this.AryRectButton=[];
|
|
761
|
+
|
|
762
|
+
var border=this.ChartBorder.GetBorder();
|
|
763
|
+
var position = { Left:border.Left, Right:border.Right, Top:border.Top, Bottom:border.Bottom, Width:border.Right-border.Left, Border:border };
|
|
764
|
+
this.DrawRightToolbar(position);
|
|
765
|
+
this.DrawTable(position);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
this.DrawTable=function(position)
|
|
769
|
+
{
|
|
770
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(this.Column)) return;
|
|
771
|
+
|
|
772
|
+
var config=this.TableConfig;
|
|
773
|
+
var top=position.Top;
|
|
774
|
+
var left=position.Left+config.Margin.Left;
|
|
775
|
+
|
|
776
|
+
var yText=top+config.Margin.Top;
|
|
777
|
+
var xText=left;
|
|
778
|
+
|
|
779
|
+
this.Canvas.font=config.Font;
|
|
780
|
+
this.Canvas.textAlign = 'left';
|
|
781
|
+
this.Canvas.textBaseline = 'bottom';
|
|
782
|
+
var cellHeight=this.Canvas.measureText("擎").width+config.CellMargin.Top+config.CellMargin.Bottom;
|
|
783
|
+
var itemPos={ Left:xText, Right:position.Right, Top:yText, Height:cellHeight, Bottom:yText+cellHeight, IsBreak:false, CellCount:0 };
|
|
784
|
+
|
|
785
|
+
for(var i=0;i<this.Column.length;++i)
|
|
786
|
+
{
|
|
787
|
+
var item=this.Column[i];
|
|
788
|
+
if (!item || !item.Symbol) continue;
|
|
789
|
+
|
|
790
|
+
var rtCell={ Left:itemPos.Left, Top:itemPos.Top, Bottom:itemPos.Bottom, Right:itemPos.Left };
|
|
791
|
+
this.DrawCellItem(item, itemPos );
|
|
792
|
+
if (itemPos.CellCount>0)
|
|
793
|
+
{
|
|
794
|
+
rtCell.Right=itemPos.Left;
|
|
795
|
+
rtCell.Width=rtCell.Right-itemPos.Left;
|
|
796
|
+
rtCell.Height=rtCell.Bottom-rtCell.Top;
|
|
797
|
+
|
|
798
|
+
this.AryRectCell.push({ Rect:rtCell, Data:item, Type:1 });
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
if (itemPos.IsBreak)
|
|
802
|
+
{
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
itemPos.Left+=config.Separator.Left;
|
|
807
|
+
if (config.Separator.Line && config.Separator.Line.Color) //分割线
|
|
808
|
+
{
|
|
809
|
+
if (itemPos.Left>=itemPos.Right) break;
|
|
810
|
+
|
|
811
|
+
var subConfig=config.Separator.Line;
|
|
812
|
+
var lineWidth=1*GetDevicePixelRatio();
|
|
813
|
+
if (IFrameSplitOperator.IsNumber(subConfig.Width)) lineWidth=subConfig.Width;
|
|
814
|
+
|
|
815
|
+
this.Canvas.strokeStyle=subConfig.Color;
|
|
816
|
+
this.Canvas.beginPath();
|
|
817
|
+
this.Canvas.moveTo(ToFixedPoint(itemPos.Left),itemPos.Top+subConfig.Top);
|
|
818
|
+
this.Canvas.lineTo(ToFixedPoint(itemPos.Left),itemPos.Bottom-subConfig.Bottom);
|
|
819
|
+
this.Canvas.stroke();
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
itemPos.Left+=config.Separator.Right;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
this.DrawCellItem=function(cellItem, itemPos)
|
|
827
|
+
{
|
|
828
|
+
var config=this.TableConfig;
|
|
829
|
+
var xText=itemPos.Left;
|
|
830
|
+
var yBottom=itemPos.Top+itemPos.Height-config.CellMargin.Bottom+config.CellMargin.YOffset;
|
|
831
|
+
var text=null;
|
|
832
|
+
|
|
833
|
+
var stockItem=null;
|
|
834
|
+
if (this.Data.MapSymbol.has(cellItem.Symbol)) stockItem=this.Data.MapSymbol.get(cellItem.Symbol);
|
|
835
|
+
|
|
836
|
+
for(var i=0;i<cellItem.Column.length ;++i)
|
|
837
|
+
{
|
|
838
|
+
var item=cellItem.Column[i];
|
|
839
|
+
if (!item) continue;
|
|
840
|
+
|
|
841
|
+
var color=config.AryTextColor[0];
|
|
842
|
+
var text=null;
|
|
843
|
+
if (stockItem && stockItem.MapData.has(item.Key))
|
|
844
|
+
{
|
|
845
|
+
var dataItem=stockItem.MapData.get(item.Key);
|
|
846
|
+
text=this.FormatValue(item, dataItem, stockItem);
|
|
847
|
+
|
|
848
|
+
if (IFrameSplitOperator.IsNumber(item.ColorID) && item.ColorID>=0 && item.ColorID<config.AryTextColor.length)
|
|
849
|
+
color=config.AryTextColor[item.ColorID];
|
|
850
|
+
|
|
851
|
+
if (item.ColorType===3 && IFrameSplitOperator.IsNumber(dataItem.Value))
|
|
852
|
+
color=this.GetPriceColor(dataItem.Value, stockItem);
|
|
853
|
+
else if (item.ColorType==1 && IFrameSplitOperator.IsNumber(dataItem.Value))
|
|
854
|
+
color=this.GetUpDownColor(dataItem.Value,0);
|
|
855
|
+
else if (item.ColorType==4)
|
|
856
|
+
color=this.UpColor;
|
|
857
|
+
else if (item.ColorType==5)
|
|
858
|
+
color=this.DownColor;
|
|
859
|
+
|
|
860
|
+
if (item.TextColor) color=item.TextColor;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
if (!text && item.Text) text=item.Text;
|
|
864
|
+
|
|
865
|
+
if (text)
|
|
866
|
+
{
|
|
867
|
+
var textWidth=this.Canvas.measureText(text).width;
|
|
868
|
+
if (xText+textWidth+config.CellMargin.Left+config.CellMargin.Right>itemPos.Right)
|
|
869
|
+
{
|
|
870
|
+
itemPos.IsBreak=true;
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
this.Canvas.fillStyle=color;
|
|
874
|
+
this.Canvas.fillText(text,xText+config.CellMargin.Left,yBottom);
|
|
875
|
+
xText+=(textWidth+config.CellMargin.Left+config.CellMargin.Right);
|
|
876
|
+
}
|
|
877
|
+
else if (item.MaxText)
|
|
878
|
+
{
|
|
879
|
+
text=item.MaxText;
|
|
880
|
+
var textWidth=this.Canvas.measureText(text).width;
|
|
881
|
+
xText+=(textWidth+config.CellMargin.Left+config.CellMargin.Right);
|
|
882
|
+
if (xText>itemPos.Right)
|
|
883
|
+
{
|
|
884
|
+
itemPos.IsBreak=true;
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
++itemPos.CellCount;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
itemPos.Left=xText;
|
|
893
|
+
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
this.FormatValue=function(column, data, stockItem)
|
|
898
|
+
{
|
|
899
|
+
var dec=0; //小数位数
|
|
900
|
+
if (IFrameSplitOperator.IsNumber(column.FloatPrecision))
|
|
901
|
+
{
|
|
902
|
+
if (column.FloatPrecision===-1) dec=GetfloatPrecision(stockItem.Symbol);
|
|
903
|
+
else dec=column.FloatPrecision;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
var text=null;
|
|
907
|
+
if (!data) return text;
|
|
908
|
+
|
|
909
|
+
if (data.Text)
|
|
910
|
+
{
|
|
911
|
+
text=data.Text;
|
|
912
|
+
}
|
|
913
|
+
else if (IFrameSplitOperator.IsNumber(data.Value))
|
|
914
|
+
{
|
|
915
|
+
var value=data.Value;
|
|
916
|
+
text=value.toFixed(dec);
|
|
917
|
+
|
|
918
|
+
//格式化
|
|
919
|
+
if (column.Format && IFrameSplitOperator.IsNumber(column.Format.Type))
|
|
920
|
+
{
|
|
921
|
+
var format=column.Format;
|
|
922
|
+
switch(format.Type)
|
|
923
|
+
{
|
|
924
|
+
case 1: //原始数据
|
|
925
|
+
text=value.toFixed(dec);
|
|
926
|
+
break;
|
|
927
|
+
case 2: //千分位分割
|
|
928
|
+
text=IFrameSplitOperator.FormatValueThousandsString(value, dec);
|
|
929
|
+
break;
|
|
930
|
+
case 3:
|
|
931
|
+
var exfloatPrecision=1;
|
|
932
|
+
if (IFrameSplitOperator.IsNumber(format.ExFloatPrecision)) exfloatPrecision=format.ExFloatPrecision;
|
|
933
|
+
text=IFrameSplitOperator.FormatValueStringV2(value, dec,exfloatPrecision);
|
|
934
|
+
break;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
if (column.StringFormat && text) text=column.StringFormat.replace('{Value}',text);
|
|
940
|
+
|
|
941
|
+
return text;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
this.GetPriceColor=function(price, stockItem)
|
|
945
|
+
{
|
|
946
|
+
var upperSymbol=null;
|
|
947
|
+
if (stockItem.Symbol) upperSymbol=stockItem.Symbol.toUpperCase();
|
|
948
|
+
if (MARKET_SUFFIX_NAME.IsChinaFutures(upperSymbol))
|
|
949
|
+
{
|
|
950
|
+
if (!IFrameSplitOperator.IsNumber(stockItem.YFClose)) return this.UnchangeColor;
|
|
951
|
+
return this.GetUpDownColor(price, stockItem.YFClose);
|
|
952
|
+
}
|
|
953
|
+
else
|
|
954
|
+
{
|
|
955
|
+
if (!IFrameSplitOperator.IsNumber(stockItem.YClose)) return this.UnchangeColor;
|
|
956
|
+
return this.GetUpDownColor(price, stockItem.YClose);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
this.GetUpDownColor=function(price, price2)
|
|
961
|
+
{
|
|
962
|
+
if (price>price2) return this.UpColor;
|
|
963
|
+
else if (price<price2) return this.DownColor;
|
|
964
|
+
else return this.UnchangeColor;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
this.DrawRightToolbar=function(position)
|
|
968
|
+
{
|
|
969
|
+
var config=this.DateTimeConfig;
|
|
970
|
+
var top=position.Top;
|
|
971
|
+
var right=position.Right;
|
|
972
|
+
|
|
973
|
+
this.Canvas.font=config.Font;
|
|
974
|
+
this.Canvas.textAlign = 'left';
|
|
975
|
+
this.Canvas.textBaseline = 'bottom';
|
|
976
|
+
var cellHeight=this.Canvas.measureText("擎").width+config.Margin.Top+config.Margin.Bottom;
|
|
977
|
+
|
|
978
|
+
var yBottom=top+cellHeight-config.Margin.Bottom+config.Margin.YOffset;
|
|
979
|
+
var xText=right;
|
|
980
|
+
|
|
981
|
+
//时间
|
|
982
|
+
var datetime=new Date();
|
|
983
|
+
var text=IFrameSplitOperator.FormatDateTimeStringV2(datetime, config.Format);
|
|
984
|
+
var textWidth=this.Canvas.measureText(config.MaxText).width+config.Margin.Left+config.Margin.Right;
|
|
985
|
+
xText-=textWidth;
|
|
986
|
+
this.Canvas.fillStyle=config.TitleColor;
|
|
987
|
+
this.Canvas.fillText(text,xText+config.Margin.Left,yBottom);
|
|
988
|
+
|
|
989
|
+
position.Right=xText;
|
|
990
|
+
|
|
991
|
+
if (this.RightToolbar && IFrameSplitOperator.IsNonEmptyArray(this.RightToolbar.AryButton))
|
|
992
|
+
{
|
|
993
|
+
var config=this.RightToolbarConfig;
|
|
994
|
+
|
|
995
|
+
xText-=config.Margin.Right;
|
|
996
|
+
for(var i=this.RightToolbar.AryButton.length-1;i>=0;--i)
|
|
997
|
+
{
|
|
998
|
+
var item=this.RightToolbar.AryButton[i];
|
|
999
|
+
var aryItem=null;
|
|
1000
|
+
if (item.Type==2) aryItem=this.GetFlashToolbarItem(item);
|
|
1001
|
+
else aryItem=item.Icon;
|
|
1002
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(aryItem)) continue;
|
|
1003
|
+
var iconFont=`${config.Icon.Size}px ${config.Icon.Family}`;
|
|
1004
|
+
this.Canvas.font=iconFont;
|
|
1005
|
+
var textWidth=config.Icon.Size+config.CellMargin.Left+config.CellMargin.Right;
|
|
1006
|
+
xText-=textWidth;
|
|
1007
|
+
yBottom=top+config.Margin.Top+(config.Icon.Size+config.CellMargin.Top+config.CellMargin.Bottom)-config.CellMargin.Bottom+config.CellMargin.YOffset;
|
|
1008
|
+
for(var j=0;j<aryItem.length;++j)
|
|
1009
|
+
{
|
|
1010
|
+
var iconItem=aryItem[j];
|
|
1011
|
+
var text=iconItem.Symbol;
|
|
1012
|
+
this.Canvas.fillStyle=iconItem.Color;
|
|
1013
|
+
this.Canvas.fillText(text,xText+config.CellMargin.Left,yBottom);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
var rtButton={ Left:xText, Bottom:yBottom, Height:config.Icon.Size, Width:config.Icon.Size };
|
|
1017
|
+
rtButton.Right=rtButton.Left+rtButton.Width;
|
|
1018
|
+
rtButton.Top=rtButton.Bottom-rtButton.Height;
|
|
1019
|
+
this.AryRectButton.push({ Rect:rtButton, Data:item, Type:2 });
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
position.Right=xText;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
this.GetFlashToolbarItem=function(btnItem)
|
|
1027
|
+
{
|
|
1028
|
+
if (!btnItem.Flash || !IFrameSplitOperator.IsNonEmptyArray(btnItem.Flash.AryIcon)) return btnItem.Icon;
|
|
1029
|
+
if (!this.MapToolbarFlash.has(btnItem.ID)) return btnItem.Icon;
|
|
1030
|
+
|
|
1031
|
+
var item=this.MapToolbarFlash.get(btnItem.ID);
|
|
1032
|
+
if (!item.Enable) return btnItem.Icon;
|
|
1033
|
+
|
|
1034
|
+
item.Counter++;
|
|
1035
|
+
|
|
1036
|
+
var index=item.Counter%btnItem.Flash.AryIcon.length;
|
|
1037
|
+
|
|
1038
|
+
return btnItem.Flash.AryIcon[index];
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
this.GetTooltipData=function(x,y,tooltip)
|
|
1042
|
+
{
|
|
1043
|
+
for(var i=0;i<this.AryRectCell.length;++i)
|
|
1044
|
+
{
|
|
1045
|
+
var item=this.AryRectCell[i];
|
|
1046
|
+
if (Path2DHelper.PtInRect(x,y, item.Rect))
|
|
1047
|
+
{
|
|
1048
|
+
tooltip.Data=item;
|
|
1049
|
+
tooltip.ChartPaint=this;
|
|
1050
|
+
tooltip.Type=21;
|
|
1051
|
+
return true;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
for(var i=0;i<this.AryRectButton.length;++i)
|
|
1056
|
+
{
|
|
1057
|
+
var item=this.AryRectButton[i];
|
|
1058
|
+
if (Path2DHelper.PtInRect(x,y, item.Rect))
|
|
1059
|
+
{
|
|
1060
|
+
tooltip.Data=item;
|
|
1061
|
+
tooltip.ChartPaint=this;
|
|
1062
|
+
tooltip.Type=22;
|
|
1063
|
+
return true;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
return false;
|
|
1068
|
+
}
|
|
1069
|
+
}
|