hqchart 1.1.14811 → 1.1.14817

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hqchart",
3
- "version": "1.1.14811",
3
+ "version": "1.1.14817",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -226,7 +226,11 @@ function JSDialogDrawTool()
226
226
  this.Destroy=function()
227
227
  {
228
228
  this.AryDivChart=[];
229
- if (this.DivDialog) document.body.removeChild(this.DivDialog);
229
+ if (this.DivDialog)
230
+ {
231
+ if (document && document.body && document.body.removeChild)
232
+ document.body.removeChild(this.DivDialog);
233
+ }
230
234
  this.DivDialog=null;
231
235
  }
232
236
 
@@ -64,7 +64,7 @@ function JSDialogSearchIndex()
64
64
 
65
65
  if (this.DivDialog)
66
66
  {
67
- document.body.removeChild(this.DivDialog);
67
+ if (document && document.body && document.body.removeChild) document.body.removeChild(this.DivDialog);
68
68
  this.DivDialog=null;
69
69
  }
70
70
  }
@@ -62,7 +62,7 @@ function JSDialogSelectRect()
62
62
 
63
63
  if (this.DivDialog)
64
64
  {
65
- document.body.removeChild(this.DivDialog);
65
+ if (document && document.body && document.body.removeChild) document.body.removeChild(this.DivDialog);
66
66
  this.DivDialog=null;
67
67
  }
68
68
  }
@@ -93,7 +93,7 @@ function JSDialogTooltip()
93
93
 
94
94
  if (this.DivDialog)
95
95
  {
96
- document.body.removeChild(this.DivDialog);
96
+ if (document && document.body && document.body.removeChild) document.body.removeChild(this.DivDialog);
97
97
  this.DivDialog=null;
98
98
  }
99
99
  }
@@ -103,7 +103,12 @@ function JSTooltipKLineChart()
103
103
 
104
104
  this.Destroy=function()
