hqchart 1.1.13335 → 1.1.13346

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.
@@ -3997,7 +3997,11 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
3997
3997
  return item;
3998
3998
  }
3999
3999
 
4000
- this.OnSize=function(option) //{ Type:1 新版本OnSize Redraw:是否重绘, XYSplit:是否重新计算分割线 }
4000
+ /*
4001
+ { Type: 1=K线柱子宽度不变 2=K线全部显示
4002
+ Redraw:是否重绘, XYSplit:是否重新计算分割线 }
4003
+ */
4004
+ this.OnSize=function(option)
4001
4005
  {
4002
4006
  //画布大小通过div获取 如果有style里的大小 使用style里的
4003
4007
  if (this.DivElement.style.height && this.DivElement.style.width)
@@ -4058,10 +4062,14 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
4058
4062
  {
4059
4063
  if (option && option.XYSplit===true) this.JSChartContainer.ResetFrameXYSplit();
4060
4064
 
4061
- if (this.JSChartContainer.OnSize && option && option.Type==1)
4065
+ if (this.JSChartContainer.OnSize && option && option.Type==1) //K线宽度不变
4062
4066
  {
4063
4067
  this.JSChartContainer.OnSize();
4064
4068
  }
4069
+ else if (this.JSChartContainer.ShowAllKLine && option && option.Type==2)
4070
+ {
4071
+ this.JSChartContainer.ShowAllKLine();
4072
+ }
4065
4073
  else
4066
4074
  {
4067
4075
  if (this.JSChartContainer.Frame) this.JSChartContainer.Frame.SetSizeChage(true);
@@ -5745,12 +5753,6 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
5745
5753
  }
5746
5754
  }
5747
5755
 
5748
- this.ChangMainDataControl=function(dataControl)
5749
- {
5750
- if (this.JSChartContainer && typeof(this.JSChartContainer.SetMainDataConotrl)=='function')
5751
- this.JSChartContainer.SetMainDataConotrl(dataControl);
5752
- }
5753
-
5754
5756
  this.AddOverlayIndex=function(obj) //{WindowIndex:窗口ID, IndexName:指标ID, Identify:叠加指标ID(可选), API}
5755
5757
  {
5756
5758
  if (this.JSChartContainer && typeof(this.JSChartContainer.AddOverlayIndex)=='function')
@@ -11955,7 +11957,9 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
11955
11957
  let sendData={ DrawPicture: drawPicture };
11956
11958
  event.Callback(event,sendData,this);
11957
11959
  }
11958
- else if (drawPicture.FinishedCallback) drawPicture.FinishedCallback(drawPicture);
11960
+
11961
+ //单个回调
11962
+ if (drawPicture.FinishedCallback) drawPicture.FinishedCallback(drawPicture);
11959
11963
 
11960
11964
  if (drawPicture.OnFinish) drawPicture.OnFinish();
11961
11965
 
@@ -13489,6 +13493,11 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
13489
13493
  if (deleteCount>0) this.ChartPaintEx=paint;
13490
13494
  }
13491
13495
  }
13496
+
13497
+ this.ClearCurrnetDrawPicture=function()
13498
+ {
13499
+ this.CurrentChartDrawPicture=null;
13500
+ }
13492
13501
  }
13493
13502
 
13494
13503
  function GetDevicePixelRatio()
@@ -13643,6 +13652,16 @@ function IsRecvOverlap(rect1, rect2)
13643
13652
  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);
13644
13653
  }
13645
13654
 
13655
+ function CopyMerginConfig(dest,src)
13656
+ {
13657
+ if (!src || !dest) return;
13658
+
13659
+ if (IFrameSplitOperator.IsNumber(src.Left)) dest.Left=src.Left;
13660
+ if (IFrameSplitOperator.IsNumber(src.Top)) dest.Top=src.Top;
13661
+ if (IFrameSplitOperator.IsNumber(src.Right)) dest.Right=src.Right;
13662
+ if (IFrameSplitOperator.IsNumber(src.Bottom)) dest.Bottom=src.Bottom;
13663
+ }
13664
+
13646
13665
 
13647
13666
  function Point()
