hqchart 1.1.13081 → 1.1.13085

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,2267 @@
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
+ 封装T型报价列表控件 (H5版本)
11
+ 不提供内置测试数据
12
+ */
13
+
14
+ function JSTReportChart(divElement)
15
+ {
16
+ this.DivElement=divElement;
17
+ this.JSChartContainer; //表格控件
18
+
19
+ //h5 canvas
20
+ this.CanvasElement=document.createElement("canvas");
21
+ this.CanvasElement.className='jstreport-drawing';
22
+ this.CanvasElement.id=Guid();
23
+ this.CanvasElement.setAttribute("tabindex",0);
24
+ if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
25
+ if(divElement.hasChildNodes())
26
+ {
27
+ JSConsole.Chart.Log("[JSTReportChart::JSReportChart] divElement hasChildNodes", divElement.childNodes);
28
+ }
29
+ divElement.appendChild(this.CanvasElement);
30
+
31
+
32
+ this.OnSize=function()
33
+ {
34
+ //画布大小通过div获取
35
+ var height=parseInt(this.DivElement.style.height.replace("px",""));
36
+ this.CanvasElement.height=height;
37
+ this.CanvasElement.width=parseInt(this.DivElement.style.width.replace("px",""));
38
+ this.CanvasElement.style.width=this.CanvasElement.width+'px';
39
+ this.CanvasElement.style.height=this.CanvasElement.height+'px';
40
+
41
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
42
+ this.CanvasElement.height*=pixelTatio;
43
+ this.CanvasElement.width*=pixelTatio;
44
+
45
+ JSConsole.Chart.Log(`[JSTReportChart::OnSize] devicePixelRatio=${window.devicePixelRatio}, height=${this.CanvasElement.height}, width=${this.CanvasElement.width}`);
46
+
47
+ if (this.JSChartContainer && this.JSChartContainer.OnSize)
48
+ {
49
+ this.JSChartContainer.OnSize();
50
+ }
51
+ }
52
+
53
+ this.SetOption=function(option)
54
+ {
55
+ var chart=this.CreateJSTReportChartContainer(option);
56
+
57
+ if (!chart) return false;
58
+
59
+ if (option.OnCreatedCallback) option.OnCreatedCallback(chart);
60
+
61
+ this.JSChartContainer=chart;
62
+ this.DivElement.JSChart=this; //div中保存一份
63
+
64
+ if (option.Symbol)
65
+ {
66
+ chart.Draw();
67
+
68
+ var name=option.Symbol;
69
+ if (option.Name) name=option.Name;
70
+ chart.ChangeSymbol(option.Symbol, {Name:name}); //下载列表码表
71
+ }
72
+
73
+ }
74
+
75
+ this.CreateJSTReportChartContainer=function(option)
76
+ {
77
+ var chart=new JSTReportChartContainer(this.CanvasElement);
78
+ chart.Create(option);
79
+
80
+ if (option.NetworkFilter) chart.NetworkFilter=option.NetworkFilter;
81
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) chart.SetColumn(option.Column);
82
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Tab)) chart.SetTab(option.Tab);
83
+ if (IFrameSplitOperator.IsNumber(option.TabSelected)) chart.SetSelectedTab(option.TabSelected);
84
+ if (IFrameSplitOperator.IsBool(option.EnableDragRow)) chart.EnableDragRow=option.EnableDragRow;
85
+ if (IFrameSplitOperator.IsNumber(option.DragRowType)) chart.DragRowType=option.DragRowType;
86
+ if (IFrameSplitOperator.IsBool(option.EnableDragHeader)) chart.EnableDragHeader=option.EnableDragHeader;
87
+ if (option.SortInfo)
88
+ {
89
+ var item=option.SortInfo;
90
+ if (IFrameSplitOperator.IsNumber(item.Field)) chart.SortInfo.Field=item.Field;
91
+ if (IFrameSplitOperator.IsNumber(item.Sort)) chart.SortInfo.Sort=item.Sort;
92
+ }
93
+
94
+ this.SetChartBorder(chart, option);
95
+
96
+ //是否自动更新
97
+ if (option.IsAutoUpdate!=null) chart.IsAutoUpdate=option.IsAutoUpdate;
98
+ if (option.AutoUpdateFrequency>0) chart.AutoUpdateFrequency=option.AutoUpdateFrequency;
99
+ if (IFrameSplitOperator.IsBool(option.EnableFilter)) chart.EnableFilter=option.EnableFilter;
100
+
101
+ //注册事件
102
+ if (option.EventCallback)
103
+ {
104
+ for(var i=0;i<option.EventCallback.length;++i)
105
+ {
106
+ var item=option.EventCallback[i];
107
+ chart.AddEventCallback(item);
108
+ }
109
+ }
110
+
111
+ return chart;
112
+ }
113
+
114
+ this.SetChartBorder=function(chart, option)
115
+ {
116
+ if (!option.Border) return;
117
+
118
+ var item=option.Border;
119
+ if (IFrameSplitOperator.IsNumber(option.Border.Left)) chart.Frame.ChartBorder.Left=option.Border.Left;
120
+ if (IFrameSplitOperator.IsNumber(option.Border.Right)) chart.Frame.ChartBorder.Right=option.Border.Right;
121
+ if (IFrameSplitOperator.IsNumber(option.Border.Top)) chart.Frame.ChartBorder.Top=option.Border.Top;
122
+ if (IFrameSplitOperator.IsNumber(option.Border.Bottom)) chart.Frame.ChartBorder.Bottom=option.Border.Bottom;
123
+
124
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
125
+ chart.Frame.ChartBorder.Left*=pixelTatio;
126
+ chart.Frame.ChartBorder.Right*=pixelTatio;
127
+ chart.Frame.ChartBorder.Top*=pixelTatio;
128
+ chart.Frame.ChartBorder.Bottom*=pixelTatio;
129
+ }
130
+
131
+ /////////////////////////////////////////////////////////////////////////////
132
+ //对外接口
133
+
134
+ //切换股票代码接口
135
+ this.ChangeSymbol=function(symbol, option)
136
+ {
137
+ if (this.JSChartContainer) this.JSChartContainer.ChangeSymbol(symbol,option);
138
+ }
139
+
140
+ this.SetColumn=function(aryColumn, option)
141
+ {
142
+ if (this.JSChartContainer) this.JSChartContainer.SetColumn(aryColumn,option);
143
+ }
144
+
145
+ //事件回调
146
+ this.AddEventCallback=function(obj)
147
+ {
148
+ if(this.JSChartContainer && typeof(this.JSChartContainer.AddEventCallback)=='function')
149
+ {
150
+ JSConsole.Chart.Log('[JSTReportChart:AddEventCallback] obj=', obj);
151
+ this.JSChartContainer.AddEventCallback(obj);
152
+ }
153
+ }
154
+
155
+ //重新加载配置
156
+ this.ReloadResource=function(option)
157
+ {
158
+ if(this.JSChartContainer && typeof(this.JSChartContainer.ReloadResource)=='function')
159
+ {
160
+ JSConsole.Chart.Log('[JSTReportChart:ReloadResource] ');
161
+ this.JSChartContainer.ReloadResource(option);
162
+ }
163
+ }
164
+
165
+ this.ChartDestory=function()
166
+ {
167
+ if (this.JSChartContainer && typeof (this.JSChartContainer.ChartDestory) == 'function')
168
+ {
169
+ this.JSChartContainer.ChartDestory();
170
+ }
171
+ }
172
+
173
+ this.Draw=function()
174
+ {
175
+ if(this.JSChartContainer && typeof(this.JSChartContainer.Draw)=='function')
176
+ {
177
+ JSConsole.Chart.Log('[JSTReportChart:Draw] ');
178
+ this.JSChartContainer.Draw();
179
+ }
180
+ }
181
+ }
182
+
183
+ JSTReportChart.Init=function(divElement)
184
+ {
185
+ var jsChartControl=new JSTReportChart(divElement);
186
+ jsChartControl.OnSize();
187
+
188
+ return jsChartControl;
189
+ }
190
+
191
+ //自定义风格
192
+ JSTReportChart.SetStyle=function(option)
193
+ {
194
+ if (option) g_JSChartResource.SetStyle(option);
195
+ }
196
+
197
+ //获取颜色配置 (设置配必须啊在JSChart.Init()之前)
198
+ JSTReportChart.GetResource=function()
199
+ {
200
+ return g_JSChartResource;
201
+ }
202
+
203
+ function HQTReportItem()
204
+ {
205
+ this.Symbol;
206
+ this.Name;
207
+ this.YClose;
208
+ this.Open;
209
+ this.Price;
210
+ this.High;
211
+ this.Low;
212
+ this.Amount;
213
+ this.Vol;
214
+ this.Positon; //持仓量
215
+
216
+ this.Increase; //涨幅
217
+ this.UpDown; //涨跌
218
+ this.Exchange; //换手
219
+ this.Amplitude; //振幅
220
+
221
+ this.BuyPrice; //买价/量
222
+ this.BuyVol;
223
+ this.SellPrice; //卖价/量
224
+ this.SellVol;
225
+
226
+ this.AvPrice; //均价
227
+
228
+ this.LimitHigh; //涨停价
229
+ this.LimitLow; //跌停价
230
+
231
+ this.CloseLine; //{Data:[], Max:, Min:, Count: }
232
+
233
+ this.ExtendData; //扩展数据
234
+ }
235
+
236
+ function JSTReportChartContainer(uielement)
237
+ {
238
+ this.ClassName='JSTReportChartContainer';
239
+ this.Frame; //框架画法
240
+ this.ChartPaint=[]; //图形画法
241
+ this.ChartSplashPaint=null; //等待提示
242
+ this.LoadDataSplashTitle="数据加载中"; //下载数据提示信息
243
+
244
+ this.SplashTitle={ StockList:"下载码表中....." } ;
245
+ this.Canvas=uielement.getContext("2d"); //画布
246
+
247
+ this.Tooltip=document.createElement("div");
248
+ this.Tooltip.className='jstreport-tooltip';
249
+ this.Tooltip.style.background=g_JSChartResource.TooltipBGColor;
250
+ this.Tooltip.style.opacity=g_JSChartResource.TooltipAlpha;
251
+ this.Tooltip.style["pointer-events"]="none";
252
+ this.Tooltip.id=Guid();
253
+ uielement.parentNode.appendChild(this.Tooltip);
254
+
255
+ this.Symbol; //期权对应的品种代码
256
+ this.Name; //期权对应的品种名称
257
+ this.NetworkFilter; //数据回调接口
258
+ this.Data={ XOffset:0, YOffset:0, Data:[], BaseExePrice:null }; //股票列表 BaseExePrice=基准
259
+ this.BorderData={ MapData:null }; //key=Field Value:[null, {ExePrice} ,{ExePrice} ]
260
+ this.SourceData={ Data:[] } ; //原始股票顺序(排序还原用) {ExePrice=行权价格 LeftData:, RightData}
261
+
262
+ this.DelayUpdateTimer=null; //延迟更新
263
+ this.DelayUpdateFrequency=500; //延迟更新时间
264
+
265
+ this.MapStockData;
266
+ this.MapExePriceData;
267
+
268
+ this.FlashBG=new Map();
269
+ this.FlashBGTimer=null; //闪烁背景 Value:{ LastTime:数据最后的时间, Data: { Key:ID, BGColor:, Time: , Count: 次数 } };
270
+ this.GlobalOption={ FlashBGCount:0 }
271
+
272
+ this.SortInfo={ Field:-1, Sort:0 }; //排序信息 {Field:排序字段id, Sort:0 不排序 1升序 2降序 }
273
+
274
+ //事件回调
275
+ this.mapEvent=new Map(); //通知外部调用 key:JSCHART_EVENT_ID value:{Callback:回调,}
276
+
277
+ this.AutoUpdateTimer=null;
278
+ this.AutoUpdateFrequency=15000; //15秒更新一次数据
279
+
280
+ this.UIElement=uielement;
281
+ this.LastPoint=new Point(); //鼠标位置
282
+ this.IsOnTouch=false;
283
+ this.TouchDrag;
284
+ this.TouchMoveMinAngle=70; //左右移动最小角度
285
+ this.YStepPixel=5*GetDevicePixelRatio();
286
+ this.XStepPixel=10*GetDevicePixelRatio();
287
+
288
+ //拖拽滚动条
289
+ this.DragXScroll=null; //{Start:{x,y}, End:{x, y}}
290
+
291
+ this.IsDestroy=false; //是否已经销毁了
292
+
293
+ this.ChartDestory=function() //销毁
294
+ {
295
+ this.IsDestroy=true;
296
+ this.StopAutoUpdate();
297
+ }
298
+
299
+ //创建
300
+ this.Create=function(option)
301
+ {
302
+ this.UIElement.JSChartContainer=this;
303
+
304
+ //创建等待提示
305
+ this.ChartSplashPaint = new ChartSplashPaint();
306
+ this.ChartSplashPaint.Canvas = this.Canvas;
307
+ this.ChartSplashPaint.SetTitle(this.LoadDataSplashTitle);
308
+ this.ChartSplashPaint.IsEnableSplash=true;
309
+
310
+ //创建框架
311
+ this.Frame=new JSTReportFrame();
312
+ this.Frame.ChartBorder=new ChartBorder();
313
+ this.Frame.ChartBorder.UIElement=this.UIElement;
314
+ this.Frame.ChartBorder.Top=30;
315
+ this.Frame.ChartBorder.Left=5;
316
+ this.Frame.ChartBorder.Bottom=20;
317
+ this.Frame.Canvas=this.Canvas;
318
+
319
+ this.ChartSplashPaint.Frame = this.Frame;
320
+
321
+ //创建表格
322
+ var chart=new ChartTReport();
323
+ chart.Frame=this.Frame;
324
+ chart.ChartBorder=this.Frame.ChartBorder;
325
+ chart.Canvas=this.Canvas;
326
+ chart.UIElement=this.UIElement;
327
+ chart.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
328
+ chart.GetExePriceDataCallback=(exePrice)=>{ return this.GetExePriceData(exePrice);}
329
+ chart.GetFlashBGDataCallback=(symbol, time)=>{ return this.GetFlashBGData(symbol, time); }
330
+ chart.Data=this.Data;
331
+ chart.BorderData=this.BorderData;
332
+ chart.GlobalOption=this.GlobalOption;
333
+ chart.SortInfo=this.SortInfo;
334
+ this.ChartPaint[0]=chart;
335
+
336
+
337
+ if (option)
338
+ {
339
+ if (IFrameSplitOperator.IsBool(option.IsShowHeader)) chart.IsShowHeader=option.IsShowHeader; //是否显示表头
340
+ if (IFrameSplitOperator.IsNumber(option.FixedColumn)) chart.FixedColumn=option.FixedColumn; //固定列
341
+
342
+ if (IFrameSplitOperator.IsNumber(option.BorderLine)) this.Frame.BorderLine=option.BorderLine; //边框
343
+ if (IFrameSplitOperator.IsBool(option.ItemBorder)) chart.IsDrawBorder=option.ItemBorder; //单元格边框
344
+ if (IFrameSplitOperator.IsNumber(option.SelectedModel)) chart.SelectedModel=option.SelectedModel;
345
+ }
346
+
347
+ var bRegisterKeydown=true;
348
+ var bRegisterWheel=true;
349
+
350
+ if (option)
351
+ {
352
+ if (option.KeyDown===false)
353
+ {
354
+ bRegisterKeydown=false;
355
+ JSConsole.Chart.Log('[JSTReportChartContainer::Create] not register keydown event.');
356
+ }
357
+
358
+ if (option.Wheel===false)
359
+ {
360
+ bRegisterWheel=false;
361
+ JSConsole.Chart.Log('[JSTReportChartContainer::Create] not register wheel event.');
362
+ }
363
+ }
364
+
365
+ if (bRegisterKeydown) this.UIElement.addEventListener("keydown", (e)=>{ this.OnKeyDown(e); }, true); //键盘消息
366
+ if (bRegisterWheel) this.UIElement.addEventListener("wheel", (e)=>{ this.OnWheel(e); }, true); //上下滚动消息
367
+
368
+
369
+ this.UIElement.ondblclick=(e)=>{ this.UIOnDblClick(e); }
370
+ this.UIElement.onmousedown=(e)=> { this.UIOnMouseDown(e); }
371
+
372
+ /*
373
+ this.UIElement.onmouseup=(e)=>{ this.UIOnMounseUp(e); }
374
+ this.UIElement.oncontextmenu=(e)=> { this.UIOnContextMenu(e); }
375
+ this.UIElement.onmousemove=(e)=>{ this.UIOnMouseMove(e);}
376
+ this.UIElement.onmouseout=(e)=>{ this.UIOnMounseOut(e); }
377
+ this.UIElement.onmouseleave=(e)=>{ this.UIOnMouseleave(e); }
378
+
379
+
380
+ //手机拖拽
381
+ this.UIElement.ontouchstart=(e)=> { this.OnTouchStart(e); }
382
+ this.UIElement.ontouchmove=(e)=> {this.OnTouchMove(e); }
383
+ this.UIElement.ontouchend=(e)=> {this.OnTouchEnd(e); }
384
+ */
385
+ }
386
+
387
+ this.Draw=function()
388
+ {
389
+ if (this.UIElement.width<=0 || this.UIElement.height<=0) return;
390
+
391
+ this.Canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);
392
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
393
+ this.Canvas.lineWidth=pixelTatio; //手机端需要根据分辨率比调整线段宽度
394
+
395
+ if (this.ChartSplashPaint && this.ChartSplashPaint.IsEnableSplash)
396
+ {
397
+ this.Frame.Draw( { IsEnableSplash:this.ChartSplashPaint.IsEnableSplash} );
398
+ this.ChartSplashPaint.Draw();
399
+ return;
400
+ }
401
+
402
+ this.Frame.Draw();
403
+ this.Frame.DrawLogo();
404
+
405
+ //框架内图形
406
+ for(var i=0;i<this.ChartPaint.length;++i)
407
+ {
408
+ var item=this.ChartPaint[i];
409
+ if (item.IsDrawFirst)
410
+ item.Draw();
411
+ }
412
+
413
+ for(var i=0; i<this.ChartPaint.length; ++i)
414
+ {
415
+ var item=this.ChartPaint[i];
416
+ if (!item.IsDrawFirst)
417
+ item.Draw();
418
+ }
419
+
420
+ if (this.GlobalOption.FlashBGCount>0)
421
+ {
422
+ this.DelayDraw(500);
423
+ }
424
+ }
425
+
426
+ this.DelayDraw=function(frequency)
427
+ {
428
+ if (typeof (this.FlashBGTimer) == 'number')
429
+ {
430
+ clearTimeout(this.FlashBGTimer);
431
+ this.FlashBGTimer = null;
432
+ }
433
+
434
+ this.FlashBGTimer=setTimeout(()=>
435
+ {
436
+ this.Draw();
437
+ },frequency);
438
+ }
439
+
440
+ this.ClearData=function()
441
+ {
442
+ this.SourceData.Data=[];
443
+ this.Data.Data=[];
444
+ this.Data.BaseExePrice=null;
445
+ this.MapStockData=null;
446
+ this.MapExePriceData=null;
447
+ this.BorderData.MapData=null;
448
+ }
449
+
450
+ this.StopAutoUpdate=function()
451
+ {
452
+ this.CancelAutoUpdate();
453
+ this.AutoUpdateEvent(false,'JSTReportChartContainer::StopAutoUpdate');
454
+ if (!this.IsAutoUpdate) return;
455
+ this.IsAutoUpdate=false;
456
+ }
457
+
458
+ //设置事件回调
459
+ //{event:事件id, callback:回调函数}
460
+ this.AddEventCallback=function(object)
461
+ {
462
+ if (!object || !object.event || !object.callback) return;
463
+
464
+ var data={Callback:object.callback, Source:object};
465
+ this.mapEvent.set(object.event,data);
466
+ }
467
+
468
+ this.RemoveEventCallback=function(eventid)
469
+ {
470
+ if (!this.mapEvent.has(eventid)) return;
471
+
472
+ this.mapEvent.delete(eventid);
473
+ }
474
+
475
+ this.GetEventCallback=function(id) //获取事件回调
476
+ {
477
+ if (!this.mapEvent.has(id)) return null;
478
+ var item=this.mapEvent.get(id);
479
+ return item;
480
+ }
481
+
482
+ this.OnSize=function()
483
+ {
484
+ if (!this.Frame) return;
485
+
486
+ this.SetSizeChange(true);
487
+ this.Draw();
488
+ this.DelayUpdateStockData();
489
+ }
490
+
491
+ this.SetSizeChange=function(bChanged)
492
+ {
493
+ for(var i=0;i<this.ChartPaint.length;++i)
494
+ {
495
+ var chart=this.ChartPaint[i];
496
+ if (chart) chart.SizeChange=bChanged;
497
+ }
498
+ }
499
+
500
+ this.ChangeSymbol=function(symbol, option)
501
+ {
502
+ this.CancelAutoUpdate();
503
+ this.ClearData();
504
+ this.Symbol=symbol;
505
+ this.Name=symbol;
506
+ if (option)
507
+ {
508
+ if (option.Name) this.Name=option.Name;
509
+ }
510
+
511
+ this.RequestStockListData();
512
+ }
513
+
514
+ this.CancelAutoUpdate=function() //关闭停止更新
515
+ {
516
+ if (typeof (this.AutoUpdateTimer) == 'number')
517
+ {
518
+ clearTimeout(this.AutoUpdateTimer);
519
+ this.AutoUpdateTimer = null;
520
+ }
521
+ }
522
+
523
+ this.SetColumn=function(aryColunm, option)
524
+ {
525
+ var chart=this.ChartPaint[0];
526
+ if (!chart) return;
527
+
528
+ chart.SetColumn(aryColunm);
529
+ chart.SizeChange=true;
530
+
531
+ if (option && option.Redraw) this.Draw();
532
+ }
533
+
534
+ //请求列表
535
+ this.RequestStockListData=function()
536
+ {
537
+ this.ChartSplashPaint.SetTitle(this.SplashTitle.StockList);
538
+ this.ChartSplashPaint.EnableSplash(true);
539
+ this.Draw();
540
+
541
+ var self=this;
542
+ if (this.NetworkFilter)
543
+ {
544
+ var obj=
545
+ {
546
+ Name:'JSTReportChartContainer::RequestStockListData', //类名::
547
+ Explain:'T型报价列表数据',
548
+ Self:this,
549
+ PreventDefault:false
550
+ };
551
+
552
+ this.NetworkFilter(obj, function(data)
553
+ {
554
+ if (!data) return;
555
+ if (data.symbol!=self.Symbol) return;
556
+
557
+ self.ChartSplashPaint.EnableSplash(false);
558
+ self.RecvStockListData(data);
559
+ });
560
+
561
+ if (obj.PreventDefault==true) return; //已被上层替换,不调用默认的网络请求
562
+ }
563
+
564
+ throw { Name:'JSTReportChartContainer::RequestStockListData', Error:'(T型报价列表数据)不提供内置测试数据' };
565
+ }
566
+
567
+ this.RecvStockListData=function(data)
568
+ {
569
+ if (IFrameSplitOperator.IsNonEmptyArray(data.data))
570
+ {
571
+ this.MapExePriceData=new Map();
572
+ this.MapStockData=new Map();
573
+ //0=行权价格 1=左边期权代码 2=右侧期权代码 3=左侧期权名称 4=右侧期权名称
574
+ for(var i=0;i<data.data.length;++i)
575
+ {
576
+ var item=data.data[i];
577
+ var exePrice=item[0];
578
+
579
+ var leftData=new HQTReportItem();
580
+ leftData.Symbol=leftData.Name=item[1];
581
+ if (item[3]) leftData.Name=item[3];
582
+
583
+ var rightData=new HQTReportItem();
584
+ rightData.Symbol=rightData.Name=item[2];
585
+ if (item[4]) rightData.Name=item[4];
586
+
587
+ this.MapStockData.set(leftData.Symbol, leftData);
588
+ this.MapStockData.set(rightData.Symbol, rightData);
589
+
590
+ var dataItem={ ExePrice:exePrice, LeftData:leftData, RightData:rightData };
591
+ this.MapExePriceData.set(dataItem.ExePrice, dataItem);
592
+
593
+ this.SourceData.Data.push(exePrice);
594
+ this.Data.Data.push(exePrice);
595
+ }
596
+ }
597
+
598
+ if (IFrameSplitOperator.IsNumber(data.baseExePrice))
599
+ {
600
+ this.Data.BaseExePrice=data.baseExePrice;
601
+ }
602
+
603
+ this.Draw();
604
+
605
+ this.UpdateStockData();
606
+ }
607
+
608
+ this.GetExePriceData=function(exePrice)
609
+ {
610
+ if (!this.MapExePriceData) return null;
611
+ if (!this.MapExePriceData.has(exePrice)) return null;
612
+
613
+ return this.MapExePriceData.get(exePrice);
614
+ }
615
+
616
+ this.UpdateStockData=function()
617
+ {
618
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
619
+ if (this.MapStockData.size<=0) return;
620
+
621
+ var arySymbol=[];
622
+ for(var mapItem of this.MapStockData)
623
+ {
624
+ arySymbol.push(mapItem[0]);
625
+ }
626
+
627
+ if (!IFrameSplitOperator.IsNonEmptyArray(arySymbol)) return;
628
+ this.RequestStockData(arySymbol);
629
+ }
630
+
631
+ //下载期权数据
632
+ this.RequestStockData=function(arySymbol)
633
+ {
634
+ var self=this;
635
+ if (this.NetworkFilter)
636
+ {
637
+ var obj=
638
+ {
639
+ Name:'JSTReportChartContainer::RequestStockData', //类名::函数名
640
+ Explain:'T型报价列表期权数据',
641
+ Request:{ Data: { stocks: arySymbol, symbol:this.Symbol } },
642
+ Self:this,
643
+ PreventDefault:false
644
+ };
645
+
646
+ this.NetworkFilter(obj, function(data)
647
+ {
648
+ self.RecvStockData(data);
649
+ self.AutoUpdate();
650
+ });
651
+
652
+ if (obj.PreventDefault==true) return;
653
+ }
654
+
655
+ throw { Name:'JSTReportChartContainer::RequestStockData', Error:'(T型报价列表期权数据)不提供内置测试数据' };
656
+ }
657
+
658
+ this.RecvStockData=function(data)
659
+ {
660
+ var setUpdateSymbol=new Set(); //更新的股票列表
661
+ if (IFrameSplitOperator.IsNonEmptyArray(data.data))
662
+ {
663
+ for(var i=0;i<data.data.length;++i)
664
+ {
665
+ var item=data.data[i];
666
+ var symbol=item[0]; //0=证券代码;
667
+ if (!symbol) continue;
668
+ var stock=null;
669
+ if (this.MapStockData.has(symbol))
670
+ {
671
+ stock=this.MapStockData.get(symbol);
672
+ }
673
+ else
674
+ {
675
+ stock=new HQTReportItem();
676
+ stock.Symbol=symbol;
677
+ this.MapStockData.set(symbol, stock);
678
+ }
679
+
680
+ this.ReadStockJsonData(stock, item);
681
+
682
+ if (!setUpdateSymbol.has(symbol)) setUpdateSymbol.add(symbol);
683
+ }
684
+ }
685
+
686
+ //实时数据排序
687
+ var chart=this.ChartPaint[0];
688
+ if (chart && (this.SortInfo.Sort==1 || this.SortInfo.Sort==2 ) && IFrameSplitOperator.IsNumber(this.SortInfo.Field) && this.SortInfo.Field>=0)
689
+ {
690
+ var column=chart.Column[this.SortInfo.Field];
691
+ var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_TREPORT_LOCAL_SORT);
692
+ if (event && event.Callback)
693
+ {
694
+ var sendData={ Column:column, SortInfo:this.SortInfo, SymbolList:this.Data.Data, Result:null };
695
+ event.Callback (event, sendData, this);
696
+ if (Array.isArray(sendData.Result)) this.Data.Data=sendData.Result;
697
+ }
698
+ else
699
+ {
700
+ this.Data.Data.sort((left, right)=> { return this.LocalSort(left, right, column, this.SortInfo.Sort, this.SortInfo.CellType); });
701
+ }
702
+ }
703
+
704
+ this.CalculateData();
705
+
706
+ this.Draw();
707
+ }
708
+
709
+ //计算统计数据
710
+ this.CalculateData=function()
711
+ {
712
+ if (!this.MapExePriceData || this.MapExePriceData.size<=0) return;
713
+
714
+ var leftMaxPosition={ Max:null, ExePrice:null, CellType:1 };
715
+ var rightMaxPosition={ Max:null,ExePrice:null, CellType:2 };
716
+ this.BorderData.MapData=new Map();
717
+ for(var mapItem of this.MapExePriceData)
718
+ {
719
+ var item=mapItem[1];
720
+ var leftData=item.LeftData;
721
+ var rightData=item.RightData;
722
+ if (leftData && IFrameSplitOperator.IsNumber(leftData.Position))
723
+ {
724
+ if (leftMaxPosition.Max==null || leftMaxPosition.Max<leftData.Position)
725
+ {
726
+ leftMaxPosition.Max=leftData.Position;
727
+ leftMaxPosition.ExePrice=mapItem[0];
728
+ }
729
+ }
730
+
731
+ if (rightData && IFrameSplitOperator.IsNumber(rightData.Position))
732
+ {
733
+ if (leftMaxPosition.Max==null || leftMaxPosition.Max<rightData.Position)
734
+ {
735
+ rightMaxPosition.Max=rightData.Position;
736
+ rightMaxPosition.ExePrice=mapItem[0];
737
+ }
738
+ }
739
+ }
740
+
741
+ var aryData=[null, null, null];
742
+ if (leftMaxPosition.ExePrice) aryData[1]=leftMaxPosition;
743
+ if (rightMaxPosition.ExePrice) aryData[2]=rightMaxPosition;
744
+
745
+ this.BorderData.MapData.set(TREPORT_COLUMN_ID.POSITION_ID, { Data:aryData });
746
+ }
747
+
748
+ //读取单条股票json数据
749
+ this.ReadStockJsonData=function(stock, item)
750
+ {
751
+ //0=证券代码 1=股票名称 2=昨收 3=开 4=高 5=低 6=收 7=成交量 8=成交金额, 9=买价 10=买量 11=卖价 12=卖量 13=均价 14=持仓 16=涨停价 17=跌停价
752
+ //21=涨幅% 22=涨跌 24=振幅%
753
+ //30=全局扩展数据 31=当前板块扩展数据
754
+
755
+ if (IFrameSplitOperator.IsString(item[1])) stock.Name=item[1];
756
+ if (IFrameSplitOperator.IsNumber(item[2])) stock.YClose=item[2];
757
+ if (IFrameSplitOperator.IsNumber(item[3])) stock.Open=item[3];
758
+ if (IFrameSplitOperator.IsNumber(item[4])) stock.High=item[4];
759
+ if (IFrameSplitOperator.IsNumber(item[5])) stock.Low=item[5];
760
+ if (IFrameSplitOperator.IsNumber(item[6])) stock.Price=item[6];
761
+ if (IFrameSplitOperator.IsNumber(item[7])) stock.Vol=item[7];
762
+ if (IFrameSplitOperator.IsNumber(item[8])) stock.Amount=item[8];
763
+ if (IFrameSplitOperator.IsNumber(item[9])) stock.BuyPrice=item[9];
764
+ if (IFrameSplitOperator.IsNumber(item[10])) stock.BuyVol=item[10];
765
+ if (IFrameSplitOperator.IsNumber(item[11])) stock.SellPrice=item[11];
766
+ if (IFrameSplitOperator.IsNumber(item[12])) stock.SellVol=item[12];
767
+ if (IFrameSplitOperator.IsNumber(item[13])) stock.AvPrice=item[13]; //均价
768
+ if (IFrameSplitOperator.IsNumber(item[14])) stock.Position=item[14]; //持仓
769
+
770
+ if (IFrameSplitOperator.IsNumber(item[16])) stock.LimitHigh=item[16]; //涨停价
771
+ if (IFrameSplitOperator.IsNumber(item[17])) stock.LimitLow=item[17]; //跌停价
772
+
773
+ if (IFrameSplitOperator.IsNumber(item[21])) stock.Increase=item[21]; //涨幅%
774
+ if (IFrameSplitOperator.IsNumber(item[22])) stock.UpDown=item[22]; //涨跌
775
+
776
+ if (IFrameSplitOperator.IsNumber(item[24])) stock.Amplitude=item[24]; //振幅%
777
+
778
+ if (item[27]) stock.NameEx=item[27]; //扩展名字
779
+
780
+ //衍生数据计算
781
+ if (!IFrameSplitOperator.IsNumber(item[21])) //涨幅%
782
+ {
783
+ if (IFrameSplitOperator.IsNumber(stock.Price) && IFrameSplitOperator.IsNumber(stock.YClose) && stock.YClose!=0)
784
+ stock.Increase=(stock.Price-stock.YClose)/stock.YClose*100;
785
+ }
786
+
787
+ if (!IFrameSplitOperator.IsNumber(item[22])) //涨跌
788
+ {
789
+ if (IFrameSplitOperator.IsNumber(stock.Price) && IFrameSplitOperator.IsNumber(stock.YClose))
790
+ stock.UpDown=stock.Price-stock.YClose;
791
+ }
792
+
793
+ if (!IFrameSplitOperator.IsNumber(item[24])) //振幅%
794
+ {
795
+ if (IFrameSplitOperator.IsNumber(stock.High) && IFrameSplitOperator.IsNumber(stock.Low) && IFrameSplitOperator.IsNumber(stock.YClose) && stock.YClose!=0)
796
+ stock.Amplitude=(stock.High-stock.Low)/stock.YClose*100;
797
+ }
798
+
799
+ if (item[30])
800
+ stock.ExtendData=item[30]; //30=全局扩展数据
801
+
802
+ if (item[32]) stock.CloseLine=item[32]; //32=收盘价线
803
+ if (item[33]) stock.KLine=item[33]; //33=K线
804
+ }
805
+
806
+
807
+ this.AutoUpdate=function(waitTime) //waitTime 更新时间
808
+ {
809
+ this.CancelAutoUpdate();
810
+ if (!this.IsAutoUpdate) return;
811
+
812
+ var self = this;
813
+ var marketStatus=2;
814
+ var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_TREPORT_MARKET_STATUS);
815
+ if (event && event.Callback)
816
+ {
817
+ var sendData={ MarketStatus:2 };
818
+ event.Callback(event, sendData, this);
819
+ if (IFrameSplitOperator.IsNumber(sendData.MarketStatus)) marketStatus=sendData.MarketStatus;
820
+ }
821
+
822
+ if (marketStatus==0 || marketStatus==3) return; //闭市,盘后
823
+
824
+ var frequency=this.AutoUpdateFrequency;
825
+ if (marketStatus==1) //盘前
826
+ {
827
+ this.AutoUpdateTimer=setTimeout(function()
828
+ {
829
+ self.AutoUpdate();
830
+ },frequency);
831
+ }
832
+ else if (marketStatus==2) //盘中
833
+ {
834
+ this.AutoUpdateTimer=setTimeout(function()
835
+ {
836
+ self.UpdateStockData();
837
+ },frequency);
838
+ }
839
+ }
840
+
841
+ //delay=是否延迟
842
+ this.DelayUpdateStockData=function()
843
+ {
844
+ if (this.DelayUpdateTimer!=null)
845
+ {
846
+ clearTimeout(this.DelayUpdateTimer);
847
+ this.DelayUpdateTimer = null;
848
+ }
849
+
850
+ var frequency=this.DelayUpdateFrequency;
851
+ this.DelayUpdateTimer=setTimeout(()=>
852
+ {
853
+ this.UpdateStockData();
854
+
855
+ },frequency);
856
+ }
857
+
858
+ this.UIOnMouseDown=function(e)
859
+ {
860
+ var pixelTatio = GetDevicePixelRatio();
861
+ var x = (e.clientX-this.UIElement.getBoundingClientRect().left)*pixelTatio;
862
+ var y = (e.clientY-this.UIElement.getBoundingClientRect().top)*pixelTatio;
863
+
864
+ var chart=this.ChartPaint[0];
865
+ if (!chart) return;
866
+
867
+ var clickData=chart.OnMouseDown(x,y,e);
868
+ if (!clickData) return;
869
+
870
+ if ((clickData.Type==2) && (e.button==0 || e.button==2)) //点击行
871
+ {
872
+ if (clickData.Redraw==true) this.Draw();
873
+ }
874
+ else if (clickData.Type==3 && e.button==0) //表头
875
+ {
876
+ this.OnClickHeader(clickData, e);
877
+ }
878
+
879
+ //document.onmousemove=(e)=>{ this.DocOnMouseMove(e); }
880
+ //document.onmouseup=(e)=> { this.DocOnMouseUp(e); }
881
+ }
882
+
883
+ //点表头
884
+ this.OnClickHeader=function(clickData, e)
885
+ {
886
+ var header=clickData.Header;
887
+
888
+ if (header.Column && header.Column.Sort==1)
889
+ {
890
+ var data={ CellType:header.CellType, ColumnIndex:header.ColumnIndex }
891
+ this.SortHeader(header.Column, data);
892
+ }
893
+
894
+ }
895
+
896
+ //排序
897
+ this.SortHeader=function(column, sortData)
898
+ {
899
+ var sortInfo={ Field:this.SortInfo.Field, Sort:this.SortInfo.Sort, CellType:this.SortInfo.CellType };
900
+ var arySortType=column.SortType;
901
+
902
+ if (sortInfo.Field!=sortData.ColumnIndex || sortInfo.CellType!=sortData.CellType)
903
+ {
904
+ sortInfo.Field=sortData.ColumnIndex;
905
+ sortInfo.CellType=sortData.CellType;
906
+ sortInfo.Sort=arySortType[0]
907
+ }
908
+ else
909
+ {
910
+ if (arySortType.length==1)
911
+ {
912
+ sortInfo.Sort=arySortType[0];
913
+ }
914
+ else
915
+ {
916
+ for(var i=0;i<arySortType.length;++i)
917
+ {
918
+ if (sortInfo.Sort==arySortType[i])
919
+ {
920
+ sortInfo.Sort=arySortType[(i+1)%arySortType.length];
921
+ break;
922
+ }
923
+ }
924
+ }
925
+ }
926
+
927
+ if (sortInfo.Sort==0) //还原
928
+ {
929
+ this.Data.Data=[];
930
+ for(var i=0;i<this.SourceData.Data.length;++i)
931
+ {
932
+ this.Data.Data.push(this.SourceData.Data[i]);
933
+ }
934
+ }
935
+ else
936
+ {
937
+ var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_TREPORT_LOCAL_SORT);
938
+ if (event && event.Callback)
939
+ {
940
+ var sendData={ Column:column, SortInfo:sortInfo, SymbolList:this.Data.Data, Result:null };
941
+ event.Callback (event, sendData, this);
942
+ if (Array.isArray(sendData.Result)) this.Data.Data=sendData.Result;
943
+ }
944
+ else
945
+ {
946
+ this.Data.Data.sort((left, right)=> { return this.LocalSort(left, right, column, sortInfo.Sort, sortInfo.CellType); });
947
+ }
948
+ }
949
+
950
+ this.Data.YOffset=0;
951
+ this.SortInfo.Field=sortInfo.Field;
952
+ this.SortInfo.Sort=sortInfo.Sort;
953
+ this.SortInfo.CellType=sortInfo.CellType;
954
+ this.Draw();
955
+ this.DelayUpdateStockData();
956
+ }
957
+
958
+ //本地排序
959
+ this.LocalSort=function(left, right, column, sortType, cellType)
960
+ {
961
+ switch(column.Type)
962
+ {
963
+ case TREPORT_COLUMN_ID.SYMBOL_ID:
964
+ case TREPORT_COLUMN_ID.NAME_ID:
965
+ return this.LocalStringSort(left, right, column, sortType, cellType);
966
+
967
+ case TREPORT_COLUMN_ID.PRICE_ID:
968
+ case TREPORT_COLUMN_ID.VOL_ID:
969
+ case TREPORT_COLUMN_ID.UPDOWN_ID:
970
+ case TREPORT_COLUMN_ID.BUY_PRICE_ID:
971
+ case TREPORT_COLUMN_ID.SELL_PRICE_ID:
972
+ case TREPORT_COLUMN_ID.AMOUNT_ID:
973
+ case TREPORT_COLUMN_ID.BUY_VOL_ID:
974
+ case TREPORT_COLUMN_ID.SELL_VOL_ID:
975
+ case TREPORT_COLUMN_ID.YCLOSE_ID:
976
+ case TREPORT_COLUMN_ID.OPEN_ID:
977
+ case TREPORT_COLUMN_ID.HIGH_ID:
978
+ case TREPORT_COLUMN_ID.LOW_ID:
979
+ case TREPORT_COLUMN_ID.AVERAGE_PRICE_ID:
980
+ case TREPORT_COLUMN_ID.EXE_PRICE_ID: //行权价格
981
+ case TREPORT_COLUMN_ID.POSITION_ID: //持仓量
982
+ case TREPORT_COLUMN_ID.AMPLITUDE_ID:
983
+ case TREPORT_COLUMN_ID.INCREASE_ID:
984
+ return this.LocalNumberSort(left, right, column, sortType, cellType);
985
+
986
+ default:
987
+
988
+ return 0;
989
+ }
990
+ }
991
+
992
+ this.LocalNumberSort=function(left, right, column, sortType, cellType)
993
+ {
994
+ var leftStock=this.GetExePriceData(left);
995
+ var rightStock=this.GetExePriceData(right);
996
+
997
+ var leftValue=-99999999999999, rightValue=-99999999999999;
998
+ if (sortType==2) leftValue=rightValue=99999999999999;
999
+
1000
+ var filedName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
1001
+
1002
+ if (cellType==0) //行权价格
1003
+ {
1004
+ if (leftStock && IFrameSplitOperator.IsNumber(leftStock.ExePrice)) leftValue=leftStock.ExePrice;
1005
+ if (rightStock && IFrameSplitOperator.IsNumber(rightStock.ExePrice)) rightValue=rightStock.ExePrice;
1006
+ }
1007
+ else if (cellType==1)
1008
+ {
1009
+ if (leftStock && leftStock.LeftData)
1010
+ {
1011
+ var value=leftStock.LeftData[filedName];
1012
+ if (IFrameSplitOperator.IsNumber(value)) leftValue=value;
1013
+ }
1014
+ if (rightStock && rightStock.LeftData)
1015
+ {
1016
+ var value=rightStock.LeftData[filedName];
1017
+ if (IFrameSplitOperator.IsNumber(value)) rightValue=value;
1018
+ }
1019
+ }
1020
+ else if (cellType==2)
1021
+ {
1022
+ if (leftStock && leftStock.RightData)
1023
+ {
1024
+ var value=leftStock.RightData[filedName];
1025
+ if (IFrameSplitOperator.IsNumber(value)) leftValue=value;
1026
+ }
1027
+ if (rightStock && rightStock.RightData)
1028
+ {
1029
+ var value=rightStock.RightData[filedName]
1030
+ if (IFrameSplitOperator.IsNumber(value)) rightValue=value;
1031
+ }
1032
+ }
1033
+
1034
+ if (sortType==1)
1035
+ {
1036
+ if (rightValue<leftValue) return -1;
1037
+ else if (rightValue<leftValue) return 1;
1038
+ else return 0;
1039
+ }
1040
+ else
1041
+ {
1042
+ if (leftValue<rightValue) return -1;
1043
+ else if (leftValue>rightValue) return 1;
1044
+ else return 0;
1045
+ }
1046
+ }
1047
+
1048
+ this.GetTReportChart=function()
1049
+ {
1050
+ var chart=this.ChartPaint[0];
1051
+ return chart;
1052
+ }
1053
+
1054
+ this.OnWheel=function(e) //滚轴
1055
+ {
1056
+ JSConsole.Chart.Log('[JSTReportChartContainer::OnWheel]',e);
1057
+ if (this.ChartSplashPaint && this.ChartSplashPaint.IsEnableSplash == true) return;
1058
+ if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
1059
+
1060
+ var x = e.clientX-this.UIElement.getBoundingClientRect().left;
1061
+ var y = e.clientY-this.UIElement.getBoundingClientRect().top;
1062
+
1063
+ var isInClient=false;
1064
+ this.Canvas.beginPath();
1065
+ this.Canvas.rect(this.Frame.ChartBorder.GetLeft(),this.Frame.ChartBorder.GetTop(),this.Frame.ChartBorder.GetWidth(),this.Frame.ChartBorder.GetHeight());
1066
+ isInClient=this.Canvas.isPointInPath(x,y);
1067
+ if (!isInClient) return;
1068
+
1069
+ var chart=this.GetTReportChart();
1070
+ if (!chart) return;
1071
+
1072
+ var wheelValue=e.wheelDelta;
1073
+ if (!IFrameSplitOperator.IsObjectExist(e.wheelDelta))
1074
+ wheelValue=e.deltaY* -0.01;
1075
+
1076
+ if (wheelValue<0) //下
1077
+ {
1078
+ var result=this.MoveSelectedRow(1)
1079
+ if (result)
1080
+ {
1081
+ if (result.Redraw) this.Draw();
1082
+ if (result.Update) this.DelayUpdateStockData();
1083
+ }
1084
+ }
1085
+ else if (wheelValue>0) //上
1086
+ {
1087
+ var result=this.MoveSelectedRow(-1);
1088
+ if (result)
1089
+ {
1090
+ if (result.Redraw) this.Draw();
1091
+ if (result.Update) this.DelayUpdateStockData();
1092
+ }
1093
+ }
1094
+
1095
+ if(e.preventDefault) e.preventDefault();
1096
+ else e.returnValue = false;
1097
+ }
1098
+
1099
+ this.OnKeyDown=function(e)
1100
+ {
1101
+ if (this.ChartSplashPaint && this.ChartSplashPaint.IsEnableSplash == true) return;
1102
+ var reportChart=this.GetTReportChart();
1103
+ if (!reportChart) return;
1104
+
1105
+ var keyID = e.keyCode ? e.keyCode :e.which;
1106
+ switch(keyID)
1107
+ {
1108
+ /*
1109
+ case 33: //page up
1110
+ if (this.GotoPreviousPage(this.PageUpDownCycle))
1111
+ {
1112
+ this.Draw();
1113
+ this.DelayUpdateStockData();
1114
+ }
1115
+ break;
1116
+ case 34: //page down
1117
+ if (this.GotoNextPage(this.PageUpDownCycle))
1118
+ {
1119
+ this.Draw();
1120
+ this.DelayUpdateStockData();
1121
+ }
1122
+ break;
1123
+ */
1124
+ case 38: //up
1125
+ var result=this.MoveSelectedRow(-1);
1126
+ if (result)
1127
+ {
1128
+ if (result.Redraw) this.Draw();
1129
+ if (result.Update) this.DelayUpdateStockData();
1130
+ }
1131
+ break;
1132
+ case 40: //down
1133
+ var result=this.MoveSelectedRow(1)
1134
+ if (result)
1135
+ {
1136
+ if (result.Redraw) this.Draw();
1137
+ if (result.Update) this.DelayUpdateStockData();
1138
+ }
1139
+ break;
1140
+ }
1141
+
1142
+ //不让滚动条滚动
1143
+ if(e.preventDefault) e.preventDefault();
1144
+ else e.returnValue = false;
1145
+ }
1146
+
1147
+ this.MoveSelectedRow=function(step)
1148
+ {
1149
+ var chart=this.ChartPaint[0];
1150
+ if (!chart) return null;
1151
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return null;
1152
+
1153
+ var result={ Redraw:false, Update:false }; //Redraw=重绘, Update=更新数据
1154
+
1155
+ var pageStatus=chart.GetCurrentPageStatus();
1156
+ var pageSize=pageStatus.PageSize;
1157
+
1158
+ var selectedIndex=pageStatus.Start;
1159
+ var cellType=1;
1160
+ if (pageStatus.SelectedRow)
1161
+ {
1162
+ cellType=pageStatus.SelectedRow.CellType;
1163
+ for(var i=0;i<this.Data.Data.length;++i)
1164
+ {
1165
+ if (pageStatus.SelectedRow.ExePrice==this.Data.Data[i])
1166
+ {
1167
+ selectedIndex=i;
1168
+ break;
1169
+ }
1170
+ }
1171
+ }
1172
+
1173
+ if (step>0)
1174
+ {
1175
+ if (selectedIndex<0 || selectedIndex<pageStatus.Start || selectedIndex>pageStatus.End)
1176
+ {
1177
+ chart.SelectedRow={ ExePrice:this.Data.Data[pageStatus.Start], CellType:cellType };
1178
+ result.Redraw=true;
1179
+ return result;
1180
+ }
1181
+
1182
+ var offset=this.Data.YOffset;
1183
+ for(var i=0;i<step;++i)
1184
+ {
1185
+ ++selectedIndex;
1186
+ if (selectedIndex>pageStatus.End) ++offset;
1187
+
1188
+ if (selectedIndex>=this.Data.Data.length)
1189
+ {
1190
+ selectedIndex=0;
1191
+ offset=0;
1192
+ }
1193
+ }
1194
+
1195
+ result.Redraw=true;
1196
+ result.Update=(offset!=this.Data.YOffset);
1197
+
1198
+ chart.SelectedRow={ ExePrice:this.Data.Data[selectedIndex], CellType:cellType };
1199
+ this.Data.YOffset=offset;
1200
+
1201
+ return result;
1202
+ }
1203
+ else if (step<0)
1204
+ {
1205
+ if (selectedIndex<0 || selectedIndex<pageStatus.Start || selectedIndex>pageStatus.End)
1206
+ {
1207
+ chart.SelectedRow={ ExePrice:this.Data.Data[pageStatus.End], CellType:cellType };
1208
+ result.Redraw=true;
1209
+ return result;
1210
+ }
1211
+
1212
+ step=Math.abs(step);
1213
+ var offset=this.Data.YOffset;
1214
+ for(var i=0;i<step;++i)
1215
+ {
1216
+ --selectedIndex;
1217
+ if (selectedIndex<pageStatus.Start) --offset;
1218
+
1219
+ if (selectedIndex<0)
1220
+ {
1221
+ selectedIndex=this.Data.Data.length-1;
1222
+ offset=this.Data.Data.length-pageSize;
1223
+ if (offset<0) offset=0;
1224
+ }
1225
+ }
1226
+
1227
+ result.Redraw=true;
1228
+ result.Update=(offset!=this.Data.YOffset);
1229
+
1230
+ chart.SelectedRow={ ExePrice:this.Data.Data[selectedIndex], CellType:cellType };
1231
+ this.Data.YOffset=offset;
1232
+
1233
+ return result;
1234
+ }
1235
+
1236
+ return null;
1237
+ }
1238
+ }
1239
+
1240
+ function JSTReportFrame()
1241
+ {
1242
+ this.ChartBorder;
1243
+ this.Canvas; //画布
1244
+
1245
+ this.BorderLine=null; //1=上 2=下 4=左 8=右
1246
+ this.ClassName="JSTReportFrame";
1247
+
1248
+ this.BorderColor=g_JSChartResource.TReport.BorderColor; //边框线
1249
+
1250
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
1251
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
1252
+
1253
+ this.ReloadResource=function(resource)
1254
+ {
1255
+ this.BorderColor=g_JSChartResource.TReport.BorderColor; //边框线
1256
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
1257
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
1258
+ }
1259
+
1260
+ this.Draw=function()
1261
+ {
1262
+ var left=ToFixedPoint(this.ChartBorder.GetLeft());
1263
+ var top=ToFixedPoint(this.ChartBorder.GetTop());
1264
+ var right=ToFixedPoint(this.ChartBorder.GetRight());
1265
+ var bottom=ToFixedPoint(this.ChartBorder.GetBottom());
1266
+ var width=right-left;
1267
+ var height=bottom-top;
1268
+
1269
+ if (!IFrameSplitOperator.IsNumber(this.BorderLine))
1270
+ {
1271
+ this.Canvas.strokeStyle=this.BorderColor;
1272
+ this.Canvas.strokeRect(left,top,width,height);
1273
+ }
1274
+ else
1275
+ {
1276
+ this.Canvas.strokeStyle=this.BorderColor;
1277
+ this.Canvas.beginPath();
1278
+
1279
+ if ((this.BorderLine&1)>0) //上
1280
+ {
1281
+ this.Canvas.moveTo(left,top);
1282
+ this.Canvas.lineTo(right,top);
1283
+ }
1284
+
1285
+ if ((this.BorderLine&2)>0) //下
1286
+ {
1287
+ this.Canvas.moveTo(left,bottom);
1288
+ this.Canvas.lineTo(right,bottom);
1289
+ }
1290
+
1291
+ if ((this.BorderLine&4)>0) //左
1292
+ {
1293
+ this.Canvas.moveTo(left,top);
1294
+ this.Canvas.lineTo(left,bottom);
1295
+ }
1296
+
1297
+ if ((this.BorderLine&8)>0) //右
1298
+ {
1299
+ this.Canvas.moveTo(right,top);
1300
+ this.Canvas.lineTo(right,bottom);
1301
+ }
1302
+
1303
+ this.Canvas.stroke();
1304
+ }
1305
+ }
1306
+
1307
+ this.DrawLogo=function()
1308
+ {
1309
+ var text=g_JSChartResource.FrameLogo.Text;
1310
+ if (!IFrameSplitOperator.IsString(text)) return;
1311
+
1312
+ this.Canvas.fillStyle=this.LogoTextColor;
1313
+ this.Canvas.font=this.LogoTextFont;
1314
+ this.Canvas.textAlign = 'right';
1315
+ this.Canvas.textBaseline = 'bottom';
1316
+
1317
+ var x=this.ChartBorder.GetRight()-30;
1318
+ var y=this.ChartBorder.GetBottom()-5;
1319
+ this.Canvas.fillText(text,x,y);
1320
+ }
1321
+ }
1322
+
1323
+ var TREPORT_COLUMN_ID=
1324
+ {
1325
+ SYMBOL_ID:0,
1326
+ NAME_ID:1,
1327
+ PRICE_ID:2, //成交价格
1328
+ VOL_ID:3, //成交量
1329
+ INCREASE_ID:4, //涨幅
1330
+ UPDOWN_ID:5, //涨跌
1331
+ BUY_PRICE_ID:6, //买价
1332
+ SELL_PRICE_ID:7, //卖价
1333
+ AMOUNT_ID:8, //总金额
1334
+ BUY_VOL_ID:9, //买量
1335
+ SELL_VOL_ID:10, //卖量
1336
+ YCLOSE_ID:11, //昨收
1337
+ OPEN_ID:12,
1338
+ HIGH_ID:13,
1339
+ LOW_ID:14,
1340
+ AVERAGE_PRICE_ID:15,//均价
1341
+ INDEX_ID:16, //序号 从1开始
1342
+ EXE_PRICE_ID:17, //行权价格
1343
+ POSITION_ID:18, //持仓量
1344
+
1345
+ AMPLITUDE_ID:22, //振幅
1346
+
1347
+ LIMIT_HIGH_ID:23, //涨停价
1348
+ LIMIT_LOW_ID:24, //跌停价
1349
+
1350
+ VOL_IN_ID:25, //内盘
1351
+ VOL_OUT_ID:26, //外盘
1352
+ NAME_EX_ID:27, //扩展名字
1353
+ CLOSE_LINE_ID:28, //收盘价线
1354
+ KLINE_ID:29, //K线
1355
+
1356
+ CUSTOM_STRING_TEXT_ID:100, //自定义字符串文本
1357
+ CUSTOM_NUMBER_TEXT_ID:101, //自定义数值型
1358
+ CUSTOM_DATETIME_TEXT_ID:102, //自定义日期类型
1359
+ CUSTOM_ICON_ID:103, //自定义图标
1360
+ }
1361
+
1362
+ var MAP_TREPORT_COLUMN_FIELD=new Map(
1363
+ [
1364
+ [TREPORT_COLUMN_ID.SYMBOL_ID, "Symbol"],
1365
+ [TREPORT_COLUMN_ID.NAME_ID, "Name"],
1366
+ [TREPORT_COLUMN_ID.PRICE_ID, "Price"],
1367
+ [TREPORT_COLUMN_ID.INCREASE_ID, "Increase"],
1368
+ [TREPORT_COLUMN_ID.UPDOWN_ID, "UpDown"],
1369
+ [TREPORT_COLUMN_ID.VOL_ID, "Vol"],
1370
+ [TREPORT_COLUMN_ID.BUY_PRICE_ID, "BuyPrice"],
1371
+ [TREPORT_COLUMN_ID.SELL_PRICE_ID, "SellPrice"],
1372
+ [TREPORT_COLUMN_ID.AMOUNT_ID, "Amount"],
1373
+ [TREPORT_COLUMN_ID.BUY_VOL_ID, "BuyVol"],
1374
+ [TREPORT_COLUMN_ID.SELL_VOL_ID, "SellVol"],
1375
+ [TREPORT_COLUMN_ID.YCLOSE_ID, "YClose"],
1376
+ [TREPORT_COLUMN_ID.OPEN_ID, "Open"],
1377
+ [TREPORT_COLUMN_ID.HIGH_ID, "High"],
1378
+ [TREPORT_COLUMN_ID.LOW_ID, "Low"],
1379
+ [TREPORT_COLUMN_ID.AVERAGE_PRICE_ID,"AvPrice"],
1380
+ [TREPORT_COLUMN_ID.POSITION_ID,"Position"],
1381
+ ]);
1382
+
1383
+
1384
+ function ChartTReport()
1385
+ {
1386
+ this.Canvas; //画布
1387
+ this.ChartBorder; //边框信息
1388
+ this.ChartFrame; //框架画法
1389
+ this.Name; //名称
1390
+ this.ClassName='ChartTReport'; //类名
1391
+ this.UIElement;
1392
+ this.IsDrawFirst=false;
1393
+ this.GetEventCallback; //获取事件
1394
+ this.GetExePriceDataCallback; //获取行权价格数据
1395
+ this.GetFlashBGDataCallback; //获取闪烁背景
1396
+ this.GetBlockDataCallback; //获取当前板块的数据
1397
+ this.Data; //数据 { XOffset:0, YOffset:0, Data:[ 50000.0, 500025.0] }
1398
+ this.BorderData;
1399
+ this.FixedRowData; //固定行
1400
+ this.SortInfo; //排序信息 { Field:排序字段id, Sort:0 不排序 1升序 2降序, CellType: }
1401
+ this.FixedColumn=2; //固定列
1402
+ this.FixedRowCount=0; //固定行
1403
+
1404
+ this.IsShowHeader=true; //是否显示表头
1405
+ this.SizeChange=true;
1406
+
1407
+ this.SelectedRow; //{ ExePrice:exePrice, CellType:0 }
1408
+ this.RectSelectedRow;
1409
+ this.IsDrawBorder=1; //是否绘制单元格边框
1410
+
1411
+ this.ShowSymbol=[]; //显示的列表 { ExePrice:行权价格 }
1412
+
1413
+ this.GlobalOption;
1414
+
1415
+ //涨跌颜色
1416
+ this.UpColor=g_JSChartResource.TReport.UpTextColor;
1417
+ this.DownColor=g_JSChartResource.TReport.DownTextColor;
1418
+ this.UnchangeColor=g_JSChartResource.TReport.UnchangeTextColor;
1419
+
1420
+ this.BorderColor=g_JSChartResource.TReport.BorderColor; //边框线
1421
+ this.SelectedColor=g_JSChartResource.TReport.SelectedColor; //选中行
1422
+
1423
+ this.UpBGColor=g_JSChartResource.TReport.UpBGColor;
1424
+ this.DownBGColor=g_JSChartResource.TReport.DownBGColor;
1425
+
1426
+ //表头配置
1427
+ this.HeaderFontConfig={ Size:g_JSChartResource.TReport.Header.Font.Size, Name:g_JSChartResource.TReport.Header.Font.Name };
1428
+ this.HeaderColor=g_JSChartResource.TReport.Header.Color;
1429
+ this.SortColor=g_JSChartResource.TReport.Header.SortColor; //排序箭头颜色
1430
+ this.HeaderMergin=
1431
+ {
1432
+ Left:g_JSChartResource.TReport.Header.Mergin.Left,
1433
+ Right:g_JSChartResource.TReport.Header.Mergin.Right,
1434
+ Top:g_JSChartResource.TReport.Header.Mergin.Top,
1435
+ Bottom:g_JSChartResource.TReport.Header.Mergin.Bottom
1436
+ };
1437
+
1438
+ this.MarkBorderConfig={ MaxPositionColor: g_JSChartResource.TReport.MarkBorder.MaxPositionColor };
1439
+
1440
+ //表格内容配置
1441
+ this.ItemFontConfig={ Size:g_JSChartResource.TReport.Item.Font.Size, Name:g_JSChartResource.TReport.Item.Font.Name };
1442
+ this.ItemMergin=
1443
+ {
1444
+ Left:g_JSChartResource.TReport.Item.Mergin.Left,
1445
+ Right:g_JSChartResource.TReport.Item.Mergin.Right,
1446
+ Top:g_JSChartResource.TReport.Item.Mergin.Top,
1447
+ Bottom:g_JSChartResource.TReport.Item.Mergin.Bottom
1448
+ };
1449
+
1450
+ this.CenterItemConfig=
1451
+ {
1452
+ TextColor:g_JSChartResource.TReport.CenterItem.TextColor,
1453
+ BaseTextColor:g_JSChartResource.TReport.CenterItem.BaseTextColor,
1454
+ BGColor: g_JSChartResource.TReport.CenterItem.BGColor
1455
+ };
1456
+
1457
+ //缓存
1458
+ this.HeaderFont=12*GetDevicePixelRatio() +"px 微软雅黑";
1459
+ this.ItemFont=15*GetDevicePixelRatio() +"px 微软雅黑";
1460
+ this.ItemFixedFont=15*GetDevicePixelRatio() +"px 微软雅黑";
1461
+ this.ItemSymbolFont=12*GetDevicePixelRatio() +"px 微软雅黑";
1462
+ this.ItemNameFont=15*GetDevicePixelRatio() +"px 微软雅黑";
1463
+ this.ItemNameHeight=0;
1464
+ this.RowCount=0; //一屏显示行数
1465
+ this.HeaderHeight=0; //表头高度
1466
+ this.RowHeight=0; //行高度
1467
+ this.IsShowAllColumn=false; //是否已显示所有列
1468
+ this.ItemExtraWidth=0; //每列额外的宽度
1469
+
1470
+ this.Column= //{ Type:列id, Title:标题, TextAlign:文字对齐方式, MaxText:文字最大宽度 , TextColor:文字颜色, Sort:0=不支持排序 1=本地排序 0=远程排序 }
1471
+ [
1472
+ { Type:TREPORT_COLUMN_ID.PRICE_ID, Title:"现价", TextAlign:"right", Width:null, MaxText:"-888.88" },
1473
+ { Type:TREPORT_COLUMN_ID.INCREASE_ID, Title:"涨幅%", TextAlign:"right", Width:null, MaxText:"-888.88" },
1474
+ { Type:TREPORT_COLUMN_ID.BUY_PRICE_ID, Title:"买价", TextAlign:"right", Width:null, MaxText:"-888.88" },
1475
+ { Type:TREPORT_COLUMN_ID.BUY_VOL_ID, Title:"买量", TextAlign:"right", Width:null, MaxText:"88888", TextColor:g_JSChartResource.TReport.FieldColor.Vol },
1476
+
1477
+ //{ Type:TREPORT_COLUMN_ID.SELL_PRICE_ID, Title:"卖价", TextAlign:"right", Width:null, MaxText:"-888.88" },
1478
+ //{ Type:TREPORT_COLUMN_ID.SELL_VOL_ID, Title:"卖量", TextAlign:"right", Width:null, MaxText:"88888", TextColor:g_JSChartResource.TReport.FieldColor.Vol },
1479
+
1480
+ //{ Type:TREPORT_COLUMN_ID.POSITION_ID, Title:"持仓量", TextAlign:"right", Width:null, MaxText:"88888", TextColor:g_JSChartResource.TReport.FieldColor.Position },
1481
+
1482
+ { Type:TREPORT_COLUMN_ID.NAME_ID, Title:"合约代码", TextAlign:"right", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Name, MaxText:"AAAAAA-A-AAAA"},
1483
+
1484
+ ];
1485
+
1486
+ this.CenterColumn={ Type:TREPORT_COLUMN_ID.EXE_PRICE_ID, Title:"购<行权价>沽", TextAlign:"center", Width:null, MaxText:"99999.99", Sort:1, SortType:[1,2] }
1487
+
1488
+ this.RectClient={};
1489
+
1490
+ this.TooltipRect=[];
1491
+
1492
+ this.ReloadResource=function(resource)
1493
+ {
1494
+ }
1495
+
1496
+ this.SetColumn=function(aryColumn)
1497
+ {
1498
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryColumn)) return;
1499
+
1500
+ this.Column=[];
1501
+ for(var i=0;i<aryColumn.length;++i)
1502
+ {
1503
+ var item=aryColumn[i];
1504
+ var colItem=this.GetDefaultColunm(item.Type);
1505
+ if (!colItem) continue;
1506
+
1507
+ if (item.Title) colItem.Title=item.Title;
1508
+ if (item.TextAlign) colItem.TextAlign=item.TextAlign;
1509
+ if (item.TextColor) colItem.TextColor=item.TextColor;
1510
+ if (item.MaxText) colItem.MaxText=item.MaxText;
1511
+ if (item.ID) colItem.ID=item.ID;
1512
+ if (IFrameSplitOperator.IsNumber(item.Sort)) colItem.Sort=item.Sort;
1513
+ if (IFrameSplitOperator.IsBool(item.EnableTooltip)) colItem.EnableTooltip=item.EnableTooltip;
1514
+ if (IFrameSplitOperator.IsNumber(item.FixedWidth)) colItem.FixedWidth=item.FixedWidth;
1515
+
1516
+ if (item.Sort==1) //1本地排序 2=远程排序
1517
+ {
1518
+ colItem.SortType=[1,2]; //默认 降序 ,升序
1519
+ if (IFrameSplitOperator.IsNonEmptyArray(item.SortType)) colItem.SortType=item.SortType.slice();
1520
+ }
1521
+
1522
+ this.Column.push(colItem);
1523
+ }
1524
+ }
1525
+
1526
+ this.GetDefaultColunm=function(id)
1527
+ {
1528
+ var DEFAULT_COLUMN=
1529
+ [
1530
+ { Type:TREPORT_COLUMN_ID.INDEX_ID, Title:"序号", TextAlign:"center", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Index, MaxText:"8888"},
1531
+ { Type:TREPORT_COLUMN_ID.SYMBOL_ID, Title:"代码", TextAlign:"right", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Symbol, MaxText:"888888"},
1532
+ { Type:TREPORT_COLUMN_ID.NAME_ID, Title:"合约名称", TextAlign:"right", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Name, MaxText:"AAAAAA-A-AAAA" },
1533
+
1534
+ { Type:TREPORT_COLUMN_ID.INCREASE_ID, Title:"涨幅%", TextAlign:"right", Width:null, MaxText:"-888.88", Sort:1, SortType:[1,2,0] },
1535
+ { Type:TREPORT_COLUMN_ID.PRICE_ID, Title:"现价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
1536
+ { Type:TREPORT_COLUMN_ID.UPDOWN_ID, Title:"涨跌", TextAlign:"right", Width:null, MaxText:"-888.88", Sort:1, SortType:[1,2,0] },
1537
+ { Type:TREPORT_COLUMN_ID.AMPLITUDE_ID, Title:"振幅%", TextAlign:"right", Width:null, MaxText:"888.88", Sort:1, SortType:[1,2,0] },
1538
+ { Type:TREPORT_COLUMN_ID.BUY_PRICE_ID, Title:"买价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
1539
+ { Type:TREPORT_COLUMN_ID.SELL_PRICE_ID, Title:"卖价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
1540
+ { Type:TREPORT_COLUMN_ID.AVERAGE_PRICE_ID, Title:"均价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
1541
+ { Type:TREPORT_COLUMN_ID.OPEN_ID, Title:"今开", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
1542
+ { Type:TREPORT_COLUMN_ID.HIGH_ID, Title:"最高", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
1543
+ { Type:TREPORT_COLUMN_ID.LOW_ID, Title:"最低", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
1544
+ { Type:TREPORT_COLUMN_ID.YCLOSE_ID, Title:"昨收", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
1545
+
1546
+ { Type:TREPORT_COLUMN_ID.POSITION_ID, Title:"持仓量", TextAlign:"right", Width:null, MaxText:"88888", Sort:1, SortType:[1,2,0], TextColor:g_JSChartResource.TReport.FieldColor.Position },
1547
+
1548
+ { Type:TREPORT_COLUMN_ID.VOL_ID, Title:"总量", TextAlign:"right", TextColor:g_JSChartResource.TReport.FieldColor.Vol, Width:null, MaxText:"88888", Sort:1, SortType:[1,2,0] },
1549
+ { Type:TREPORT_COLUMN_ID.AMOUNT_ID, Title:"总金额", TextAlign:"right", TextColor:g_JSChartResource.TReport.FieldColor.Amount, Width:null, MaxText:"8888.8擎", Sort:1, SortType:[1,2,0] },
1550
+
1551
+ { Type:TREPORT_COLUMN_ID.BUY_VOL_ID, Title:"买量", TextAlign:"right", TextColor:g_JSChartResource.TReport.FieldColor.Vol, Width:null, MaxText:"88888", Sort:1, SortType:[1,2,0] },
1552
+ { Type:TREPORT_COLUMN_ID.SELL_VOL_ID, Title:"卖量", TextAlign:"right", TextColor:g_JSChartResource.TReport.FieldColor.Vol, Width:null, MaxText:"88888", Sort:1, SortType:[1,2,0] },
1553
+ ];
1554
+
1555
+ for(var i=0;i<DEFAULT_COLUMN.length;++i)
1556
+ {
1557
+ var item=DEFAULT_COLUMN[i];
1558
+ if (item.Type==id) return item;
1559
+ }
1560
+
1561
+ return null;
1562
+ }
1563
+
1564
+ this.Draw=function()
1565
+ {
1566
+ this.ShowSymbol=[];
1567
+ this.TooltipRect=[];
1568
+ this.RectSelectedRow=null;
1569
+
1570
+ if (this.GlobalOption) this.GlobalOption.FlashBGCount=0;
1571
+
1572
+ if (this.SizeChange) this.CalculateSize();
1573
+ else this.UpdateCacheData();
1574
+
1575
+ this.Canvas.save();
1576
+
1577
+ this.Canvas.beginPath();
1578
+ this.Canvas.rect(this.RectClient.Left,this.RectClient.Top,(this.RectClient.Right-this.RectClient.Left),(this.RectClient.Bottom-this.RectClient.Top));
1579
+ //this.Canvas.stroke(); //调试用
1580
+ this.Canvas.clip();
1581
+
1582
+ this.DrawHeader();
1583
+ this.DrawBody();
1584
+ this.Canvas.restore();
1585
+
1586
+ //this.DrawBorder();
1587
+
1588
+ this.SizeChange=false;
1589
+ }
1590
+
1591
+ //更新缓存变量
1592
+ this.UpdateCacheData=function()
1593
+ {
1594
+ this.RectClient.Left=this.ChartBorder.GetLeft();
1595
+ this.RectClient.Right=this.ChartBorder.GetRight();
1596
+ this.RectClient.Top=this.ChartBorder.GetTop();
1597
+ this.RectClient.Bottom=this.ChartBorder.GetBottom();
1598
+ }
1599
+
1600
+ this.CalculateSize=function() //计算大小
1601
+ {
1602
+ this.UpdateCacheData();
1603
+
1604
+ var pixelRatio=GetDevicePixelRatio();
1605
+ this.HeaderFont=`${this.HeaderFontConfig.Size*pixelRatio}px ${ this.HeaderFontConfig.Name}`;
1606
+ this.ItemFont=`${this.ItemFontConfig.Size*pixelRatio}px ${ this.ItemFontConfig.Name}`;
1607
+
1608
+ this.RowHeight=this.GetFontHeight(this.ItemFont,"擎")+ this.ItemMergin.Top+ this.ItemMergin.Bottom;
1609
+
1610
+ this.Canvas.font=this.ItemFont;
1611
+ var itemWidth=0;
1612
+ for(var i=0;i<this.Column.length;++i)
1613
+ {
1614
+ var item=this.Column[i];
1615
+ if (IFrameSplitOperator.IsNumber(item.FixedWidth)) itemWidth=item.FixedWidth;
1616
+ else itemWidth=this.Canvas.measureText(item.MaxText).width;
1617
+
1618
+ item.Width=itemWidth+4+this.ItemMergin.Left+this.ItemMergin.Right;
1619
+ }
1620
+
1621
+ //表头中间列
1622
+ var item=this.CenterColumn;
1623
+ if (IFrameSplitOperator.IsNumber(item.FixedWidth)) itemWidth=item.FixedWidth;
1624
+ else itemWidth=this.Canvas.measureText(item.MaxText).width;
1625
+ item.Width=itemWidth+4+this.ItemMergin.Left+this.ItemMergin.Right;
1626
+
1627
+ this.Canvas.font=this.HeaderFont;
1628
+ for(var i=0;i<this.Column.length;++i)
1629
+ {
1630
+ var item=this.Column[i];
1631
+ if (!item.Title || item.Title.length<=0) continue;
1632
+ var text=item.Title;
1633
+ if (item.Sort>0) text+="↓";
1634
+ itemWidth=this.Canvas.measureText(text).width;
1635
+ itemWidth+=(4+this.HeaderMergin.Left+this.HeaderMergin.Right);
1636
+ if (item.Width<itemWidth) item.Width=itemWidth;
1637
+ }
1638
+
1639
+ //表头中间列
1640
+ var item=this.CenterColumn;
1641
+ if (!item.Title || item.Title.length>0)
1642
+ {
1643
+ var text=item.Title;
1644
+ if (item.Sort>0) text+="↓";
1645
+ itemWidth=this.Canvas.measureText(text).width;
1646
+ itemWidth+=(4+this.HeaderMergin.Left+this.HeaderMergin.Right);
1647
+ if (item.Width<itemWidth) item.Width=itemWidth;
1648
+ }
1649
+
1650
+
1651
+ this.HeaderHeight=this.GetFontHeight(this.HeaderFont,"擎")+ this.HeaderMergin.Top+ this.HeaderMergin.Bottom;
1652
+ if (!this.IsShowHeader) this.HeaderHeight=0;
1653
+
1654
+ this.RowCount=parseInt((this.RectClient.Bottom-this.RectClient.Top-this.HeaderHeight)/this.RowHeight);
1655
+
1656
+ var subWidth=this.CenterColumn.Width;
1657
+ var reportWidth=this.RectClient.Right-this.RectClient.Left;
1658
+ for(var i=0;i<this.Column.length;++i)
1659
+ {
1660
+ var item=this.Column[i];
1661
+ subWidth+=item.Width*2;
1662
+ }
1663
+
1664
+ if (subWidth<reportWidth)
1665
+ {
1666
+ this.IsShowAllColumn=true;
1667
+ this.ItemExtraWidth=0;
1668
+ if (reportWidth-subWidth-4>0)
1669
+ this.ItemExtraWidth=(reportWidth-subWidth-4)/(this.Column.length*2+1);
1670
+ }
1671
+ else
1672
+ {
1673
+ this.IsShowAllColumn=false;
1674
+ this.ItemExtraWidth=0;
1675
+ }
1676
+ }
1677
+
1678
+ this.DrawHeader=function()
1679
+ {
1680
+ if (!this.IsShowHeader) return;
1681
+
1682
+ var left=this.RectClient.Left;
1683
+ var top=this.RectClient.Top;
1684
+ var y=top+this.HeaderMergin.Top+(this.HeaderHeight-this.HeaderMergin.Top-this.HeaderMergin.Bottom)/2;
1685
+ var xCenter=(this.RectClient.Right-this.RectClient.Left)/2+this.RectClient.Left;
1686
+
1687
+ this.Canvas.font=this.HeaderFont;
1688
+ this.Canvas.fillStyle=this.HeaderColor;
1689
+
1690
+ var reportleft=this.RectClient.Left;
1691
+ var reportRight=this.RectClient.Right;
1692
+
1693
+ //中间列
1694
+ var item=this.CenterColumn;
1695
+ var rtCenterItem=this.GetCenterItemRect();
1696
+ if (this.SortInfo && this.SortInfo.Sort>0 && this.SortInfo.CellType==0)
1697
+ this.DrawSortHeader(item.Title,item.TextAlign,rtCenterItem.Left,y,rtCenterItem.TextWidth,this.SortInfo.Sort);
1698
+ else
1699
+ this.DrawText(item.Title,item.TextAlign,rtCenterItem.Left,y,rtCenterItem.TextWidth);
1700
+
1701
+ var xLeft=rtCenterItem.Left; //左边
1702
+ var xRight=rtCenterItem.Right;//右边
1703
+ for(var i=this.Data.XOffset;i<this.Column.length;++i)
1704
+ {
1705
+ var item=this.Column[i];
1706
+ var itemWidth=item.Width+this.ItemExtraWidth;
1707
+ var textWidth=itemWidth-this.HeaderMergin.Left-this.HeaderMergin.Right;
1708
+ var x=xLeft-itemWidth+this.HeaderMergin.Left;
1709
+
1710
+ if (xLeft-itemWidth<reportleft) break;
1711
+
1712
+ var bSort=(this.SortInfo && this.SortInfo.Field==i && this.SortInfo.Sort>0);
1713
+ if (bSort && this.SortInfo.CellType==1) this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort);
1714
+ else this.DrawText(item.Title,item.TextAlign,x,y,textWidth);
1715
+ xLeft-=itemWidth;
1716
+
1717
+ var x=xRight+this.HeaderMergin.Left;
1718
+ if (bSort && this.SortInfo.CellType==2) this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort);
1719
+ else this.DrawText(item.Title,item.TextAlign,x,y,textWidth);
1720
+ xRight+=itemWidth;
1721
+ }
1722
+ }
1723
+
1724
+ this.DrawSortHeader=function(text, textAlign, x, y, width, sortType)
1725
+ {
1726
+ var sortText=sortType==1?"↓":"↑";
1727
+ var sortTextWidth=this.Canvas.measureText(sortText).width;
1728
+ var textWidth=this.Canvas.measureText(text).width+2;
1729
+ this.Canvas.textBaseline="middle";
1730
+ this.Canvas.textAlign="left";
1731
+
1732
+ if (textAlign=='center')
1733
+ {
1734
+ x=x+width/2-(sortTextWidth+textWidth)/2;
1735
+ }
1736
+ else if (textAlign=='right')
1737
+ {
1738
+ x=(x+width)-sortTextWidth-textWidth;
1739
+ }
1740
+ else
1741
+ {
1742
+
1743
+ }
1744
+
1745
+ this.Canvas.fillText(text,x,y);
1746
+ this.Canvas.fillStyle=this.SortColor;
1747
+ this.Canvas.fillText(sortText,x+textWidth,y);
1748
+ this.Canvas.fillStyle=this.HeaderColor;
1749
+ }
1750
+
1751
+ this.DrawText=function(text, textAlign, x, y, textWidth)
1752
+ {
1753
+ if (textAlign=='center')
1754
+ {
1755
+ x=x+textWidth/2;
1756
+ this.Canvas.textAlign="center";
1757
+ }
1758
+ else if (textAlign=='right')
1759
+ {
1760
+ x=x+textWidth;
1761
+ this.Canvas.textAlign="right";
1762
+ }
1763
+ else
1764
+ {
1765
+ this.Canvas.textAlign="left";
1766
+ }
1767
+
1768
+ this.Canvas.textBaseline="middle";
1769
+ this.Canvas.fillText(text,x,y);
1770
+ }
1771
+
1772
+ this.GetFontHeight=function(font,word)
1773
+ {
1774
+ return GetFontHeight(this.Canvas, font, word);
1775
+ }
1776
+
1777
+ this.DrawBody=function()
1778
+ {
1779
+ if (!this.Data) return;
1780
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
1781
+
1782
+ this.Canvas.font=this.ItemFont;
1783
+ var top=this.RectClient.Top+this.HeaderHeight;
1784
+ var left=this.RectClient.Left;
1785
+ var rowWidth=this.RectClient.Right-this.RectClient.Left;
1786
+
1787
+ var textTop=top;
1788
+ this.Canvas.font=this.ItemFont;
1789
+ for(var i=this.Data.YOffset, j=0; i<this.Data.Data.length && j<this.RowCount ;++i, ++j)
1790
+ {
1791
+ var exePrice=this.Data.Data[i];
1792
+
1793
+ this.DrawRow(exePrice, textTop, i);
1794
+
1795
+ this.ShowSymbol.push( { Index:i, ExePrice:exePrice } );
1796
+
1797
+ textTop+=this.RowHeight;
1798
+ }
1799
+
1800
+ if (this.RectSelectedRow)
1801
+ {
1802
+ this.Canvas.fillStyle=this.SelectedColor;
1803
+ var lineWidth=2;
1804
+ this.Canvas.fillRect(this.RectSelectedRow.Left,this.RectSelectedRow.Bottom-lineWidth, (this.RectSelectedRow.Right-this.RectSelectedRow.Left), lineWidth);
1805
+ }
1806
+ }
1807
+
1808
+ this.GetCenterItemRect=function()
1809
+ {
1810
+ var xCenter=(this.RectClient.Right-this.RectClient.Left)/2+this.RectClient.Left;
1811
+
1812
+ //中间列
1813
+ var item=this.CenterColumn;
1814
+ var itemWidth=item.Width+this.ItemExtraWidth;
1815
+ var left=xCenter-itemWidth/2;
1816
+ var right=xCenter+itemWidth/2;
1817
+ var textWidth=itemWidth-this.HeaderMergin.Left-this.HeaderMergin.Right;
1818
+
1819
+ return { Left:left, Right:right, TextWidth:textWidth, Width:itemWidth };
1820
+ }
1821
+
1822
+ this.DrawRow=function(exePrice, top, dataIndex)
1823
+ {
1824
+ var rtCenterItem=this.GetCenterItemRect();
1825
+
1826
+ var xLeft=rtCenterItem.Left; //左边
1827
+ var xRight=rtCenterItem.Right; //右边
1828
+
1829
+ var reportleft=this.RectClient.Left;
1830
+ var reportRight=this.RectClient.Right;
1831
+
1832
+ var data= { ExePrice:exePrice , TData:null };
1833
+ if (this.GetExePriceDataCallback) data.TData=this.GetExePriceDataCallback(exePrice);
1834
+ //if (this.GetFlashBGDataCallback) data.FlashBG=this.GetFlashBGDataCallback(exePrice, Date.now());
1835
+ data.Decimal=2;
1836
+
1837
+ var bSelected=false;
1838
+ if (this.SelectedRow && this.SelectedRow.ExePrice==exePrice) bSelected=true;
1839
+
1840
+ var rtItem={ Left:xLeft, Right:xRight, Top:top, Height:this.RowHeight };
1841
+ rtItem.Bottom=rtItem.Top+rtItem.Height;
1842
+ rtItem.Width=rtItem.Right-rtItem.Left;
1843
+ this.DrawCenterItem(dataIndex, data, this.CenterColumn, rtItem, 0);
1844
+ if (bSelected && this.SelectedRow.CellType==0) this.RectSelectedRow=rtItem;
1845
+
1846
+ if (IFrameSplitOperator.IsNumber(this.Data.BaseExePrice))
1847
+ {
1848
+ var leftBGColor=null, rightBGColor=null;
1849
+ if (exePrice>this.Data.BaseExePrice)
1850
+ {
1851
+ leftBGColor=this.UpBGColor;
1852
+ rightBGColor=this.DownBGColor;
1853
+ }
1854
+ else
1855
+ {
1856
+ leftBGColor=this.DownBGColor;
1857
+ rightBGColor=this.UpBGColor;
1858
+ }
1859
+
1860
+ if (leftBGColor)
1861
+ {
1862
+ var rtBG={Left:reportleft+1, Right:rtCenterItem.Left, Top:top, Height:this.RowHeight };
1863
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
1864
+ rtBG.Width=rtBG.Right-rtBG.Left;
1865
+ this.Canvas.fillStyle=leftBGColor;
1866
+ this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
1867
+ }
1868
+
1869
+ if (rightBGColor)
1870
+ {
1871
+ var rtBG={Left:rtCenterItem.Right, Right:reportRight, Top:top, Height:this.RowHeight };
1872
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
1873
+ rtBG.Width=rtBG.Right-rtBG.Left;
1874
+ this.Canvas.fillStyle=rightBGColor;
1875
+ this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
1876
+ }
1877
+ }
1878
+
1879
+ for(var i=this.Data.XOffset;i<this.Column.length;++i)
1880
+ {
1881
+ var item=this.Column[i];
1882
+ var itemWidth=item.Width+this.ItemExtraWidth;
1883
+ xLeft-=itemWidth;
1884
+ if (xLeft<reportleft) break;
1885
+
1886
+ var leftData=null, rightData=null;
1887
+ if (data.TData) leftData=data.TData.LeftData;
1888
+ if (data.TData) rightData=data.TData.RightData;
1889
+
1890
+ rtItem={ Left:xLeft, Right:xLeft+itemWidth, Top:top, Height:this.RowHeight, Width:itemWidth };
1891
+ rtItem.Bottom=rtItem.Top+rtItem.Height;
1892
+
1893
+ this.DrawItem(dataIndex, data, leftData, item, rtItem, 1);
1894
+
1895
+ if (bSelected && this.SelectedRow.CellType==1)
1896
+ {
1897
+ if (!this.RectSelectedRow) this.RectSelectedRow=rtItem;
1898
+ else this.RectSelectedRow.Left=rtItem.Left;
1899
+ }
1900
+
1901
+ rtItem={ Left:xRight, Right:xRight+itemWidth, Top:top, Height:this.RowHeight, Width:itemWidth };
1902
+ rtItem.Bottom=rtItem.Top+rtItem.Height;
1903
+
1904
+ this.DrawItem(dataIndex, data, rightData, item, rtItem, 2);
1905
+ xRight+=itemWidth;
1906
+
1907
+ if (bSelected && this.SelectedRow.CellType==2)
1908
+ {
1909
+ if (!this.RectSelectedRow) this.RectSelectedRow=rtItem;
1910
+ else this.RectSelectedRow.Right=rtItem.Right;
1911
+ }
1912
+ }
1913
+ }
1914
+
1915
+ this.DrawCenterItem=function(index, data, column, rtItem, cellType) //cellType 0=中间字段 1=左侧 2=右侧
1916
+ {
1917
+ //tooltip提示
1918
+ if (column.EnableTooltip===true) this.TooltipRect.push({ Rect:rtItem, data:data, Index:index, Column:column, CellType:cellType });
1919
+
1920
+ var rtText={ Left:rtItem.Left+this.ItemMergin.Left, Right:rtItem.Right-this.ItemMergin.Right, Top:rtItem.Top+this.ItemMergin.Top, Bottom:rtItem.Bottom-this.ItemMergin.Bottom };
1921
+ rtText.Width=rtText.Right-rtText.Left;
1922
+ rtText.Height=rtText.Bottom-rtText.Top;
1923
+
1924
+ var drawInfo={ Text:null, TextColor:this.CenterItemConfig.TextColor, BGColor:this.CenterItemConfig.BGColor, TextAlign:column.TextAlign, Rect:rtItem, RectText:rtText };
1925
+ drawInfo.Text=`${data.ExePrice.toFixed(data.Decimal)}`;
1926
+
1927
+ this.DrawCell(drawInfo);
1928
+ }
1929
+
1930
+ this.DrawItem=function(index, exePriceData, data, column, rtItem, cellType)
1931
+ {
1932
+ if (column.EnableTooltip===true) this.TooltipRect.push({ Rect:rtItem, data:data, Index:index, Column:column, CellType:cellType });
1933
+
1934
+ var rtText={ Left:rtItem.Left+this.ItemMergin.Left, Right:rtItem.Right-this.ItemMergin.Right, Top:rtItem.Top+this.ItemMergin.Top, Bottom:rtItem.Bottom-this.ItemMergin.Bottom };
1935
+ rtText.Width=rtText.Right-rtText.Left;
1936
+ rtText.Height=rtText.Bottom-rtText.Top;
1937
+
1938
+ var drawInfo={ Text:null, TextColor:column.TextColor , TextAlign:column.TextAlign, Rect:rtItem, RectText:rtText };
1939
+
1940
+ if (data)
1941
+ {
1942
+ switch(column.Type)
1943
+ {
1944
+ case TREPORT_COLUMN_ID.SYMBOL_ID:
1945
+ case TREPORT_COLUMN_ID.NAME_ID:
1946
+ var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
1947
+ if (fieldName) drawInfo.Text=data[fieldName];
1948
+ break;
1949
+
1950
+ case TREPORT_COLUMN_ID.PRICE_ID: //最新价格
1951
+ case TREPORT_COLUMN_ID.BUY_PRICE_ID: //买价
1952
+ case TREPORT_COLUMN_ID.SELL_PRICE_ID: //卖价
1953
+ var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
1954
+ if (fieldName) this.GetPriceDrawInfo(data[fieldName], data, exePriceData, drawInfo);
1955
+ break;
1956
+
1957
+ case TREPORT_COLUMN_ID.SELL_VOL_ID: //卖量
1958
+ case TREPORT_COLUMN_ID.BUY_VOL_ID: //买量
1959
+ case TREPORT_COLUMN_ID.POSITION_ID: //持仓量
1960
+ var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
1961
+ if (fieldName) drawInfo.Text=this.FormatVolString(data[fieldName]);
1962
+ break;
1963
+ case TREPORT_COLUMN_ID.INCREASE_ID:
1964
+ case TREPORT_COLUMN_ID.UPDOWN_ID:
1965
+ case TREPORT_COLUMN_ID.AMPLITUDE_ID:
1966
+ var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
1967
+ if (fieldName)
1968
+ {
1969
+ var value=data[fieldName];
1970
+ if (IFrameSplitOperator.IsNumber(value))
1971
+ {
1972
+ drawInfo.Text=value.toFixed(2);
1973
+ drawInfo.TextColor=this.GetUpDownColor(value,0);
1974
+ }
1975
+ else
1976
+ {
1977
+ this.GetNullDrawInfo(drawInfo);
1978
+ }
1979
+ }
1980
+ break;
1981
+
1982
+ default:
1983
+ drawInfo.Text=`-----`;
1984
+ }
1985
+
1986
+ this.GetMarkBorderData(drawInfo, exePriceData.ExePrice, column.Type, cellType);
1987
+ }
1988
+
1989
+ this.DrawCell(drawInfo);
1990
+ }
1991
+
1992
+ this.GetMarkBorderData=function(drawInfo, exePrice, columnType, cellType)
1993
+ {
1994
+ if (!this.BorderData || !this.BorderData.MapData) return;
1995
+ if (!this.BorderData.MapData.has(columnType)) return;
1996
+ var borderData=this.BorderData.MapData.get(columnType);
1997
+ if (!IFrameSplitOperator.IsNonEmptyArray(borderData.Data)) return;
1998
+
1999
+ if (cellType==1)
2000
+ {
2001
+ var leftBorder=borderData.Data[1];
2002
+ if (!leftBorder) return;
2003
+
2004
+ if (leftBorder.ExePrice==exePrice)
2005
+ {
2006
+ drawInfo.BorderColor=this.MarkBorderConfig.MaxPositionColor;
2007
+ }
2008
+
2009
+ }
2010
+ else if (cellType==2)
2011
+ {
2012
+ var rightBorder=borderData.Data[2];
2013
+ if (!rightBorder) return;
2014
+ if (rightBorder.ExePrice==exePrice)
2015
+ {
2016
+ drawInfo.BorderColor=this.MarkBorderConfig.MaxPositionColor;
2017
+ }
2018
+ }
2019
+ }
2020
+
2021
+ this.GetNullDrawInfo=function(drawInfo)
2022
+ {
2023
+ drawInfo.Text="--";
2024
+ drawInfo.TextColor=this.UnchangeColor;
2025
+ }
2026
+
2027
+ this.GetPriceDrawInfo=function(price, stock, data, drawInfo)
2028
+ {
2029
+ if (!IFrameSplitOperator.IsNumber(price))
2030
+ {
2031
+ this.GetNullDrawInfo(drawInfo);
2032
+ return;
2033
+ }
2034
+
2035
+ drawInfo.Text=price.toFixed(data.Decimal);
2036
+ if (!IFrameSplitOperator.IsNumber(stock.YClose))
2037
+ drawInfo.TextColor=this.UnchangeColor;
2038
+ else
2039
+ drawInfo.TextColor=this.GetUpDownColor(price, stock.YClose);
2040
+ }
2041
+
2042
+ //单独处理成交量显示
2043
+ this.FormatVolString=function(value,languageID)
2044
+ {
2045
+ if (!IFrameSplitOperator.IsNumber(value)) return null;
2046
+
2047
+ return IFrameSplitOperator.FormatVolString(value, languageID);
2048
+ }
2049
+
2050
+ this.GetUpDownColor=function(price, price2)
2051
+ {
2052
+ if (price>price2) return this.UpColor;
2053
+ else if (price<price2) return this.DownColor;
2054
+ else return this.UnchangeColor;
2055
+ }
2056
+
2057
+ this.DrawCell=function(drawInfo)
2058
+ {
2059
+ var rtText=drawInfo.RectText;
2060
+ var yCenter=rtText.Top+(rtText.Height/2);
2061
+
2062
+ if (drawInfo.BGColor) //背景
2063
+ {
2064
+ var rtItem=drawInfo.Rect;
2065
+ this.Canvas.fillStyle=drawInfo.BGColor;
2066
+ this.Canvas.fillRect(rtItem.Left,rtItem.Top,rtItem.Width,rtItem.Height);
2067
+ }
2068
+
2069
+ if (drawInfo.BorderColor) //边框
2070
+ {
2071
+ var rtItem=drawInfo.Rect;
2072
+ this.Canvas.strokeStyle=drawInfo.BorderColor;
2073
+ this.Canvas.strokeRect(ToFixedPoint(rtItem.Left),ToFixedPoint(rtItem.Top+1),ToFixedRect(rtItem.Width),ToFixedRect(rtItem.Height-3));
2074
+ }
2075
+
2076
+ if (drawInfo.Text) //文字
2077
+ {
2078
+ if(drawInfo.TextColor) this.Canvas.fillStyle=drawInfo.TextColor;
2079
+ this.DrawText(drawInfo.Text, drawInfo.TextAlign, rtText.Left, yCenter, rtText.Width);
2080
+ }
2081
+ }
2082
+
2083
+ this.OnMouseDown=function(x,y,e) //Type: 2=行 3=表头
2084
+ {
2085
+ if (!this.Data) return null;
2086
+
2087
+ var pixelTatio = GetDevicePixelRatio();
2088
+ var insidePoint={X:x/pixelTatio, Y:y/pixelTatio};
2089
+
2090
+ if (this.UIElement)
2091
+ var uiElement={Left:this.UIElement.getBoundingClientRect().left, Top:this.UIElement.getBoundingClientRect().top};
2092
+ else
2093
+ var uiElement={Left:null, Top:null};
2094
+
2095
+ var row=this.PtInBody(x,y);
2096
+ if (row)
2097
+ {
2098
+ var bRedraw=false;
2099
+ if (!this.SelectedRow)
2100
+ {
2101
+ this.SelectedRow={ ExePrice:row.ExePrice, CellType:row.CellType };
2102
+ bRedraw=true;
2103
+ }
2104
+ else if (this.SelectedRow.ExePrice!=row.ExePrice || this.SelectedRow.CellType!=row.CellType)
2105
+ {
2106
+ this.SelectedRow.ExePrice=row.ExePrice;
2107
+ this.SelectedRow.CellType=row.CellType;
2108
+ bRedraw=true;
2109
+ }
2110
+
2111
+ var eventID=JSCHART_EVENT_ID.ON_CLICK_TREPORT_ROW;
2112
+ if (e.button==2) eventID=JSCHART_EVENT_ID.ON_RCLICK_TREPORT_ROW;
2113
+
2114
+ this.SendClickEvent(eventID, { Data:row, X:x, Y:y, e:e, Inside:insidePoint, UIElement:uiElement });
2115
+
2116
+ return { Type:2, Redraw:bRedraw, Row:row }; //行
2117
+ }
2118
+
2119
+ var header=this.PtInHeader(x,y);
2120
+ if (header)
2121
+ {
2122
+ var eventID=JSCHART_EVENT_ID.ON_CLICK_TREPORT_HEADER;
2123
+ if (e.button==2)
2124
+ {
2125
+ eventID=JSCHART_EVENT_ID.ON_RCLICK_TREPORT_HEADER;
2126
+ }
2127
+ else if (e.button==0)
2128
+ {
2129
+ eventID=JSCHART_EVENT_ID.ON_CLICK_TREPORT_HEADER;
2130
+ }
2131
+
2132
+ this.SendClickEvent(eventID, { Data:header, X:x, Y:y , e:e, Inside:insidePoint, UIElement:uiElement});
2133
+ return { Type:3, Redraw:bRedraw, Header:header }; //表头
2134
+ }
2135
+
2136
+ return null;
2137
+ }
2138
+
2139
+ this.PtInBody=function(x,y)
2140
+ {
2141
+ if (!this.Data) return null;
2142
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return null;
2143
+
2144
+ var top=this.RectClient.Top+this.HeaderHeight;
2145
+ var left=this.RectClient.Left;
2146
+ var right=this.RectClient.Right;
2147
+
2148
+ var textTop=top;
2149
+ for(var i=this.Data.YOffset, j=0; i<this.Data.Data.length && j<this.RowCount ;++i, ++j)
2150
+ {
2151
+ var exePrice=this.Data.Data[i];
2152
+ var rtRow={ Left:left, Top:textTop, Right:right, Bottom: textTop+this.RowHeight };
2153
+ rtRow.Height=rtRow.Bottom-rtRow.Top;
2154
+ rtRow.Width=rtRow.Right-rtRow.Left;
2155
+ if (x>=rtRow.Left && x<=rtRow.Right && y>=rtRow.Top && y<=rtRow.Bottom)
2156
+ {
2157
+ var data={ RectRow:rtRow, DataIndex:i, Index:j, ExePrice:exePrice };
2158
+ return this.PtInItem(x,y, data);
2159
+ }
2160
+
2161
+ textTop+=this.RowHeight;
2162
+ }
2163
+
2164
+ return null;
2165
+ }
2166
+
2167
+ this.PtInItem=function(x, y, info, exePrice)
2168
+ {
2169
+ var rtCenterItem=this.GetCenterItemRect();
2170
+ var rtRow=info.RectRow;
2171
+ var rtCenter={Left:rtCenterItem.Left, Right:rtCenterItem.Right, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom };
2172
+
2173
+ if (x>=rtCenter.Left && x<=rtCenter.Right && y>=rtCenter.Top && y<=rtCenter.Bottom)
2174
+ {
2175
+ var data={ Rect:rtCenter, DataIndex:info.DataIndex, Index:info.Index , ExePrice:info.ExePrice, CellType:0, Column:this.CenterColumn };
2176
+ data.Item=this.GetExePriceDataCallback(info.ExePrice);
2177
+ return data;
2178
+ }
2179
+
2180
+ var xLeft=rtCenterItem.Left; //左边
2181
+ var xRight=rtCenterItem.Right; //右边
2182
+
2183
+ var reportleft=this.RectClient.Left;
2184
+ var reportRight=this.RectClient.Right;
2185
+
2186
+ for(var i=this.Data.XOffset;i<this.Column.length;++i)
2187
+ {
2188
+ var item=this.Column[i];
2189
+ var itemWidth=item.Width+this.ItemExtraWidth;
2190
+ xLeft-=itemWidth;
2191
+ if (xLeft<reportleft) break;
2192
+
2193
+ var rtItem={ Left:xLeft, Right:xLeft+itemWidth, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom, Width:itemWidth };
2194
+ if (x>=rtItem.Left && x<=rtItem.Right && y>=rtItem.Top && y<=rtItem.Bottom)
2195
+ {
2196
+ var data={ Rect:rtCenter, DataIndex:info.DataIndex, Index:info.Index , ExePrice:info.ExePrice, CellType:1, ColumnIndex:i, Column:item };
2197
+ data.Item=this.GetExePriceDataCallback(info.ExePrice);
2198
+ return data;
2199
+ }
2200
+
2201
+ rtItem={ Left:xRight, Right:xRight+itemWidth, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom, Width:itemWidth };
2202
+ if (x>=rtItem.Left && x<=rtItem.Right && y>=rtItem.Top && y<=rtItem.Bottom)
2203
+ {
2204
+ var data={ Rect:rtCenter, DataIndex:info.DataIndex, Index:info.Index , ExePrice:info.ExePrice, CellType:2, ColumnIndex:i, Column:item };
2205
+ data.Item=this.GetExePriceDataCallback(info.ExePrice);
2206
+ return data;
2207
+ }
2208
+
2209
+ xRight+=itemWidth;
2210
+ }
2211
+
2212
+ return null;
2213
+ }
2214
+
2215
+ this.PtInHeader=function(x,y)
2216
+ {
2217
+ if (!this.IsShowHeader) return null;
2218
+
2219
+ var left=this.RectClient.Left;
2220
+ var right=this.RectClient.Right;
2221
+ var top=this.RectClient.Top;
2222
+ var bottom=top+this.HeaderHeight;
2223
+
2224
+ if (!(x>=left && x<=right && y>=top && y<=bottom)) return null;
2225
+
2226
+ var rtHeader={Left:left, Right:right, Top:top, Bottom:bottom};
2227
+ rtHeader.Width=rtHeader.Right-rtHeader.Left;
2228
+ rtHeader.Height=rtHeader.Bottom-rtHeader.Top;
2229
+ var data={ RectRow:rtHeader, DataIndex:-1, Index:-1, ExePrice:null };
2230
+ return this.PtInItem(x,y, data);
2231
+ }
2232
+
2233
+ this.SendClickEvent=function(id, data)
2234
+ {
2235
+ var event=this.GetEventCallback(id);
2236
+ if (event && event.Callback)
2237
+ {
2238
+ event.Callback(event,data,this);
2239
+ }
2240
+ }
2241
+
2242
+
2243
+ this.GetCurrentPageStatus=function() //{ Start:起始索引, End:结束索引(数据), PageSize:页面可以显示几条记录, IsEnd:是否是最后一页, IsSinglePage:是否只有一页数据}
2244
+ {
2245
+ var result={ Start:this.Data.YOffset, PageSize:this.RowCount, IsEnd:false, SelectedRow:this.SelectedRow, IsSinglePage:false, DataCount:0 };
2246
+ if (IFrameSplitOperator.IsNonEmptyArray(this.Data.Data))
2247
+ {
2248
+ result.End=this.Data.YOffset+this.RowCount-1;
2249
+ result.IsSinglePage=this.Data.Data.length<=this.RowCount;
2250
+ result.DataCount=this.Data.Data.length;
2251
+ if (result.End>=this.Data.Data.length-1) result.IsEnd=true;
2252
+ if (result.End>=this.Data.Data.length) result.End=this.Data.Data.length-1;
2253
+ }
2254
+ else
2255
+ {
2256
+ result.Start=0;
2257
+ result.End=0;
2258
+ result.IsEnd=true;
2259
+ result.IsSinglePage=true;
2260
+ }
2261
+
2262
+ return result;
2263
+ }
2264
+
2265
+ }
2266
+
2267
+