105
105
  {
106
- if (this.DivDialog) document.body.removeChild(this.DivDialog);
106
+ if (this.DivDialog)
107
+ {
108
+ if (document && document.body && document.body.removeChild)
109
+ document.body.removeChild(this.DivDialog);
110
+ }
111
+
107
112
  this.DivDialog=null;
108
113
  this.TitleBox=null;
109
114
  if (!this.KLine.JSChart) this.KLine.JSChart.ChartDestory();
@@ -60,7 +60,11 @@ function JSPopKeyboard()
60
60
 
61
61
  this.Destroy=function()
62
62
  {
63
- if (this.DivDialog) document.body.removeChild(this.DivDialog);
63
+ if (this.DivDialog)
64
+ {
65
+ if (document && document.body && document.body.removeChild)
66
+ document.body.removeChild(this.DivDialog);
67
+ }
64
68
 
65
69
  this.DivDialog=null;
66
70
  this.TitleBox=null;
@@ -156,7 +156,11 @@ function JSPopMinuteChart()
156
156
 
157
157
  this.Destroy=function()
158
158
  {
159
- if (this.DivDialog) document.body.removeChild(this.DivDialog);
159
+ if (this.DivDialog)
160
+ {
161
+ if (document && document.body && document.body.removeChild)
162
+ document.body.removeChild(this.DivDialog);
163
+ }
160
164
  this.DivDialog=null;
161
165
  this.TitleBox=null;
162
166
  this.Minute.JSChart=null;
@@ -403,6 +403,12 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
403
403
  if (option.DrawTool.StorageKey && chart.ChartDrawStorage) chart.ChartDrawStorage.Load(option.DrawTool.StorageKey);
404
404
  }
405
405
 
406
+ if (option.KeyboardMove)
407
+ {
408
+ var item=option.KeyboardMove;
409
+ if (IFrameSplitOperator.IsPlusNumber(item.Delay)) chart.KeyboardMove.Delay=item.Delay;
410
+ }
411
+
406
412
  if (IFrameSplitOperator.IsNumber(option.StepPixel)) chart.StepPixel=option.StepPixel;
407
413
  if (option.ZoomStepPixel>0) chart.ZoomStepPixel=option.ZoomStepPixel;
408
414
  if (option.IsApiPeriod==true) chart.IsApiPeriod=option.IsApiPeriod;
@@ -3180,7 +3186,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3180
3186
  this.DisableMouse=false; //禁止鼠标事件
3181
3187
  this.LanguageID=JSCHART_LANGUAGE_ID.LANGUAGE_CHINESE_ID;
3182
3188
  this.PressTime=500;
3183
- this.IsPress=false; //是否长按
3189
+ this.IsPress=false; //是否长按
3190
+ this.IsPressKeyboard=false; //是否键盘按键
3184
3191
 
3185
3192
  this.NetworkFilter; //网络请求回调 function(data, callback);
3186
3193
  this.LastMouseStatus={ MouseOnToolbar:null }; // MouseOnToolbar={ Rect:{}, Title: }
@@ -3264,6 +3271,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3264
3271
  this.AryHotKey=[]; //热键 { KeyID:87, SecondKeyID:1, CMD:JSCHART_MENU_ID.CMD_FULLSCREEN_SUMMARY_ID, Args:null, Description:"Alt+W 全屏区间统计" },
3265
3272
 
3266
3273
  this.FastSlideConfig={ MinDistance:500, MinSpeed:3, MaxTime:250, Enable:false }; //快速滑动配置 MinDistance=最小的距离 MinSpeed=最小速度 MaxTime=最大间隔时间(ms)
3274
+ this.KeyboardMove={ Timer:null, Delay:100 , Enable:false, Event:null }; //键盘左右移动
3267
3275
 
3268
3276
  this.RestoreFocus=function(delay)
3269
3277
  {
@@ -7433,6 +7441,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
7433
7441
  if (this.ChartSplashPaint && this.ChartSplashPaint.IsEnableSplash == true) return;
7434
7442
 
7435
7443
  var keyID = e.keyCode ? e.keyCode :e.which;
7444
+ this.IsPressKeyboard=true;
7436
7445
 
7437
7446
  //回调事件
7438
7447
  var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_KEYDOWN);
@@ -7467,6 +7476,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
7467
7476
  switch(keyID)
7468
7477
  {
7469
7478
  case 37: //left
7479
+ if (this.KeyboardMove.Enable) break;
7470
7480
  if ((e.ctrlKey||e.shiftKey) && this.OnCustomKeyDown)
7471
7481
  {
7472
7482
  if (this.OnCustomKeyDown(keyID, e))
@@ -7506,6 +7516,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
7506
7516
  }
7507
7517
  break;
7508
7518
  case 39: //right
7519
+ if (this.KeyboardMove.Enable) break;
7509
7520
  if ((e.ctrlKey|| e.shiftKey) && this.OnCustomKeyDown)
7510
7521
  {
7511
7522
  if (this.OnCustomKeyDown(keyID, e))
@@ -7640,11 +7651,167 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
7640
7651
 
7641
7652
  if (draw) this.DrawDynamicInfo();
7642
7653
 
7654
+ if (keyID==37 || keyID==39)
7655
+ this.StartKeyboardMoveTimer(e);
7656
+
7643
7657
  //不让滚动条滚动
7644
7658
  if(e.preventDefault) e.preventDefault();
7645
7659
  else e.returnValue = false;
7646
7660
  }
7647
7661
 
7662
+
7663
+ this.ClearKeyboardMoveTimer=function()
7664
+ {
7665
+ if (!this.KeyboardMove) return;
7666
+
7667
+ this.KeyboardMove.Event=null;
7668
+
7669
+ if (this.KeyboardMove.Timer)
7670
+ {
7671
+ clearTimeout(this.KeyboardMove.Timer);
7672
+ this.KeyboardMove.Timer=null;
7673
+ JSConsole.Chart.Log(`[JSChartContainer::ClearKeyboardMoveTimer] Stop` );
7674
+ }
7675
+
7676
+ this.KeyboardMove.Enable=false;
7677
+ }
7678
+
7679
+ this.StartKeyboardMoveTimer=function(e)
7680
+ {
7681
+ if (!this.KeyboardMove) return;
7682
+ if (this.KeyboardMove.Enable) return; //已启动
7683
+
7684
+ this.KeyboardMove.Event=e;
7685
+ this.KeyboardMove.Enable=true;
7686
+
7687
+ JSConsole.Chart.Log(`[JSChartContainer::StartKeyboardMoveTimer] Start` );
7688
+
7689
+ this.AutoKeyboardMove();
7690
+ }
7691
+
7692
+ this.AutoKeyboardMove=function()
7693
+ {
7694
+ if (!this.KeyboardMove) return false;
7695
+ if (!this.KeyboardMove.Enable) return false;
7696
+ if (!this.KeyboardMove.Event) return false;
7697
+
7698
+ this.KeyboardMove.Timer=setTimeout(()=>
7699
+ {
7700
+ this.OnKeyboardMoveTimerProc();
7701
+ },this.KeyboardMove.Delay);
7702
+ }
7703
+
7704
+
7705
+ this.OnKeyboardMoveTimerProc=function()
7706
+ {
7707
+ if (!this.KeyboardMove) return false;
7708
+ if (!this.KeyboardMove.Enable) return false;
7709
+ if (!this.KeyboardMove.Event) return false;
7710
+
7711
+ var e=this.KeyboardMove.Event;
7712
+ var keyID = e.keyCode ? e.keyCode :e.which;
7713
+ var bStop=false;
7714
+ switch(keyID)
7715
+ {
7716
+ case 37: //left
7717
+ if ((e.ctrlKey||e.shiftKey) && this.OnCustomKeyDown)
7718
+ {
7719
+ if (this.OnCustomKeyDown(keyID, e))
7720
+ break;
7721
+ }
7722
+
7723
+ //K线 如果超出K线数据了 调整到最后一个数据
7724
+ if (this.FixCursorIndexValid && this.FixCursorIndexValid())
7725
+ {
7726
+ this.UpdatePointByCursorIndex();
7727
+ this.DrawDynamicInfo();
7728
+ this.ShowTooltipByKeyDown();
7729
+ break;
7730
+ }
7731
+
7732
+ if (this.CursorIndex<=0.99999)
7733
+ {
7734
+ if (!this.DataMoveLeft())
7735
+ { //左移数据到头了 触发下载新数据
7736
+ if (this.DragDownloadData) this.DragDownloadData();
7737
+ break;
7738
+ }
7739
+ this.UpdataDataoffset();
7740
+ this.UpdatePointByCursorIndex();
7741
+ this.UpdateFrameMaxMin();
7742
+ this.ResetFrameXSplit();
7743
+ this.Draw();
7744
+ this.ShowTooltipByKeyDown();
7745
+ this.OnKLinePageChange("keydown");
7746
+ }
7747
+ else
7748
+ {
7749
+ --this.CursorIndex;
7750
+ this.UpdatePointByCursorIndex();
7751
+ this.DrawDynamicInfo();
7752
+ this.ShowTooltipByKeyDown();
7753
+ }
7754
+ break;
7755
+
7756
+ case 39: //right
7757
+ if ((e.ctrlKey|| e.shiftKey) && this.OnCustomKeyDown)
7758
+ {
7759
+ if (this.OnCustomKeyDown(keyID, e))
7760
+ break;
7761
+ }
7762
+
7763
+ //K线 如果超出K线数据了 调整到最后一个数据
7764
+ if (this.FixCursorIndexValid && this.FixCursorIndexValid())
7765
+ {
7766
+ this.UpdatePointByCursorIndex();
7767
+ this.DrawDynamicInfo();
7768
+ this.ShowTooltipByKeyDown();
7769
+ break;
7770
+ }
7771
+
7772
+ var xPointcount=0;
7773
+ if (this.Frame.XPointCount) xPointcount=this.Frame.XPointCount;
7774
+ else xPointcount=this.Frame.SubFrame[0].Frame.XPointCount;
7775
+ if (this.CursorIndex+1>=xPointcount)
7776
+ {
7777
+ if (!this.DataMoveRight()) break;
7778
+ this.UpdataDataoffset();
7779
+ this.UpdatePointByCursorIndex();
7780
+ this.UpdateFrameMaxMin();
7781
+ this.ResetFrameXSplit();
7782
+ this.Draw();
7783
+ this.ShowTooltipByKeyDown();
7784
+ this.OnKLinePageChange("keydown");
7785
+ }
7786
+ else
7787
+ {
7788
+ //判断是否在最后一个数据上
7789
+ var data=null;
7790
+ if (this.Frame.Data) data=this.Frame.Data;
7791
+ else data=this.Frame.SubFrame[0].Frame.Data;
7792
+ if (!data) break;
7793
+ if (this.CursorIndex+data.DataOffset+1>=data.Data.length) break;
7794
+
7795
+ ++this.CursorIndex;
7796
+ this.UpdatePointByCursorIndex();
7797
+ this.DrawDynamicInfo();
7798
+ this.ShowTooltipByKeyDown();
7799
+ }
7800
+ break;
7801
+ }
7802
+
7803
+
7804
+ if (!bStop) this.AutoKeyboardMove();
7805
+ return true;
7806
+ }
7807
+
7808
+
7809
+ this.OnKeyUp=function(e)
7810
+ {
7811
+ this.IsPressKeyboard=false;
7812
+ this.ClearKeyboardMoveTimer();
7813
+ }
7814
+
7648
7815
  this.OnDoubleClick=function(x,y,e)
7649
7816
  {
7650
7817
 
@@ -53195,11 +53362,24 @@ IFrameSplitOperator.FormatDateTimeStringV2=function(datetime, format, languageID
53195
53362
  {
53196
53363
  case "YYYY-MM-DD":
53197
53364
  return `${datetime.getFullYear()}-${IFrameSplitOperator.NumberToString(datetime.getMonth()+1)}-${IFrameSplitOperator.NumberToString(datetime.getDate())}`;
53198
-
53365
+ case 'MM-DD':
53366
+ return `${IFrameSplitOperator.NumberToString(datetime.getMonth()+1)}-${IFrameSplitOperator.NumberToString(datetime.getDate())}`;
53367
+ case "MM/DD":
53368
+ return `${IFrameSplitOperator.NumberToString(datetime.getMonth()+1)}/${IFrameSplitOperator.NumberToString(datetime.getDate())}`;
53369
+ case "YYYY-MM":
53370
+ return `${datetime.getFullYear()}-${IFrameSplitOperator.NumberToString(datetime.getMonth()+1)}`;
53371
+ case "YYYY/MM/DD":
53372
+ return `${datetime.getFullYear()}/${IFrameSplitOperator.NumberToString(datetime.getMonth()+1)}/${IFrameSplitOperator.NumberToString(datetime.getDate())}`;
53373
+ case "DD/MM/YYYY":
53374
+ return `${IFrameSplitOperator.NumberToString(datetime.getDate())}/${IFrameSplitOperator.NumberToString(datetime.getMonth()+1)}/${datetime.getFullYear()}`;
53375
+
53376
+
53199
53377
  case "HH:MM:SS":
53200
53378
  return `${IFrameSplitOperator.NumberToString(datetime.getHours())}:${IFrameSplitOperator.NumberToString(datetime.getMinutes())}:${IFrameSplitOperator.NumberToString(datetime.getSeconds())}`;
53201
53379
  case "HH:MM":
53202
53380
  return `${IFrameSplitOperator.NumberToString(datetime.getHours())}:${IFrameSplitOperator.NumberToString(datetime.getMinutes())}`;
53381
+ case "HH:MM:SS.fff":
53382
+ return `${IFrameSplitOperator.NumberToString(datetime.getHours())}:${IFrameSplitOperator.NumberToString(datetime.getMinutes())}:${IFrameSplitOperator.NumberToString(datetime.getSeconds())}.${IFrameSplitOperator.MillisecondToString(datetime.getMilliseconds())}`;
53203
53383
  default:
53204
53384
  return null;
53205
53385
  }
@@ -79746,7 +79926,12 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
79746
79926
  }
79747
79927
  }
79748
79928
 
79749
- if (bRegisterKeydown) this.UIElement.addEventListener("keydown", (e)=>{ this.OnKeyDown(e); }, true); //键盘消息
79929
+ if (bRegisterKeydown)
79930
+ {
79931
+ this.UIElement.addEventListener("keydown", (e)=>{ this.OnKeyDown(e); }, true); //键盘消息
79932
+ this.UIElement.addEventListener("keyup", (e)=>{ this.OnKeyUp(e);}, true);
79933
+ }
79934
+
79750
79935
  if (bRegisterWheel) this.UIElement.addEventListener("wheel", (e)=>{ this.OnWheel(e); }, true); //上下滚动消息
79751
79936
 
79752
79937
  this.InitalPopMinuteChart(option);
@@ -81526,7 +81711,8 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
81526
81711
 
81527
81712
  this.RecvRealtimeData=function(data)
81528
81713
  {
81529
- if (this.IsOnTouch==true) return; //正在操作中不更新数据
81714
+ if (this.IsOnTouch==true) return; //正在操作手势不更新数据
81715
+ if (this.IsPressKeyboard==true) return; //正在操作键盘不更新数据
81530
81716
 
81531
81717
  if (data.Ver==3.0)
81532
81718
  {
@@ -81866,6 +82052,8 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
81866
82052
  this.RecvMinuteRealtimeDataV2=function(data) //新版本的
81867
82053
  {
81868
82054
  if (this.IsOnTouch==true) return; //正在操作中不更新数据
82055
+ if (this.IsPressKeyboard==true) return; //正在操作键盘不更新数据
82056
+
81869
82057
  if (this.EnableVerifyRecvData && data.symbol!=this.Symbol)
81870
82058
  {
81871
82059
  JSConsole.Chart.Warn(`[KLineChartContainer::RecvMinuteRealtimeDataV2] recv data symbol not match. HQChart[${this.Symbol}] , Recv[${data.symbol}]`);
@@ -95532,7 +95720,11 @@ function DepthChartContainer(uielement)
95532
95720
  }
95533
95721
  }
95534
95722
 
95535
- if (bRegisterKeydown) this.UIElement.addEventListener("keydown", (e)=>{ this.OnKeyDown(e); }, true); //键盘消息
95723
+ if (bRegisterKeydown)
95724
+ {
95725
+ this.UIElement.addEventListener("keydown", (e)=>{ this.OnKeyDown(e); }, true); //键盘消息
95726
+ this.UIElement.addEventListener("keyup", (e)=>{ this.OnKeyUp(e);}, true);
95727
+ }
95536
95728
  if (bRegisterWheel) this.UIElement.addEventListener("wheel", (e)=>{ this.OnWheel(e); }, true); //上下滚动消息
95537
95729
  }
95538
95730
 
@@ -5617,6 +5617,8 @@ function ChartReport()
5617
5617
  for(var i=0;i<this.Column.length;++i)
5618
5618
  {
5619
5619
  var item=this.Column[i];
5620
+ this.Canvas.font=this.ItemFont;
5621
+
5620
5622
  if (item.Type==REPORT_COLUMN_ID.SYMBOL_NAME_ID)
5621
5623
  {
5622
5624
  this.Canvas.font=this.ItemNameFont;
@@ -6104,6 +6106,7 @@ function ChartReport()
6104
6106
  }
6105
6107
 
6106
6108
  this.DrawFullRowBGColor(symbol, eventDrawBG, i, rtRowBG, { Selected:selectedSymbol } );
6109
+ this.DrawFlashFullRowBGColor(symbol, rtRowBG);
6107
6110
 
6108
6111
  if (bFillRow)
6109
6112
  {
@@ -6153,6 +6156,27 @@ function ChartReport()
6153
6156
  }
6154
6157
  }
6155
6158
 
6159
+ this.DrawFlashFullRowBGColor=function(symbol, rtBG)
6160
+ {
6161
+ var data= { Symbol:symbol, FlashBG:null };
6162
+ if (this.GetFlashBGDataCallback) data.FlashBG=this.GetFlashBGDataCallback(symbol, Date.now());
6163
+ if (!data.FlashBG) return;
6164
+
6165
+ var id=-1;
6166
+ if (!data.FlashBG.Data.has(id)) return;
6167
+
6168
+ var flashItem=data.FlashBG.Data.get(id);
6169
+ if (flashItem && flashItem.Count)
6170
+ {
6171
+ this.Canvas.fillStyle=flashItem.Color;
6172
+ this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
6173
+ }
6174
+
6175
+ --flashItem.Count;
6176
+
6177
+ if (this.GlobalOption) ++this.GlobalOption.FlashBGCount;
6178
+ }
6179
+
6156
6180
  this.DrawSelectedRow=function()
6157
6181
  {
6158
6182
  if (this.SelectedStyle===2 && IFrameSplitOperator.IsNonEmptyArray(this.AryFullSelectedRow))
@@ -7792,6 +7816,8 @@ function ChartReport()
7792
7816
  {
7793
7817
  drawInfo.Botton={ Rect:rtBG, Type:1 };
7794
7818
  }
7819
+
7820
+ this.Canvas.font=this.ItemFont;
7795
7821
  }
7796
7822
 
7797
7823
  this.DrawProgressBar=function(drawInfo, left, top, width)