13648
13667
  {
@@ -59406,6 +59425,79 @@ function IChartDrawPicture()
59406
59425
  //复制
59407
59426
  //this.CopyData=function() { }
59408
59427
  //this.PtInButtons=function(x, y) { }
59428
+
59429
+
59430
+ //计算标签页大小
59431
+ this.CalculateLabelSize=function(labelInfo)
59432
+ {
59433
+ var config=labelInfo.Config;
59434
+ this.Canvas.font=config.Font;
59435
+ this.Canvas.textAlign="left";
59436
+ this.Canvas.textBaseline="top";
59437
+ var lineHeight=this.Canvas.measureText("擎").width+2;
59438
+
59439
+ var maxWidth=0, lineCount=0, labelHeight=config.Mergin.Top+config.Mergin.Bottom;
59440
+ for(var i=0;i<labelInfo.AryText.length;++i)
59441
+ {
59442
+ if (i>0) labelHeight+=config.LineSpace;
59443
+
59444
+ var item=labelInfo.AryText[i];
59445
+ item.NameWidth=0;
59446
+ item.TextWidth=0;
59447
+ if (item.Name) item.NameWidth=this.Canvas.measureText(item.Name).width+2;
59448
+ if (item.Text) item.TextWidth=this.Canvas.measureText(item.Text).width+2;
59449
+
59450
+ var itemWidth=item.NameWidth+item.TextWidth;
59451
+ if (maxWidth<itemWidth) maxWidth=itemWidth;
59452
+ ++lineCount;
59453
+
59454
+ labelHeight+=lineHeight;
59455
+ }
59456
+
59457
+ var labelWidth=maxWidth+config.Mergin.Left+config.Mergin.Right;
59458
+
59459
+ labelInfo.Width=labelWidth;
59460
+ labelInfo.Height=labelHeight;
59461
+ labelInfo.LineHeight=lineHeight;
59462
+ }
59463
+
59464
+ this.DrawDefaultLabel=function(labelInfo, rtBG)
59465
+ {
59466
+ var config=labelInfo.Config;
59467
+
59468
+ if (config.BGColor)
59469
+ {
59470
+ this.Canvas.fillStyle=config.BGColor
59471
+ this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));
59472
+ }
59473
+
59474
+ var xText=rtBG.Left+config.Mergin.Left;
59475
+ var yText=rtBG.Top+config.Mergin.Top;
59476
+ for(var i=0;i<labelInfo.AryText.length;++i)
59477
+ {
59478
+ var item=labelInfo.AryText[i];
59479
+
59480
+ if (i>0) yText+=config.LineSpace;
59481
+
59482
+ if (item.Name)
59483
+ {
59484
+ this.Canvas.fillStyle=item.NameColor;
59485
+ this.Canvas.fillText(item.Name,xText,yText);
59486
+ }
59487
+
59488
+ if (item.Text)
59489
+ {
59490
+ var xOut=xText+item.NameWidth;
59491
+ if (config.TextAlign==1) //右对齐
59492
+ xOut=rtBG.Right-config.Mergin.Right-item.TextWidth;
59493
+
59494
+ this.Canvas.fillStyle=item.TextColor;
59495
+ this.Canvas.fillText(item.Text,xOut ,yText);
59496
+ }
59497
+
59498
+ yText+=labelInfo.LineHeight;
59499
+ }
59500
+ }
59409
59501
  }
59410
59502
 
59411
59503
  IChartDrawPicture.ColorToRGBA=function(color,opacity)
@@ -59544,7 +59636,8 @@ IChartDrawPicture.ArrayDrawPricture=
59544
59636
  { Name:"FibRetracement", ClassName:"ChartFibRetracement", Create:function() { return new ChartFibRetracement(); }}, //斐波那契回测
59545
59637
  { Name:"FibSpeedResistanceFan", ClassName:"ChartFibSpeedResistanceFan", Create:function() { return new ChartFibSpeedResistanceFan(); }}, //斐波那契扇形
59546
59638
  { Name:"PriceRange", ClassName:"ChartPriceRange", Create:function() { return new ChartPriceRange(); }},
59547
- { Name:"DateRange", ClassName:"ChartDateRange", Create:function() { return new ChartDateRange(); }}
59639
+ { Name:"DateRange", ClassName:"ChartDateRange", Create:function() { return new ChartDateRange(); }},
59640
+ { Name:"InfoLine", ClassName:"ChartInfoLine", Create:function() { return new ChartInfoLine(); }},
59548
59641
  ];
59549
59642
 
