hqchart 1.1.15008 → 1.1.15018

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.
@@ -813,12 +813,27 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
813
813
  var item=option.LatestPointFlash;
814
814
  if (item.Enable)
815
815
  {
816
- this.CreateExtraCanvasElement(JSChart.LatestPointFlashKey, { ZIndex:6 });
816
+ var zIndex=6;
817
+ if (IFrameSplitOperator.IsNumber(item.ZIndex)) zIndex=item.ZIndex;
818
+ this.CreateExtraCanvasElement(JSChart.LatestPointFlashKey, { ZIndex:zIndex });
817
819
  chart.CreateExtendChart("LatestPointFlashPaint", item);
818
820
  chart.StartLatestPointFlash();
819
821
  }
820
822
  }
821
823
 
824
+ if (option.KLineCountDown)
825
+ {
826
+ var item=option.KLineCountDown;
827
+ if (item.Enable)
828
+ {
829
+ var zIndex=4;
830
+ if (IFrameSplitOperator.IsNumber(item.ZIndex)) zIndex=item.ZIndex;
831
+ this.CreateExtraCanvasElement(JSChart.KLineCountDownKey, { ZIndex:zIndex });
832
+ chart.CreateExtendChart("KLineCountDownPaint", item);
833
+ chart.StartCountDown();
834
+ }
835
+ }
836
+
822
837
  return chart;
823
838
  }
824
839
 
@@ -1877,6 +1892,9 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
1877
1892
  if (option.FloatTooltip && option.FloatTooltip.Enable)
1878
1893
  chart.InitalFloatTooltip(option.FloatTooltip);
1879
1894
 
1895
+ if (option.SmallFloatTooltip && option.SmallFloatTooltip.Enable)
1896
+ chart.InitalSmallFloatTooltip(option.SmallFloatTooltip);
1897
+
1880
1898
  if (option.SelectRectDialog && option.SelectRectDialog.Enable)
1881
1899
  chart.InitalSelectRectDialog(option.SelectRectDialog);
1882
1900
 
@@ -2389,6 +2407,7 @@ JSChart.CorssCursorCanvasKey="hqchart_corsscursor";
2389
2407
  JSChart.TooltipCursorCanvasKey="hqchart_tooltip";
2390
2408
  JSChart.RectDragCanvasKey="hqchart_drag_rect";
2391
2409
  JSChart.LatestPointFlashKey="hqchart_point_flash"; //最新数据点闪烁
2410
+ JSChart.KLineCountDownKey="hqchart_kline_countdown"; //倒计时
2392
2411
 
2393
2412
  //初始化
2394
2413
  JSChart.Init=function(divElement,bScreen,bCacheCanvas)
@@ -2835,6 +2854,8 @@ var JSCHART_EVENT_ID=
2835
2854
  ON_REPORT_SHOW_TOOLTIP:175, //报价列表 提示信息\
2836
2855
 
2837
2856
  ON_FORMAT_TVLONGPOSITION_LABEL:176,
2857
+
2858
+ ON_FORMAT_COUNTDOWN_TEXT:177, //倒计时
2838
2859
  }
2839
2860
 
2840
2861
  var JSCHART_OPERATOR_ID=
@@ -3302,7 +3323,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3302
3323
  this.DisplayLatestOption={ Timer:null, Enable: false, DelayTime:60*1000*3, LastPoint:null };
3303
3324
  this.DrawDynamicInfoOption={ Timer:null, Enable:false , DelayTime:10 };
3304
3325
 
3305
- this.LatestPointFlashOption={ Timer:null, DelayTime:100 };
3326
+ this.LatestPointFlashOption={ Timer:null, DelayTime:100 }; //最后一个数据闪烁
3327
+ this.CountDownOption={ Timer:null, DelayTime:300 }; //倒计时
3306
3328
 
3307
3329
  this.CustomChartDrag; //自定义图形的拖拽操作 { Type:, Data: }
3308
3330
 
@@ -3320,6 +3342,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3320
3342
  this.FloatTooltip; //浮动tooltip信息
3321
3343
  this.DialogSearchIndex; //指标搜索
3322
3344
  this.DialogModifyIndexParam; //指标参数修改
3345
+ this.SmallFloatTooltipGroup; //小浮框tooltip信息集合
3323
3346
 
3324
3347
 
3325
3348
  this.RestoreFocusTimer=null; //恢复焦点定时器
@@ -3404,6 +3427,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3404
3427
 
3405
3428
  this.GlobalOption.LatestPoint=null;
3406
3429
  this.GlobalOption.TradeStatus=null;
3430
+ this.GlobalOption.CountDown=null;
3407
3431
  }
3408
3432
 
3409
3433
  this.RestoreFocus=function(delay)
@@ -3476,6 +3500,17 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3476
3500
  this.FloatTooltip.Create();
3477
3501
  }
3478
3502
 
3503
+
3504
+ this.InitalSmallFloatTooltip=function(option)
3505
+ {
3506
+ if (this.SmallFloatTooltipGroup) return;
3507
+
3508
+ this.SmallFloatTooltipGroup=new JSSmallFloatTooltipGroup();
3509
+ this.SmallFloatTooltipGroup.Inital(this, option);
3510
+ this.SmallFloatTooltipGroup.Create();
3511
+ }
3512
+
3513
+
3479
3514
  this.InitalModifyDrawDialog=function()
3480
3515
  {
3481
3516
  if ( this.DialogModifyDraw) return;
@@ -3653,6 +3688,13 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3653
3688
  this.FloatTooltip.Hide();
3654
3689
  }
3655
3690
 
