hqchart 1.1.13335 → 1.1.13339

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.
@@ -105,7 +105,11 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
105
105
  return item;
106
106
  }
107
107
 
108
- this.OnSize=function(option) //{ Type:1 新版本OnSize Redraw:是否重绘, XYSplit:是否重新计算分割线 }
108
+ /*
109
+ { Type: 1=K线柱子宽度不变 2=K线全部显示
110
+ Redraw:是否重绘, XYSplit:是否重新计算分割线 }
111
+ */
112
+ this.OnSize=function(option)
109
113
  {
110
114
  //画布大小通过div获取 如果有style里的大小 使用style里的
111
115
  if (this.DivElement.style.height && this.DivElement.style.width)
@@ -166,10 +170,14 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
166
170
  {
167
171
  if (option && option.XYSplit===true) this.JSChartContainer.ResetFrameXYSplit();
168
172
 
169
- if (this.JSChartContainer.OnSize && option && option.Type==1)
173
+ if (this.JSChartContainer.OnSize && option && option.Type==1) //K线宽度不变
170
174
  {
171
175
  this.JSChartContainer.OnSize();
172
176
  }
177
+ else if (this.JSChartContainer.ShowAllKLine && option && option.Type==2)
178
+ {
179
+ this.JSChartContainer.ShowAllKLine();
180
+ }
173
181
  else
174
182
  {
175
183
  if (this.JSChartContainer.Frame) this.JSChartContainer.Frame.SetSizeChage(true);
@@ -9751,6 +9759,16 @@ function IsRecvOverlap(rect1, rect2)
9751
9759
  return Math.max(rect1.Left,rect2.Left) < Math.min(rect1.Right,rect2.Right) && Math.max(rect1.Top,rect2.Top) < Math.min(rect1.Bottom,rect2.Bottom);
9752
9760
  }
9753
9761
 
9762
+ function CopyMerginConfig(dest,src)
9763
+ {
9764
+ if (!src || !dest) return;
9765
+
9766
+ if (IFrameSplitOperator.IsNumber(src.Left)) dest.Left=src.Left;
9767
+ if (IFrameSplitOperator.IsNumber(src.Top)) dest.Top=src.Top;
9768
+ if (IFrameSplitOperator.IsNumber(src.Right)) dest.Right=src.Right;
9769
+ if (IFrameSplitOperator.IsNumber(src.Bottom)) dest.Bottom=src.Bottom;
9770
+ }
9771
+
9754
9772
 
9755
9773
  function Point()
9756
9774
  {
@@ -55514,6 +55532,79 @@ function IChartDrawPicture()
55514
55532
  //复制
55515
55533
  //this.CopyData=function() { }
55516
55534
  //this.PtInButtons=function(x, y) { }
55535
+
55536
+
55537
+ //计算标签页大小
55538
+ this.CalculateLabelSize=function(labelInfo)
55539
+ {
55540
+ var config=labelInfo.Config;
55541
+ this.Canvas.font=config.Font;
55542
+ this.Canvas.textAlign="left";
55543
+ this.Canvas.textBaseline="top";
55544
+ var lineHeight=this.Canvas.measureText("擎").width+2;
55545
+
55546
+ var maxWidth=0, lineCount=0, labelHeight=config.Mergin.Top+config.Mergin.Bottom;
55547
+ for(var i=0;i<labelInfo.AryText.length;++i)
55548
+ {
55549
+ if (i>0) labelHeight+=config.LineSpace;
55550
+
55551
+ var item=labelInfo.AryText[i];
55552
+ item.NameWidth=0;
55553
+ item.TextWidth=0;
55554
+ if (item.Name) item.NameWidth=this.Canvas.measureText(item.Name).width+2;
55555
+ if (item.Text) item.TextWidth=this.Canvas.measureText(item.Text).width+2;
55556
+
55557
+ var itemWidth=item.NameWidth+item.TextWidth;
55558
+ if (maxWidth<itemWidth) maxWidth=itemWidth;
55559
+ ++lineCount;
55560
+
55561
+ labelHeight+=lineHeight;
55562
+ }
55563
+
55564
+ var labelWidth=maxWidth+config.Mergin.Left+config.Mergin.Right;
55565
+
55566
+ labelInfo.Width=labelWidth;
55567
+ labelInfo.Height=labelHeight;
55568
+ labelInfo.LineHeight=lineHeight;
55569
+ }
55570
+
55571
+ this.DrawDefaultLabel=function(labelInfo, rtBG)
55572
+ {
55573
+ var config=labelInfo.Config;
55574
+
55575
+ if (config.BGColor)
55576
+ {
55577
+ this.Canvas.fillStyle=config.BGColor
55578
+ this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));
55579
+ }
55580
+
55581
+ var xText=rtBG.Left+config.Mergin.Left;
55582
+ var yText=rtBG.Top+config.Mergin.Top;
55583
+ for(var i=0;i<labelInfo.AryText.length;++i)
55584
+ {
55585
+ var item=labelInfo.AryText[i];
55586
+
55587
+ if (i>0) yText+=config.LineSpace;
55588
+
55589
+ if (item.Name)
55590
+ {
55591
+ this.Canvas.fillStyle=item.NameColor;
55592
+ this.Canvas.fillText(item.Name,xText,yText);
55593
+ }
55594
+
55595
+ if (item.Text)
55596
+ {
55597
+ var xOut=xText+item.NameWidth;
55598
+ if (config.TextAlign==1) //右对齐
55599
+ xOut=rtBG.Right-config.Mergin.Right-item.TextWidth;
55600
+
55601
+ this.Canvas.fillStyle=item.TextColor;
55602
+ this.Canvas.fillText(item.Text,xOut ,yText);
55603
+ }
55604
+
55605
+ yText+=labelInfo.LineHeight;
55606
+ }
55607
+ }
55517
55608
  }