59550
59643
  IChartDrawPicture.MapIonFont=new Map(
@@ -64407,9 +64500,13 @@ function ChartDrawMonitorLine()
64407
64500
  this.LabelConfig=
64408
64501
  {
64409
64502
  Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
64410
- BGColor:"rgb(30,144,255)", YTextOffset:4,
64503
+ BGColor:"rgb(30,144,255)",
64411
64504
  LineColor:"rgba(255,215,0,0.8)",
64412
64505
  LineDash:[3,5],
64506
+
64507
+ Mergin:{ Left:5, Right:5, Top:5, Bottom:4 },
64508
+ LineSpace:5, //行间距
64509
+ TextAlign:1, //对齐方式 0=left 1=right
64413
64510
  }
64414
64511
 
64415
64512
  this.PointToValue_Backup=this.PointToValue;
@@ -64443,7 +64540,9 @@ function ChartDrawMonitorLine()
64443
64540
  if (item.BGColor) dest.BGColor=item.BGColor;
64444
64541
  if (item.LineColor) dest.LineColor=item.LineColor;
64445
64542
  if (item.LineDash) dest.LineDash=item.LineDash;
64446
- if (IFrameSplitOperator.IsNumber(item.YTextOffset)) dest.YTextOffset=item.YTextOffset;
64543
+ if (IFrameSplitOperator.IsNumber(item.LineSpace)) dest.LineSpace=item.LineSpace;
64544
+ if (IFrameSplitOperator.IsNumber(item.TextAlign)) dest.TextAlign=item.TextAlign;
64545
+ if (item.Mergin) CopyMerginConfig(dest.Mergin, item.Mergin);
64447
64546
  }
64448
64547
 
64449
64548
  if (option.FormatLabelTextCallback) this.FormatLabelTextCallback=option.FormatLabelTextCallback;
@@ -64557,6 +64656,7 @@ function ChartDrawMonitorLine()
64557
64656
  this.DrawLabel=function(labelInfo)
64558
64657
  {
64559
64658
  if (!this.FormatLabelTextCallback) return;
64659
+ labelInfo.Config=this.LabelConfig;
64560
64660
  this.FormatLabelTextCallback(labelInfo);
64561
64661
  if (!IFrameSplitOperator.IsNonEmptyArray(labelInfo.AryText)) return;
64562
64662
  if (!IFrameSplitOperator.IsNumber(labelInfo.YValue)) return;
@@ -64573,54 +64673,14 @@ function ChartDrawMonitorLine()
64573
64673
  ]
64574
64674
  */
64575
64675
 
64576
- var y=this.Frame.GetYFromData(labelInfo.YValue,false);
64577
- this.Canvas.font=this.LabelConfig.Font;
64578
- this.Canvas.textAlign="left";
64579
- this.Canvas.textBaseline="top";
64580
- var lineHeight=this.Canvas.measureText("擎").width+2;
64581
- var maxWidth=0, lineCount=0;
64582
- for(var i=0;i<labelInfo.AryText.length;++i)
64583
- {
64584
- var item=labelInfo.AryText[i];
64585
- item.NameWidth=0;
64586
- item.TextWidth=0;
64587
- if (item.Name) item.NameWidth=this.Canvas.measureText(item.Name).width+2;
64588
- if (item.Text) item.TextWidth=this.Canvas.measureText(item.Text).width+2;
64589
-
64590
- var itemWidth=item.NameWidth+item.TextWidth;
64591
- if (maxWidth<itemWidth) maxWidth=itemWidth;
64592
- ++lineCount;
64593
- }
64676
+ this.CalculateLabelSize(labelInfo);
64594
64677
 
64595
- var rtBG={ Left:labelInfo.Left+1, Top:y, Width:maxWidth+4, Height:lineHeight*lineCount+4 };
64678
+ var y=this.Frame.GetYFromData(labelInfo.YValue,false);
64679
+ var rtBG={ Left:labelInfo.Left+1, Top:y, Width:labelInfo.Width, Height:labelInfo.Height };
64596
64680
  rtBG.Right=rtBG.Left+rtBG.Width;
64597
64681
  rtBG.Bottom=rtBG.Top+rtBG.Height;
64598
- if (this.LabelConfig.BGColor)
64599
- {
64600
- this.Canvas.fillStyle=this.LabelConfig.BGColor
64601
- this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));
64602
- }
64603
-
64604
- var xText=rtBG.Left+2;
64605
- var yText=rtBG.Top+this.LabelConfig.YTextOffset;
64606
- for(var i=0;i<labelInfo.AryText.length;++i)
64607
- {
64608
- var item=labelInfo.AryText[i];
64609
-
64610
- if (item.Name)
64611
- {
64612
- this.Canvas.fillStyle=item.NameColor;
64613
- this.Canvas.fillText(item.Name,xText,yText);
64614
- }
64615
-
64616
- if (item.Text)
64617
- {
64618
- this.Canvas.fillStyle=item.TextColor;
64619
- this.Canvas.fillText(item.Text,xText+item.NameWidth ,yText);
64620
- }
64621
-
64622
- yText+=lineHeight;
64623
- }
64682
+
64683
+ this.DrawDefaultLabel(labelInfo, rtBG);
64624
64684
  }