3691
+ this.HideSmallFloatTooltip=function()
3692
+ {
3693
+ if (!this.SmallFloatTooltipGroup) return;
3694
+
3695
+ this.SmallFloatTooltipGroup.Hide();
3696
+ }
3697
+
3656
3698
  this.DestroyTooltipDialog=function()
3657
3699
  {
3658
3700
  if (!this.DialogTooltip) return;
@@ -3669,6 +3711,14 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3669
3711
  this.FloatTooltip=null;
3670
3712
  }
3671
3713
 
3714
+ this.DestroySmallFloatTooltip=function()
3715
+ {
3716
+ if (!this.SmallFloatTooltipGroup) return;
3717
+
3718
+ this.SmallFloatTooltipGroup.Destroy();
3719
+ this.SmallFloatTooltipGroup=null;
3720
+ }
3721
+
3672
3722
  this.DestroySearchIndexDialog=function()
3673
3723
  {
3674
3724
  if (!this.DialogSearchIndex) return;
@@ -3722,6 +3772,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3722
3772
  {
3723
3773
  this.HideFloatTooltip();
3724
3774
  this.CloseTooltipDialog();
3775
+ this.HideSmallFloatTooltip();
3725
3776
 
3726
3777
  if (this.DialogDrawTool) this.DialogDrawTool.Close();
3727
3778
  this.CloseModifyDrawDialog();
@@ -3811,6 +3862,30 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3811
3862
  chart.FlashCount=flashCount;
3812
3863
  }
3813
3864
 
3865
+ this.StartCountDown=function()
3866
+ {
3867
+ this.CountDownOption.Timer=setInterval(()=>
3868
+ {
3869
+ this.DrawCountDown();
3870
+ }, this.CountDownOption.DelayTime);
3871
+ }
3872
+
3873
+ this.DrawCountDown=function()
3874
+ {
3875
+ var finder=this.GetExtendChartByClassName("KLineCountDownPaint");
3876
+ if (finder && finder.Chart)
3877
+ finder.Chart.Draw();
3878
+ }
3879
+
3880
+ this.StopCountDown=function()
3881
+ {
3882
+ if (this.CountDownOption.Timer)
3883
+ {
3884
+ clearInterval(this.CountDownOption.Timer);
3885
+ this.CountDownOption.Timer=null;
3886
+ }
3887
+ }
3888
+
3814
3889
  this.ChartDestroy=function() //销毁
3815
3890
  {
3816
3891
  this.IsDestroy=true;
@@ -3818,6 +3893,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3818
3893
 
3819
3894
  this.DestroyTooltipDialog();
3820
3895
  this.DestroyFloatTooltip();
3896
+ this.DestroySmallFloatTooltip();
3821
3897
 
3822
3898
  this.DestroySearchIndexDialog();
3823
3899
  this.DestroyDialogModifyIndexParam();
@@ -3832,6 +3908,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3832
3908
  if (this.DestroyPopMinuteChart) this.DestroyPopMinuteChart();
3833
3909
 
3834
3910
  this.StopLatestPointFlash();
3911
+ this.StopCountDown();
3835
3912
 
3836
3913
  document.oncontextmenu=null;
3837
3914
  this.RemoveAllEventListener();
@@ -7274,6 +7351,49 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
7274
7351
  return null;
7275
7352
  }
7276
7353
 
7354
+ this.GetCorssCursorTooltipData=function(option)
7355
+ {
7356
+ if (!this.ChartCorssCursor) return null;
7357
+ if (this.ChartCorssCursor.Status===0) return null;
7358
+
7359
+ var kItem=this.ChartCorssCursor.StringFormatX.KItem;
7360
+ if (!kItem) return null;
7361
+
7362
+ //X轴取十字光标坐标
7363
+ var toolTip={ AryData:[], X:this.ChartCorssCursor.StringFormatX.Point.X };
7364
+
7365
+ for(var i=0;i<this.ChartPaint.length;++i)
7366
+ {
7367
+ var item=this.ChartPaint[i];
7368
+ if (!item.GetCorssCursorTooltipData) continue;
7369
+
7370
+ item.GetCorssCursorTooltipData(kItem, toolTip);
7371
+ }
7372
+
7373
+ if (IFrameSplitOperator.IsNonEmptyArray(this.Frame.SubFrame))
7374
+ {
7375
+ for(var i=0;i<this.Frame.SubFrame.length;++i)
7376
+ {
7377
+ var subFrame=this.Frame.SubFrame[i];
7378
+ for(var j=0;j<subFrame.OverlayIndex.length;++j)
7379
+ {
7380
+ var overlayItem=subFrame.OverlayIndex[j];
7381
+ for(var k=0;k<overlayItem.ChartPaint.length;++k)
7382
+ {
7383
+ var item=overlayItem.ChartPaint[k];
7384
+ if (!item.GetCorssCursorTooltipData) continue;
7385
+
7386
+ item.GetCorssCursorTooltipData(kItem, toolTip);
7387
+ }
7388
+ }
7389
+ }
7390
+ }
7391
+
7392
+ if (!IFrameSplitOperator.IsNonEmptyArray(toolTip.AryData)) return null;
7393
+
7394
+ return toolTip;
7395
+ }
7396
+
7277
7397
  this.PtInExtendChartButtons=function(x,y)
7278
7398
  {
7279
7399
  for(var i=0;i<this.ExtendChartPaint.length; ++i)
@@ -7587,6 +7707,10 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
7587
7707
  }
7588
7708
  }
7589
7709
 
7710
+ var corssTooltipData=this.GetCorssCursorTooltipData(null);
7711
+ if (corssTooltipData) this.DrawSmallFloatTooltip(corssTooltipData);
7712
+ else this.HideSmallFloatTooltip();
7713
+
7590
7714
  this.SetCursor(mouseStatus);
