hqchart 1.1.13339 → 1.1.13350

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.
@@ -334,13 +334,22 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
334
334
  if (IFrameSplitOperator.IsBool(item.IsShowKLineDivTooltip)) chart.IsShowKLineDivTooltip=item.IsShowKLineDivTooltip;
335
335
  if (option.KLine.MaxRequestMinuteDayCount>0) chart.MaxRequestMinuteDayCount=option.KLine.MaxRequestMinuteDayCount;
336
336
  if (option.KLine.DrawType) chart.KLineDrawType=option.KLine.DrawType;
337
- if (option.KLine.FirstShowDate>19910101) chart.CustomShow={ Date:option.KLine.FirstShowDate, PageSize:option.KLine.PageSize };
337
+ if (option.KLine.FirstShowDate>19910101) chart.CustomShow={ Date:option.KLine.FirstShowDate, PageSize:option.KLine.PageSize }; //!!已弃用 新的格式"CustomShow"
338
338
  if (option.KLine.RightSpaceCount>0) chart.RightSpaceCount=option.KLine.RightSpaceCount;
339
339
  if (option.KLine.ZoomType>0) chart.ZoomType=option.KLine.ZoomType;
340
340
  if (option.KLine.DataWidth>=1) chart.KLineSize={ DataWidth:option.KLine.DataWidth };
341
341
  if (IFrameSplitOperator.IsNumber(option.KLine.RightFormula)) chart.RightFormula=option.KLine.RightFormula;
342
342
  }
343
343
 
344
+ //自定义显示位置
345
+ if (option.CustomShow && IFrameSplitOperator.IsPlusNumber(option.CustomShow.Date))
346
+ {
347
+ var item=option.CustomShow;
348
+ chart.CustomShow={ Date:item.Date };
349
+ if (IFrameSplitOperator.IsNumber(item.Time)) chart.CustomShow.Time=item.Time;
350
+ if (IFrameSplitOperator.IsPlusNumber(item.PageSize)) chart.CustomShow.PageSize=item.PageSize;
351
+ }
352
+
344
353
  if (option.EnableFlowCapital)
345
354
  {
346
355
  var item=option.EnableFlowCapital;
@@ -1861,12 +1870,6 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
1861
1870
  }
1862
1871
  }
1863
1872
 
1864
- this.ChangMainDataControl=function(dataControl)
1865
- {
1866
- if (this.JSChartContainer && typeof(this.JSChartContainer.SetMainDataConotrl)=='function')
1867
- this.JSChartContainer.SetMainDataConotrl(dataControl);
1868
- }
1869
-
1870
1873
  this.AddOverlayIndex=function(obj) //{WindowIndex:窗口ID, IndexName:指标ID, Identify:叠加指标ID(可选), API}
1871
1874
  {
1872
1875
  if (this.JSChartContainer && typeof(this.JSChartContainer.AddOverlayIndex)=='function')
@@ -8071,7 +8074,9 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
8071
8074
  let sendData={ DrawPicture: drawPicture };
8072
8075
  event.Callback(event,sendData,this);
8073
8076
  }
8074
- else if (drawPicture.FinishedCallback) drawPicture.FinishedCallback(drawPicture);
8077
+
8078
+ //单个回调
8079
+ if (drawPicture.FinishedCallback) drawPicture.FinishedCallback(drawPicture);
8075
8080
 
8076
8081
  if (drawPicture.OnFinish) drawPicture.OnFinish();
8077
8082
 
@@ -9605,6 +9610,11 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
9605
9610
  if (deleteCount>0) this.ChartPaintEx=paint;
9606
9611
  }
9607
9612
  }
9613
+
9614
+ this.ClearCurrnetDrawPicture=function()
9615
+ {
9616
+ this.CurrentChartDrawPicture=null;
9617
+ }
9608
9618
  }
9609
9619
 
9610
9620
  function GetDevicePixelRatio()
@@ -55745,6 +55755,7 @@ IChartDrawPicture.ArrayDrawPricture=
55745
55755
  { Name:"PriceRange", ClassName:"ChartPriceRange", Create:function() { return new ChartPriceRange(); }},
55746
55756
  { Name:"DateRange", ClassName:"ChartDateRange", Create:function() { return new ChartDateRange(); }},
55747
55757
  { Name:"InfoLine", ClassName:"ChartInfoLine", Create:function() { return new ChartInfoLine(); }},