55518
55609
 
55519
55610
  IChartDrawPicture.ColorToRGBA=function(color,opacity)
@@ -55652,7 +55743,8 @@ IChartDrawPicture.ArrayDrawPricture=
55652
55743
  { Name:"FibRetracement", ClassName:"ChartFibRetracement", Create:function() { return new ChartFibRetracement(); }}, //斐波那契回测
55653
55744
  { Name:"FibSpeedResistanceFan", ClassName:"ChartFibSpeedResistanceFan", Create:function() { return new ChartFibSpeedResistanceFan(); }}, //斐波那契扇形
55654
55745
  { Name:"PriceRange", ClassName:"ChartPriceRange", Create:function() { return new ChartPriceRange(); }},
55655
- { Name:"DateRange", ClassName:"ChartDateRange", Create:function() { return new ChartDateRange(); }}
55746
+ { Name:"DateRange", ClassName:"ChartDateRange", Create:function() { return new ChartDateRange(); }},
55747
+ { Name:"InfoLine", ClassName:"ChartInfoLine", Create:function() { return new ChartInfoLine(); }},
55656
55748
  ];
55657
55749
 
55658
55750
  IChartDrawPicture.MapIonFont=new Map(
@@ -60515,9 +60607,13 @@ function ChartDrawMonitorLine()
60515
60607
  this.LabelConfig=
60516
60608
  {
60517
60609
  Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
60518
- BGColor:"rgb(30,144,255)", YTextOffset:4,
60610
+ BGColor:"rgb(30,144,255)",
60519
60611
  LineColor:"rgba(255,215,0,0.8)",
60520
60612
  LineDash:[3,5],
60613
+
60614
+ Mergin:{ Left:5, Right:5, Top:5, Bottom:4 },
60615
+ LineSpace:5, //行间距
60616
+ TextAlign:1, //对齐方式 0=left 1=right
60521
60617
  }
60522
60618
 
60523
60619
  this.PointToValue_Backup=this.PointToValue;
@@ -60551,7 +60647,9 @@ function ChartDrawMonitorLine()
60551
60647
  if (item.BGColor) dest.BGColor=item.BGColor;
60552
60648
  if (item.LineColor) dest.LineColor=item.LineColor;
60553
60649
  if (item.LineDash) dest.LineDash=item.LineDash;
60554
- if (IFrameSplitOperator.IsNumber(item.YTextOffset)) dest.YTextOffset=item.YTextOffset;
60650
+ if (IFrameSplitOperator.IsNumber(item.LineSpace)) dest.LineSpace=item.LineSpace;
60651
+ if (IFrameSplitOperator.IsNumber(item.TextAlign)) dest.TextAlign=item.TextAlign;
60652
+ if (item.Mergin) CopyMerginConfig(dest.Mergin, item.Mergin);
60555
60653
  }
60556
60654
 
60557
60655
  if (option.FormatLabelTextCallback) this.FormatLabelTextCallback=option.FormatLabelTextCallback;
@@ -60665,6 +60763,7 @@ function ChartDrawMonitorLine()
60665
60763
  this.DrawLabel=function(labelInfo)