7591
7715
  }
7592
7716
 
@@ -8311,6 +8435,10 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
8311
8435
 
8312
8436
  this.ShowTooltipByKeyDown=function()
8313
8437
  {
8438
+ var corssTooltipData=this.GetCorssCursorTooltipData(null);
8439
+ if (corssTooltipData) this.DrawSmallFloatTooltip(corssTooltipData);
8440
+ else this.HideSmallFloatTooltip();
8441
+
8314
8442
  if (!this.KLineTooltipConfig.Enable || !this.KLineTooltipConfig.EnableKeyDown)
8315
8443
  {
8316
8444
  this.HideFloatTooltip();
@@ -8329,7 +8457,6 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
8329
8457
  var kItem=kData.Data[dataIndex];
8330
8458
  if (!kItem) return;
8331
8459
 
8332
- var data=this.Frame.Data;
8333
8460
  var toolTip=new TooltipData();
8334
8461
  toolTip.Data=kItem;
8335
8462
  toolTip.ChartPaint=this.ChartPaint[0];
@@ -8697,6 +8824,29 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
8697
8824
  if (this.Tooltip.style.display!="none") this.Tooltip.style.display = "none";
8698
8825
 
8699
8826
  this.HideFloatTooltip();
8827
+ this.HideSmallFloatTooltip();
8828
+ }
8829
+
8830
+ this.DrawSmallFloatTooltip=function(toolTip)
8831
+ {
8832
+ if (!this.SmallFloatTooltipGroup) return;
8833
+
8834
+ this.UpdateSmallFloatTooltip(toolTip)
8835
+ }
8836
+
8837
+ this.UpdateSmallFloatTooltip=function(toolTip)
8838
+ {
8839
+ if (!this.SmallFloatTooltipGroup) return;
8840
+
8841
+ var sendData=
8842
+ {
8843
+ Tooltip:toolTip,
8844
+ Symbol:this.Symbol,
8845
+ Name:this.Name,
8846
+ DataType:1,
8847
+ };
8848
+
8849
+ this.SmallFloatTooltipGroup.Update(sendData);
8700
8850
  }
8701
8851
 
8702
8852
  this.UpdateSelectRect=function(start,end)
@@ -33871,7 +34021,8 @@ function ChartKLineTable()
33871
34021
  this.RowHeight=10; //行高
33872
34022
  this.RowHeightType=1; //0=均分 1=固定高度
33873
34023
  this.TextFontConfig=CloneData(g_JSChartResource.ChartKLineTable.TextFont);
33874
- this.ItemMergin=CloneData(g_JSChartResource.ChartKLineTable.ItemMergin);
34024
+ this.ItemMargin=CloneData(g_JSChartResource.ChartKLineTable.ItemMargin);
34025
+ this.CellWidth=12*GetDevicePixelRatio();
33875
34026
 
33876
34027
  this.TextFont;
33877
34028
  this.TextColor='rgb(0,0,0)';
@@ -33881,6 +34032,37 @@ function ChartKLineTable()
33881
34032
  this.MapCache=null; //key=date/date-time value={ Date:, Time:, Data:[ ] }
33882
34033
  this.GetKValue=ChartData.GetKValue;
33883
34034
  this.AryCellRect=[]; //保存单元格信息
34035
+
34036
+
34037
+ this.SetOption=function(option)
34038
+ {
34039
+ if (!option) return;
34040
+
34041
+ if (option.BGColor) this.BGColor=option.BGColor;
34042
+ if (option.TextColor) this.TextColor=option.TextColor;
34043
+ if (option.BorderColor) this.BorderColor=option.BorderColor;
34044
+ if (IFrameSplitOperator.IsNumber(option.RowNamePosition)) this.RowNamePosition=option.RowNamePosition;
34045
+ if (IFrameSplitOperator.IsNumber(option.RowHeightType)) this.RowHeightType=option.RowHeightType;
34046
+
34047
+ if (option.ItemMargin)
34048
+ {
34049
+ var subItem=option.ItemMargin;
34050
+ if (IFrameSplitOperator.IsNumber(subItem.Left)) this.ItemMargin.Left=subItem.Left;
34051
+ if (IFrameSplitOperator.IsNumber(subItem.Top)) this.ItemMargin.Top=subItem.Top;
34052
+ if (IFrameSplitOperator.IsNumber(subItem.Bottom)) this.ItemMargin.Bottom=subItem.Bottom;
34053
+ if (IFrameSplitOperator.IsNumber(subItem.Right)) this.ItemMargin.Right=subItem.Right;
34054
+ if (IFrameSplitOperator.IsNumber(subItem.YOffset)) this.ItemMargin.YOffset=subItem.YOffset;
34055
+ }
34056
+
34057
+ if (option.TextFont)
34058
+ {
34059
+ var subItem=option.TextFont;
34060
+ if (IFrameSplitOperator.IsNumber(subItem.FontMaxSize)) this.TextFontConfig.FontMaxSize=subItem.FontMaxSize;
34061
+ if (subItem.Family) this.TextFontConfig.Family=subItem.Family;
34062
+ }
34063
+
34064
+ if (IFrameSplitOperator.IsPlusNumber(option.CellWidth)) this.CellWidth=option.CellWidth;
34065
+ }
33884
34066
 
33885
34067
  this.BuildCacheData=function()
33886
34068
  {
@@ -33939,7 +34121,7 @@ function ChartKLineTable()
33939
34121
  {
33940
34122
  if (this.RowHeightType==1)
33941
34123
  {
33942
- this.RowHeight=this.TextFontConfig.FontMaxSize+this.ItemMergin.Top+this.ItemMergin.Bottom;
34124
+ this.RowHeight=this.TextFontConfig.FontMaxSize+this.ItemMargin.Top+this.ItemMargin.Bottom;
33943
34125
  }
33944
34126
  else
33945
34127
  {
@@ -33998,23 +34180,40 @@ function ChartKLineTable()
33998
34180
 
33999
34181
  var itemHeight=this.RowHeight;
34000
34182
  var itemWidth=dataWidth+distanceWidth;
34001
- if (itemHeight-this.ItemMergin.Top-this.ItemMergin.Bottom>0) itemHeight=itemHeight-this.ItemMergin.Top-this.ItemMergin.Bottom;
34002
- if (itemWidth-this.ItemMergin.Left-this.ItemMergin.Right>0) itemWidth=itemWidth-this.ItemMergin.Left-this.ItemMergin.Right;
34183
+ if (itemHeight-this.ItemMargin.Top-this.ItemMargin.Bottom>0) itemHeight=itemHeight-this.ItemMargin.Top-this.ItemMargin.Bottom;
34184
+ if (itemWidth-this.ItemMargin.Left-this.ItemMargin.Right>0) itemWidth=itemWidth-this.ItemMargin.Left-this.ItemMargin.Right;
34003
34185
 
34004
34186
  var font=this.GetDynamicTextFont(itemHeight, itemWidth);
34005
34187
  this.TextFont=font;
34006
34188
  this.Canvas.font=this.TextFont;
34189
+ var bMinute=this.IsMinuteFrame();
34190
+ var cellWidth=1
34191
+ if (bMinute)
34192
+ {
34193
+ cellWidth=(border.Right-border.Left)/this.ChartFrame.XPointCount;
34194
+ if (cellWidth<1) cellWidth=1;
34195
+ }
34007
34196
 
34008
34197
  for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
34009
34198
  {
34010
34199
  var kItem=this.Data.Data[i];
34011
34200
  if (!kItem) continue;
34012
34201
 
34013
- var left=xOffset;
34014
- var right=xOffset+dataWidth+distanceWidth;
34015
- if (right>chartright) break;
34016
- var x=left+(right-left)/2;
34017
- if (x>chartright) break;
34202
+ if (bMinute)
34203
+ {
34204
+ var x=this.ChartFrame.GetXFromIndex(j);
34205
+ var left=x-cellWidth/2;
34206
+ var right=x+cellWidth/2;
34207
+ }
34208
+ else
34209
+ {
34210
+ var left=xOffset;
34211
+ var right=xOffset+dataWidth+distanceWidth;
34212
+ if (right>chartright) break;
34213
+ var x=left+(right-left)/2;
34214
+ if (x>chartright) break;
34215
+ }
34216
+
34018
34217
 
34019
34218
  var bDrawName=false;
34020
34219
  if (j==0 && this.RowNamePosition===1) bDrawName=true;
@@ -34038,7 +34237,7 @@ function ChartKLineTable()
34038
34237
 
34039
34238
  var x=left,y=top, width=right-left;
34040
34239
  var yOffset=3;
34041
- if (this.ItemMergin.YOffset) yOffset=this.ItemMergin.YOffset;
34240
+ if (this.ItemMargin.YOffset) yOffset=this.ItemMargin.YOffset;
34042
34241
  for(var i=0;i<this.RowName.length;++i)
34043
34242
  {
34044
34243
  var item=this.RowName[i];
@@ -34120,7 +34319,7 @@ function ChartKLineTable()
34120
34319
 
34121
34320
  var x=rtBG.Right, y=rtBG.Top;
34122
34321
  var yOffset=3;
34123
- if (this.ItemMergin.YOffset) yOffset=this.ItemMergin.YOffset;
34322
+ if (this.ItemMargin.YOffset) yOffset=this.ItemMargin.YOffset;
34124
34323
  for(var i=0;i<this.RowName.length;++i)
34125
34324
  {
34126
34325
  var item=this.RowName[i];
@@ -34151,7 +34350,7 @@ function ChartKLineTable()
34151
34350
 
34152
34351
  var x=left,y=top, width=right-left;
34153
34352
  var yOffset=3;
34154
- if (this.ItemMergin.YOffset) yOffset=this.ItemMergin.YOffset;
34353
+ if (this.ItemMargin.YOffset) yOffset=this.ItemMargin.YOffset;
34155
34354
  for(var i=0; i<data.Data.length; ++i, y+=this.RowHeight)
34156
34355
  {
34157
34356
  var item=data.Data[i];
@@ -40233,7 +40432,7 @@ function ChartMinutePriceLine()
40233
40432
  {
40234
40433
  InterLastPoint:{X:this.LastPoint.X, Y:this.LastPoint.Y}, //内部点 给画布用
40235
40434
  LastPoint:{X:this.LastPoint.X/pixelRatio, Y:this.LastPoint.Y/pixelRatio}, //外部点 给DOM用
40236
- Price:this.LastPoint.Price, Data:this.LastPoint.Data,
40435
+ Price:this.LastPoint.Value, Data:this.LastPoint.Data,
40237
40436
  PixelRatio:pixelRatio,
40238
40437
  };
40239
40438
  event.Callback(event,data,this);
@@ -47445,6 +47644,69 @@ function ChartStackedBar()
47445
47644
 
47446
47645
  }
47447
47646
 
47647
+ //绘制随光标移动的浮动文字。
47648
+ //用法:DRAWFLAGTEXT(COND,PRICE,TEXT),光标处当COND条件满足时,在PRICE位置用半透明窗口显示文字TEXT,随光标移动而移动。将\\n插入TEXT内容中可实现文字换行。
47649
+ //例如:DRAWFLAGTEXT(CLOSE/OPEN>1.08,LOW,'大阳线')表示当光标移动到涨幅大于8%的地方,在最低价位置显示'大阳线'字样的浮动窗口。
47650
+ function ChartDrawFlagText()
47651
+ {
47652
+ this.newMethod=IChartPainting; //派生
47653
+ this.newMethod();
47654
+ delete this.newMethod;
47655
+
47656
+ this.ClassName="ChartDrawFlagText";
47657
+
47658
+ this.MapCache=null; //key=date/date-time value={ Date:, Time:, Data:[ ] }
47659
+ this.AryData=[];
47660
+
47661
+ this.GetKValue=ChartData.GetKValue;
47662
+ this.BuildCacheData=function()
47663
+ {
47664
+ var mapData=new Map();
47665
+ this.MapCache=mapData;
47666
+ if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
47667
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryData)) return;
47668
+
47669
+ for(var i=0;i<this.Data.Data.length;++i)
47670
+ {
47671
+ var item=this.AryData[i];
47672
+ if (!item) continue;
47673
+
47674
+ var kItem=this.Data.Data[i];
47675
+ item.Date=kItem.Date;
47676
+ item.Time=kItem.Time;
47677
+
47678
+ var key=this.BuildKey(kItem);
47679
+ mapData.set(key, item);
47680
+ }
47681
+ }
47682
+
47683
+ this.Draw=function()
47684
+ {
47685
+
47686
+ }
47687
+
47688
+ this.GetCorssCursorTooltipData=function(kItem, tooltip)
47689
+ {
47690
+ if (!kItem) return null;
47691
+ if (!this.MapCache) return null;
47692
+
47693
+ var key=this.BuildKey(kItem);
47694
+ if (!this.MapCache.has(key)) return null;
47695
+
47696
+ var item=this.MapCache.get(key);
47697
+ if (item.YValue>this.ChartFrame.HorizontalMax || item.YValue<this.ChartFrame.HorizontalMin) return null;
47698
+
47699
+ var y=this.ChartFrame.GetYFromData(item.YValue,false);
47700
+ tooltip.AryData.push({ Data:item, Y:y, ChartPaint:this, Type:1 });
47701
+ return item;
47702
+ }
47703
+
47704
+ this.GetMaxMin=function()
47705
+ {
47706
+ return {Min:null, Max:null};
47707
+ }
47708
+ }
47709
+
47448
47710
  //锁 支持横屏
47449
47711
  function ChartLock()
47450
47712
  {
@@ -47873,7 +48135,8 @@ function ExtendChartPaintFactory()
47873
48135
  ["DragMovePaint", { Create:function() { return new DragMovePaint(); } }],
47874
48136
  ["SessionBreaksPaint", { Create:function() { return new SessionBreaksPaint(); }}],
47875
48137
  ["FrameButtomToolbarPaint", {Create:function() { return new FrameButtomToolbarPaint(); }}],
47876
- ["LatestPointFlashPaint", {Create:function() { return new LatestPointFlashPaint(); }}]
48138
+ ["LatestPointFlashPaint", {Create:function() { return new LatestPointFlashPaint(); }}],
48139
+ ["KLineCountDownPaint", { Create:function(){ return new KLineCountDownPaint(); }}]
47877
48140
  ]
47878
48141
  );
47879
48142
 
@@ -52615,6 +52878,238 @@ function LatestPointFlashPaint()
52615
52878
  }
52616
52879
  }
52617
52880
 
52881
+
52882
+ //K线倒计时
52883
+ function KLineCountDownPaint()
52884
+ {
52885
+ this.newMethod=IExtendChartPainting; //派生
52886
+ this.newMethod();
52887
+ delete this.newMethod;
52888
+
52889
+ this.ClassName='KLineCountDownPaint';
52890
+ this.HQChart;
52891
+ this.CanvasEx;
52892
+ this.Frequency=500; //闪烁频率ms
52893
+ this.Font=g_JSChartResource.KLineCountDownPaint.Font;
52894
+ this.PriceColor=g_JSChartResource.KLineCountDownPaint.PriceColor;
52895
+ this.TimeColor=g_JSChartResource.KLineCountDownPaint.TimeColor;
52896
+
52897
+ this.TextMargin=CloneData(g_JSChartResource.KLineCountDownPaint.TextMargin);
52898
+ this.LabelMargin=CloneData(g_JSChartResource.KLineCountDownPaint.LabelMargin);
52899
+ this.LineConfig=CloneData(g_JSChartResource.KLineCountDownPaint.Line); //{ IsShow:true, Width:1, Dash:[3,4] };
52900
+
52901
+ this.UnchangeConfig=CloneData(g_JSChartResource.KLineCountDownPaint.Unchange);
52902
+ this.UpConfig=CloneData(g_JSChartResource.KLineCountDownPaint.Up);
52903
+ this.DownConfig=CloneData(g_JSChartResource.KLineCountDownPaint.Down);
52904
+
52905
+ //临时使用
52906
+ this.MainFrame;
52907
+ this.LastItem;
52908
+
52909
+ this.SetOption=function(option)
52910
+ {
52911
+ if (this.HQChart)
52912
+ {
52913
+ var extraElement=this.HQChart.GetExtraCanvas(JSChart.KLineCountDownKey);
52914
+ if (extraElement && extraElement.Canvas) this.CanvasEx=extraElement.Canvas; //绑定独立的画布
52915
+ }
52916
+
52917
+ if (option)
52918
+ {
52919
+ if (IFrameSplitOperator.IsNumber(option.Frequency)) this.Frequency=option.Frequency;
52920
+ if (option.TextMargin) CopyMarginConfig(option.TextMargin, this.TextMargin);
52921
+ if (option.LabelMargin) CopyMarginConfig(option.LabelMargin, this.LabelMargin);
52922
+ if (option.UnchangeColor) this.UnchangeColor=option.UnchangeColor;
52923
+ if (option.UpColor) this.UpColor=option.UpColor;
52924
+ if (option.DownColor) this.DownColor=option.DownColor;
52925
+
52926
+ if (option.Line)
52927
+ {
52928
+ var item=option.Line;
52929
+ if (IFrameSplitOperator.IsBool(item.IsShow)) this.LineConfig.IsShow=item.IsShow;
52930
+ if (IFrameSplitOperator.IsNumber(item.Width)) this.LineConfig.Width=item.Width;
52931
+ if (item.Dash) this.LineConfig.Dash=item.Dash;
52932
+ }
52933
+ }
52934
+ }
52935
+
52936
+ this.ReloadResource=function(resource)
52937
+ {
52938
+ this.Font=g_JSChartResource.KLineCountDownPaint.Font;
52939
+ this.PriceColor=g_JSChartResource.KLineCountDownPaint.PriceColor;
52940
+ this.TimeColor=g_JSChartResource.KLineCountDownPaint.TimeColor;
52941
+
52942
+ this.TextMargin=CloneData(g_JSChartResource.KLineCountDownPaint.TextMargin);
52943
+ this.LabelMargin=CloneData(g_JSChartResource.KLineCountDownPaint.LabelMargin);
52944
+ this.LineConfig=CloneData(g_JSChartResource.KLineCountDownPaint.Line); //{ IsShow:true, Width:1, Dash:[3,4] };
52945
+
52946
+ this.UnchangeConfig=CloneData(g_JSChartResource.KLineCountDownPaint.Unchange);
52947
+ this.UpConfig=CloneData(g_JSChartResource.KLineCountDownPaint.Up);
52948
+ this.DownConfig=CloneData(g_JSChartResource.KLineCountDownPaint.Down);
52949
+ }
52950
+
52951
+ this.Draw=function()
52952
+ {
52953
+ this.MainFrame=null;
52954
+ this.LastItem=null;
52955
+
52956
+ if (!this.HQChart) return;
52957
+ if (!this.CanvasEx) return;
52958
+ this.HQChart.ClearCanvas(this.CanvasEx);
52959
+ var kData=this.HQChart.GetKData();
52960
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return;
52961
+
52962
+ var lastItem=kData.Data[kData.Data.length-1];
52963
+ if (!lastItem || !IFrameSplitOperator.IsNumber(lastItem.Close)) return;
52964
+ var frame=this.ChartFrame.SubFrame[0].Frame;
52965
+ if (!frame) return;
52966
+ var price=lastItem.Close;
52967
+ if (price>frame.HorizontalMax || price<frame.HorizontalMin) return;
52968
+
52969
+ if (frame.IsHScreen) return;
52970
+
52971
+ this.MainFrame=frame;
52972
+ this.LastItem=lastItem;
52973
+
52974
+ this.CanvasEx.save();
52975
+ this.DrawDownPaint();
52976
+ this.CanvasEx.restore();
52977
+
52978
+ this.MainFrame=null;
52979
+ this.LastItem=null;
52980
+ //if (!this.HQChart.GlobalOption || !this.HQChart.GlobalOption.CountDown) return;
52981
+ }
52982
+
52983
+ this.DrawDownPaint=function()
52984
+ {
52985
+ if (!this.MainFrame || !this.LastItem || !IFrameSplitOperator.IsNumber(this.LastItem.Close)) return;
52986
+
52987
+ var decNum=GetfloatPrecision(this.HQChart.Symbol); //小数位数
52988
+ var yPrice=this.MainFrame.GetYFromData(this.LastItem.Close,false);
52989
+ var strPrice=this.LastItem.Close.toFixed(decNum);
52990
+
52991
+ var config=this.GetColorConfig(this.LastItem);
52992
+ var out={ BGColor:config.BGColor, Font:this.Font, AryText:[ ], YPrice:yPrice };
52993
+
52994
+ var item={ Text:strPrice, Color:config.PriceColor };
52995
+ out.AryText.push(item);
52996
+
52997
+ var item={ Text:"--:--", Color:config.TimeColor};
52998
+ out.AryText.push(item);
52999
+
53000
+ var event=this.HQChart.GetEventCallback(JSCHART_EVENT_ID.ON_FORMAT_COUNTDOWN_TEXT);
53001
+ if (event && event.Callback)
53002
+ {
53003
+ var sendData={ LastItem:this.LastItem, Frame:this.MainFrame, Out:out, Period:this.HQChart.Period, Symbol:this.HQChart.Symbol };
53004
+ event.Callback(event, sendData, this);
53005
+ }
53006
+
53007
+ if (!this.CalculateLableSize(out)) return;
53008
+
53009
+ this.DrawLable(out);
53010
+ }
53011
+
53012
+ this.CalculateLableSize=function(out)
53013
+ {
53014
+ if (!out || !IFrameSplitOperator.IsNonEmptyArray(out.AryText)) return false;
53015
+
53016
+ this.CanvasEx.font=this.Font;
53017
+ this.FontHeight=this.CanvasEx.measureText("O").width; //行高
53018
+
53019
+ var lableWidth=0, lableHeight=0
53020
+ for(var i=0; i<out.AryText.length; ++i)
53021
+ {
53022
+ var item=out.AryText[i];
53023
+ if (!item || !item.Text) continue;
53024
+ item.TextWidth=this.CanvasEx.measureText(item.Text).width;
53025
+ item.TextWidth+=this.TextMargin.Left+this.TextMargin.Right;
53026
+
53027
+ if (lableWidth<item.TextWidth) lableWidth=item.TextWidth;
53028
+ lableHeight+=this.FontHeight+this.TextMargin.Top+this.TextMargin.Bottom;
53029
+ }
53030
+
53031
+ out.Width=lableWidth+this.LabelMargin.Left+this.LabelMargin.Right;
53032
+ out.Height=lableHeight+this.LabelMargin.Top+this.LabelMargin.Bottom;
53033
+
53034
+ return true;
53035
+ }
53036
+
53037
+ this.FixedRect=function(rt)
53038
+ {
53039
+ rt.Left=ToFixedRect(rt.Left);
53040
+ rt.Top=ToFixedRect(rt.Top);
53041
+ rt.Width=ToFixedRect(rt.Width);
53042
+ rt.Height=ToFixedRect(rt.Height);
53043
+
53044
+ rt.Right=rt.Left+rt.Width;
53045
+ rt.Bottom=rt.Top+rt.Height;
53046
+ }
53047
+
53048
+ this.DrawLable=function(out)
53049
+ {
53050
+ if (!out || !IFrameSplitOperator.IsNonEmptyArray(out.AryText)) return;
53051
+
53052
+ var border=this.MainFrame.GetBorder();
53053
+ var chartBorder=this.MainFrame.ChartBorder;
53054
+ var lineHeight=this.FontHeight+this.TextMargin.Top+this.TextMargin.Bottom;
53055
+ if (chartBorder.Right>10 ) //外部刻度
53056
+ {
53057
+ var rtBG={ Left:border.Right, Top:out.YPrice-lineHeight/2, Width:out.Width, Height:out.Height };
53058
+ rtBG.Right=rtBG.Left+rtBG.Width;
53059
+ if (rtBG.Right>border.ChartWidth)
53060
+ {
53061
+ rtBG.Right=border.ChartWidth-1;
53062
+ rtBG.Left=rtBG.Right-rtBG.Width;
53063
+ }
53064
+
53065
+ this.FixedRect(rtBG);
53066
+ this.CanvasEx.fillStyle=out.BGColor;
53067
+ this.CanvasEx.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
53068
+ }
53069
+
53070
+ this.Canvas.textAlign = "left";
53071
+ this.Canvas.textBaseline = "bottom";
53072
+ var yText=rtBG.Top+lineHeight+this.LabelMargin.Top;
53073
+ var xText=rtBG.Left+this.TextMargin.Left+this.LabelMargin.Left;
53074
+ for(var i=0;i<out.AryText.length;++i)
53075
+ {
53076
+ var item=out.AryText[i];
53077
+ var yOffset=this.TextMargin.YOffset;
53078
+
53079
+ this.CanvasEx.fillStyle=item.Color;
53080
+ this.CanvasEx.fillText(item.Text, xText, yText+yOffset-this.TextMargin.Bottom);
53081
+
53082
+ yText+=lineHeight;
53083
+ }
53084
+
53085
+ //线段
53086
+ var config=this.LineConfig;
53087
+ if (config.IsShow)
53088
+ {
53089
+ this.CanvasEx.strokeStyle=out.BGColor;
53090
+ this.CanvasEx.lineWidth=config.Width;
53091
+ if (IFrameSplitOperator.IsNonEmptyArray(config.Dash)) this.CanvasEx.setLineDash(config.Dash);
53092
+ this.CanvasEx.beginPath();
53093
+ var xLeft=border.LeftEx;
53094
+ var xRight=rtBG.Left;
53095
+ this.CanvasEx.moveTo(xLeft,ToFixedPoint(out.YPrice));
53096
+ this.CanvasEx.lineTo(xRight,ToFixedPoint(out.YPrice));
53097
+ this.CanvasEx.stroke();
53098
+ }
53099
+ }
53100
+
53101
+ this.GetColorConfig=function(kItem, symbol)
53102
+ {
53103
+ var config=this.UnchangeConfig;
53104
+ if (!kItem) return config;
53105
+
53106
+ if (kItem.Close>kItem.YClose) config=this.UpConfig;
53107
+ else if (kItem.Close<kItem.YClose) config=this.DownConfig;
53108
+
53109
+ return config;
53110
+ }
53111
+ }
53112
+
52618
53113
  //拖拽效果图
52619
53114
  var JSCHART_DRAGCHART_TYPE_ID=
52620
53115
  {
@@ -66545,6 +67040,7 @@ function ChartDrawHLine()
66545
67040
  this.Font=14*GetDevicePixelRatio() +"px 微软雅黑";
66546
67041
  this.TextFont=12*GetDevicePixelRatio() +"px 微软雅黑";
66547
67042
  this.RightSpaceWidth=50;
67043
+ this.PriceBGColor;
66548
67044
 
66549
67045
  this.ButtonPosition=0; //按钮位置, 0=价格后面, 1=价格上面 2=价格上面 左对齐 3=垂直排列
66550
67046
  this.ButtonBGColor='rgb(190,190,190)';
@@ -66651,6 +67147,8 @@ function ChartDrawHLine()
66651
67147
  if (IFrameSplitOperator.IsNumber(item.Bottom)) this.TextMargin.Bottom=item.Bottom;
66652
67148
  if (IFrameSplitOperator.IsNumber(item.YOffset)) this.TextMargin.YOffset=item.YOffset;
66653
67149
  }
67150
+
67151
+ if (option.PriceBGColor) this.PriceBGColor=option.PriceBGColor;
66654
67152
  }
66655
67153
  }