55758
+ { Name:"TrendAngle", ClassName:"ChartTrendAngle", Create:function() { return new ChartTrendAngle(); }}
55748
55759
  ];
55749
55760
 
55750
55761
  IChartDrawPicture.MapIonFont=new Map(
@@ -55909,6 +55920,103 @@ function ChartDrawPictureLine()
55909
55920
  }
55910
55921
  }
55911
55922
 
55923
+ //趋势线角度
55924
+ function ChartTrendAngle()
55925
+ {
55926
+ this.newMethod=ChartDrawPictureLine; //派生
55927
+ this.newMethod();
55928
+ delete this.newMethod;
55929
+
55930
+ this.ClassName='ChartTrendAngle';
55931
+ this.AngleLineLength=100;
55932
+ this.AngleLineDash=[3,3];
55933
+ this.Font=12*GetDevicePixelRatio() +"px 微软雅黑";
55934
+ this.Super_SetOption=this.SetOption; //父类函数
55935
+
55936
+ this.SetOption=function(option)
55937
+ {
55938
+ if (this.Super_SetOption) this.Super_SetOption(option);
55939
+ if (option)
55940
+ {
55941
+ if (IFrameSplitOperator.IsNumber(option.AngleLineLength)) this.AngleLineLength=option.AngleLineLength;
55942
+ if (option.Font) this.Font=option.Font;
55943
+ if (option.AngleLineDash) this.AngleLineDash=option.AngleLineDash;
55944
+ }
55945
+ }
55946
+
55947
+ this.Draw=function()
55948
+ {
55949
+ this.LinePoint=[];
55950
+ if (this.IsFrameMinSize()) return;
55951
+ if (!this.IsShow) return;
55952
+
55953
+ var drawPoint=this.CalculateDrawPoint( {IsCheckX:true, IsCheckY:false} );
55954
+ if (!drawPoint) return;
55955
+ if (drawPoint.length!=2) return;
55956
+
55957
+ this.ClipFrame();
55958
+
55959
+ var ptStart=drawPoint[0];
55960
+ var ptEnd=drawPoint[1];
55961
+
55962
+ this.SetLineWidth();
55963
+ this.Canvas.strokeStyle=this.LineColor;
55964
+ this.Canvas.beginPath();
55965
+ this.Canvas.moveTo(ptStart.X,ptStart.Y);
55966
+ this.Canvas.lineTo(ptEnd.X,ptEnd.Y);
55967
+ this.Canvas.stroke();
55968
+ this.RestoreLineWidth();
55969
+
55970
+ this.DrawAngle(ptStart, ptEnd);
55971
+
55972
+ var line={Start:ptStart, End:ptEnd};
55973
+ this.LinePoint.push(line);
55974
+
55975
+ this.DrawPoint(drawPoint); //画点
55976
+ this.Canvas.restore();
55977
+ }
55978
+
55979
+ this.DrawAngle=function(ptStart, ptEnd)
55980
+ {
55981
+ var pixelRatio=GetDevicePixelRatio();
55982
+ var angle=this.CalculateAngle(ptStart.X, ptStart.Y, ptEnd.X, ptEnd.Y); //角度
55983
+ var lineLength=this.AngleLineLength*pixelRatio; //角度线长度
55984
+ var ptRight={ X:ptStart.X+lineLength, Y:ptStart.Y };
55985
+
55986
+ if (this.AngleLineDash) this.Canvas.setLineDash(this.AngleLineDash); //画虚线
55987
+
55988
+ this.Canvas.lineWidth=1*GetDevicePixelRatio();
55989
+ this.Canvas.beginPath();
55990
+ this.Canvas.moveTo(ToFixedPoint(ptStart.X),ToFixedPoint(ptStart.Y));
55991
+ this.Canvas.lineTo(ToFixedPoint(ptRight.X),ToFixedPoint(ptRight.Y));
55992
+ this.Canvas.stroke();
55993
+
55994
+ this.Canvas.beginPath();
55995
+ if (angle<=180)
55996
+ {
55997
+ this.Canvas.arc(ptStart.X,ToFixedPoint(ptStart.Y),lineLength,0,(Math.PI / 180)*(360-angle), true);
55998
+ var text=`${angle.toFixed(0)}°`;
55999
+ }
56000
+ else
56001
+ {
56002
+ this.Canvas.arc(ptStart.X,ToFixedPoint(ptStart.Y),lineLength,0,(Math.PI / 180)*(360-angle), false);
56003
+ var text=`${(angle-360).toFixed(0)}°`;
56004
+ }
56005
+
56006
+ this.Canvas.stroke();
56007
+
56008
+ this.Canvas.textAlign="left";
56009
+ this.Canvas.textBaseline="middle";
56010
+ this.Canvas.font=this.Font;
56011
+ this.Canvas.fillStyle=this.LineColor;
56012
+
56013
+ if (this.AngleLineDash) this.Canvas.setLineDash([]);
56014
+
56015
+
56016
+ this.Canvas.fillText(text,ptRight.X+5,ptRight.Y);
56017
+ }
56018
+ }
56019
+
55912
56020
  //画图工具-涂鸦线段 Y轴关联数值, X轴不关联