60666
60764
  {
60667
60765
  if (!this.FormatLabelTextCallback) return;
60766
+ labelInfo.Config=this.LabelConfig;
60668
60767
  this.FormatLabelTextCallback(labelInfo);
60669
60768
  if (!IFrameSplitOperator.IsNonEmptyArray(labelInfo.AryText)) return;
60670
60769
  if (!IFrameSplitOperator.IsNumber(labelInfo.YValue)) return;
@@ -60681,54 +60780,14 @@ function ChartDrawMonitorLine()
60681
60780
  ]
60682
60781
  */
60683
60782
 
60684
- var y=this.Frame.GetYFromData(labelInfo.YValue,false);
60685
- this.Canvas.font=this.LabelConfig.Font;
60686
- this.Canvas.textAlign="left";
60687
- this.Canvas.textBaseline="top";
60688
- var lineHeight=this.Canvas.measureText("擎").width+2;
60689
- var maxWidth=0, lineCount=0;
60690
- for(var i=0;i<labelInfo.AryText.length;++i)
60691
- {
60692
- var item=labelInfo.AryText[i];
60693
- item.NameWidth=0;
60694
- item.TextWidth=0;
60695
- if (item.Name) item.NameWidth=this.Canvas.measureText(item.Name).width+2;
60696
- if (item.Text) item.TextWidth=this.Canvas.measureText(item.Text).width+2;
60697
-
60698
- var itemWidth=item.NameWidth+item.TextWidth;
60699
- if (maxWidth<itemWidth) maxWidth=itemWidth;
60700
- ++lineCount;
60701
- }
60783
+ this.CalculateLabelSize(labelInfo);
60702
60784
 
60703
- var rtBG={ Left:labelInfo.Left+1, Top:y, Width:maxWidth+4, Height:lineHeight*lineCount+4 };
60785
+ var y=this.Frame.GetYFromData(labelInfo.YValue,false);
60786
+ var rtBG={ Left:labelInfo.Left+1, Top:y, Width:labelInfo.Width, Height:labelInfo.Height };
60704
60787
  rtBG.Right=rtBG.Left+rtBG.Width;
60705
60788
  rtBG.Bottom=rtBG.Top+rtBG.Height;
60706
- if (this.LabelConfig.BGColor)
60707
- {
60708
- this.Canvas.fillStyle=this.LabelConfig.BGColor
60709
- this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));
60710
- }
60711
-
60712
- var xText=rtBG.Left+2;
60713
- var yText=rtBG.Top+this.LabelConfig.YTextOffset;
60714
- for(var i=0;i<labelInfo.AryText.length;++i)
60715
- {
60716
- var item=labelInfo.AryText[i];
60717
-
60718
- if (item.Name)
60719
- {
60720
- this.Canvas.fillStyle=item.NameColor;
60721
- this.Canvas.fillText(item.Name,xText,yText);
60722
- }
60723
-
60724
- if (item.Text)
60725
- {
60726
- this.Canvas.fillStyle=item.TextColor;
60727
- this.Canvas.fillText(item.Text,xText+item.NameWidth ,yText);
60728
- }
60729
-
60730
- yText+=lineHeight;
60731
- }
60789
+
60790
+ this.DrawDefaultLabel(labelInfo, rtBG);
60732
60791
  }
60733
60792
  }
60734
60793
 
@@ -64550,6 +64609,139 @@ function ChartDateRange()
64550
64609
  }
64551
64610
  }
64552
64611
 