66656
67154
 
@@ -67091,7 +67589,8 @@ function ChartDrawHLine()
67091
67589
  if (!bVisibleRange) this.Canvas.setLineDash([]);
67092
67590
  }
67093
67591
 
67094
- this.Canvas.fillStyle=this.LineColor;
67592
+ if (this.PriceBGColor) this.Canvas.fillStyle=this.PriceBGColor;
67593
+ else this.Canvas.fillStyle=this.LineColor;
67095
67594
  this.Canvas.font=this.Font;
67096
67595
  var textWidth=this.Canvas.measureText(strValue).width;
67097
67596
  var lineHeight=this.GetFontHeight();
@@ -76826,7 +77325,7 @@ function JSChartResource()
76826
77325
  this.ChartKLineTable=
76827
77326
  {
76828
77327
  TextFont:{ Family:'Arial' , FontMaxSize:25 },
76829
- ItemMergin:{ Left:5, Right:5, Top:4, Bottom:2 },
77328
+ ItemMargin:{ Left:5, Right:5, Top:4, Bottom:2 },
76830
77329
  };
76831
77330
 
76832
77331
  this.ChartSimpleTable=
@@ -77394,6 +77893,18 @@ function JSChartResource()
77394
77893
  SplitLine:{ Color:'rgb(73,133,231)', Width:1*GetDevicePixelRatio(), Dash:[5*GetDevicePixelRatio(),5*GetDevicePixelRatio()] }