55913
56021
  function ChartDrawGraffitiLine()
55914
56022
  {
@@ -64688,9 +64796,9 @@ function ChartInfoLine()
64688
64796
  labelInfo.PtStart=ptStart;
64689
64797
  labelInfo.PtEnd=ptEnd;
64690
64798
 
64691
- this.DrawLabel(labelInfo);
64692
-
64693
64799
  this.Canvas.restore();
64800
+
64801
+ this.DrawLabel(labelInfo);
64694
64802
  }
64695
64803
 
64696
64804
  this.DrawLabel=function(labelInfo)
@@ -68188,7 +68296,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
68188
68296
  this.SourceDataLimit=new Map(); //每个周期缓存数据最大个数 key=周期 value=最大个数
68189
68297
  this.CtrlMoveStep=5; //Ctrl+(Left/Right) 移动数据个数
68190
68298
 
68191
- this.CustomShow=null; //首先显示的K线的起始日期 { Date:日期 PageSize:}
68299
+ this.CustomShow=null; //首先显示的K线的起始日期 { Date:日期, Time:时间, PageSize:}
68192
68300
  this.ZoomType=0; //缩放模式 0=最右边固定缩放, 1=十字光标两边缩放
68193
68301
  this.IsZoomLockRight=false;
68194
68302
  this.KLineSize=null; //{ DataWidth:, }
@@ -68774,47 +68882,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
68774
68882
  var hisData=this.ChartOperator_Temp_GetHistroyData();
68775
68883
  if (!hisData) return; //数据还没有到达
68776
68884
 
68777
- var index=null;
68778
- if (ChartData.IsDayPeriod(this.Period,true))
68779
- {
68780
- for(var i=0;i<hisData.Data.length;++i)
68781
- {
68782
- var item=hisData.Data[i];
68783
- if (item.Date>=obj.Date)
68784
- {
68785
- index=i;
68786
- break;
68787
- }
68788
- }
68789
- }
68790
- else if (ChartData.IsMinutePeriod(this.Period,true))
68791
- {
68792
- let findTime=obj.Time;
68793
- if (IFrameSplitOperator.IsPlusNumber(findTime))
68794
- {
68795
- for(var i=0;i<hisData.Data.length;++i)
68796
- {
68797
- var item=hisData.Data[i];
68798
- if (item.Date>obj.Date || (item.Date==obj.Date && item.Time>=findTime))
68799
- {
68800
- index=i;
68801
- break;
68802
- }
68803
- }
68804
- }
68805
- else //只有日期
68806
- {
68807
- for(var i=0;i<hisData.Data.length;++i)
68808
- {
68809
- var item=hisData.Data[i];
68810
- if (item.Date>=obj.Date)
68811
- {
68812
- index=i;
68813
- break;
68814
- }
68815
- }
68816
- }
68817
- }
68885
+ var index=this.ChartOperator_GetIndex_ByDateTime(hisData, obj, this.Period, 0);
68818
68886
 
68819
68887
  if (index===null)
68820
68888
  {
@@ -68934,6 +69002,63 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
68934
69002
  this.UpdatePointByCursorIndex(); //更新十字光标位子
68935
69003
  }
68936
69004
 