64612
+ //线段信息统计
64613
+ function ChartInfoLine()
64614
+ {
64615
+ this.newMethod=IChartDrawPicture; //派生
64616
+ this.newMethod();
64617
+ delete this.newMethod;
64618
+
64619
+ this.ClassName='ChartInfoLine';
64620
+ this.PointCount=2;
64621
+ this.Font=12*GetDevicePixelRatio() +"px 微软雅黑";
64622
+
64623
+ this.IsPointIn=this.IsPointIn_XYValue_Line;
64624
+ this.GetXYCoordinate=this.GetXYCoordinate_default;
64625
+ this.IsShowYCoordinate=false;
64626
+ this.CopyData=this.CopyData_default;
64627
+ this.OnlyMoveXIndex=true;
64628
+ this.IsSupportMagnet=true;
64629
+
64630
+ this.LabelConfig=
64631
+ {
64632
+ Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
64633
+ BGColor:"rgba(135, 206 ,250,0.95)",
64634
+ Mergin:{ Left:10, Right:10, Top:10, Bottom:8 },
64635
+ LineSpace:5, //行间距
64636
+ TextAlign:1, //对齐方式 0=left 1=right
64637
+ }
64638
+
64639
+ this.FormatLabelTextCallback=null;
64640
+
64641
+ this.SetOption=function(option)
64642
+ {
64643
+ if (option.LineColor) this.LineColor=option.LineColor;
64644
+ if (option.Label)
64645
+ {
64646
+ var item=option.Label;
64647
+ var dest=this.LabelConfig
64648
+ if (item.Font) dest.Font=item.Font;
64649
+ if (item.BGColor) dest.BGColor=item.BGColor;
64650
+ if (IFrameSplitOperator.IsNumber(item.LineSpace)) dest.LineSpace=item.LineSpace;
64651
+ if (IFrameSplitOperator.IsNumber(item.TextAlign)) dest.TextAlign=item.TextAlign;
64652
+ if (item.Mergin) CopyMerginConfig(dest.Mergin, item.Mergin);
64653
+ }
64654
+
64655
+ if (option.FormatLabelTextCallback) this.FormatLabelTextCallback=option.FormatLabelTextCallback;
64656
+ }
64657
+
64658
+ this.Draw=function()
64659
+ {
64660
+ this.LinePoint=[];
64661
+ if (this.IsFrameMinSize()) return;
64662
+ if (!this.IsShow) return;
64663
+
64664
+ var drawPoint=this.CalculateDrawPoint( {IsCheckX:true, IsCheckY:false} );
64665
+ if (!drawPoint) return;
64666
+ if (drawPoint.length!=2) return;
64667
+
64668
+ this.ClipFrame();
64669
+
64670
+ var ptStart=drawPoint[0];
64671
+ var ptEnd=drawPoint[1];
64672
+
64673
+ this.SetLineWidth();
64674
+ this.Canvas.strokeStyle=this.LineColor;
64675
+ this.Canvas.beginPath();
64676
+ this.Canvas.moveTo(ptStart.X,ptStart.Y);
64677
+ this.Canvas.lineTo(ptEnd.X,ptEnd.Y);
64678
+ this.Canvas.stroke();
64679
+ this.RestoreLineWidth();
64680
+
64681
+ var line={Start:ptStart, End:ptEnd};
64682
+ this.LinePoint.push(line);
64683
+
64684
+ this.DrawPoint(drawPoint); //画点
64685
+
64686
+ var labelInfo={ };
64687
+ labelInfo.Config=this.LabelConfig;
64688
+ labelInfo.PtStart=ptStart;
64689
+ labelInfo.PtEnd=ptEnd;
64690
+
64691
+ this.DrawLabel(labelInfo);
64692
+
64693
+ this.Canvas.restore();
64694
+ }
64695
+
64696
+ this.DrawLabel=function(labelInfo)
64697
+ {
64698
+ if (!this.FormatLabelTextCallback) return;
64699
+
64700
+ labelInfo.AryPoint=this.Point;
64701
+ if (this.Status!=10)
64702
+ {
64703
+ labelInfo.AryValue=this.PointToKLine(this.Point);
64704
+ }
64705
+ else
64706
+ {
64707
+ labelInfo.AryValue=this.Value;
64708
+ }
64709
+
64710
+ labelInfo.Data=this.Frame.Data; //数据
64711
+
64712
+ this.FormatLabelTextCallback(labelInfo);
64713
+ if (!IFrameSplitOperator.IsNonEmptyArray(labelInfo.AryText)) return;
64714
+
64715
+ this.CalculateLabelSize(labelInfo);
64716
+
64717
+ var ptStart=labelInfo.PtStart;
64718
+ var ptEnd=labelInfo.PtEnd;
64719
+ if (ptStart.X>ptEnd.X)
64720
+ {
64721
+ ptStart=labelInfo.PtEnd;
64722
+ ptEnd=labelInfo.PtStart;
64723
+ }
64724
+
64725
+ var config=labelInfo.Config;
64726
+ var xCenter=labelInfo.PtStart.X+(labelInfo.PtEnd.X-labelInfo.PtStart.X)/2;
64727
+ var yCenter=labelInfo.PtStart.Y+(labelInfo.PtEnd.Y-labelInfo.PtStart.Y)/2;
64728
+ if (ptStart.Y<ptEnd.Y)
64729
+ {
64730
+ var rtBG={ Left:xCenter, Bottom:yCenter, Width:labelInfo.Width, Height:labelInfo.Height };
64731
+ rtBG.Right=rtBG.Left+rtBG.Width;
64732
+ rtBG.Top=rtBG.Bottom-rtBG.Height;
64733
+ }
64734
+ else
64735
+ {
64736
+ var rtBG={ Left:xCenter, Top:yCenter, Width:labelInfo.Width, Height:labelInfo.Height };
64737
+ rtBG.Right=rtBG.Left+rtBG.Width;
64738
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
64739
+ }
64740
+
64741
+ this.DrawDefaultLabel(labelInfo, rtBG);
64742
+ }
64743
+ }
64744
+
64553
64745
 