64625
64685
  }
64626
64686
 
@@ -68442,6 +68502,139 @@ function ChartDateRange()
68442
68502
  }
68443
68503
  }
68444
68504
 
68505
+ //线段信息统计
68506
+ function ChartInfoLine()
68507
+ {
68508
+ this.newMethod=IChartDrawPicture; //派生
68509
+ this.newMethod();
68510
+ delete this.newMethod;
68511
+
68512
+ this.ClassName='ChartInfoLine';
68513
+ this.PointCount=2;
68514
+ this.Font=12*GetDevicePixelRatio() +"px 微软雅黑";
68515
+
68516
+ this.IsPointIn=this.IsPointIn_XYValue_Line;
68517
+ this.GetXYCoordinate=this.GetXYCoordinate_default;
68518
+ this.IsShowYCoordinate=false;
68519
+ this.CopyData=this.CopyData_default;
68520
+ this.OnlyMoveXIndex=true;
68521
+ this.IsSupportMagnet=true;
68522
+
68523
+ this.LabelConfig=
68524
+ {
68525
+ Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
68526
+ BGColor:"rgba(135, 206 ,250,0.95)",
68527
+ Mergin:{ Left:10, Right:10, Top:10, Bottom:8 },
68528
+ LineSpace:5, //行间距
68529
+ TextAlign:1, //对齐方式 0=left 1=right
68530
+ }
68531
+
68532
+ this.FormatLabelTextCallback=null;
68533
+
68534
+ this.SetOption=function(option)
68535
+ {
68536
+ if (option.LineColor) this.LineColor=option.LineColor;
68537
+ if (option.Label)
68538
+ {
68539
+ var item=option.Label;
68540
+ var dest=this.LabelConfig
68541
+ if (item.Font) dest.Font=item.Font;
68542
+ if (item.BGColor) dest.BGColor=item.BGColor;
68543
+ if (IFrameSplitOperator.IsNumber(item.LineSpace)) dest.LineSpace=item.LineSpace;
68544
+ if (IFrameSplitOperator.IsNumber(item.TextAlign)) dest.TextAlign=item.TextAlign;
68545
+ if (item.Mergin) CopyMerginConfig(dest.Mergin, item.Mergin);
68546
+ }
68547
+
68548
+ if (option.FormatLabelTextCallback) this.FormatLabelTextCallback=option.FormatLabelTextCallback;
68549
+ }
68550
+
68551
+ this.Draw=function()
68552
+ {
68553
+ this.LinePoint=[];
68554
+ if (this.IsFrameMinSize()) return;
68555
+ if (!this.IsShow) return;
68556
+
68557
+ var drawPoint=this.CalculateDrawPoint( {IsCheckX:true, IsCheckY:false} );
68558
+ if (!drawPoint) return;
68559
+ if (drawPoint.length!=2) return;
68560
+
68561
+ this.ClipFrame();
68562
+
68563
+ var ptStart=drawPoint[0];
68564
+ var ptEnd=drawPoint[1];
68565
+
68566
+ this.SetLineWidth();
68567
+ this.Canvas.strokeStyle=this.LineColor;
68568
+ this.Canvas.beginPath();
68569
+ this.Canvas.moveTo(ptStart.X,ptStart.Y);
68570
+ this.Canvas.lineTo(ptEnd.X,ptEnd.Y);
68571
+ this.Canvas.stroke();
68572
+ this.RestoreLineWidth();
68573
+
68574
+ var line={Start:ptStart, End:ptEnd};
68575
+ this.LinePoint.push(line);
68576
+
68577
+ this.DrawPoint(drawPoint); //画点
68578
+
68579
+ var labelInfo={ };
68580
+ labelInfo.Config=this.LabelConfig;
68581
+ labelInfo.PtStart=ptStart;
68582
+ labelInfo.PtEnd=ptEnd;
68583
+
68584
+ this.Canvas.restore();
68585
+
68586
+ this.DrawLabel(labelInfo);
68587
+ }
68588
+
68589
+ this.DrawLabel=function(labelInfo)
68590
+ {
68591
+ if (!this.FormatLabelTextCallback) return;
68592
+
68593
+ labelInfo.AryPoint=this.Point;
68594
+ if (this.Status!=10)
68595
+ {
68596
+ labelInfo.AryValue=this.PointToKLine(this.Point);
68597
+ }
68598
+ else
68599
+ {
68600
+ labelInfo.AryValue=this.Value;
68601
+ }
68602
+
68603
+ labelInfo.Data=this.Frame.Data; //数据
68604
+
68605
+ this.FormatLabelTextCallback(labelInfo);
68606
+ if (!IFrameSplitOperator.IsNonEmptyArray(labelInfo.AryText)) return;
68607
+
68608
+ this.CalculateLabelSize(labelInfo);
68609
+
68610
+ var ptStart=labelInfo.PtStart;
68611
+ var ptEnd=labelInfo.PtEnd;
68612
+ if (ptStart.X>ptEnd.X)
68613
+ {
68614
+ ptStart=labelInfo.PtEnd;
68615
+ ptEnd=labelInfo.PtStart;
68616
+ }
68617
+
68618
+ var config=labelInfo.Config;
68619
+ var xCenter=labelInfo.PtStart.X+(labelInfo.PtEnd.X-labelInfo.PtStart.X)/2;
68620
+ var yCenter=labelInfo.PtStart.Y+(labelInfo.PtEnd.Y-labelInfo.PtStart.Y)/2;
68621
+ if (ptStart.Y<ptEnd.Y)
68622
+ {
68623
+ var rtBG={ Left:xCenter, Bottom:yCenter, Width:labelInfo.Width, Height:labelInfo.Height };
68624
+ rtBG.Right=rtBG.Left+rtBG.Width;
68625
+ rtBG.Top=rtBG.Bottom-rtBG.Height;
68626
+ }
68627
+ else
68628
+ {
68629
+ var rtBG={ Left:xCenter, Top:yCenter, Width:labelInfo.Width, Height:labelInfo.Height };
68630
+ rtBG.Right=rtBG.Left+rtBG.Width;
68631
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
68632
+ }
68633
+
68634
+ this.DrawDefaultLabel(labelInfo, rtBG);
68635
+ }
68636
+ }
68637
+
68445
68638
 