69005
+ //定位K线的索引
69006
+ //searchType 0模糊匹配 1=精确匹配
69007
+ this.ChartOperator_GetIndex_ByDateTime=function(hisData, dateTime, period, searchType)
69008
+ {
69009
+ if (!hisData) return null; //数据还没有到达
69010
+ if (!IFrameSplitOperator.IsNonEmptyArray(hisData.Data)) return null;
69011
+ if (!IFrameSplitOperator.IsPlusNumber(dateTime.Date) || dateTime.Date<19810101) return null;
69012
+
69013
+ if (ChartData.IsDayPeriod(period, true))
69014
+ {
69015
+ for(var i=0;i<hisData.Data.length;++i)
69016
+ {
69017
+ var item=hisData.Data[i];
69018
+ if (searchType==1)
69019
+ {
69020
+ if (item.Date==dateTime.Date) return i;
69021
+ }
69022
+ else
69023
+ {
69024
+ if (item.Date>=dateTime.Date) return i;
69025
+ }
69026
+ }
69027
+
69028
+ return null;
69029
+ }
69030
+
69031
+ if (ChartData.IsMinutePeriod(period,true) || ChartData.IsMilliSecondPeriod(period))
69032
+ {
69033
+ var findTime=null;
69034
+ if (IFrameSplitOperator.IsNumber(dateTime.Time)) findTime=dateTime.Time;
69035
+ for(var i=0;i<hisData.Data.length;++i)
69036
+ {
69037
+ var item=hisData.Data[i];
69038
+ if (searchType==1) //精确匹配
69039
+ {
69040
+ if (findTime==null) return null;
69041
+ if (item.Date==dateTime.Date && item.Time==findTime) return i;
69042
+ }
69043
+ else
69044
+ {
69045
+ if (findTime==null) //只有日期
69046
+ {
69047
+ if (item.Date>=dateTime.Date) return i;
69048
+ }
69049
+ else
69050
+ {
69051
+ if (item.Date>dateTime.Date || (item.Date==dateTime.Date && item.Time>=findTime)) return i;
69052
+ }
69053
+ }
69054
+ }
69055
+
69056
+ return null;
69057
+ }
69058
+
69059
+ return null;
69060
+ }
69061
+
68937
69062
  this.OnWheel=function(e)
68938
69063
  {
68939
69064
  JSConsole.Chart.Log('[KLineChartContainer::OnWheel]',e);
@@ -69552,37 +69677,21 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
69552
69677
 
69553
69678
  this.SetCustomShow=function(customShow,hisData)
69554
69679
  {
69555
- if (!customShow || !customShow.Date || customShow.Date<19910101) return;
69556
-
69557
- var firstDate=customShow.Date;
69558
- var index=null;
69559
- for(var i =0;i<hisData.Data.length;++i)
69560
- {
69561
- var item=hisData.Data[i];
69562
- if (item.Date>=firstDate)
69563
- {
69564
- index=i;
69565
- break;
69566
- }
69567
- }
69680
+ var index=this.ChartOperator_GetIndex_ByDateTime(hisData,customShow, this.Period, 0);
69568
69681
  if (index===null)
69569
69682
  {
69570
- JSConsole.Chart.Log(`[KLineChartContainer::SetCustomShow] Can't find first date=${firstDate}`);
69683
+ JSConsole.Chart.Log("[KLineChartContainer::SetCustomShow] Can't find index by customShow=",customShow);
69571
69684
  return;
69572
69685
  }
69573
69686
 
69574
- var count=hisData.Data.length-index;
69575
- if (customShow.PageSize>0) count=customShow.PageSize;
69576
-
69577
- var customShowCount=count;
69578
- var pageSize=this.GetMaxMinPageSize();
69579
- if (count>pageSize.Max) customShowCount=pageSize.Max;
69580
- else if (count<pageSize.Min) customShowCount=pageSize.Min;
69581
-
69582
- for(var i in this.Frame.SubFrame)
69687
+ if (IFrameSplitOperator.IsPlusNumber(customShow.PageSize)) //调整一屏显示个数 否则使用默认的
69583
69688
  {
69584
- var item =this.Frame.SubFrame[i].Frame;
69585
- item.XPointCount=customShowCount;
69689
+ var showCount=customShow.PageSize;
69690
+ for(var i=0;i<this.Frame.SubFrame.length; ++i)
69691
+ {
69692
+ var item =this.Frame.SubFrame[i].Frame;
69693
+ item.XPointCount=showCount;
69694
+ }
69586
69695
  }
69587
69696
 
69588
69697
  this.ChartPaint[0].Data.DataOffset=index;
@@ -72870,6 +72979,14 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
72870
72979
  }
72871
72980
  }
72872
72981
  }