77395
77894
  }
77396
77895
 
77896
+ this.KLineCountDownPaint=
77897
+ {
77898
+ Font:`${14*GetDevicePixelRatio()}px 微软雅黑`,
77899
+ TextMargin:{ Left:0, Right:0, Bottom:2, Top:2, YOffset:0 },
77900
+ LabelMargin:{ Left:5, Right:5, Bottom:4, Top:2 },
77901
+ Line:{ IsShow:true, Width:1, Dash:[5*GetDevicePixelRatio(), 5*GetDevicePixelRatio()] },
77902
+
77903
+ Unchange:{ BGColor:"rgb(0,0,0)", PriceColor:"rgb(250,250,250)", TimeColor:"rgb(190,190,190)" },
77904
+ Up:{ BGColor:"rgb(238,21,21)", PriceColor:"rgb(250,250,250)", TimeColor:"rgb(190,190,190)" },
77905
+ Down:{ BGColor:"rgb(25,158,0)", PriceColor:"rgb(250,250,250)", TimeColor:"rgb(190,190,190)" },
77906
+ }
77907
+
77397
77908
 
77398
77909
  //成交明细
77399
77910
  this.DealList=
@@ -78726,6 +79237,61 @@ function JSChartResource()
78726
79237
  if (style.ChartScatterPlotV2) this.SetChartScatterPlotV2(style.ChartScatterPlotV2);