68446
68639
  function ChartDrawStorage()
68447
68640
  {
@@ -73170,6 +73363,30 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
73170
73363
  }
73171
73364
  }
73172
73365
 
73366
+ this.ShowAllKLine=function()
73367
+ {
73368
+ var chart=this.ChartPaint[0];
73369
+ if (!chart) return false;
73370
+ var kData=chart.Data;
73371
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return false;
73372
+
73373
+ var xCount=kData.Data.length+this.RightSpaceCount;
73374
+ for(var i=0;i<this.Frame.SubFrame.length;++i)
73375
+ {
73376
+ var item =this.Frame.SubFrame[i].Frame;
73377
+ item.XPointCount=xCount;
73378
+ }
73379
+
73380
+ kData.DataOffset=0;
73381
+ this.CursorIndex=0;
73382
+
73383
+ this.UpdataDataoffset(); //更新数据偏移
73384
+ this.UpdateFrameMaxMin(); //调整坐标最大 最小值
73385
+ this.Frame.SetSizeChage(true);
73386
+ this.UpdatePointByCursorIndex(2); //取消十字光标
73387
+ this.Draw();
73388
+ }
73389
+
73173
73390
  this.UpdateMainData=function(hisData, lastDataCount)
73174
73391
  {
73175
73392
  var frameHisdata=null;
@@ -77202,11 +77419,6 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
77202
77419
  return true;
77203
77420
  }
77204
77421
 
77205
- this.ClearCurrnetDrawPicture=function()
77206
- {
77207
- this.CurrentChartDrawPicture=null;
77208
- }
77209
-
77210
77422
  this.AddChartDrawPicture=function(obj)
77211
77423
  {
77212
77424
  if (!obj) return null;
@@ -132906,7 +133118,7 @@ function ScrollBarBGChart()
132906
133118
 
132907
133119
 
132908
133120
 
132909
- var HQCHART_VERSION="1.1.13334";
133121
+ var HQCHART_VERSION="1.1.13345";
132910
133122
 
132911
133123
  function PrintHQChartVersion()
132912
133124
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var HQCHART_VERSION="1.1.13334";
8
+ var HQCHART_VERSION="1.1.13345";
9
9
 
10
10
  function PrintHQChartVersion()
11
11
  {