72982
+
72983
+ if (option.CustomShow && IFrameSplitOperator.IsPlusNumber(option.CustomShow.Date))
72984
+ {
72985
+ var item=option.CustomShow;
72986
+ this.CustomShow={ Date:item.Date };
72987
+ if (IFrameSplitOperator.IsNumber(item.Time)) this.CustomShow.Time=item.Time;
72988
+ if (IFrameSplitOperator.IsPlusNumber(item.PageSize)) this.CustomShow.PageSize=item.PageSize;
72989
+ }
72873
72990
  }
72874
72991
 
72875
72992
  this.ReloadChartDrawPicture();
@@ -73526,11 +73643,6 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
73526
73643
  return true;
73527
73644
  }
73528
73645
 
73529
- this.ClearCurrnetDrawPicture=function()
73530
- {
73531
- this.CurrentChartDrawPicture=null;
73532
- }
73533
-
73534
73646
  this.AddChartDrawPicture=function(obj)
73535
73647
  {
73536
73648
  if (!obj) return null;
@@ -54,6 +54,12 @@
54
54
  <div class="content unicode" style="display: block;">
55
55
  <ul class="icon_lists dib-box">
56
56
 
57
+ <li class="dib">
58
+ <span class="icon hqchart_drawtool">&#xe60c;</span>
59
+ <div class="name">趋势线角度</div>
60
+ <div class="code-name">&amp;#xe60c;</div>
61
+ </li>
62
+
57
63
  <li class="dib">
58
64
  <span class="icon hqchart_drawtool">&#xe64a;</span>
59
65
  <div class="name">info line</div>
@@ -438,9 +444,9 @@
438
444
  <pre><code class="language-css"
439
445
  >@font-face {
440
446
  font-family: 'hqchart_drawtool';
441
- src: url('iconfont.woff2?t=1716274976221') format('woff2'),
442
- url('iconfont.woff?t=1716274976221') format('woff'),
443
- url('iconfont.ttf?t=1716274976221') format('truetype');
447
+ src: url('iconfont.woff2?t=1716529516458') format('woff2'),
448
+ url('iconfont.woff?t=1716529516458') format('woff'),
449
+ url('iconfont.ttf?t=1716529516458') format('truetype');
444
450
  }
445
451
  </code></pre>
446
452
  <h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
@@ -466,6 +472,15 @@
466
472
  <div class="content font-class">
467
473
  <ul class="icon_lists dib-box">
468
474
 
475
+ <li class="dib">
476
+ <span class="icon hqchart_drawtool icon-qushixianjiaodu"></span>
477
+ <div class="name">
478
+ 趋势线角度
479
+ </div>
480
+ <div class="code-name">.icon-qushixianjiaodu
481
+ </div>
482
+ </li>
483
+
469
484
  <li class="dib">
470
485
  <span class="icon hqchart_drawtool icon-infoline"></span>
471
486
  <div class="name">
@@ -1042,6 +1057,14 @@
1042
1057
  <div class="content symbol">
1043
1058
  <ul class="icon_lists dib-box">
1044
1059
 
1060
+ <li class="dib">
1061
+ <svg class="icon svg-icon" aria-hidden="true">
1062
+ <use xlink:href="#icon-qushixianjiaodu"></use>
1063
+ </svg>
1064
+ <div class="name">趋势线角度</div>
1065
+ <div class="code-name">#icon-qushixianjiaodu</div>
1066
+ </li>
1067
+
1045
1068
  <li class="dib">
1046
1069
  <svg class="icon svg-icon" aria-hidden="true">
1047
1070
  <use xlink:href="#icon-infoline"></use>
@@ -1,8 +1,8 @@
1
1
  @font-face {
2
2
  font-family: "hqchart_drawtool"; /* Project id 4529603 */
3
- src: url('iconfont.woff2?t=1716274976221') format('woff2'),
4
- url('iconfont.woff?t=1716274976221') format('woff'),
5
- url('iconfont.ttf?t=1716274976221') format('truetype');
3
+ src: url('iconfont.woff2?t=1716529516458') format('woff2'),
4
+ url('iconfont.woff?t=1716529516458') format('woff'),
5
+ url('iconfont.ttf?t=1716529516458') format('truetype');
6
6
  }
7
7
 
8
8
  .hqchart_drawtool {
@@ -13,6 +13,10 @@
13
13
  -moz-osx-font-smoothing: grayscale;
14
14
  }
15
15
 
16
+ .icon-qushixianjiaodu:before {
17
+ content: "\e60c";
18
+ }
19
+
16
20
  .icon-infoline:before {
17
21
  content: "\e64a";
18
22
  }