hqchart 1.1.13081 → 1.1.13090
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/umychart.vue.js +314 -27
- package/package.json +1 -1
- package/src/jscommon/umychart.TReport.js +2398 -0
- package/src/jscommon/umychart.js +118 -14
- package/src/jscommon/umychart.report.js +1 -1
- package/src/jscommon/umychart.style.js +53 -0
- package/src/jscommon/umychart.uniapp.h5/umychart.uniapp.h5.js +173 -16
- package/src/jscommon/umychart.version.js +1 -1
- package/src/jscommon/umychart.vue/umychart.vue.js +2739 -180
|
@@ -0,0 +1,2398 @@
|
|
|
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.UIOnDblClick=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.GetTReportChart();
|
|
865
|
+
if (chart) chart.OnDblClick(x,y,e);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
this.UIOnMouseDown=function(e)
|
|
869
|
+
{
|
|
870
|
+
var pixelTatio = GetDevicePixelRatio();
|
|
871
|
+
var x = (e.clientX-this.UIElement.getBoundingClientRect().left)*pixelTatio;
|
|
872
|
+
var y = (e.clientY-this.UIElement.getBoundingClientRect().top)*pixelTatio;
|
|
873
|
+
|
|
874
|
+
var chart=this.ChartPaint[0];
|
|
875
|
+
if (!chart) return;
|
|
876
|
+
|
|
877
|
+
var clickData=chart.OnMouseDown(x,y,e);
|
|
878
|
+
if (!clickData) return;
|
|
879
|
+
|
|
880
|
+
if ((clickData.Type==2) && (e.button==0 || e.button==2)) //点击行
|
|
881
|
+
{
|
|
882
|
+
if (clickData.Redraw==true) this.Draw();
|
|
883
|
+
}
|
|
884
|
+
else if (clickData.Type==3 && e.button==0) //表头
|
|
885
|
+
{
|
|
886
|
+
this.OnClickHeader(clickData, e);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
//document.onmousemove=(e)=>{ this.DocOnMouseMove(e); }
|
|
890
|
+
//document.onmouseup=(e)=> { this.DocOnMouseUp(e); }
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
//点表头
|
|
894
|
+
this.OnClickHeader=function(clickData, e)
|
|
895
|
+
{
|
|
896
|
+
var header=clickData.Header;
|
|
897
|
+
|
|
898
|
+
if (header.Column && header.Column.Sort==1)
|
|
899
|
+
{
|
|
900
|
+
var data={ CellType:header.CellType, ColumnIndex:header.ColumnIndex }
|
|
901
|
+
this.SortHeader(header.Column, data);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
//排序
|
|
907
|
+
this.SortHeader=function(column, sortData)
|
|
908
|
+
{
|
|
909
|
+
var sortInfo={ Field:this.SortInfo.Field, Sort:this.SortInfo.Sort, CellType:this.SortInfo.CellType };
|
|
910
|
+
var arySortType=column.SortType;
|
|
911
|
+
|
|
912
|
+
if (sortInfo.Field!=sortData.ColumnIndex || sortInfo.CellType!=sortData.CellType)
|
|
913
|
+
{
|
|
914
|
+
sortInfo.Field=sortData.ColumnIndex;
|
|
915
|
+
sortInfo.CellType=sortData.CellType;
|
|
916
|
+
sortInfo.Sort=arySortType[0]
|
|
917
|
+
}
|
|
918
|
+
else
|
|
919
|
+
{
|
|
920
|
+
if (arySortType.length==1)
|
|
921
|
+
{
|
|
922
|
+
sortInfo.Sort=arySortType[0];
|
|
923
|
+
}
|
|
924
|
+
else
|
|
925
|
+
{
|
|
926
|
+
for(var i=0;i<arySortType.length;++i)
|
|
927
|
+
{
|
|
928
|
+
if (sortInfo.Sort==arySortType[i])
|
|
929
|
+
{
|
|
930
|
+
sortInfo.Sort=arySortType[(i+1)%arySortType.length];
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
if (sortInfo.Sort==0) //还原
|
|
938
|
+
{
|
|
939
|
+
this.Data.Data=[];
|
|
940
|
+
for(var i=0;i<this.SourceData.Data.length;++i)
|
|
941
|
+
{
|
|
942
|
+
this.Data.Data.push(this.SourceData.Data[i]);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
else
|
|
946
|
+
{
|
|
947
|
+
var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_TREPORT_LOCAL_SORT);
|
|
948
|
+
if (event && event.Callback)
|
|
949
|
+
{
|
|
950
|
+
var sendData={ Column:column, SortInfo:sortInfo, SymbolList:this.Data.Data, Result:null };
|
|
951
|
+
event.Callback (event, sendData, this);
|
|
952
|
+
if (Array.isArray(sendData.Result)) this.Data.Data=sendData.Result;
|
|
953
|
+
}
|
|
954
|
+
else
|
|
955
|
+
{
|
|
956
|
+
this.Data.Data.sort((left, right)=> { return this.LocalSort(left, right, column, sortInfo.Sort, sortInfo.CellType); });
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
this.Data.YOffset=0;
|
|
961
|
+
this.SortInfo.Field=sortInfo.Field;
|
|
962
|
+
this.SortInfo.Sort=sortInfo.Sort;
|
|
963
|
+
this.SortInfo.CellType=sortInfo.CellType;
|
|
964
|
+
this.Draw();
|
|
965
|
+
this.DelayUpdateStockData();
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
//本地排序
|
|
969
|
+
this.LocalSort=function(left, right, column, sortType, cellType)
|
|
970
|
+
{
|
|
971
|
+
switch(column.Type)
|
|
972
|
+
{
|
|
973
|
+
case TREPORT_COLUMN_ID.SYMBOL_ID:
|
|
974
|
+
case TREPORT_COLUMN_ID.NAME_ID:
|
|
975
|
+
return this.LocalStringSort(left, right, column, sortType, cellType);
|
|
976
|
+
|
|
977
|
+
case TREPORT_COLUMN_ID.PRICE_ID:
|
|
978
|
+
case TREPORT_COLUMN_ID.VOL_ID:
|
|
979
|
+
case TREPORT_COLUMN_ID.UPDOWN_ID:
|
|
980
|
+
case TREPORT_COLUMN_ID.BUY_PRICE_ID:
|
|
981
|
+
case TREPORT_COLUMN_ID.SELL_PRICE_ID:
|
|
982
|
+
case TREPORT_COLUMN_ID.AMOUNT_ID:
|
|
983
|
+
case TREPORT_COLUMN_ID.BUY_VOL_ID:
|
|
984
|
+
case TREPORT_COLUMN_ID.SELL_VOL_ID:
|
|
985
|
+
case TREPORT_COLUMN_ID.YCLOSE_ID:
|
|
986
|
+
case TREPORT_COLUMN_ID.OPEN_ID:
|
|
987
|
+
case TREPORT_COLUMN_ID.HIGH_ID:
|
|
988
|
+
case TREPORT_COLUMN_ID.LOW_ID:
|
|
989
|
+
case TREPORT_COLUMN_ID.AVERAGE_PRICE_ID:
|
|
990
|
+
case TREPORT_COLUMN_ID.EXE_PRICE_ID: //行权价格
|
|
991
|
+
case TREPORT_COLUMN_ID.POSITION_ID: //持仓量
|
|
992
|
+
case TREPORT_COLUMN_ID.AMPLITUDE_ID:
|
|
993
|
+
case TREPORT_COLUMN_ID.INCREASE_ID:
|
|
994
|
+
return this.LocalNumberSort(left, right, column, sortType, cellType);
|
|
995
|
+
|
|
996
|
+
default:
|
|
997
|
+
|
|
998
|
+
return 0;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
this.LocalNumberSort=function(left, right, column, sortType, cellType)
|
|
1003
|
+
{
|
|
1004
|
+
var leftStock=this.GetExePriceData(left);
|
|
1005
|
+
var rightStock=this.GetExePriceData(right);
|
|
1006
|
+
|
|
1007
|
+
var leftValue=-99999999999999, rightValue=-99999999999999;
|
|
1008
|
+
if (sortType==2) leftValue=rightValue=99999999999999;
|
|
1009
|
+
|
|
1010
|
+
var filedName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
|
|
1011
|
+
|
|
1012
|
+
if (cellType==0) //行权价格
|
|
1013
|
+
{
|
|
1014
|
+
if (leftStock && IFrameSplitOperator.IsNumber(leftStock.ExePrice)) leftValue=leftStock.ExePrice;
|
|
1015
|
+
if (rightStock && IFrameSplitOperator.IsNumber(rightStock.ExePrice)) rightValue=rightStock.ExePrice;
|
|
1016
|
+
}
|
|
1017
|
+
else if (cellType==1)
|
|
1018
|
+
{
|
|
1019
|
+
if (leftStock && leftStock.LeftData)
|
|
1020
|
+
{
|
|
1021
|
+
var value=leftStock.LeftData[filedName];
|
|
1022
|
+
if (IFrameSplitOperator.IsNumber(value)) leftValue=value;
|
|
1023
|
+
}
|
|
1024
|
+
if (rightStock && rightStock.LeftData)
|
|
1025
|
+
{
|
|
1026
|
+
var value=rightStock.LeftData[filedName];
|
|
1027
|
+
if (IFrameSplitOperator.IsNumber(value)) rightValue=value;
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
else if (cellType==2)
|
|
1031
|
+
{
|
|
1032
|
+
if (leftStock && leftStock.RightData)
|
|
1033
|
+
{
|
|
1034
|
+
var value=leftStock.RightData[filedName];
|
|
1035
|
+
if (IFrameSplitOperator.IsNumber(value)) leftValue=value;
|
|
1036
|
+
}
|
|
1037
|
+
if (rightStock && rightStock.RightData)
|
|
1038
|
+
{
|
|
1039
|
+
var value=rightStock.RightData[filedName]
|
|
1040
|
+
if (IFrameSplitOperator.IsNumber(value)) rightValue=value;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
if (sortType==1)
|
|
1045
|
+
{
|
|
1046
|
+
if (rightValue<leftValue) return -1;
|
|
1047
|
+
else if (rightValue<leftValue) return 1;
|
|
1048
|
+
else return 0;
|
|
1049
|
+
}
|
|
1050
|
+
else
|
|
1051
|
+
{
|
|
1052
|
+
if (leftValue<rightValue) return -1;
|
|
1053
|
+
else if (leftValue>rightValue) return 1;
|
|
1054
|
+
else return 0;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
this.GetTReportChart=function()
|
|
1059
|
+
{
|
|
1060
|
+
var chart=this.ChartPaint[0];
|
|
1061
|
+
return chart;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
this.OnWheel=function(e) //滚轴
|
|
1065
|
+
{
|
|
1066
|
+
JSConsole.Chart.Log('[JSTReportChartContainer::OnWheel]',e);
|
|
1067
|
+
if (this.ChartSplashPaint && this.ChartSplashPaint.IsEnableSplash == true) return;
|
|
1068
|
+
if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
|
|
1069
|
+
|
|
1070
|
+
var x = e.clientX-this.UIElement.getBoundingClientRect().left;
|
|
1071
|
+
var y = e.clientY-this.UIElement.getBoundingClientRect().top;
|
|
1072
|
+
|
|
1073
|
+
var isInClient=false;
|
|
1074
|
+
this.Canvas.beginPath();
|
|
1075
|
+
this.Canvas.rect(this.Frame.ChartBorder.GetLeft(),this.Frame.ChartBorder.GetTop(),this.Frame.ChartBorder.GetWidth(),this.Frame.ChartBorder.GetHeight());
|
|
1076
|
+
isInClient=this.Canvas.isPointInPath(x,y);
|
|
1077
|
+
if (!isInClient) return;
|
|
1078
|
+
|
|
1079
|
+
var chart=this.GetTReportChart();
|
|
1080
|
+
if (!chart) return;
|
|
1081
|
+
|
|
1082
|
+
var wheelValue=e.wheelDelta;
|
|
1083
|
+
if (!IFrameSplitOperator.IsObjectExist(e.wheelDelta))
|
|
1084
|
+
wheelValue=e.deltaY* -0.01;
|
|
1085
|
+
|
|
1086
|
+
if (wheelValue<0) //下
|
|
1087
|
+
{
|
|
1088
|
+
var result=this.MoveSelectedRow(1)
|
|
1089
|
+
if (result)
|
|
1090
|
+
{
|
|
1091
|
+
if (result.Redraw) this.Draw();
|
|
1092
|
+
if (result.Update) this.DelayUpdateStockData();
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
else if (wheelValue>0) //上
|
|
1096
|
+
{
|
|
1097
|
+
var result=this.MoveSelectedRow(-1);
|
|
1098
|
+
if (result)
|
|
1099
|
+
{
|
|
1100
|
+
if (result.Redraw) this.Draw();
|
|
1101
|
+
if (result.Update) this.DelayUpdateStockData();
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
if(e.preventDefault) e.preventDefault();
|
|
1106
|
+
else e.returnValue = false;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
this.OnKeyDown=function(e)
|
|
1110
|
+
{
|
|
1111
|
+
if (this.ChartSplashPaint && this.ChartSplashPaint.IsEnableSplash == true) return;
|
|
1112
|
+
var reportChart=this.GetTReportChart();
|
|
1113
|
+
if (!reportChart) return;
|
|
1114
|
+
|
|
1115
|
+
var keyID = e.keyCode ? e.keyCode :e.which;
|
|
1116
|
+
switch(keyID)
|
|
1117
|
+
{
|
|
1118
|
+
/*
|
|
1119
|
+
case 33: //page up
|
|
1120
|
+
if (this.GotoPreviousPage(this.PageUpDownCycle))
|
|
1121
|
+
{
|
|
1122
|
+
this.Draw();
|
|
1123
|
+
this.DelayUpdateStockData();
|
|
1124
|
+
}
|
|
1125
|
+
break;
|
|
1126
|
+
case 34: //page down
|
|
1127
|
+
if (this.GotoNextPage(this.PageUpDownCycle))
|
|
1128
|
+
{
|
|
1129
|
+
this.Draw();
|
|
1130
|
+
this.DelayUpdateStockData();
|
|
1131
|
+
}
|
|
1132
|
+
break;
|
|
1133
|
+
*/
|
|
1134
|
+
case 38: //up
|
|
1135
|
+
var result=this.MoveSelectedRow(-1);
|
|
1136
|
+
if (result)
|
|
1137
|
+
{
|
|
1138
|
+
if (result.Redraw) this.Draw();
|
|
1139
|
+
if (result.Update) this.DelayUpdateStockData();
|
|
1140
|
+
}
|
|
1141
|
+
break;
|
|
1142
|
+
case 40: //down
|
|
1143
|
+
var result=this.MoveSelectedRow(1)
|
|
1144
|
+
if (result)
|
|
1145
|
+
{
|
|
1146
|
+
if (result.Redraw) this.Draw();
|
|
1147
|
+
if (result.Update) this.DelayUpdateStockData();
|
|
1148
|
+
}
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
//不让滚动条滚动
|
|
1153
|
+
if(e.preventDefault) e.preventDefault();
|
|
1154
|
+
else e.returnValue = false;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
this.MoveSelectedRow=function(step)
|
|
1158
|
+
{
|
|
1159
|
+
var chart=this.ChartPaint[0];
|
|
1160
|
+
if (!chart) return null;
|
|
1161
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return null;
|
|
1162
|
+
|
|
1163
|
+
var result={ Redraw:false, Update:false }; //Redraw=重绘, Update=更新数据
|
|
1164
|
+
|
|
1165
|
+
var pageStatus=chart.GetCurrentPageStatus();
|
|
1166
|
+
var pageSize=pageStatus.PageSize;
|
|
1167
|
+
|
|
1168
|
+
var selectedIndex=pageStatus.Start;
|
|
1169
|
+
var cellType=1;
|
|
1170
|
+
if (pageStatus.SelectedRow)
|
|
1171
|
+
{
|
|
1172
|
+
cellType=pageStatus.SelectedRow.CellType;
|
|
1173
|
+
for(var i=0;i<this.Data.Data.length;++i)
|
|
1174
|
+
{
|
|
1175
|
+
if (pageStatus.SelectedRow.ExePrice==this.Data.Data[i])
|
|
1176
|
+
{
|
|
1177
|
+
selectedIndex=i;
|
|
1178
|
+
break;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
if (step>0)
|
|
1184
|
+
{
|
|
1185
|
+
if (selectedIndex<0 || selectedIndex<pageStatus.Start || selectedIndex>pageStatus.End)
|
|
1186
|
+
{
|
|
1187
|
+
chart.SelectedRow={ ExePrice:this.Data.Data[pageStatus.Start], CellType:cellType };
|
|
1188
|
+
result.Redraw=true;
|
|
1189
|
+
return result;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
var offset=this.Data.YOffset;
|
|
1193
|
+
for(var i=0;i<step;++i)
|
|
1194
|
+
{
|
|
1195
|
+
++selectedIndex;
|
|
1196
|
+
if (selectedIndex>pageStatus.End) ++offset;
|
|
1197
|
+
|
|
1198
|
+
if (selectedIndex>=this.Data.Data.length)
|
|
1199
|
+
{
|
|
1200
|
+
selectedIndex=0;
|
|
1201
|
+
offset=0;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
result.Redraw=true;
|
|
1206
|
+
result.Update=(offset!=this.Data.YOffset);
|
|
1207
|
+
|
|
1208
|
+
chart.SelectedRow={ ExePrice:this.Data.Data[selectedIndex], CellType:cellType };
|
|
1209
|
+
this.Data.YOffset=offset;
|
|
1210
|
+
|
|
1211
|
+
return result;
|
|
1212
|
+
}
|
|
1213
|
+
else if (step<0)
|
|
1214
|
+
{
|
|
1215
|
+
if (selectedIndex<0 || selectedIndex<pageStatus.Start || selectedIndex>pageStatus.End)
|
|
1216
|
+
{
|
|
1217
|
+
chart.SelectedRow={ ExePrice:this.Data.Data[pageStatus.End], CellType:cellType };
|
|
1218
|
+
result.Redraw=true;
|
|
1219
|
+
return result;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
step=Math.abs(step);
|
|
1223
|
+
var offset=this.Data.YOffset;
|
|
1224
|
+
for(var i=0;i<step;++i)
|
|
1225
|
+
{
|
|
1226
|
+
--selectedIndex;
|
|
1227
|
+
if (selectedIndex<pageStatus.Start) --offset;
|
|
1228
|
+
|
|
1229
|
+
if (selectedIndex<0)
|
|
1230
|
+
{
|
|
1231
|
+
selectedIndex=this.Data.Data.length-1;
|
|
1232
|
+
offset=this.Data.Data.length-pageSize;
|
|
1233
|
+
if (offset<0) offset=0;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
result.Redraw=true;
|
|
1238
|
+
result.Update=(offset!=this.Data.YOffset);
|
|
1239
|
+
|
|
1240
|
+
chart.SelectedRow={ ExePrice:this.Data.Data[selectedIndex], CellType:cellType };
|
|
1241
|
+
this.Data.YOffset=offset;
|
|
1242
|
+
|
|
1243
|
+
return result;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
return null;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
//obj={ ID:, Color: , Time:, Count: }
|
|
1250
|
+
this.SetFlashBGItem=function(symbol, obj)
|
|
1251
|
+
{
|
|
1252
|
+
var item={ ID:obj.ID, Color:obj.Color, Count:1 };
|
|
1253
|
+
if (IFrameSplitOperator.IsNumber(obj.Count)) item.Count=obj.Count;
|
|
1254
|
+
if (IFrameSplitOperator.IsNumber(obj.Time)) item.Time=obj.Time;
|
|
1255
|
+
else item.Time=Date.now();
|
|
1256
|
+
|
|
1257
|
+
if (this.FlashBG.has(symbol))
|
|
1258
|
+
{
|
|
1259
|
+
var stockItem=this.FlashBG.get(symbol);
|
|
1260
|
+
stockItem.LastTime=item.Time;
|
|
1261
|
+
stockItem.Data.set(item.ID, item);
|
|
1262
|
+
}
|
|
1263
|
+
else
|
|
1264
|
+
{
|
|
1265
|
+
var stockItem={ LastTime:item.Time, Data:new Map([ [item.ID, item ] ]) };
|
|
1266
|
+
this.FlashBG.set(symbol, stockItem);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
this.GetFlashBGData=function(symbol, time)
|
|
1271
|
+
{
|
|
1272
|
+
if (!this.FlashBG) return null;
|
|
1273
|
+
if (!this.FlashBG.has(symbol)) return null;
|
|
1274
|
+
|
|
1275
|
+
var timeDiff=3*1000;
|
|
1276
|
+
var stockItem=this.FlashBG.get(symbol);
|
|
1277
|
+
if (time-stockItem.LastTime>=timeDiff) //超时的删除
|
|
1278
|
+
{
|
|
1279
|
+
this.FlashBG.delete(symbol);
|
|
1280
|
+
return null;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
if (!stockItem.Data || stockItem.Data.size<=0)
|
|
1284
|
+
{
|
|
1285
|
+
this.FlashBG.delete(symbol);
|
|
1286
|
+
return null;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
var aryDelID=[]; //超时需要参数的
|
|
1290
|
+
for(var mapItem of stockItem.Data)
|
|
1291
|
+
{
|
|
1292
|
+
var item=mapItem[1];
|
|
1293
|
+
if (time-item.Time>=timeDiff || item.Count<=0)
|
|
1294
|
+
aryDelID.push(item.ID);
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
if (IFrameSplitOperator.IsNonEmptyArray(aryDelID))
|
|
1298
|
+
{
|
|
1299
|
+
for(var i=0; i<aryDelID.length; ++i)
|
|
1300
|
+
{
|
|
1301
|
+
stockItem.Data.delete(aryDelID[i]);
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
if (stockItem.Data.size<=0)
|
|
1305
|
+
{
|
|
1306
|
+
this.FlashBG.delete(symbol);
|
|
1307
|
+
return null;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
return stockItem;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
function JSTReportFrame()
|
|
1316
|
+
{
|
|
1317
|
+
this.ChartBorder;
|
|
1318
|
+
this.Canvas; //画布
|
|
1319
|
+
|
|
1320
|
+
this.BorderLine=null; //1=上 2=下 4=左 8=右
|
|
1321
|
+
this.ClassName="JSTReportFrame";
|
|
1322
|
+
|
|
1323
|
+
this.BorderColor=g_JSChartResource.TReport.BorderColor; //边框线
|
|
1324
|
+
|
|
1325
|
+
this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
|
|
1326
|
+
this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
|
|
1327
|
+
|
|
1328
|
+
this.ReloadResource=function(resource)
|
|
1329
|
+
{
|
|
1330
|
+
this.BorderColor=g_JSChartResource.TReport.BorderColor; //边框线
|
|
1331
|
+
this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
|
|
1332
|
+
this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
this.Draw=function()
|
|
1336
|
+
{
|
|
1337
|
+
var left=ToFixedPoint(this.ChartBorder.GetLeft());
|
|
1338
|
+
var top=ToFixedPoint(this.ChartBorder.GetTop());
|
|
1339
|
+
var right=ToFixedPoint(this.ChartBorder.GetRight());
|
|
1340
|
+
var bottom=ToFixedPoint(this.ChartBorder.GetBottom());
|
|
1341
|
+
var width=right-left;
|
|
1342
|
+
var height=bottom-top;
|
|
1343
|
+
|
|
1344
|
+
if (!IFrameSplitOperator.IsNumber(this.BorderLine))
|
|
1345
|
+
{
|
|
1346
|
+
this.Canvas.strokeStyle=this.BorderColor;
|
|
1347
|
+
this.Canvas.strokeRect(left,top,width,height);
|
|
1348
|
+
}
|
|
1349
|
+
else
|
|
1350
|
+
{
|
|
1351
|
+
this.Canvas.strokeStyle=this.BorderColor;
|
|
1352
|
+
this.Canvas.beginPath();
|
|
1353
|
+
|
|
1354
|
+
if ((this.BorderLine&1)>0) //上
|
|
1355
|
+
{
|
|
1356
|
+
this.Canvas.moveTo(left,top);
|
|
1357
|
+
this.Canvas.lineTo(right,top);
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
if ((this.BorderLine&2)>0) //下
|
|
1361
|
+
{
|
|
1362
|
+
this.Canvas.moveTo(left,bottom);
|
|
1363
|
+
this.Canvas.lineTo(right,bottom);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
if ((this.BorderLine&4)>0) //左
|
|
1367
|
+
{
|
|
1368
|
+
this.Canvas.moveTo(left,top);
|
|
1369
|
+
this.Canvas.lineTo(left,bottom);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
if ((this.BorderLine&8)>0) //右
|
|
1373
|
+
{
|
|
1374
|
+
this.Canvas.moveTo(right,top);
|
|
1375
|
+
this.Canvas.lineTo(right,bottom);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
this.Canvas.stroke();
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
this.DrawLogo=function()
|
|
1383
|
+
{
|
|
1384
|
+
var text=g_JSChartResource.FrameLogo.Text;
|
|
1385
|
+
if (!IFrameSplitOperator.IsString(text)) return;
|
|
1386
|
+
|
|
1387
|
+
this.Canvas.fillStyle=this.LogoTextColor;
|
|
1388
|
+
this.Canvas.font=this.LogoTextFont;
|
|
1389
|
+
this.Canvas.textAlign = 'right';
|
|
1390
|
+
this.Canvas.textBaseline = 'bottom';
|
|
1391
|
+
|
|
1392
|
+
var x=this.ChartBorder.GetRight()-30;
|
|
1393
|
+
var y=this.ChartBorder.GetBottom()-5;
|
|
1394
|
+
this.Canvas.fillText(text,x,y);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
var TREPORT_COLUMN_ID=
|
|
1399
|
+
{
|
|
1400
|
+
SYMBOL_ID:0,
|
|
1401
|
+
NAME_ID:1,
|
|
1402
|
+
PRICE_ID:2, //成交价格
|
|
1403
|
+
VOL_ID:3, //成交量
|
|
1404
|
+
INCREASE_ID:4, //涨幅
|
|
1405
|
+
UPDOWN_ID:5, //涨跌
|
|
1406
|
+
BUY_PRICE_ID:6, //买价
|
|
1407
|
+
SELL_PRICE_ID:7, //卖价
|
|
1408
|
+
AMOUNT_ID:8, //总金额
|
|
1409
|
+
BUY_VOL_ID:9, //买量
|
|
1410
|
+
SELL_VOL_ID:10, //卖量
|
|
1411
|
+
YCLOSE_ID:11, //昨收
|
|
1412
|
+
OPEN_ID:12,
|
|
1413
|
+
HIGH_ID:13,
|
|
1414
|
+
LOW_ID:14,
|
|
1415
|
+
AVERAGE_PRICE_ID:15,//均价
|
|
1416
|
+
INDEX_ID:16, //序号 从1开始
|
|
1417
|
+
EXE_PRICE_ID:17, //行权价格
|
|
1418
|
+
POSITION_ID:18, //持仓量
|
|
1419
|
+
|
|
1420
|
+
AMPLITUDE_ID:22, //振幅
|
|
1421
|
+
|
|
1422
|
+
LIMIT_HIGH_ID:23, //涨停价
|
|
1423
|
+
LIMIT_LOW_ID:24, //跌停价
|
|
1424
|
+
|
|
1425
|
+
VOL_IN_ID:25, //内盘
|
|
1426
|
+
VOL_OUT_ID:26, //外盘
|
|
1427
|
+
NAME_EX_ID:27, //扩展名字
|
|
1428
|
+
CLOSE_LINE_ID:28, //收盘价线
|
|
1429
|
+
KLINE_ID:29, //K线
|
|
1430
|
+
|
|
1431
|
+
CUSTOM_STRING_TEXT_ID:100, //自定义字符串文本
|
|
1432
|
+
CUSTOM_NUMBER_TEXT_ID:101, //自定义数值型
|
|
1433
|
+
CUSTOM_DATETIME_TEXT_ID:102, //自定义日期类型
|
|
1434
|
+
CUSTOM_ICON_ID:103, //自定义图标
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
var MAP_TREPORT_COLUMN_FIELD=new Map(
|
|
1438
|
+
[
|
|
1439
|
+
[TREPORT_COLUMN_ID.SYMBOL_ID, "Symbol"],
|
|
1440
|
+
[TREPORT_COLUMN_ID.NAME_ID, "Name"],
|
|
1441
|
+
[TREPORT_COLUMN_ID.PRICE_ID, "Price"],
|
|
1442
|
+
[TREPORT_COLUMN_ID.INCREASE_ID, "Increase"],
|
|
1443
|
+
[TREPORT_COLUMN_ID.UPDOWN_ID, "UpDown"],
|
|
1444
|
+
[TREPORT_COLUMN_ID.VOL_ID, "Vol"],
|
|
1445
|
+
[TREPORT_COLUMN_ID.BUY_PRICE_ID, "BuyPrice"],
|
|
1446
|
+
[TREPORT_COLUMN_ID.SELL_PRICE_ID, "SellPrice"],
|
|
1447
|
+
[TREPORT_COLUMN_ID.AMOUNT_ID, "Amount"],
|
|
1448
|
+
[TREPORT_COLUMN_ID.BUY_VOL_ID, "BuyVol"],
|
|
1449
|
+
[TREPORT_COLUMN_ID.SELL_VOL_ID, "SellVol"],
|
|
1450
|
+
[TREPORT_COLUMN_ID.YCLOSE_ID, "YClose"],
|
|
1451
|
+
[TREPORT_COLUMN_ID.OPEN_ID, "Open"],
|
|
1452
|
+
[TREPORT_COLUMN_ID.HIGH_ID, "High"],
|
|
1453
|
+
[TREPORT_COLUMN_ID.LOW_ID, "Low"],
|
|
1454
|
+
[TREPORT_COLUMN_ID.AVERAGE_PRICE_ID,"AvPrice"],
|
|
1455
|
+
[TREPORT_COLUMN_ID.POSITION_ID,"Position"],
|
|
1456
|
+
]);
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
function ChartTReport()
|
|
1460
|
+
{
|
|
1461
|
+
this.Canvas; //画布
|
|
1462
|
+
this.ChartBorder; //边框信息
|
|
1463
|
+
this.ChartFrame; //框架画法
|
|
1464
|
+
this.Name; //名称
|
|
1465
|
+
this.ClassName='ChartTReport'; //类名
|
|
1466
|
+
this.UIElement;
|
|
1467
|
+
this.IsDrawFirst=false;
|
|
1468
|
+
this.GetEventCallback; //获取事件
|
|
1469
|
+
this.GetExePriceDataCallback; //获取行权价格数据
|
|
1470
|
+
this.GetFlashBGDataCallback; //获取闪烁背景
|
|
1471
|
+
this.GetBlockDataCallback; //获取当前板块的数据
|
|
1472
|
+
this.Data; //数据 { XOffset:0, YOffset:0, Data:[ 50000.0, 500025.0] }
|
|
1473
|
+
this.BorderData;
|
|
1474
|
+
this.FixedRowData; //固定行
|
|
1475
|
+
this.SortInfo; //排序信息 { Field:排序字段id, Sort:0 不排序 1升序 2降序, CellType: }
|
|
1476
|
+
this.FixedColumn=2; //固定列
|
|
1477
|
+
this.FixedRowCount=0; //固定行
|
|
1478
|
+
|
|
1479
|
+
this.IsShowHeader=true; //是否显示表头
|
|
1480
|
+
this.SizeChange=true;
|
|
1481
|
+
|
|
1482
|
+
this.SelectedRow; //{ ExePrice:exePrice, CellType:0 }
|
|
1483
|
+
this.RectSelectedRow;
|
|
1484
|
+
this.IsDrawBorder=1; //是否绘制单元格边框
|
|
1485
|
+
|
|
1486
|
+
this.ShowSymbol=[]; //显示的列表 { ExePrice:行权价格 }
|
|
1487
|
+
|
|
1488
|
+
this.GlobalOption;
|
|
1489
|
+
|
|
1490
|
+
//涨跌颜色
|
|
1491
|
+
this.UpColor=g_JSChartResource.TReport.UpTextColor;
|
|
1492
|
+
this.DownColor=g_JSChartResource.TReport.DownTextColor;
|
|
1493
|
+
this.UnchangeColor=g_JSChartResource.TReport.UnchangeTextColor;
|
|
1494
|
+
|
|
1495
|
+
this.BorderColor=g_JSChartResource.TReport.BorderColor; //边框线
|
|
1496
|
+
this.SelectedColor=g_JSChartResource.TReport.SelectedColor; //选中行
|
|
1497
|
+
|
|
1498
|
+
this.UpBGColor=g_JSChartResource.TReport.UpBGColor;
|
|
1499
|
+
this.DownBGColor=g_JSChartResource.TReport.DownBGColor;
|
|
1500
|
+
|
|
1501
|
+
//表头配置
|
|
1502
|
+
this.HeaderFontConfig={ Size:g_JSChartResource.TReport.Header.Font.Size, Name:g_JSChartResource.TReport.Header.Font.Name };
|
|
1503
|
+
this.HeaderColor=g_JSChartResource.TReport.Header.Color;
|
|
1504
|
+
this.SortColor=g_JSChartResource.TReport.Header.SortColor; //排序箭头颜色
|
|
1505
|
+
this.HeaderMergin=
|
|
1506
|
+
{
|
|
1507
|
+
Left:g_JSChartResource.TReport.Header.Mergin.Left,
|
|
1508
|
+
Right:g_JSChartResource.TReport.Header.Mergin.Right,
|
|
1509
|
+
Top:g_JSChartResource.TReport.Header.Mergin.Top,
|
|
1510
|
+
Bottom:g_JSChartResource.TReport.Header.Mergin.Bottom
|
|
1511
|
+
};
|
|
1512
|
+
|
|
1513
|
+
this.MarkBorderConfig={ MaxPositionColor: g_JSChartResource.TReport.MarkBorder.MaxPositionColor };
|
|
1514
|
+
|
|
1515
|
+
//表格内容配置
|
|
1516
|
+
this.ItemFontConfig={ Size:g_JSChartResource.TReport.Item.Font.Size, Name:g_JSChartResource.TReport.Item.Font.Name };
|
|
1517
|
+
this.ItemMergin=
|
|
1518
|
+
{
|
|
1519
|
+
Left:g_JSChartResource.TReport.Item.Mergin.Left,
|
|
1520
|
+
Right:g_JSChartResource.TReport.Item.Mergin.Right,
|
|
1521
|
+
Top:g_JSChartResource.TReport.Item.Mergin.Top,
|
|
1522
|
+
Bottom:g_JSChartResource.TReport.Item.Mergin.Bottom
|
|
1523
|
+
};
|
|
1524
|
+
|
|
1525
|
+
this.CenterItemConfig=
|
|
1526
|
+
{
|
|
1527
|
+
TextColor:g_JSChartResource.TReport.CenterItem.TextColor,
|
|
1528
|
+
BaseTextColor:g_JSChartResource.TReport.CenterItem.BaseTextColor,
|
|
1529
|
+
BGColor: g_JSChartResource.TReport.CenterItem.BGColor
|
|
1530
|
+
};
|
|
1531
|
+
|
|
1532
|
+
//缓存
|
|
1533
|
+
this.HeaderFont=12*GetDevicePixelRatio() +"px 微软雅黑";
|
|
1534
|
+
this.ItemFont=15*GetDevicePixelRatio() +"px 微软雅黑";
|
|
1535
|
+
this.ItemFixedFont=15*GetDevicePixelRatio() +"px 微软雅黑";
|
|
1536
|
+
this.ItemSymbolFont=12*GetDevicePixelRatio() +"px 微软雅黑";
|
|
1537
|
+
this.ItemNameFont=15*GetDevicePixelRatio() +"px 微软雅黑";
|
|
1538
|
+
this.ItemNameHeight=0;
|
|
1539
|
+
this.RowCount=0; //一屏显示行数
|
|
1540
|
+
this.HeaderHeight=0; //表头高度
|
|
1541
|
+
this.RowHeight=0; //行高度
|
|
1542
|
+
this.IsShowAllColumn=false; //是否已显示所有列
|
|
1543
|
+
this.ItemExtraWidth=0; //每列额外的宽度
|
|
1544
|
+
|
|
1545
|
+
this.Column= //{ Type:列id, Title:标题, TextAlign:文字对齐方式, MaxText:文字最大宽度 , TextColor:文字颜色, Sort:0=不支持排序 1=本地排序 0=远程排序 }
|
|
1546
|
+
[
|
|
1547
|
+
{ Type:TREPORT_COLUMN_ID.PRICE_ID, Title:"现价", TextAlign:"right", Width:null, MaxText:"-888.88" },
|
|
1548
|
+
{ Type:TREPORT_COLUMN_ID.INCREASE_ID, Title:"涨幅%", TextAlign:"right", Width:null, MaxText:"-888.88" },
|
|
1549
|
+
{ Type:TREPORT_COLUMN_ID.BUY_PRICE_ID, Title:"买价", TextAlign:"right", Width:null, MaxText:"-888.88" },
|
|
1550
|
+
{ Type:TREPORT_COLUMN_ID.BUY_VOL_ID, Title:"买量", TextAlign:"right", Width:null, MaxText:"88888", TextColor:g_JSChartResource.TReport.FieldColor.Vol },
|
|
1551
|
+
|
|
1552
|
+
//{ Type:TREPORT_COLUMN_ID.SELL_PRICE_ID, Title:"卖价", TextAlign:"right", Width:null, MaxText:"-888.88" },
|
|
1553
|
+
//{ Type:TREPORT_COLUMN_ID.SELL_VOL_ID, Title:"卖量", TextAlign:"right", Width:null, MaxText:"88888", TextColor:g_JSChartResource.TReport.FieldColor.Vol },
|
|
1554
|
+
|
|
1555
|
+
//{ Type:TREPORT_COLUMN_ID.POSITION_ID, Title:"持仓量", TextAlign:"right", Width:null, MaxText:"88888", TextColor:g_JSChartResource.TReport.FieldColor.Position },
|
|
1556
|
+
|
|
1557
|
+
{ Type:TREPORT_COLUMN_ID.NAME_ID, Title:"合约代码", TextAlign:"right", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Name, MaxText:"AAAAAA-A-AAAA"},
|
|
1558
|
+
|
|
1559
|
+
];
|
|
1560
|
+
|
|
1561
|
+
this.CenterColumn={ Type:TREPORT_COLUMN_ID.EXE_PRICE_ID, Title:"购<行权价>沽", TextAlign:"center", Width:null, MaxText:"99999.99", Sort:1, SortType:[1,2] }
|
|
1562
|
+
|
|
1563
|
+
this.RectClient={};
|
|
1564
|
+
|
|
1565
|
+
this.TooltipRect=[];
|
|
1566
|
+
|
|
1567
|
+
this.ReloadResource=function(resource)
|
|
1568
|
+
{
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
this.SetColumn=function(aryColumn)
|
|
1572
|
+
{
|
|
1573
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(aryColumn)) return;
|
|
1574
|
+
|
|
1575
|
+
this.Column=[];
|
|
1576
|
+
for(var i=0;i<aryColumn.length;++i)
|
|
1577
|
+
{
|
|
1578
|
+
var item=aryColumn[i];
|
|
1579
|
+
var colItem=this.GetDefaultColunm(item.Type);
|
|
1580
|
+
if (!colItem) continue;
|
|
1581
|
+
|
|
1582
|
+
if (item.Title) colItem.Title=item.Title;
|
|
1583
|
+
if (item.TextAlign) colItem.TextAlign=item.TextAlign;
|
|
1584
|
+
if (item.TextColor) colItem.TextColor=item.TextColor;
|
|
1585
|
+
if (item.MaxText) colItem.MaxText=item.MaxText;
|
|
1586
|
+
if (item.ID) colItem.ID=item.ID;
|
|
1587
|
+
if (IFrameSplitOperator.IsNumber(item.Sort)) colItem.Sort=item.Sort;
|
|
1588
|
+
if (IFrameSplitOperator.IsBool(item.EnableTooltip)) colItem.EnableTooltip=item.EnableTooltip;
|
|
1589
|
+
if (IFrameSplitOperator.IsNumber(item.FixedWidth)) colItem.FixedWidth=item.FixedWidth;
|
|
1590
|
+
|
|
1591
|
+
if (item.Sort==1) //1本地排序 2=远程排序
|
|
1592
|
+
{
|
|
1593
|
+
colItem.SortType=[1,2]; //默认 降序 ,升序
|
|
1594
|
+
if (IFrameSplitOperator.IsNonEmptyArray(item.SortType)) colItem.SortType=item.SortType.slice();
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
this.Column.push(colItem);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
this.GetDefaultColunm=function(id)
|
|
1602
|
+
{
|
|
1603
|
+
var DEFAULT_COLUMN=
|
|
1604
|
+
[
|
|
1605
|
+
{ Type:TREPORT_COLUMN_ID.INDEX_ID, Title:"序号", TextAlign:"center", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Index, MaxText:"8888"},
|
|
1606
|
+
{ Type:TREPORT_COLUMN_ID.SYMBOL_ID, Title:"代码", TextAlign:"right", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Symbol, MaxText:"888888"},
|
|
1607
|
+
{ Type:TREPORT_COLUMN_ID.NAME_ID, Title:"合约名称", TextAlign:"right", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Name, MaxText:"AAAAAA-A-AAAA" },
|
|
1608
|
+
|
|
1609
|
+
{ Type:TREPORT_COLUMN_ID.INCREASE_ID, Title:"涨幅%", TextAlign:"right", Width:null, MaxText:"-888.88", Sort:1, SortType:[1,2,0] },
|
|
1610
|
+
{ Type:TREPORT_COLUMN_ID.PRICE_ID, Title:"现价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
|
|
1611
|
+
{ Type:TREPORT_COLUMN_ID.UPDOWN_ID, Title:"涨跌", TextAlign:"right", Width:null, MaxText:"-888.88", Sort:1, SortType:[1,2,0] },
|
|
1612
|
+
{ Type:TREPORT_COLUMN_ID.AMPLITUDE_ID, Title:"振幅%", TextAlign:"right", Width:null, MaxText:"888.88", Sort:1, SortType:[1,2,0] },
|
|
1613
|
+
{ Type:TREPORT_COLUMN_ID.BUY_PRICE_ID, Title:"买价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
|
|
1614
|
+
{ Type:TREPORT_COLUMN_ID.SELL_PRICE_ID, Title:"卖价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
|
|
1615
|
+
{ Type:TREPORT_COLUMN_ID.AVERAGE_PRICE_ID, Title:"均价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
|
|
1616
|
+
{ Type:TREPORT_COLUMN_ID.OPEN_ID, Title:"今开", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
|
|
1617
|
+
{ Type:TREPORT_COLUMN_ID.HIGH_ID, Title:"最高", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
|
|
1618
|
+
{ Type:TREPORT_COLUMN_ID.LOW_ID, Title:"最低", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
|
|
1619
|
+
{ Type:TREPORT_COLUMN_ID.YCLOSE_ID, Title:"昨收", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
|
|
1620
|
+
|
|
1621
|
+
{ 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 },
|
|
1622
|
+
|
|
1623
|
+
{ 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] },
|
|
1624
|
+
{ 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] },
|
|
1625
|
+
|
|
1626
|
+
{ 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] },
|
|
1627
|
+
{ 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] },
|
|
1628
|
+
];
|
|
1629
|
+
|
|
1630
|
+
for(var i=0;i<DEFAULT_COLUMN.length;++i)
|
|
1631
|
+
{
|
|
1632
|
+
var item=DEFAULT_COLUMN[i];
|
|
1633
|
+
if (item.Type==id) return item;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
return null;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
this.Draw=function()
|
|
1640
|
+
{
|
|
1641
|
+
this.ShowSymbol=[];
|
|
1642
|
+
this.TooltipRect=[];
|
|
1643
|
+
this.RectSelectedRow=null;
|
|
1644
|
+
|
|
1645
|
+
if (this.GlobalOption) this.GlobalOption.FlashBGCount=0;
|
|
1646
|
+
|
|
1647
|
+
if (this.SizeChange) this.CalculateSize();
|
|
1648
|
+
else this.UpdateCacheData();
|
|
1649
|
+
|
|
1650
|
+
this.Canvas.save();
|
|
1651
|
+
|
|
1652
|
+
this.Canvas.beginPath();
|
|
1653
|
+
this.Canvas.rect(this.RectClient.Left,this.RectClient.Top,(this.RectClient.Right-this.RectClient.Left),(this.RectClient.Bottom-this.RectClient.Top));
|
|
1654
|
+
//this.Canvas.stroke(); //调试用
|
|
1655
|
+
this.Canvas.clip();
|
|
1656
|
+
|
|
1657
|
+
this.DrawHeader();
|
|
1658
|
+
this.DrawBody();
|
|
1659
|
+
this.Canvas.restore();
|
|
1660
|
+
|
|
1661
|
+
//this.DrawBorder();
|
|
1662
|
+
|
|
1663
|
+
this.SizeChange=false;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
//更新缓存变量
|
|
1667
|
+
this.UpdateCacheData=function()
|
|
1668
|
+
{
|
|
1669
|
+
this.RectClient.Left=this.ChartBorder.GetLeft();
|
|
1670
|
+
this.RectClient.Right=this.ChartBorder.GetRight();
|
|
1671
|
+
this.RectClient.Top=this.ChartBorder.GetTop();
|
|
1672
|
+
this.RectClient.Bottom=this.ChartBorder.GetBottom();
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
this.CalculateSize=function() //计算大小
|
|
1676
|
+
{
|
|
1677
|
+
this.UpdateCacheData();
|
|
1678
|
+
|
|
1679
|
+
var pixelRatio=GetDevicePixelRatio();
|
|
1680
|
+
this.HeaderFont=`${this.HeaderFontConfig.Size*pixelRatio}px ${ this.HeaderFontConfig.Name}`;
|
|
1681
|
+
this.ItemFont=`${this.ItemFontConfig.Size*pixelRatio}px ${ this.ItemFontConfig.Name}`;
|
|
1682
|
+
|
|
1683
|
+
this.RowHeight=this.GetFontHeight(this.ItemFont,"擎")+ this.ItemMergin.Top+ this.ItemMergin.Bottom;
|
|
1684
|
+
|
|
1685
|
+
this.Canvas.font=this.ItemFont;
|
|
1686
|
+
var itemWidth=0;
|
|
1687
|
+
for(var i=0;i<this.Column.length;++i)
|
|
1688
|
+
{
|
|
1689
|
+
var item=this.Column[i];
|
|
1690
|
+
if (IFrameSplitOperator.IsNumber(item.FixedWidth)) itemWidth=item.FixedWidth;
|
|
1691
|
+
else itemWidth=this.Canvas.measureText(item.MaxText).width;
|
|
1692
|
+
|
|
1693
|
+
item.Width=itemWidth+4+this.ItemMergin.Left+this.ItemMergin.Right;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
//表头中间列
|
|
1697
|
+
var item=this.CenterColumn;
|
|
1698
|
+
if (IFrameSplitOperator.IsNumber(item.FixedWidth)) itemWidth=item.FixedWidth;
|
|
1699
|
+
else itemWidth=this.Canvas.measureText(item.MaxText).width;
|
|
1700
|
+
item.Width=itemWidth+4+this.ItemMergin.Left+this.ItemMergin.Right;
|
|
1701
|
+
|
|
1702
|
+
this.Canvas.font=this.HeaderFont;
|
|
1703
|
+
for(var i=0;i<this.Column.length;++i)
|
|
1704
|
+
{
|
|
1705
|
+
var item=this.Column[i];
|
|
1706
|
+
if (!item.Title || item.Title.length<=0) continue;
|
|
1707
|
+
var text=item.Title;
|
|
1708
|
+
if (item.Sort>0) text+="↓";
|
|
1709
|
+
itemWidth=this.Canvas.measureText(text).width;
|
|
1710
|
+
itemWidth+=(4+this.HeaderMergin.Left+this.HeaderMergin.Right);
|
|
1711
|
+
if (item.Width<itemWidth) item.Width=itemWidth;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
//表头中间列
|
|
1715
|
+
var item=this.CenterColumn;
|
|
1716
|
+
if (!item.Title || item.Title.length>0)
|
|
1717
|
+
{
|
|
1718
|
+
var text=item.Title;
|
|
1719
|
+
if (item.Sort>0) text+="↓";
|
|
1720
|
+
itemWidth=this.Canvas.measureText(text).width;
|
|
1721
|
+
itemWidth+=(4+this.HeaderMergin.Left+this.HeaderMergin.Right);
|
|
1722
|
+
if (item.Width<itemWidth) item.Width=itemWidth;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
this.HeaderHeight=this.GetFontHeight(this.HeaderFont,"擎")+ this.HeaderMergin.Top+ this.HeaderMergin.Bottom;
|
|
1727
|
+
if (!this.IsShowHeader) this.HeaderHeight=0;
|
|
1728
|
+
|
|
1729
|
+
this.RowCount=parseInt((this.RectClient.Bottom-this.RectClient.Top-this.HeaderHeight)/this.RowHeight);
|
|
1730
|
+
|
|
1731
|
+
var subWidth=this.CenterColumn.Width;
|
|
1732
|
+
var reportWidth=this.RectClient.Right-this.RectClient.Left;
|
|
1733
|
+
for(var i=0;i<this.Column.length;++i)
|
|
1734
|
+
{
|
|
1735
|
+
var item=this.Column[i];
|
|
1736
|
+
subWidth+=item.Width*2;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
if (subWidth<reportWidth)
|
|
1740
|
+
{
|
|
1741
|
+
this.IsShowAllColumn=true;
|
|
1742
|
+
this.ItemExtraWidth=0;
|
|
1743
|
+
if (reportWidth-subWidth-4>0)
|
|
1744
|
+
this.ItemExtraWidth=(reportWidth-subWidth-4)/(this.Column.length*2+1);
|
|
1745
|
+
}
|
|
1746
|
+
else
|
|
1747
|
+
{
|
|
1748
|
+
this.IsShowAllColumn=false;
|
|
1749
|
+
this.ItemExtraWidth=0;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
this.DrawHeader=function()
|
|
1754
|
+
{
|
|
1755
|
+
if (!this.IsShowHeader) return;
|
|
1756
|
+
|
|
1757
|
+
var left=this.RectClient.Left;
|
|
1758
|
+
var top=this.RectClient.Top;
|
|
1759
|
+
var y=top+this.HeaderMergin.Top+(this.HeaderHeight-this.HeaderMergin.Top-this.HeaderMergin.Bottom)/2;
|
|
1760
|
+
var xCenter=(this.RectClient.Right-this.RectClient.Left)/2+this.RectClient.Left;
|
|
1761
|
+
|
|
1762
|
+
this.Canvas.font=this.HeaderFont;
|
|
1763
|
+
this.Canvas.fillStyle=this.HeaderColor;
|
|
1764
|
+
|
|
1765
|
+
var reportleft=this.RectClient.Left;
|
|
1766
|
+
var reportRight=this.RectClient.Right;
|
|
1767
|
+
|
|
1768
|
+
//中间列
|
|
1769
|
+
var item=this.CenterColumn;
|
|
1770
|
+
var rtCenterItem=this.GetCenterItemRect();
|
|
1771
|
+
if (this.SortInfo && this.SortInfo.Sort>0 && this.SortInfo.CellType==0)
|
|
1772
|
+
this.DrawSortHeader(item.Title,item.TextAlign,rtCenterItem.Left,y,rtCenterItem.TextWidth,this.SortInfo.Sort);
|
|
1773
|
+
else
|
|
1774
|
+
this.DrawText(item.Title,item.TextAlign,rtCenterItem.Left,y,rtCenterItem.TextWidth);
|
|
1775
|
+
|
|
1776
|
+
var xLeft=rtCenterItem.Left; //左边
|
|
1777
|
+
var xRight=rtCenterItem.Right;//右边
|
|
1778
|
+
for(var i=this.Data.XOffset;i<this.Column.length;++i)
|
|
1779
|
+
{
|
|
1780
|
+
var item=this.Column[i];
|
|
1781
|
+
var itemWidth=item.Width+this.ItemExtraWidth;
|
|
1782
|
+
var textWidth=itemWidth-this.HeaderMergin.Left-this.HeaderMergin.Right;
|
|
1783
|
+
var x=xLeft-itemWidth+this.HeaderMergin.Left;
|
|
1784
|
+
|
|
1785
|
+
if (xLeft-itemWidth<reportleft) break;
|
|
1786
|
+
|
|
1787
|
+
var bSort=(this.SortInfo && this.SortInfo.Field==i && this.SortInfo.Sort>0);
|
|
1788
|
+
if (bSort && this.SortInfo.CellType==1) this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort);
|
|
1789
|
+
else this.DrawText(item.Title,item.TextAlign,x,y,textWidth);
|
|
1790
|
+
xLeft-=itemWidth;
|
|
1791
|
+
|
|
1792
|
+
var x=xRight+this.HeaderMergin.Left;
|
|
1793
|
+
if (bSort && this.SortInfo.CellType==2) this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort);
|
|
1794
|
+
else this.DrawText(item.Title,item.TextAlign,x,y,textWidth);
|
|
1795
|
+
xRight+=itemWidth;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
this.DrawSortHeader=function(text, textAlign, x, y, width, sortType)
|
|
1800
|
+
{
|
|
1801
|
+
var sortText=sortType==1?"↓":"↑";
|
|
1802
|
+
var sortTextWidth=this.Canvas.measureText(sortText).width;
|
|
1803
|
+
var textWidth=this.Canvas.measureText(text).width+2;
|
|
1804
|
+
this.Canvas.textBaseline="middle";
|
|
1805
|
+
this.Canvas.textAlign="left";
|
|
1806
|
+
|
|
1807
|
+
if (textAlign=='center')
|
|
1808
|
+
{
|
|
1809
|
+
x=x+width/2-(sortTextWidth+textWidth)/2;
|
|
1810
|
+
}
|
|
1811
|
+
else if (textAlign=='right')
|
|
1812
|
+
{
|
|
1813
|
+
x=(x+width)-sortTextWidth-textWidth;
|
|
1814
|
+
}
|
|
1815
|
+
else
|
|
1816
|
+
{
|
|
1817
|
+
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
this.Canvas.fillText(text,x,y);
|
|
1821
|
+
this.Canvas.fillStyle=this.SortColor;
|
|
1822
|
+
this.Canvas.fillText(sortText,x+textWidth,y);
|
|
1823
|
+
this.Canvas.fillStyle=this.HeaderColor;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
this.DrawText=function(text, textAlign, x, y, textWidth)
|
|
1827
|
+
{
|
|
1828
|
+
if (textAlign=='center')
|
|
1829
|
+
{
|
|
1830
|
+
x=x+textWidth/2;
|
|
1831
|
+
this.Canvas.textAlign="center";
|
|
1832
|
+
}
|
|
1833
|
+
else if (textAlign=='right')
|
|
1834
|
+
{
|
|
1835
|
+
x=x+textWidth;
|
|
1836
|
+
this.Canvas.textAlign="right";
|
|
1837
|
+
}
|
|
1838
|
+
else
|
|
1839
|
+
{
|
|
1840
|
+
this.Canvas.textAlign="left";
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
this.Canvas.textBaseline="middle";
|
|
1844
|
+
this.Canvas.fillText(text,x,y);
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
this.GetFontHeight=function(font,word)
|
|
1848
|
+
{
|
|
1849
|
+
return GetFontHeight(this.Canvas, font, word);
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
this.DrawBody=function()
|
|
1853
|
+
{
|
|
1854
|
+
if (!this.Data) return;
|
|
1855
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
|
|
1856
|
+
|
|
1857
|
+
this.Canvas.font=this.ItemFont;
|
|
1858
|
+
var top=this.RectClient.Top+this.HeaderHeight;
|
|
1859
|
+
var left=this.RectClient.Left;
|
|
1860
|
+
var rowWidth=this.RectClient.Right-this.RectClient.Left;
|
|
1861
|
+
|
|
1862
|
+
var textTop=top;
|
|
1863
|
+
this.Canvas.font=this.ItemFont;
|
|
1864
|
+
for(var i=this.Data.YOffset, j=0; i<this.Data.Data.length && j<this.RowCount ;++i, ++j)
|
|
1865
|
+
{
|
|
1866
|
+
var exePrice=this.Data.Data[i];
|
|
1867
|
+
|
|
1868
|
+
this.DrawRow(exePrice, textTop, i);
|
|
1869
|
+
|
|
1870
|
+
this.ShowSymbol.push( { Index:i, ExePrice:exePrice } );
|
|
1871
|
+
|
|
1872
|
+
textTop+=this.RowHeight;
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
if (this.RectSelectedRow)
|
|
1876
|
+
{
|
|
1877
|
+
this.Canvas.fillStyle=this.SelectedColor;
|
|
1878
|
+
var lineWidth=2;
|
|
1879
|
+
this.Canvas.fillRect(this.RectSelectedRow.Left,this.RectSelectedRow.Bottom-lineWidth, (this.RectSelectedRow.Right-this.RectSelectedRow.Left), lineWidth);
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
this.GetCenterItemRect=function()
|
|
1884
|
+
{
|
|
1885
|
+
var xCenter=(this.RectClient.Right-this.RectClient.Left)/2+this.RectClient.Left;
|
|
1886
|
+
|
|
1887
|
+
//中间列
|
|
1888
|
+
var item=this.CenterColumn;
|
|
1889
|
+
var itemWidth=item.Width+this.ItemExtraWidth;
|
|
1890
|
+
var left=xCenter-itemWidth/2;
|
|
1891
|
+
var right=xCenter+itemWidth/2;
|
|
1892
|
+
var textWidth=itemWidth-this.HeaderMergin.Left-this.HeaderMergin.Right;
|
|
1893
|
+
|
|
1894
|
+
return { Left:left, Right:right, TextWidth:textWidth, Width:itemWidth };
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
this.DrawRow=function(exePrice, top, dataIndex)
|
|
1898
|
+
{
|
|
1899
|
+
var rtCenterItem=this.GetCenterItemRect();
|
|
1900
|
+
|
|
1901
|
+
var xLeft=rtCenterItem.Left; //左边
|
|
1902
|
+
var xRight=rtCenterItem.Right; //右边
|
|
1903
|
+
|
|
1904
|
+
var reportleft=this.RectClient.Left;
|
|
1905
|
+
var reportRight=this.RectClient.Right;
|
|
1906
|
+
|
|
1907
|
+
var data= { ExePrice:exePrice , TData:null };
|
|
1908
|
+
if (this.GetExePriceDataCallback) data.TData=this.GetExePriceDataCallback(exePrice);
|
|
1909
|
+
if (this.GetFlashBGDataCallback && data.TData)
|
|
1910
|
+
{
|
|
1911
|
+
if (data.TData.LeftData) //左侧
|
|
1912
|
+
{
|
|
1913
|
+
var item=data.TData.LeftData;
|
|
1914
|
+
data.TData.LeftFlashBG=this.GetFlashBGDataCallback(item.Symbol, Date.now());
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
if (data.TData.RightData) //右侧
|
|
1918
|
+
{
|
|
1919
|
+
var item=data.TData.RightData;
|
|
1920
|
+
data.TData.RightFlashBG=this.GetFlashBGDataCallback(item.Symbol, Date.now());
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
data.Decimal=2;
|
|
1925
|
+
|
|
1926
|
+
var bSelected=false;
|
|
1927
|
+
if (this.SelectedRow && this.SelectedRow.ExePrice==exePrice) bSelected=true;
|
|
1928
|
+
|
|
1929
|
+
var rtItem={ Left:xLeft, Right:xRight, Top:top, Height:this.RowHeight };
|
|
1930
|
+
rtItem.Bottom=rtItem.Top+rtItem.Height;
|
|
1931
|
+
rtItem.Width=rtItem.Right-rtItem.Left;
|
|
1932
|
+
this.DrawCenterItem(dataIndex, data, this.CenterColumn, rtItem, 0);
|
|
1933
|
+
if (bSelected && this.SelectedRow.CellType==0) this.RectSelectedRow=rtItem;
|
|
1934
|
+
|
|
1935
|
+
if (IFrameSplitOperator.IsNumber(this.Data.BaseExePrice))
|
|
1936
|
+
{
|
|
1937
|
+
var leftBGColor=null, rightBGColor=null;
|
|
1938
|
+
if (exePrice>this.Data.BaseExePrice)
|
|
1939
|
+
{
|
|
1940
|
+
leftBGColor=this.UpBGColor;
|
|
1941
|
+
rightBGColor=this.DownBGColor;
|
|
1942
|
+
}
|
|
1943
|
+
else
|
|
1944
|
+
{
|
|
1945
|
+
leftBGColor=this.DownBGColor;
|
|
1946
|
+
rightBGColor=this.UpBGColor;
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
if (leftBGColor)
|
|
1950
|
+
{
|
|
1951
|
+
var rtBG={Left:reportleft+1, Right:rtCenterItem.Left, Top:top, Height:this.RowHeight };
|
|
1952
|
+
rtBG.Bottom=rtBG.Top+rtBG.Height;
|
|
1953
|
+
rtBG.Width=rtBG.Right-rtBG.Left;
|
|
1954
|
+
this.Canvas.fillStyle=leftBGColor;
|
|
1955
|
+
this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
if (rightBGColor)
|
|
1959
|
+
{
|
|
1960
|
+
var rtBG={Left:rtCenterItem.Right, Right:reportRight, Top:top, Height:this.RowHeight };
|
|
1961
|
+
rtBG.Bottom=rtBG.Top+rtBG.Height;
|
|
1962
|
+
rtBG.Width=rtBG.Right-rtBG.Left;
|
|
1963
|
+
this.Canvas.fillStyle=rightBGColor;
|
|
1964
|
+
this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
for(var i=this.Data.XOffset;i<this.Column.length;++i)
|
|
1969
|
+
{
|
|
1970
|
+
var item=this.Column[i];
|
|
1971
|
+
var itemWidth=item.Width+this.ItemExtraWidth;
|
|
1972
|
+
xLeft-=itemWidth;
|
|
1973
|
+
if (xLeft<reportleft) break;
|
|
1974
|
+
|
|
1975
|
+
var leftData=null, rightData=null;
|
|
1976
|
+
if (data.TData) leftData=data.TData.LeftData;
|
|
1977
|
+
if (data.TData) rightData=data.TData.RightData;
|
|
1978
|
+
|
|
1979
|
+
rtItem={ Left:xLeft, Right:xLeft+itemWidth, Top:top, Height:this.RowHeight, Width:itemWidth };
|
|
1980
|
+
rtItem.Bottom=rtItem.Top+rtItem.Height;
|
|
1981
|
+
|
|
1982
|
+
this.DrawItem(dataIndex, data, leftData, item, rtItem, 1);
|
|
1983
|
+
|
|
1984
|
+
if (bSelected && this.SelectedRow.CellType==1)
|
|
1985
|
+
{
|
|
1986
|
+
if (!this.RectSelectedRow) this.RectSelectedRow=rtItem;
|
|
1987
|
+
else this.RectSelectedRow.Left=rtItem.Left;
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
rtItem={ Left:xRight, Right:xRight+itemWidth, Top:top, Height:this.RowHeight, Width:itemWidth };
|
|
1991
|
+
rtItem.Bottom=rtItem.Top+rtItem.Height;
|
|
1992
|
+
|
|
1993
|
+
this.DrawItem(dataIndex, data, rightData, item, rtItem, 2);
|
|
1994
|
+
xRight+=itemWidth;
|
|
1995
|
+
|
|
1996
|
+
if (bSelected && this.SelectedRow.CellType==2)
|
|
1997
|
+
{
|
|
1998
|
+
if (!this.RectSelectedRow) this.RectSelectedRow=rtItem;
|
|
1999
|
+
else this.RectSelectedRow.Right=rtItem.Right;
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
this.DrawCenterItem=function(index, data, column, rtItem, cellType) //cellType 0=中间字段 1=左侧 2=右侧
|
|
2005
|
+
{
|
|
2006
|
+
//tooltip提示
|
|
2007
|
+
if (column.EnableTooltip===true) this.TooltipRect.push({ Rect:rtItem, data:data, Index:index, Column:column, CellType:cellType });
|
|
2008
|
+
|
|
2009
|
+
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 };
|
|
2010
|
+
rtText.Width=rtText.Right-rtText.Left;
|
|
2011
|
+
rtText.Height=rtText.Bottom-rtText.Top;
|
|
2012
|
+
|
|
2013
|
+
var drawInfo={ Text:null, TextColor:this.CenterItemConfig.TextColor, BGColor:this.CenterItemConfig.BGColor, TextAlign:column.TextAlign, Rect:rtItem, RectText:rtText };
|
|
2014
|
+
drawInfo.Text=`${data.ExePrice.toFixed(data.Decimal)}`;
|
|
2015
|
+
|
|
2016
|
+
this.DrawCell(drawInfo);
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
this.DrawItem=function(index, exePriceData, data, column, rtItem, cellType)
|
|
2020
|
+
{
|
|
2021
|
+
if (column.EnableTooltip===true) this.TooltipRect.push({ Rect:rtItem, data:data, Index:index, Column:column, CellType:cellType });
|
|
2022
|
+
|
|
2023
|
+
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 };
|
|
2024
|
+
rtText.Width=rtText.Right-rtText.Left;
|
|
2025
|
+
rtText.Height=rtText.Bottom-rtText.Top;
|
|
2026
|
+
|
|
2027
|
+
var drawInfo={ Text:null, TextColor:column.TextColor , TextAlign:column.TextAlign, Rect:rtItem, RectText:rtText };
|
|
2028
|
+
|
|
2029
|
+
if (data)
|
|
2030
|
+
{
|
|
2031
|
+
switch(column.Type)
|
|
2032
|
+
{
|
|
2033
|
+
case TREPORT_COLUMN_ID.SYMBOL_ID:
|
|
2034
|
+
case TREPORT_COLUMN_ID.NAME_ID:
|
|
2035
|
+
var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
|
|
2036
|
+
if (fieldName) drawInfo.Text=data[fieldName];
|
|
2037
|
+
break;
|
|
2038
|
+
|
|
2039
|
+
case TREPORT_COLUMN_ID.PRICE_ID: //最新价格
|
|
2040
|
+
case TREPORT_COLUMN_ID.BUY_PRICE_ID: //买价
|
|
2041
|
+
case TREPORT_COLUMN_ID.SELL_PRICE_ID: //卖价
|
|
2042
|
+
var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
|
|
2043
|
+
if (fieldName) this.GetPriceDrawInfo(data[fieldName], data, exePriceData, drawInfo);
|
|
2044
|
+
break;
|
|
2045
|
+
|
|
2046
|
+
case TREPORT_COLUMN_ID.SELL_VOL_ID: //卖量
|
|
2047
|
+
case TREPORT_COLUMN_ID.BUY_VOL_ID: //买量
|
|
2048
|
+
case TREPORT_COLUMN_ID.POSITION_ID: //持仓量
|
|
2049
|
+
var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
|
|
2050
|
+
if (fieldName) drawInfo.Text=this.FormatVolString(data[fieldName]);
|
|
2051
|
+
break;
|
|
2052
|
+
case TREPORT_COLUMN_ID.INCREASE_ID:
|
|
2053
|
+
case TREPORT_COLUMN_ID.UPDOWN_ID:
|
|
2054
|
+
case TREPORT_COLUMN_ID.AMPLITUDE_ID:
|
|
2055
|
+
var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
|
|
2056
|
+
if (fieldName)
|
|
2057
|
+
{
|
|
2058
|
+
var value=data[fieldName];
|
|
2059
|
+
if (IFrameSplitOperator.IsNumber(value))
|
|
2060
|
+
{
|
|
2061
|
+
drawInfo.Text=value.toFixed(2);
|
|
2062
|
+
drawInfo.TextColor=this.GetUpDownColor(value,0);
|
|
2063
|
+
}
|
|
2064
|
+
else
|
|
2065
|
+
{
|
|
2066
|
+
this.GetNullDrawInfo(drawInfo);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
break;
|
|
2070
|
+
|
|
2071
|
+
default:
|
|
2072
|
+
drawInfo.Text=`-----`;
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
this.GetMarkBorderData(drawInfo, exePriceData.ExePrice, column.Type, cellType);
|
|
2076
|
+
this.GetFlashBGData(drawInfo, exePriceData, column.Type, cellType);
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
this.DrawCell(drawInfo, exePriceData, column.Type, cellType);
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
this.GetFlashBGData=function(drawInfo, exePriceData, columnType, cellType)
|
|
2083
|
+
{
|
|
2084
|
+
if (!exePriceData.TData) return;
|
|
2085
|
+
|
|
2086
|
+
var data=null;
|
|
2087
|
+
if (cellType==1) data=exePriceData.TData.LeftFlashBG;
|
|
2088
|
+
else if (cellType==2) data=exePriceData.TData.RightFlashBG;
|
|
2089
|
+
|
|
2090
|
+
if (!data || !data.Data) return;
|
|
2091
|
+
|
|
2092
|
+
if (data.Data.has(columnType))
|
|
2093
|
+
{
|
|
2094
|
+
var item=data.Data.get(columnType);
|
|
2095
|
+
drawInfo.FlashBGColor=item.Color;
|
|
2096
|
+
--item.Count;
|
|
2097
|
+
|
|
2098
|
+
if (this.GlobalOption) ++this.GlobalOption.FlashBGCount;
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
this.GetMarkBorderData=function(drawInfo, exePrice, columnType, cellType)
|
|
2103
|
+
{
|
|
2104
|
+
if (!this.BorderData || !this.BorderData.MapData) return;
|
|
2105
|
+
if (!this.BorderData.MapData.has(columnType)) return;
|
|
2106
|
+
var borderData=this.BorderData.MapData.get(columnType);
|
|
2107
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(borderData.Data)) return;
|
|
2108
|
+
|
|
2109
|
+
if (cellType==1)
|
|
2110
|
+
{
|
|
2111
|
+
var leftBorder=borderData.Data[1];
|
|
2112
|
+
if (!leftBorder) return;
|
|
2113
|
+
|
|
2114
|
+
if (leftBorder.ExePrice==exePrice)
|
|
2115
|
+
{
|
|
2116
|
+
drawInfo.BorderColor=this.MarkBorderConfig.MaxPositionColor;
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
}
|
|
2120
|
+
else if (cellType==2)
|
|
2121
|
+
{
|
|
2122
|
+
var rightBorder=borderData.Data[2];
|
|
2123
|
+
if (!rightBorder) return;
|
|
2124
|
+
if (rightBorder.ExePrice==exePrice)
|
|
2125
|
+
{
|
|
2126
|
+
drawInfo.BorderColor=this.MarkBorderConfig.MaxPositionColor;
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
this.GetNullDrawInfo=function(drawInfo)
|
|
2132
|
+
{
|
|
2133
|
+
drawInfo.Text="--";
|
|
2134
|
+
drawInfo.TextColor=this.UnchangeColor;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
this.GetPriceDrawInfo=function(price, stock, data, drawInfo)
|
|
2138
|
+
{
|
|
2139
|
+
if (!IFrameSplitOperator.IsNumber(price))
|
|
2140
|
+
{
|
|
2141
|
+
this.GetNullDrawInfo(drawInfo);
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
drawInfo.Text=price.toFixed(data.Decimal);
|
|
2146
|
+
if (!IFrameSplitOperator.IsNumber(stock.YClose))
|
|
2147
|
+
drawInfo.TextColor=this.UnchangeColor;
|
|
2148
|
+
else
|
|
2149
|
+
drawInfo.TextColor=this.GetUpDownColor(price, stock.YClose);
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
//单独处理成交量显示
|
|
2153
|
+
this.FormatVolString=function(value,languageID)
|
|
2154
|
+
{
|
|
2155
|
+
if (!IFrameSplitOperator.IsNumber(value)) return null;
|
|
2156
|
+
|
|
2157
|
+
return IFrameSplitOperator.FormatVolString(value, languageID);
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
this.GetUpDownColor=function(price, price2)
|
|
2161
|
+
{
|
|
2162
|
+
if (price>price2) return this.UpColor;
|
|
2163
|
+
else if (price<price2) return this.DownColor;
|
|
2164
|
+
else return this.UnchangeColor;
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
this.DrawCell=function(drawInfo)
|
|
2168
|
+
{
|
|
2169
|
+
var rtText=drawInfo.RectText;
|
|
2170
|
+
var yCenter=rtText.Top+(rtText.Height/2);
|
|
2171
|
+
|
|
2172
|
+
if (drawInfo.BGColor) //背景
|
|
2173
|
+
{
|
|
2174
|
+
var rtItem=drawInfo.Rect;
|
|
2175
|
+
this.Canvas.fillStyle=drawInfo.BGColor;
|
|
2176
|
+
this.Canvas.fillRect(rtItem.Left,rtItem.Top,rtItem.Width,rtItem.Height);
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
if (drawInfo.FlashBGColor) //闪动背景
|
|
2180
|
+
{
|
|
2181
|
+
var rtItem=drawInfo.Rect;
|
|
2182
|
+
this.Canvas.fillStyle=drawInfo.FlashBGColor;
|
|
2183
|
+
this.Canvas.fillRect(rtItem.Left,rtItem.Top,rtItem.Width,rtItem.Height);
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
if (drawInfo.BorderColor) //边框
|
|
2187
|
+
{
|
|
2188
|
+
var rtItem=drawInfo.Rect;
|
|
2189
|
+
this.Canvas.strokeStyle=drawInfo.BorderColor;
|
|
2190
|
+
this.Canvas.strokeRect(ToFixedPoint(rtItem.Left),ToFixedPoint(rtItem.Top+1),ToFixedRect(rtItem.Width),ToFixedRect(rtItem.Height-3));
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
if (drawInfo.Text) //文字
|
|
2194
|
+
{
|
|
2195
|
+
if(drawInfo.TextColor) this.Canvas.fillStyle=drawInfo.TextColor;
|
|
2196
|
+
this.DrawText(drawInfo.Text, drawInfo.TextAlign, rtText.Left, yCenter, rtText.Width);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
this.OnMouseDown=function(x,y,e) //Type: 2=行 3=表头
|
|
2201
|
+
{
|
|
2202
|
+
if (!this.Data) return null;
|
|
2203
|
+
|
|
2204
|
+
var pixelTatio = GetDevicePixelRatio();
|
|
2205
|
+
var insidePoint={X:x/pixelTatio, Y:y/pixelTatio};
|
|
2206
|
+
|
|
2207
|
+
if (this.UIElement)
|
|
2208
|
+
var uiElement={Left:this.UIElement.getBoundingClientRect().left, Top:this.UIElement.getBoundingClientRect().top};
|
|
2209
|
+
else
|
|
2210
|
+
var uiElement={Left:null, Top:null};
|
|
2211
|
+
|
|
2212
|
+
var row=this.PtInBody(x,y);
|
|
2213
|
+
if (row)
|
|
2214
|
+
{
|
|
2215
|
+
var bRedraw=false;
|
|
2216
|
+
if (!this.SelectedRow)
|
|
2217
|
+
{
|
|
2218
|
+
this.SelectedRow={ ExePrice:row.ExePrice, CellType:row.CellType };
|
|
2219
|
+
bRedraw=true;
|
|
2220
|
+
}
|
|
2221
|
+
else if (this.SelectedRow.ExePrice!=row.ExePrice || this.SelectedRow.CellType!=row.CellType)
|
|
2222
|
+
{
|
|
2223
|
+
this.SelectedRow.ExePrice=row.ExePrice;
|
|
2224
|
+
this.SelectedRow.CellType=row.CellType;
|
|
2225
|
+
bRedraw=true;
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
var eventID=JSCHART_EVENT_ID.ON_CLICK_TREPORT_ROW;
|
|
2229
|
+
if (e.button==2) eventID=JSCHART_EVENT_ID.ON_RCLICK_TREPORT_ROW;
|
|
2230
|
+
|
|
2231
|
+
this.SendClickEvent(eventID, { Data:row, X:x, Y:y, e:e, Inside:insidePoint, UIElement:uiElement });
|
|
2232
|
+
|
|
2233
|
+
return { Type:2, Redraw:bRedraw, Row:row }; //行
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
var header=this.PtInHeader(x,y);
|
|
2237
|
+
if (header)
|
|
2238
|
+
{
|
|
2239
|
+
var eventID=JSCHART_EVENT_ID.ON_CLICK_TREPORT_HEADER;
|
|
2240
|
+
if (e.button==2)
|
|
2241
|
+
{
|
|
2242
|
+
eventID=JSCHART_EVENT_ID.ON_RCLICK_TREPORT_HEADER;
|
|
2243
|
+
}
|
|
2244
|
+
else if (e.button==0)
|
|
2245
|
+
{
|
|
2246
|
+
eventID=JSCHART_EVENT_ID.ON_CLICK_TREPORT_HEADER;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
this.SendClickEvent(eventID, { Data:header, X:x, Y:y , e:e, Inside:insidePoint, UIElement:uiElement});
|
|
2250
|
+
return { Type:3, Redraw:bRedraw, Header:header }; //表头
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
return null;
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
this.PtInBody=function(x,y)
|
|
2257
|
+
{
|
|
2258
|
+
if (!this.Data) return null;
|
|
2259
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return null;
|
|
2260
|
+
|
|
2261
|
+
var top=this.RectClient.Top+this.HeaderHeight;
|
|
2262
|
+
var left=this.RectClient.Left;
|
|
2263
|
+
var right=this.RectClient.Right;
|
|
2264
|
+
|
|
2265
|
+
var textTop=top;
|
|
2266
|
+
for(var i=this.Data.YOffset, j=0; i<this.Data.Data.length && j<this.RowCount ;++i, ++j)
|
|
2267
|
+
{
|
|
2268
|
+
var exePrice=this.Data.Data[i];
|
|
2269
|
+
var rtRow={ Left:left, Top:textTop, Right:right, Bottom: textTop+this.RowHeight };
|
|
2270
|
+
rtRow.Height=rtRow.Bottom-rtRow.Top;
|
|
2271
|
+
rtRow.Width=rtRow.Right-rtRow.Left;
|
|
2272
|
+
if (x>=rtRow.Left && x<=rtRow.Right && y>=rtRow.Top && y<=rtRow.Bottom)
|
|
2273
|
+
{
|
|
2274
|
+
var data={ RectRow:rtRow, DataIndex:i, Index:j, ExePrice:exePrice };
|
|
2275
|
+
return this.PtInItem(x,y, data);
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
textTop+=this.RowHeight;
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
return null;
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
this.PtInItem=function(x, y, info, exePrice)
|
|
2285
|
+
{
|
|
2286
|
+
var rtCenterItem=this.GetCenterItemRect();
|
|
2287
|
+
var rtRow=info.RectRow;
|
|
2288
|
+
var rtCenter={Left:rtCenterItem.Left, Right:rtCenterItem.Right, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom };
|
|
2289
|
+
|
|
2290
|
+
if (x>=rtCenter.Left && x<=rtCenter.Right && y>=rtCenter.Top && y<=rtCenter.Bottom)
|
|
2291
|
+
{
|
|
2292
|
+
var data={ Rect:rtCenter, DataIndex:info.DataIndex, Index:info.Index , ExePrice:info.ExePrice, CellType:0, Column:this.CenterColumn };
|
|
2293
|
+
data.Item=this.GetExePriceDataCallback(info.ExePrice);
|
|
2294
|
+
return data;
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
var xLeft=rtCenterItem.Left; //左边
|
|
2298
|
+
var xRight=rtCenterItem.Right; //右边
|
|
2299
|
+
|
|
2300
|
+
var reportleft=this.RectClient.Left;
|
|
2301
|
+
var reportRight=this.RectClient.Right;
|
|
2302
|
+
|
|
2303
|
+
for(var i=this.Data.XOffset;i<this.Column.length;++i)
|
|
2304
|
+
{
|
|
2305
|
+
var item=this.Column[i];
|
|
2306
|
+
var itemWidth=item.Width+this.ItemExtraWidth;
|
|
2307
|
+
xLeft-=itemWidth;
|
|
2308
|
+
if (xLeft<reportleft) break;
|
|
2309
|
+
|
|
2310
|
+
var rtItem={ Left:xLeft, Right:xLeft+itemWidth, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom, Width:itemWidth };
|
|
2311
|
+
if (x>=rtItem.Left && x<=rtItem.Right && y>=rtItem.Top && y<=rtItem.Bottom)
|
|
2312
|
+
{
|
|
2313
|
+
var data={ Rect:rtCenter, DataIndex:info.DataIndex, Index:info.Index , ExePrice:info.ExePrice, CellType:1, ColumnIndex:i, Column:item };
|
|
2314
|
+
data.Item=this.GetExePriceDataCallback(info.ExePrice);
|
|
2315
|
+
return data;
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
rtItem={ Left:xRight, Right:xRight+itemWidth, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom, Width:itemWidth };
|
|
2319
|
+
if (x>=rtItem.Left && x<=rtItem.Right && y>=rtItem.Top && y<=rtItem.Bottom)
|
|
2320
|
+
{
|
|
2321
|
+
var data={ Rect:rtCenter, DataIndex:info.DataIndex, Index:info.Index , ExePrice:info.ExePrice, CellType:2, ColumnIndex:i, Column:item };
|
|
2322
|
+
data.Item=this.GetExePriceDataCallback(info.ExePrice);
|
|
2323
|
+
return data;
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
xRight+=itemWidth;
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
return null;
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
this.PtInHeader=function(x,y)
|
|
2333
|
+
{
|
|
2334
|
+
if (!this.IsShowHeader) return null;
|
|
2335
|
+
|
|
2336
|
+
var left=this.RectClient.Left;
|
|
2337
|
+
var right=this.RectClient.Right;
|
|
2338
|
+
var top=this.RectClient.Top;
|
|
2339
|
+
var bottom=top+this.HeaderHeight;
|
|
2340
|
+
|
|
2341
|
+
if (!(x>=left && x<=right && y>=top && y<=bottom)) return null;
|
|
2342
|
+
|
|
2343
|
+
var rtHeader={Left:left, Right:right, Top:top, Bottom:bottom};
|
|
2344
|
+
rtHeader.Width=rtHeader.Right-rtHeader.Left;
|
|
2345
|
+
rtHeader.Height=rtHeader.Bottom-rtHeader.Top;
|
|
2346
|
+
var data={ RectRow:rtHeader, DataIndex:-1, Index:-1, ExePrice:null };
|
|
2347
|
+
return this.PtInItem(x,y, data);
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
this.SendClickEvent=function(id, data)
|
|
2351
|
+
{
|
|
2352
|
+
var event=this.GetEventCallback(id);
|
|
2353
|
+
if (event && event.Callback)
|
|
2354
|
+
{
|
|
2355
|
+
event.Callback(event,data,this);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
|
|
2360
|
+
this.GetCurrentPageStatus=function() //{ Start:起始索引, End:结束索引(数据), PageSize:页面可以显示几条记录, IsEnd:是否是最后一页, IsSinglePage:是否只有一页数据}
|
|
2361
|
+
{
|
|
2362
|
+
var result={ Start:this.Data.YOffset, PageSize:this.RowCount, IsEnd:false, SelectedRow:this.SelectedRow, IsSinglePage:false, DataCount:0 };
|
|
2363
|
+
if (IFrameSplitOperator.IsNonEmptyArray(this.Data.Data))
|
|
2364
|
+
{
|
|
2365
|
+
result.End=this.Data.YOffset+this.RowCount-1;
|
|
2366
|
+
result.IsSinglePage=this.Data.Data.length<=this.RowCount;
|
|
2367
|
+
result.DataCount=this.Data.Data.length;
|
|
2368
|
+
if (result.End>=this.Data.Data.length-1) result.IsEnd=true;
|
|
2369
|
+
if (result.End>=this.Data.Data.length) result.End=this.Data.Data.length-1;
|
|
2370
|
+
}
|
|
2371
|
+
else
|
|
2372
|
+
{
|
|
2373
|
+
result.Start=0;
|
|
2374
|
+
result.End=0;
|
|
2375
|
+
result.IsEnd=true;
|
|
2376
|
+
result.IsSinglePage=true;
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
return result;
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
this.OnDblClick=function(x,y,e)
|
|
2383
|
+
{
|
|
2384
|
+
if (!this.Data) return false;
|
|
2385
|
+
|
|
2386
|
+
var row=this.PtInBody(x,y);
|
|
2387
|
+
if (row)
|
|
2388
|
+
{
|
|
2389
|
+
this.SendClickEvent(JSCHART_EVENT_ID.ON_DBCLICK_TREPORT_ROW, { Data:row, X:x, Y:y });
|
|
2390
|
+
return true;
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
return false;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
|