78727
79238
 
78728
79239
  if (style.ChartDrawTVLongPosition) this.SetChartDrawTVLongPosition(style.ChartDrawTVLongPosition);
79240
+ if (style.KLineCountDownPaint) this.SetKLineCountDownPaint(style.KLineCountDownPaint);
79241
+ }
79242
+
79243
+
79244
+ this.SetKLineCountDownPaint=function(style)
79245
+ {
79246
+ var dest=this.KLineCountDownPaint;
79247
+ if (style.Font) dest.Font=style.Font;
79248
+
79249
+ if (style.TextMargin)
79250
+ {
79251
+ var item=style.TextMargin;
79252
+ CopyMarginConfig(dest.TextMargin, item);
79253
+ if (IFrameSplitOperator.IsNumber(item.YOffset)) dest.TextMargin.YOffset=item.YOffset;
79254
+ }
79255
+
79256
+ if (style.LabelMargin) CopyMarginConfig(dest.LabelMargin, style.LabelMargin);
79257
+
79258
+ if (style.Line)
79259
+ {
79260
+ var item=style.Line;
79261
+ if (IFrameSplitOperator.IsNumber(item.Width)) dest.Line.Width=item.Width;
79262
+ if (IFrameSplitOperator.IsBool(item.IsShow)) dest.Line.Width=item.Width;
79263
+ if (item.Dash) dest.Line.Dash=item.Dash;
79264
+ }
79265
+
79266
+ if (style.Unchange)
79267
+ {
79268
+ var item=style.Unchange;
79269
+ var subDest=dest.Unchange;
79270
+
79271
+ if (item.BGColor) subDest.BGColor=item.BGColor;
79272
+ if (item.PriceColor) subDest.PriceColor=item.PriceColor;
79273
+ if (item.TimeColor) subDest.TimeColor=item.TimeColor;
79274
+ }
79275
+
79276
+ if (style.Up)
79277
+ {
79278
+ var item=style.Up;
79279
+ var subDest=dest.Up;
79280
+
79281
+ if (item.BGColor) subDest.BGColor=item.BGColor;
79282
+ if (item.PriceColor) subDest.PriceColor=item.PriceColor;
79283
+ if (item.TimeColor) subDest.TimeColor=item.TimeColor;
79284
+ }
79285
+
79286
+ if (style.Down)
79287
+ {
79288
+ var item=style.Down;
79289
+ var subDest=dest.Down;
79290
+
79291
+ if (item.BGColor) subDest.BGColor=item.BGColor;
79292
+ if (item.PriceColor) subDest.PriceColor=item.PriceColor;
79293
+ if (item.TimeColor) subDest.TimeColor=item.TimeColor;
79294
+ }
78729
79295
  }
78730
79296
 
78731
79297