hqchart 1.1.15390 → 1.1.15438

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.
@@ -0,0 +1,1205 @@
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
+ 股票买卖5档 (H5版本)
11
+ 不提供内置测试数据
12
+ */
13
+
14
+ function JSStockInfoChart(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='jsstockinfo-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("[JSStockInfoChart::JSStockInfoChart] 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(`[JSStockInfoChart::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.CreateJSStockInfoChartContainer(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
+ if (option.Symbol)
77
+ {
78
+ chart.ChangeSymbol(option.Symbol); //下载列表码表
79
+ }
80
+ else
81
+ {
82
+ chart.Draw();
83
+ }
84
+ }
85
+
86
+ this.CreateResizeListener=function()
87
+ {
88
+ this.ResizeListener = new ResizeObserver((entries)=>{ this.OnDivResize(entries); });
89
+ this.ResizeListener.observe(this.DivElement);
90
+ }
91
+
92
+ this.OnDivResize=function(entries)
93
+ {
94
+ JSConsole.Chart.Log("[JSStockInfoChart::OnDivResize] entries=", entries);
95
+
96
+ this.OnSize();
97
+ }
98
+
99
+ //切换股票代码接口
100
+ this.ChangeSymbol=function(symbol, option)
101
+ {
102
+ if (this.JSChartContainer) this.JSChartContainer.ChangeSymbol(symbol,option);
103
+ }
104
+
105
+ this.CreateJSStockInfoChartContainer=function(option)
106
+ {
107
+ var chart=new JSStockInfoChartContainer(this.CanvasElement);
108
+ chart.Create(option);
109
+
110
+ this.SetChartBorder(chart, option);
111
+
112
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) chart.SetColumn(option.Column);
113
+ if (IFrameSplitOperator.IsNonEmptyArray(option.HeaderColumn)) chart.SetHeaderColumn(option.HeaderColumn);
114
+ //是否自动更新
115
+ if (option.NetworkFilter) chart.NetworkFilter=option.NetworkFilter;
116
+
117
+ if (option.IsAutoUpdate!=null) chart.IsAutoUpdate=option.IsAutoUpdate;
118
+ if (option.AutoUpdateFrequency>0) chart.AutoUpdateFrequency=option.AutoUpdateFrequency;
119
+
120
+ //注册事件
121
+ if (option.EventCallback)
122
+ {
123
+ for(var i=0;i<option.EventCallback.length;++i)
124
+ {
125
+ var item=option.EventCallback[i];
126
+ chart.AddEventCallback(item);
127
+ }
128
+ }
129
+
130
+ return chart;
131
+ }
132
+
133
+ this.SetChartBorder=function(chart, option)
134
+ {
135
+ if (!option.Border) return;
136
+
137
+ var item=option.Border;
138
+ if (IFrameSplitOperator.IsNumber(option.Border.Left)) chart.Frame.ChartBorder.Left=option.Border.Left;
139
+ if (IFrameSplitOperator.IsNumber(option.Border.Right)) chart.Frame.ChartBorder.Right=option.Border.Right;
140
+ if (IFrameSplitOperator.IsNumber(option.Border.Top)) chart.Frame.ChartBorder.Top=option.Border.Top;
141
+ if (IFrameSplitOperator.IsNumber(option.Border.Bottom)) chart.Frame.ChartBorder.Bottom=option.Border.Bottom;
142
+
143
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
144
+ chart.Frame.ChartBorder.Left*=pixelTatio;
145
+ chart.Frame.ChartBorder.Right*=pixelTatio;
146
+ chart.Frame.ChartBorder.Top*=pixelTatio;
147
+ chart.Frame.ChartBorder.Bottom*=pixelTatio;
148
+ }
149
+
150
+ //事件回调
151
+ this.AddEventCallback=function(obj)
152
+ {
153
+ if(this.JSChartContainer && typeof(this.JSChartContainer.AddEventCallback)=='function')
154
+ {
155
+ JSConsole.Chart.Log('[JSStockInfoChart:AddEventCallback] obj=', obj);
156
+ this.JSChartContainer.AddEventCallback(obj);
157
+ }
158
+ }
159
+
160
+ //重新加载配置
161
+ this.ReloadResource=function(option)
162
+ {
163
+ if(this.JSChartContainer && typeof(this.JSChartContainer.ReloadResource)=='function')
164
+ {
165
+ JSConsole.Chart.Log('[JSStockInfoChart:ReloadResource] ');
166
+ this.JSChartContainer.ReloadResource(option);
167
+ }
168
+ }
169
+
170
+ this.ChartDestroy=function()
171
+ {
172
+ if (this.JSChartContainer && typeof (this.JSChartContainer.ChartDestroy) == 'function')
173
+ {
174
+ this.JSChartContainer.ChartDestroy();
175
+ }
176
+ }
177
+
178
+ this.Draw=function()
179
+ {
180
+ if(this.JSChartContainer && typeof(this.JSChartContainer.Draw)=='function')
181
+ {
182
+ JSConsole.Chart.Log('[JSStockInfoChart:Draw] ');
183
+ this.JSChartContainer.Draw();
184
+ }
185
+ }
186
+ }
187
+
188
+ JSStockInfoChart.Init=function(divElement)
189
+ {
190
+ var jsChartControl=new JSStockInfoChart(divElement);
191
+ jsChartControl.OnSize();
192
+
193
+ return jsChartControl;
194
+ }
195
+
196
+ //自定义风格
197
+ JSStockInfoChart.SetStyle=function(option)
198
+ {
199
+ if (option) g_JSChartResource.SetStyle(option);
200
+ }
201
+
202
+ //获取颜色配置 (JSStockInfoChart.Init()之前)
203
+ JSStockInfoChart.GetResource=function()
204
+ {
205
+ return g_JSChartResource;
206
+ }
207
+
208
+ JSStockInfoChart.GetfloatPrecision=function(symbol)
209
+ {
210
+ return GetfloatPrecision(symbol);
211
+ }
212
+
213
+
214
+ function JSStockInfoChartContainer(uielement)
215
+ {
216
+ this.ClassName='JSStockInfoChartContainer';
217
+ this.Frame; //框架画法
218
+ this.ChartPaint=[]; //图形画法
219
+ this.ChartSplashPaint=null; //等待提示
220
+ this.LoadDataSplashTitle="数据加载中"; //下载数据提示信息
221
+
222
+ this.Canvas=uielement.getContext("2d"); //画布
223
+
224
+ this.Symbol; //代码
225
+ this.NetworkFilter; //数据回调接口
226
+ this.Data=
227
+ {
228
+ Name:null,
229
+ YClose:null, //昨收盘
230
+ YFClose:null, //昨计算价
231
+ Symbol:null,
232
+
233
+ Buys:
234
+ [
235
+ { Name:"买一", Price:null, Vol:null, Amount:null },
236
+ { Name:"买二", Price:null, Vol:null, Amount:null },
237
+ { Name:"买三", Price:null, Vol:null, Amount:null },
238
+ { Name:"买四", Price:null, Vol:null, Amount:null },
239
+ { Name:"买五", Price:null, Vol:null, Amount:null },
240
+ { Name:"买六", Price:null, Vol:null, Amount:null },
241
+ { Name:"买七", Price:null, Vol:null, Amount:null },
242
+ { Name:"买八", Price:null, Vol:null, Amount:null },
243
+ { Name:"买九", Price:null, Vol:null, Amount:null },
244
+ { Name:"买十", Price:null, Vol:null, Amount:null },
245
+ ],
246
+
247
+ Sells:
248
+ [
249
+ { Name:"卖一", Price:null, Vol:null, Amount:null },
250
+ { Name:"卖二", Price:null, Vol:null, Amount:null },
251
+ { Name:"卖三", Price:null, Vol:null, Amount:null },
252
+ { Name:"卖四", Price:null, Vol:null, Amount:null },
253
+ { Name:"卖五", Price:null, Vol:null, Amount:null },
254
+ { Name:"卖六", Price:null, Vol:null, Amount:null },
255
+ { Name:"卖七", Price:null, Vol:null, Amount:null },
256
+ { Name:"卖八", Price:null, Vol:null, Amount:null },
257
+ { Name:"卖九", Price:null, Vol:null, Amount:null },
258
+ { Name:"卖十", Price:null, Vol:null, Amount:null },
259
+ ],
260
+
261
+ MapData:new Map(), //key=, { Value:, Text:, }
262
+ };
263
+ //股票数据
264
+ this.BorderData={ MapData:null }; //key=Field Value:[null, {ExePrice} ,{ExePrice} ]
265
+
266
+ this.MapStockData;
267
+
268
+ //事件回调
269
+ this.mapEvent=new Map(); //通知外部调用 key:JSCHART_EVENT_ID value:{Callback:回调,}
270
+
271
+ this.AutoUpdateTimer=null;
272
+ this.AutoUpdateFrequency=15000; //15秒更新一次数据
273
+
274
+ this.UIElement=uielement;
275
+
276
+ this.IsDestroy=false; //是否已经销毁了
277
+
278
+ this.ChartDestroy=function() //销毁
279
+ {
280
+ this.IsDestroy=true;
281
+ this.StopAutoUpdate();
282
+ }
283
+
284
+ //设置事件回调
285
+ //{event:事件id, callback:回调函数}
286
+ this.AddEventCallback=function(object)
287
+ {
288
+ if (!object || !object.event || !object.callback) return;
289
+
290
+ var data={Callback:object.callback, Source:object};
291
+ this.mapEvent.set(object.event,data);
292
+ }
293
+
294
+ this.ClearData=function()
295
+ {
296
+ this.Data.Name=null;
297
+ this.Data.YClose=null;
298
+ this.Data.YFClose=null;
299
+
300
+ this.Data.Buys=
301
+ [
302
+ { Name:"买一", Price:null, Vol:null, Amount:null },
303
+ { Name:"买二", Price:null, Vol:null, Amount:null },
304
+ { Name:"买三", Price:null, Vol:null, Amount:null },
305
+ { Name:"买四", Price:null, Vol:null, Amount:null },
306
+ { Name:"买五", Price:null, Vol:null, Amount:null },
307
+ { Name:"买六", Price:null, Vol:null, Amount:null },
308
+ { Name:"买七", Price:null, Vol:null, Amount:null },
309
+ { Name:"买八", Price:null, Vol:null, Amount:null },
310
+ { Name:"买九", Price:null, Vol:null, Amount:null },
311
+ { Name:"买十", Price:null, Vol:null, Amount:null },
312
+ ];
313
+
314
+ this.Data.Sells=
315
+ [
316
+ { Name:"卖一", Price:null, Vol:null, Amount:null },
317
+ { Name:"卖二", Price:null, Vol:null, Amount:null },
318
+ { Name:"卖三", Price:null, Vol:null, Amount:null },
319
+ { Name:"卖四", Price:null, Vol:null, Amount:null },
320
+ { Name:"卖五", Price:null, Vol:null, Amount:null },
321
+ { Name:"卖六", Price:null, Vol:null, Amount:null },
322
+ { Name:"卖七", Price:null, Vol:null, Amount:null },
323
+ { Name:"卖八", Price:null, Vol:null, Amount:null },
324
+ { Name:"卖九", Price:null, Vol:null, Amount:null },
325
+ { Name:"卖十", Price:null, Vol:null, Amount:null },
326
+ ];
327
+
328
+ this.Data.MapData=new Map();
329
+ }
330
+
331
+ this.ChangeSymbol=function(symbol, option)
332
+ {
333
+ this.CancelAutoUpdate();
334
+ this.ClearData();
335
+ this.Symbol=symbol;
336
+ this.Data.Symbol=symbol;
337
+
338
+ if (option)
339
+ {
340
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) this.SetColumn(option.Column);
341
+ if (IFrameSplitOperator.IsNumber(option.BuySellCount)) this.SetBuySellCount(option.BuySellCount);
342
+ }
343
+
344
+ this.Draw();
345
+ this.RequestStockData();
346
+
347
+ if (this.IsAutoUpdate)
348
+ {
349
+ var frequency=this.AutoUpdateFrequency;
350
+ setInterval(()=>
351
+ {
352
+ var marketStatus=MARKET_SUFFIX_NAME.GetMarketStatus(this.Symbol);
353
+ if (marketStatus==0 || marketStatus==3) //闭市,盘后
354
+ return;
355
+
356
+ this.RequestStockData();
357
+ }, frequency)
358
+ }
359
+ }
360
+
361
+ this.CancelAutoUpdate=function() //关闭停止更新
362
+ {
363
+ if (this.AutoUpdateTimer)
364
+ {
365
+ clearInterval(this.AutoUpdateTimer);
366
+ this.AutoUpdateTimer = null;
367
+ }
368
+ }
369
+
370
+ this.StopAutoUpdate=function()
371
+ {
372
+ this.CancelAutoUpdate();
373
+ if (!this.IsAutoUpdate) return;
374
+ this.IsAutoUpdate=false;
375
+ }
376
+
377
+ this.RequestStockData=function()
378
+ {
379
+ if (this.NetworkFilter)
380
+ {
381
+ var obj=
382
+ {
383
+ Name:'JSStockInfoChartContainer::RequestStockData', //类名::函数名
384
+ Explain:'股票5档实时数据',
385
+ Request: { Data:{symbol:this.Symbol} },
386
+ Self:this,
387
+ PreventDefault:false
388
+ };
389
+
390
+ this.NetworkFilter(obj, (data)=>
391
+ {
392
+ this.RecvStockData(data);
393
+ });
394
+
395
+ if (obj.PreventDefault==true) return; //已被上层替换,不调用默认的网络请求
396
+ }
397
+ }
398
+
399
+ this.RecvStockData=function(recv)
400
+ {
401
+ if (!recv) return;
402
+
403
+ if (recv.name) this.Data.Name=recv.Name;
404
+ if (IFrameSplitOperator.IsNumber(recv.yclose)) this.Data.YClose=recv.yclose;
405
+ if (IFrameSplitOperator.IsNumber(recv.yfclose)) this.Data.YFClose=recv.yfclose;
406
+
407
+ if (recv.name) this.Data.Name=recv.name;
408
+
409
+ if (IFrameSplitOperator.IsNonEmptyArray(recv.data))
410
+ {
411
+ for(var i=0;i<recv.data.length;++i)
412
+ {
413
+ var item=recv.data[i];
414
+ if (item.Name=="Buys")
415
+ {
416
+ if (IFrameSplitOperator.IsNonEmptyArray(item.Value))
417
+ {
418
+ for(var j=0;j<item.Value.length && j<this.Data.Buys.length;++j)
419
+ {
420
+ var srcItem=item.Value[j];
421
+ var destItem=this.Data.Buys[j];
422
+ destItem.Price=srcItem.Price;
423
+ destItem.Vol=srcItem.Vol;
424
+ }
425
+ }
426
+ }
427
+ else if (item.Name=="Sells")
428
+ {
429
+ if (IFrameSplitOperator.IsNonEmptyArray(item.Value))
430
+ {
431
+ for(var j=0;j<item.Value.length && j<this.Data.Sells.length;++j)
432
+ {
433
+ var srcItem=item.Value[j];
434
+ var destItem=this.Data.Sells[j];
435
+ destItem.Price=srcItem.Price;
436
+ destItem.Vol=srcItem.Vol;
437
+ }
438
+ }
439
+ }
440
+ else if (item.Name=="Symbol")
441
+ {
442
+ this.Data.Symbol=item.Value.Text;
443
+ }
444
+ else
445
+ {
446
+ this.Data.MapData.set(item.Name, item.Value);
447
+ }
448
+ }
449
+ }
450
+
451
+ this.Draw();
452
+ }
453
+
454
+ //创建
455
+ this.Create=function(option)
456
+ {
457
+ this.UIElement.JSChartContainer=this;
458
+
459
+ //创建框架
460
+ this.Frame=new JSStockInfoFrame();
461
+ this.Frame.ChartBorder=new ChartBorder();
462
+ this.Frame.ChartBorder.UIElement=this.UIElement;
463
+ this.Frame.ChartBorder.Top=30;
464
+ this.Frame.ChartBorder.Left=5;
465
+ this.Frame.ChartBorder.Bottom=20;
466
+ this.Frame.Canvas=this.Canvas;
467
+
468
+ //创建表格
469
+ var chart=new ChartStockData();
470
+ chart.Frame=this.Frame;
471
+ chart.ChartBorder=this.Frame.ChartBorder;
472
+ chart.Canvas=this.Canvas;
473
+ chart.UIElement=this.UIElement;
474
+ chart.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
475
+ chart.Data=this.Data;
476
+ chart.BorderData=this.BorderData;
477
+ chart.GlobalOption=this.GlobalOption;
478
+ chart.FixedRowData=this.FixedRowData;
479
+ chart.SortInfo=this.SortInfo;
480
+ this.ChartPaint[0]=chart;
481
+
482
+
483
+ if (option)
484
+ {
485
+
486
+ }
487
+
488
+
489
+
490
+ /*
491
+ this.UIElement.ondblclick=(e)=>{ this.UIOnDblClick(e); }
492
+ this.UIElement.onmousedown=(e)=> { this.UIOnMouseDown(e); }
493
+ this.UIElement.onmousemove=(e)=>{ this.UIOnMouseMove(e);}
494
+ this.UIElement.onmouseout=(e)=>{ this.UIOnMounseOut(e); }
495
+ this.UIElement.onmouseleave=(e)=>{ this.UIOnMouseleave(e); }
496
+ this.UIElement.oncontextmenu=(e)=> { this.UIOnContextMenu(e); }
497
+ */
498
+ }
499
+
500
+ this.Draw=function()
501
+ {
502
+ if (this.UIElement.width<=0 || this.UIElement.height<=0) return;
503
+
504
+ this.Canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);
505
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
506
+ this.Canvas.lineWidth=pixelTatio; //手机端需要根据分辨率比调整线段宽度
507
+
508
+ this.Frame.Draw();
509
+ this.Frame.DrawLogo();
510
+
511
+ //框架内图形
512
+ for(var i=0;i<this.ChartPaint.length;++i)
513
+ {
514
+ var item=this.ChartPaint[i];
515
+ item.Draw();
516
+ }
517
+
518
+ for(var i=0; i<this.ChartPaint.length; ++i)
519
+ {
520
+ var item=this.ChartPaint[i];
521
+ item.Draw();
522
+ }
523
+ }
524
+
525
+ this.OnSize=function()
526
+ {
527
+ if (!this.Frame) return;
528
+
529
+ this.SetSizeChange(true);
530
+ this.Draw();
531
+ }
532
+
533
+ this.SetSizeChange=function(bChanged)
534
+ {
535
+ for(var i=0;i<this.ChartPaint.length;++i)
536
+ {
537
+ var chart=this.ChartPaint[i];
538
+ if (chart) chart.SizeChange=bChanged;
539
+ }
540
+ }
541
+
542
+ this.ReloadResource=function(option)
543
+ {
544
+ this.Frame.ReloadResource(option);
545
+
546
+ for(var i=0;i<this.ChartPaint.length;++i)
547
+ {
548
+ var item=this.ChartPaint[i];
549
+ if (item.ReloadResource) item.ReloadResource(option);
550
+ }
551
+
552
+ if (option && (option.Redraw || option.Draw))
553
+ {
554
+ this.SetSizeChange(true);
555
+ this.Draw();
556
+ }
557
+ }
558
+
559
+ this.SetColumn=function(aryColunm, option)
560
+ {
561
+ var chart=this.ChartPaint[0];
562
+ if (!chart) return;
563
+
564
+ chart.SetColumn(aryColunm);
565
+ chart.SizeChange=true;
566
+
567
+ if (option && option.Redraw) this.Draw();
568
+ }
569
+
570
+ this.SetHeaderColumn=function(aryColunm, option)
571
+ {
572
+ var chart=this.ChartPaint[0];
573
+ if (!chart) return;
574
+
575
+ chart.SetHeaderColumn(aryColunm);
576
+ chart.SizeChange=true;
577
+
578
+ if (option && option.Redraw) this.Draw();
579
+ }
580
+
581
+ this.SetBuySellCount=function(count, option)
582
+ {
583
+ var chart=this.ChartPaint[0];
584
+ if (!chart) return;
585
+
586
+ chart.BuySellCount=count;
587
+ chart.SizeChange=true;
588
+
589
+ if (option && option.Redraw) this.Draw();
590
+ }
591
+ }
592
+
593
+ function JSStockInfoFrame()
594
+ {
595
+ this.ChartBorder;
596
+ this.Canvas; //画布
597
+
598
+ this.BorderLine=null; //1=上 2=下 4=左 8=右
599
+ this.ClassName="JSStockInfoFrame";
600
+
601
+ this.BorderColor=g_JSChartResource.StockInfo.BorderColor; //边框线
602
+
603
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
604
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
605
+
606
+ this.ReloadResource=function(resource)
607
+ {
608
+ this.BorderColor=g_JSChartResource.StockInfo.BorderColor; //边框线
609
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
610
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
611
+ }
612
+
613
+ this.Draw=function()
614
+ {
615
+ var left=ToFixedPoint(this.ChartBorder.GetLeft());
616
+ var top=ToFixedPoint(this.ChartBorder.GetTop());
617
+ var right=ToFixedPoint(this.ChartBorder.GetRight());
618
+ var bottom=ToFixedPoint(this.ChartBorder.GetBottom());
619
+ var width=right-left;
620
+ var height=bottom-top;
621
+
622
+ if (!IFrameSplitOperator.IsNumber(this.BorderLine))
623
+ {
624
+ this.Canvas.strokeStyle=this.BorderColor;
625
+ this.Canvas.strokeRect(left,top,width,height);
626
+ }
627
+ else
628
+ {
629
+ this.Canvas.strokeStyle=this.BorderColor;
630
+ this.Canvas.beginPath();
631
+
632
+ if ((this.BorderLine&1)>0) //上
633
+ {
634
+ this.Canvas.moveTo(left,top);
635
+ this.Canvas.lineTo(right,top);
636
+ }
637
+
638
+ if ((this.BorderLine&2)>0) //下
639
+ {
640
+ this.Canvas.moveTo(left,bottom);
641
+ this.Canvas.lineTo(right,bottom);
642
+ }
643
+
644
+ if ((this.BorderLine&4)>0) //左
645
+ {
646
+ this.Canvas.moveTo(left,top);
647
+ this.Canvas.lineTo(left,bottom);
648
+ }
649
+
650
+ if ((this.BorderLine&8)>0) //右
651
+ {
652
+ this.Canvas.moveTo(right,top);
653
+ this.Canvas.lineTo(right,bottom);
654
+ }
655
+
656
+ this.Canvas.stroke();
657
+ }
658
+ }
659
+
660
+ this.DrawLogo=function()
661
+ {
662
+ var text=g_JSChartResource.FrameLogo.Text;
663
+ if (!IFrameSplitOperator.IsString(text)) return;
664
+
665
+ this.Canvas.fillStyle=this.LogoTextColor;
666
+ this.Canvas.font=this.LogoTextFont;
667
+ this.Canvas.textAlign = 'right';
668
+ this.Canvas.textBaseline = 'bottom';
669
+
670
+ var x=this.ChartBorder.GetRight()-30;
671
+ var y=this.ChartBorder.GetBottom()-5;
672
+ this.Canvas.fillText(text,x,y);
673
+ }
674
+ }
675
+
676
+
677
+ function ChartStockData()
678
+ {
679
+ this.Canvas; //画布
680
+ this.ChartBorder; //边框信息
681
+ this.ChartFrame; //框架画法
682
+ this.Name; //名称
683
+ this.ClassName='ChartStockData'; //类名
684
+ this.UIElement;
685
+ this.GetEventCallback; //获取事件
686
+ this.Data; //数据
687
+ this.BorderData;
688
+ this.SizeChange=true;
689
+ this.Decimal=2; //价格小数位数
690
+
691
+ this.UpColor=g_JSChartResource.StockInfo.UpTextColor;
692
+ this.DownColor=g_JSChartResource.StockInfo.DownTextColor;
693
+ this.UnchangeColor=g_JSChartResource.StockInfo.UnchangeTextColor;
694
+
695
+ this.HeaderConfig=CloneData(g_JSChartResource.StockInfo.Header);
696
+ this.HeaderColumn=
697
+ [
698
+ { Name:"现价", Key:"Price", ColorType:3, FloatPrecision:-1, DefaultText:"--.--" },
699
+ { Name:"涨幅", Key:"Increase", ColorType:1, FloatPrecision:2, StringFormat:"{Value}%", DefaultText:"--.--%" },
700
+ { Name:"涨跌", Key:"UpDown",ColorType:1, FloatPrecision:-1, DefaultText:"--.--" }
701
+ ]
702
+
703
+ //买卖5档配置
704
+ this.BuySellConfig=CloneData(g_JSChartResource.StockInfo.BuySell);
705
+ this.BuySellCount=5; //显示几档买卖盘
706
+
707
+ this.TableConfig=CloneData(g_JSChartResource.StockInfo.Table);
708
+
709
+ //显示的字段
710
+ this.Column=
711
+ [
712
+ [{ Name:"涨停价", Key:"UpLimit",ColorType:3, FloatPrecision:-1 }, { Name:"跌停价", Key:"DownLimit" , ColorType:3, FloatPrecision:-1 }],
713
+ [{ Name:"现价", Key:"Price", ColorType:3, FloatPrecision:-1 }, { Name:"今开", Key:"Open",ColorType:3, FloatPrecision:-1 }],
714
+ [{ Name:"最高", Key:"High",ColorType:3, FloatPrecision:-1 }, { Name:"最低", Key:"Low",ColorType:3, FloatPrecision:-1 }],
715
+ [{ Name:"涨幅", Key:"Increase", ColorType:1, FloatPrecision:2, StringFormat:"{Value}%" }, { Name:"涨跌", Key:"UpDown",ColorType:1, FloatPrecision:-1 }],
716
+ [{ Name:"振幅", Key:"Amplitude", FloatPrecision:2, StringFormat:"{Value}%" }, { Name:"换手率", Key:"Exchange", FloatPrecision:2, StringFormat:"{Value}%" }],
717
+
718
+ [{ Name:"总量", Key:"Vol", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }, { Name:"总额", Key:"Amount", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }],
719
+ [{ Name:"内盘", Key:"InVol", ColorType:4, FloatPrecision:0 }, { Name:"外盘", Key:"OutVol",ColorType:5, FloatPrecision:0 }],
720
+ [{ Name:"TTM", Key:"PE_TTM", FloatPrecision:2 }, { Name:"市净率", Key:"PB", FloatPrecision:2 }],
721
+ [{ Name:"流通市值", Key:"FlowMarketValue", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }, { Name:"总市值", Key:"TotalMarketValue", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }],
722
+ ]
723
+
724
+ this.ReloadResource=function(resource)
725
+ {
726
+ this.UpColor=g_JSChartResource.StockInfo.UpTextColor;
727
+ this.DownColor=g_JSChartResource.StockInfo.DownTextColor;
728
+ this.UnchangeColor=g_JSChartResource.StockInfo.UnchangeTextColor;
729
+
730
+ this.HeaderConfig=CloneData(g_JSChartResource.StockInfo.Header);
731
+
732
+ //买卖5档配置
733
+ this.BuySellConfig=CloneData(g_JSChartResource.StockInfo.BuySell);
734
+
735
+ this.TableConfig=CloneData(g_JSChartResource.StockInfo.Table);
736
+ }
737
+
738
+ this.SetColumn=function(aryColumn)
739
+ {
740
+ this.Column=[];
741
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryColumn)) return;
742
+
743
+ for(var i=0;i<aryColumn.length;++i)
744
+ {
745
+ var item=aryColumn[i];
746
+ if (!item) continue;
747
+ this.Column.push(CloneData(item));
748
+ }
749
+ }
750
+
751
+ this.SetHeaderColumn=function(aryColumn)
752
+ {
753
+ this.HeaderColumn=[];
754
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryColumn)) return;
755
+
756
+ for(var i=0;i<aryColumn.length;++i)
757
+ {
758
+ var item=aryColumn[i];
759
+ if (!item) continue;
760
+ this.HeaderColumn.push(CloneData(item));
761
+ }
762
+ }
763
+
764
+ this.Draw=function()
765
+ {
766
+ this.Decimal=GetfloatPrecision(this.Data.Symbol);
767
+ var border=this.ChartBorder.GetBorder();
768
+ var position = { Left:border.Left, Right:border.Right, Top:border.Top, Width:border.Right-border.Left, Border:border };
769
+ this.DrawHeader(position);
770
+ this.DrawBuySell(position);
771
+ this.DrawTable(position);
772
+ }
773
+
774
+ this.DrawHeader=function(position)
775
+ {
776
+ var config=this.HeaderConfig;
777
+ var top=position.Top;
778
+ var left=position.Left;
779
+ var xText=left;
780
+ var yText=top;
781
+
782
+ this.Canvas.font=config.Name.Font;
783
+ var nameHeight=this.Canvas.measureText("擎").width;
784
+ nameHeight+=config.Name.Margin.Top+config.Name.Margin.Bottom;
785
+
786
+ this.Canvas.font=config.Symbol.Font;
787
+ var symbolHeight=this.Canvas.measureText("擎").width;
788
+ symbolHeight+=config.Symbol.Margin.Top+config.Symbol.Margin.Bottom;
789
+
790
+ var lineHeight=Math.max(symbolHeight, nameHeight);
791
+
792
+ this.Canvas.textAlign = 'left';
793
+ this.Canvas.textBaseline = 'bottom';
794
+ if (this.Data.Name)
795
+ {
796
+ var text=this.Data.Name;
797
+ xText+=config.Name.Margin.Left;
798
+ var yBottom=yText+lineHeight-config.Name.Margin.Bottom+config.Name.Margin.YOffset;
799
+
800
+ this.Canvas.font=config.Name.Font;
801
+ this.Canvas.fillStyle=config.Name.Color;
802
+ this.Canvas.fillText(text,xText,yBottom);
803
+ var textWidth=this.Canvas.measureText(text).width;
804
+
805
+ xText+=textWidth+config.Name.Margin.Right;
806
+ }
807
+
808
+ if (this.Data.Symbol)
809
+ {
810
+ var text=MARKET_SUFFIX_NAME.GetShortSymbol(this.Data.Symbol);
811
+ xText+=config.Symbol.Margin.Left;
812
+ var yBottom=yText+lineHeight-config.Symbol.Margin.Bottom+config.Symbol.Margin.YOffset;
813
+
814
+ this.Canvas.font=config.Symbol.Font;
815
+ this.Canvas.fillStyle=config.Symbol.Color;
816
+ this.Canvas.fillText(text,xText,yBottom);
817
+ var textWidth=this.Canvas.measureText(text).width;
818
+
819
+ xText+=textWidth+config.Symbol.Margin.Right;
820
+ }
821
+
822
+ yText+=lineHeight;
823
+
824
+ if (IFrameSplitOperator.IsNonEmptyArray(this.HeaderColumn))
825
+ {
826
+ lineHeight=0;
827
+ for(var i=0;i<this.HeaderColumn.length && i<config.AryCell.length;++i)
828
+ {
829
+ var subConfig=config.AryCell[i];
830
+ this.Canvas.font=subConfig.Font;
831
+ var textHeight=this.Canvas.measureText("擎").width;
832
+ textHeight+=subConfig.Margin.Top+subConfig.Margin.Bottom;
833
+ if (lineHeight<textHeight) lineHeight=textHeight;
834
+ }
835
+
836
+ var xText=left;
837
+ for(var i=0;i<this.HeaderColumn.length && i<config.AryCell.length;++i)
838
+ {
839
+ var item=this.HeaderColumn[i];
840
+ var text="--.--";
841
+ color=config.TextColor;
842
+ if (item.DefaultText) text=item.DefaultText;
843
+ var subConfig=config.AryCell[i];
844
+ if (this.Data.MapData && this.Data.MapData.has(item.Key))
845
+ {
846
+ var dataItem=this.Data.MapData.get(item.Key);
847
+ var text=this.FormatValue(item, dataItem);
848
+
849
+ if (item.ColorType===3 && IFrameSplitOperator.IsNumber(dataItem.Value))
850
+ color=this.GetPriceColor(dataItem.Value);
851
+ else if (item.ColorType==1 && IFrameSplitOperator.IsNumber(dataItem.Value))
852
+ color=this.GetUpDownColor(dataItem.Value,0);
853
+ else if (item.ColorType==4)
854
+ color=this.UpColor;
855
+ else if (item.ColorType==5)
856
+ color=this.DownColor;
857
+ }
858
+
859
+ if (item.TextColor) color=item.TextColor;
860
+
861
+ if (text)
862
+ {
863
+ this.Canvas.font=subConfig.Font;
864
+ var textWidth=this.Canvas.measureText(text).width;
865
+ var x=xText+subConfig.Margin.Left;
866
+ this.Canvas.fillStyle=color;
867
+ var yBottom=yText+lineHeight-subConfig.Margin.Bottom+subConfig.Margin.YOffset;
868
+ this.Canvas.fillText(text,x,yBottom);
869
+
870
+ xText+=subConfig.Margin.Left+subConfig.Margin.Right+textWidth;
871
+ }
872
+ }
873
+
874
+ yText+=lineHeight;
875
+ }
876
+
877
+ position.Top=yText;
878
+
879
+ if (config.BottomLine && config.BottomLine.Enable)
880
+ {
881
+ var xLeft=position.Border.Left, xRight=position.Border.Right;
882
+ this.Canvas.strokeStyle=config.BottomLine.Color;
883
+ this.Canvas.lineWidth=1*GetDevicePixelRatio();
884
+ this.Canvas.beginPath();
885
+ this.Canvas.moveTo(xLeft,ToFixedPoint(yText));
886
+ this.Canvas.lineTo(xRight,ToFixedPoint(yText));
887
+ this.Canvas.stroke();
888
+ }
889
+ }
890
+
891
+ //买卖5档
892
+ this.DrawBuySell=function(position)
893
+ {
894
+ if (this.BuySellCount<=0) return;
895
+
896
+ var config=this.BuySellConfig;
897
+ var top=position.Top;
898
+ var left=position.Left+config.Margin.Left;
899
+ var cellWidth=(position.Width-config.Margin.Left-config.Margin.Right)/4;
900
+
901
+ var yText=top+config.Margin.Top;
902
+ var xText=left;
903
+
904
+ this.Canvas.font=config.Font;
905
+ this.Canvas.textAlign = 'left';
906
+ this.Canvas.textBaseline = 'bottom';
907
+ var cellHeight=this.Canvas.measureText("擎").width+config.CellMargin.Top+config.CellMargin.Bottom;
908
+ var count=this.BuySellCount;
909
+ var sellVol=0, buyVol=0;
910
+ for(var i=count-1;i>=0;--i)
911
+ {
912
+ xText=left;
913
+ var item=this.Data.Sells[i];
914
+ this.DrawBuySellItem(item, xText, yText, cellWidth, cellHeight);
915
+ if (IFrameSplitOperator.IsNumber(item.Vol)) sellVol+=item.Vol;
916
+ yText+=cellHeight;
917
+ }
918
+
919
+ var yCenter=null;
920
+ if (config.CenterLine) //留出画线的位置
921
+ {
922
+ yCenter=yText;
923
+ var lineConfig=config.CenterLine;
924
+ var lineWidth=lineConfig.Width;
925
+ yText+=lineWidth;
926
+ }
927
+
928
+
929
+ for(var i=0;i<count && i<this.Data.Buys.length;++i)
930
+ {
931
+ xText=left;
932
+ var item=this.Data.Buys[i];
933
+ this.DrawBuySellItem(item, xText, yText, cellWidth, cellHeight);
934
+ if (IFrameSplitOperator.IsNumber(item.Vol)) buyVol+=item.Vol;
935
+ yText+=cellHeight;
936
+ }
937
+
938
+ position.Top=yText;
939
+
940
+ if (IFrameSplitOperator.IsNumber(yCenter) && config.CenterLine)
941
+ {
942
+ var lineConfig=config.CenterLine;
943
+ var xLeft=position.Border.Left, xRight=position.Border.Right;
944
+ var lineWidth=lineConfig.Width;
945
+ if (buyVol+sellVol>0)
946
+ {
947
+ var buyRate=buyVol/(buyVol+sellVol);
948
+ var barWidth=xRight-xLeft;
949
+ var buyWidth=barWidth*buyRate;
950
+ var xCenter=xLeft+buyWidth;
951
+ this.Canvas.lineWidth=lineWidth;
952
+ this.Canvas.strokeStyle=lineConfig.BuyColor;
953
+ this.Canvas.beginPath();
954
+ this.Canvas.moveTo(xLeft,ToFixedPoint2(lineWidth,yCenter));
955
+ this.Canvas.lineTo(xCenter,ToFixedPoint2(lineWidth,yCenter));
956
+ this.Canvas.stroke();
957
+
958
+ this.Canvas.strokeStyle=lineConfig.SellColor;
959
+ this.Canvas.beginPath();
960
+ this.Canvas.moveTo(xCenter,ToFixedPoint2(lineWidth,yCenter,));
961
+ this.Canvas.lineTo(xRight,ToFixedPoint2(lineWidth,yCenter));
962
+ this.Canvas.stroke();
963
+ }
964
+ else
965
+ {
966
+ this.Canvas.strokeStyle=lineConfig.NoneColor;
967
+ this.Canvas.lineWidth=lineWidth;
968
+ this.Canvas.beginPath();
969
+ this.Canvas.moveTo(xLeft,ToFixedPoint2(lineWidth,yCenter));
970
+ this.Canvas.lineTo(xRight,ToFixedPoint2(lineWidth,yCenter));
971
+ this.Canvas.stroke();
972
+ }
973
+ }
974
+
975
+ if (config.BottomLine && config.BottomLine.Enable)
976
+ {
977
+ var xLeft=position.Border.Left, xRight=position.Border.Right;
978
+ this.Canvas.strokeStyle=config.BottomLine.Color;
979
+ this.Canvas.lineWidth=1*GetDevicePixelRatio();
980
+ this.Canvas.beginPath();
981
+ this.Canvas.moveTo(xLeft,ToFixedPoint(yText));
982
+ this.Canvas.lineTo(xRight,ToFixedPoint(yText));
983
+ this.Canvas.stroke();
984
+ }
985
+
986
+ if (config.TopLine && config.TopLine.Enable)
987
+ {
988
+ var xLeft=position.Border.Left, xRight=position.Border.Right;
989
+ this.Canvas.strokeStyle=config.BottomLine.Color;
990
+ this.Canvas.lineWidth=1*GetDevicePixelRatio();
991
+ this.Canvas.beginPath();
992
+ this.Canvas.moveTo(xLeft,ToFixedPoint(top));
993
+ this.Canvas.lineTo(xRight,ToFixedPoint(top));
994
+ this.Canvas.stroke();
995
+ }
996
+ }
997
+
998
+ this.DrawBuySellItem=function(item, left, top, cellWidth, cellHeight)
999
+ {
1000
+ var config=this.BuySellConfig;
1001
+ var xText=left;
1002
+ var yBottom=top+cellHeight-config.CellMargin.Bottom+config.CellMargin.YOffset;
1003
+
1004
+ if (item.Name)
1005
+ {
1006
+ this.Canvas.fillStyle=config.TitleColor;
1007
+ this.Canvas.fillText(item.Name,xText+config.CellMargin.Left,yBottom);
1008
+ }
1009
+ xText+=cellWidth;
1010
+
1011
+ if (IFrameSplitOperator.IsNumber(item.Price))
1012
+ {
1013
+ var text=item.Price.toFixed(this.Decimal);
1014
+ var textWidth=this.Canvas.measureText(text).width;
1015
+ var x=xText+cellWidth-textWidth-config.CellMargin.Right;
1016
+ this.Canvas.fillStyle=this.GetPriceColor(item.Price);
1017
+ this.Canvas.fillText(text,x,yBottom);
1018
+ }
1019
+ xText+=cellWidth;
1020
+
1021
+ xText+=cellWidth;
1022
+
1023
+ if (IFrameSplitOperator.IsNumber(item.Vol))
1024
+ {
1025
+ var text=item.Vol.toFixed(0);
1026
+ var textWidth=this.Canvas.measureText(text).width;
1027
+ var x=xText+cellWidth-textWidth-config.CellMargin.Right;
1028
+ this.Canvas.fillStyle=config.VolColor;
1029
+ this.Canvas.fillText(text,x,yBottom);
1030
+ }
1031
+ }
1032
+
1033
+
1034
+ this.DrawTable=function(position)
1035
+ {
1036
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Column)) return;
1037
+
1038
+ var config=this.TableConfig;
1039
+ var top=position.Top;
1040
+ var left=position.Left+config.Margin.Left;
1041
+ var cellWidth=(position.Width-config.Margin.Left-config.Margin.Right)/4;
1042
+
1043
+ var yText=top+config.Margin.Top;
1044
+ var xText=left;
1045
+
1046
+ this.Canvas.font=config.Font;
1047
+ this.Canvas.textAlign = 'left';
1048
+ this.Canvas.textBaseline = 'bottom';
1049
+ var cellHeight=this.Canvas.measureText("擎").width+config.CellMargin.Top+config.CellMargin.Bottom;
1050
+
1051
+ for(var i=0;i<this.Column.length;++i)
1052
+ {
1053
+ xText=left;
1054
+ var item=this.Column[i];
1055
+ if (!item || !IFrameSplitOperator.IsNonEmptyArray(item)) continue;
1056
+ this.DrawRowItem(item, xText, yText, cellWidth, cellHeight);
1057
+
1058
+ yText+=cellHeight;
1059
+ }
1060
+ }
1061
+
1062
+ this.DrawRowItem=function(aryData, left, top, cellWidth, cellHeight)
1063
+ {
1064
+ var config=this.TableConfig;
1065
+ var xText=left;
1066
+ var yBottom=top+cellHeight-config.CellMargin.Bottom+config.CellMargin.YOffset;
1067
+
1068
+ for(var i=0;i<aryData.length && i<2;++i)
1069
+ {
1070
+ var item=aryData[i];
1071
+ if (item)
1072
+ {
1073
+ if (item.Name)
1074
+ {
1075
+ this.Canvas.fillStyle=config.TitleColor;
1076
+ this.Canvas.fillText(item.Name,xText+config.CellMargin.Left,yBottom);
1077
+ }
1078
+ xText+=cellWidth;
1079
+
1080
+ if (this.Data.MapData && this.Data.MapData.has(item.Key))
1081
+ {
1082
+ var dataItem=this.Data.MapData.get(item.Key);
1083
+ color=config.TextColor;
1084
+
1085
+ var text=this.FormatValue(item, dataItem);
1086
+
1087
+ if (item.ColorType===3 && IFrameSplitOperator.IsNumber(dataItem.Value))
1088
+ color=this.GetPriceColor(dataItem.Value);
1089
+ else if (item.ColorType==1 && IFrameSplitOperator.IsNumber(dataItem.Value))
1090
+ color=this.GetUpDownColor(dataItem.Value,0);
1091
+ else if (item.ColorType==4)
1092
+ color=this.UpColor;
1093
+ else if (item.ColorType==5)
1094
+ color=this.DownColor;
1095
+
1096
+ if (item.TextColor) color=item.TextColor;
1097
+
1098
+ if (text)
1099
+ {
1100
+ if (i==0 && item.ShowType==1) //整行显示
1101
+ {
1102
+ var textWidth=this.Canvas.measureText(text).width;
1103
+ var x=xText+(cellWidth*3)-textWidth-config.CellMargin.Right;
1104
+ this.Canvas.fillStyle=color;
1105
+ this.Canvas.fillText(text,x,yBottom);
1106
+ break;
1107
+ }
1108
+ else
1109
+ {
1110
+ var textWidth=this.Canvas.measureText(text).width;
1111
+ var x=xText+cellWidth-textWidth-config.CellMargin.Right;
1112
+ this.Canvas.fillStyle=color;
1113
+ this.Canvas.fillText(text,x,yBottom);
1114
+ }
1115
+
1116
+ }
1117
+ }
1118
+ xText+=cellWidth;
1119
+ }
1120
+ else
1121
+ {
1122
+ xText+=cellWidth+cellWidth;
1123
+ }
1124
+ }
1125
+
1126
+ }
1127
+
1128
+
1129
+ this.FormatValue=function(column, data)
1130
+ {
1131
+ var dec=0; //小数位数
1132
+ if (IFrameSplitOperator.IsNumber(column.FloatPrecision))
1133
+ {
1134
+ if (column.FloatPrecision===-1) dec=this.Decimal;
1135
+ else dec=column.FloatPrecision;
1136
+ }
1137
+
1138
+ var text=null;
1139
+ if (!data) return text;
1140
+
1141
+ if (data.Text)
1142
+ {
1143
+ text=data.Text;
1144
+ }
1145
+ else if (IFrameSplitOperator.IsNumber(data.Value))
1146
+ {
1147
+ var value=data.Value;
1148
+ text=value.toFixed(dec);
1149
+
1150
+ //格式化
1151
+ if (column.Format && IFrameSplitOperator.IsNumber(column.Format.Type))
1152
+ {
1153
+ var format=column.Format;
1154
+ switch(format.Type)
1155
+ {
1156
+ case 1: //原始数据
1157
+ text=value.toFixed(dec);
1158
+ break;
1159
+ case 2: //千分位分割
1160
+ text=IFrameSplitOperator.FormatValueThousandsString(value, dec);
1161
+ break;
1162
+ case 3:
1163
+ var exfloatPrecision=1;
1164
+ if (IFrameSplitOperator.IsNumber(format.ExFloatPrecision)) exfloatPrecision=format.ExFloatPrecision;
1165
+ text=IFrameSplitOperator.FormatValueStringV2(value, dec,exfloatPrecision);
1166
+ break;
1167
+ }
1168
+ }
1169
+ }
1170
+
1171
+ if (column.StringFormat && text) text=column.StringFormat.replace('{Value}',text);
1172
+
1173
+ return text;
1174
+ }
1175
+
1176
+ this.GetPriceColor=function(price)
1177
+ {
1178
+ var upperSymbol=null;
1179
+ if (this.Data.Symbol) upperSymbol=this.Data.Symbol.toUpperCase();
1180
+ if (MARKET_SUFFIX_NAME.IsChinaFutures(upperSymbol))
1181
+ {
1182
+ if (!IFrameSplitOperator.IsNumber(this.Data.YFClose)) return this.UnchangeColor;
1183
+ return this.GetUpDownColor(price, this.Data.YFClose);
1184
+ }
1185
+ else
1186
+ {
1187
+ if (!IFrameSplitOperator.IsNumber(this.Data.YClose)) return this.UnchangeColor;
1188
+ return this.GetUpDownColor(price, this.Data.YClose);
1189
+ }
1190
+ }
1191
+
1192
+ this.GetUpDownColor=function(price, price2)
1193
+ {
1194
+ if (price>price2) return this.UpColor;
1195
+ else if (price<price2) return this.DownColor;
1196
+ else return this.UnchangeColor;
1197
+ }
1198
+ }
1199
+
1200
+
1201
+
1202
+
1203
+
1204
+
1205
+