64554
64746
  function ChartDrawStorage()
64555
64747
  {
@@ -69278,6 +69470,30 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
69278
69470
  }
69279
69471
  }
69280
69472
 
69473
+ this.ShowAllKLine=function()
69474
+ {
69475
+ var chart=this.ChartPaint[0];
69476
+ if (!chart) return false;
69477
+ var kData=chart.Data;
69478
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return false;
69479
+
69480
+ var xCount=kData.Data.length+this.RightSpaceCount;
69481
+ for(var i=0;i<this.Frame.SubFrame.length;++i)
69482
+ {
69483
+ var item =this.Frame.SubFrame[i].Frame;
69484
+ item.XPointCount=xCount;
69485
+ }
69486
+
69487
+ kData.DataOffset=0;
69488
+ this.CursorIndex=0;
69489
+
69490
+ this.UpdataDataoffset(); //更新数据偏移
69491
+ this.UpdateFrameMaxMin(); //调整坐标最大 最小值
69492
+ this.Frame.SetSizeChage(true);
69493
+ this.UpdatePointByCursorIndex(2); //取消十字光标
69494
+ this.Draw();
69495
+ }
69496
+
69281
69497
  this.UpdateMainData=function(hisData, lastDataCount)
69282
69498
  {
69283
69499
  var frameHisdata=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">&#xe64a;</span>
59
+ <div class="name">info line</div>
60
+ <div class="code-name">&amp;#xe64a;</div>
61
+ </li>
62
+
57
63
  <li class="dib">
58
64
  <span class="icon hqchart_drawtool">&#xe656;</span>
59
65
  <div class="name">字体背景色</div>
@@ -432,9 +438,9 @@
432
438
  <pre><code class="language-css"
433
439
  >@font-face {
434
440
  font-family: 'hqchart_drawtool';
435
- src: url('iconfont.woff2?t=1716173088340') format('woff2'),
436
- url('iconfont.woff?t=1716173088340') format('woff'),
437
- url('iconfont.ttf?t=1716173088340') format('truetype');
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');
438
444
  }
439
445
  </code></pre>
440
446
  <h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
@@ -460,6 +466,15 @@
460
466
  <div class="content font-class">
461
467
  <ul class="icon_lists dib-box">
462
468
 
469
+ <li class="dib">
470
+ <span class="icon hqchart_drawtool icon-infoline"></span>
471
+ <div class="name">
472
+ info line
473
+ </div>
474
+ <div class="code-name">.icon-infoline
475
+ </div>
476
+ </li>
477
+
463
478
  <li class="dib">
464
479
  <span class="icon hqchart_drawtool icon-zitibeijingse"></span>
465
480
  <div class="name">
@@ -1027,6 +1042,14 @@
1027
1042
  <div class="content symbol">
1028
1043
  <ul class="icon_lists dib-box">
1029
1044
 
1045
+ <li class="dib">
1046
+ <svg class="icon svg-icon" aria-hidden="true">
1047
+ <use xlink:href="#icon-infoline"></use>
1048
+ </svg>
1049
+ <div class="name">info line</div>
1050
+ <div class="code-name">#icon-infoline</div>
1051
+ </li>
1052
+
1030
1053
  <li class="dib">
1031
1054
  <svg class="icon svg-icon" aria-hidden="true">
1032
1055
  <use xlink:href="#icon-zitibeijingse"></use>
@@ -1,8 +1,8 @@
1
1
  @font-face {
2
2
  font-family: "hqchart_drawtool"; /* Project id 4529603 */
3
- src: url('iconfont.woff2?t=1716173088340') format('woff2'),
4
- url('iconfont.woff?t=1716173088340') format('woff'),
5
- url('iconfont.ttf?t=1716173088340') format('truetype');
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');
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-infoline:before {
17
+ content: "\e64a";
18
+ }
19
+
16
20
  .icon-zitibeijingse:before {
17
21
  content: "\e656";
18
22
  }