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.
@@ -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);
@@ -13643,6 +13651,16 @@ function IsRecvOverlap(rect1, rect2)
13643
13651
  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
13652
  }
13645
13653
 
13654
+ function CopyMerginConfig(dest,src)
13655
+ {
13656
+ if (!src || !dest) return;
13657
+
13658
+ if (IFrameSplitOperator.IsNumber(src.Left)) dest.Left=src.Left;
13659
+ if (IFrameSplitOperator.IsNumber(src.Top)) dest.Top=src.Top;
13660
+ if (IFrameSplitOperator.IsNumber(src.Right)) dest.Right=src.Right;
13661
+ if (IFrameSplitOperator.IsNumber(src.Bottom)) dest.Bottom=src.Bottom;
13662
+ }
13663
+
13646
13664
 
13647
13665
  function Point()
13648
13666
  {
@@ -59406,6 +59424,79 @@ function IChartDrawPicture()
59406
59424
  //复制
59407
59425
  //this.CopyData=function() { }
59408
59426
  //this.PtInButtons=function(x, y) { }
59427
+
59428
+
59429
+ //计算标签页大小
59430
+ this.CalculateLabelSize=function(labelInfo)
59431
+ {
59432
+ var config=labelInfo.Config;
59433
+ this.Canvas.font=config.Font;
59434
+ this.Canvas.textAlign="left";
59435
+ this.Canvas.textBaseline="top";
59436
+ var lineHeight=this.Canvas.measureText("擎").width+2;
59437
+
59438
+ var maxWidth=0, lineCount=0, labelHeight=config.Mergin.Top+config.Mergin.Bottom;
59439
+ for(var i=0;i<labelInfo.AryText.length;++i)
59440
+ {
59441
+ if (i>0) labelHeight+=config.LineSpace;
59442
+
59443
+ var item=labelInfo.AryText[i];
59444
+ item.NameWidth=0;
59445
+ item.TextWidth=0;
59446
+ if (item.Name) item.NameWidth=this.Canvas.measureText(item.Name).width+2;
59447
+ if (item.Text) item.TextWidth=this.Canvas.measureText(item.Text).width+2;
59448
+
59449
+ var itemWidth=item.NameWidth+item.TextWidth;
59450
+ if (maxWidth<itemWidth) maxWidth=itemWidth;
59451
+ ++lineCount;
59452
+
59453
+ labelHeight+=lineHeight;
59454
+ }
59455
+
59456
+ var labelWidth=maxWidth+config.Mergin.Left+config.Mergin.Right;
59457
+
59458
+ labelInfo.Width=labelWidth;
59459
+ labelInfo.Height=labelHeight;
59460
+ labelInfo.LineHeight=lineHeight;
59461
+ }
59462
+
59463
+ this.DrawDefaultLabel=function(labelInfo, rtBG)
59464
+ {
59465
+ var config=labelInfo.Config;
59466
+
59467
+ if (config.BGColor)
59468
+ {
59469
+ this.Canvas.fillStyle=config.BGColor
59470
+ this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));
59471
+ }
59472
+
59473
+ var xText=rtBG.Left+config.Mergin.Left;
59474
+ var yText=rtBG.Top+config.Mergin.Top;
59475
+ for(var i=0;i<labelInfo.AryText.length;++i)
59476
+ {
59477
+ var item=labelInfo.AryText[i];
59478
+
59479
+ if (i>0) yText+=config.LineSpace;
59480
+
59481
+ if (item.Name)
59482
+ {
59483
+ this.Canvas.fillStyle=item.NameColor;
59484
+ this.Canvas.fillText(item.Name,xText,yText);
59485
+ }
59486
+
59487
+ if (item.Text)
59488
+ {
59489
+ var xOut=xText+item.NameWidth;
59490
+ if (config.TextAlign==1) //右对齐
59491
+ xOut=rtBG.Right-config.Mergin.Right-item.TextWidth;
59492
+
59493
+ this.Canvas.fillStyle=item.TextColor;
59494
+ this.Canvas.fillText(item.Text,xOut ,yText);
59495
+ }
59496
+
59497
+ yText+=labelInfo.LineHeight;
59498
+ }
59499
+ }
59409
59500
  }
59410
59501
 
59411
59502
  IChartDrawPicture.ColorToRGBA=function(color,opacity)
@@ -59544,7 +59635,8 @@ IChartDrawPicture.ArrayDrawPricture=
59544
59635
  { Name:"FibRetracement", ClassName:"ChartFibRetracement", Create:function() { return new ChartFibRetracement(); }}, //斐波那契回测
59545
59636
  { Name:"FibSpeedResistanceFan", ClassName:"ChartFibSpeedResistanceFan", Create:function() { return new ChartFibSpeedResistanceFan(); }}, //斐波那契扇形
59546
59637
  { Name:"PriceRange", ClassName:"ChartPriceRange", Create:function() { return new ChartPriceRange(); }},
59547
- { Name:"DateRange", ClassName:"ChartDateRange", Create:function() { return new ChartDateRange(); }}
59638
+ { Name:"DateRange", ClassName:"ChartDateRange", Create:function() { return new ChartDateRange(); }},
59639
+ { Name:"InfoLine", ClassName:"ChartInfoLine", Create:function() { return new ChartInfoLine(); }},
59548
59640
  ];
59549
59641
 
59550
59642
  IChartDrawPicture.MapIonFont=new Map(
@@ -64407,9 +64499,13 @@ function ChartDrawMonitorLine()
64407
64499
  this.LabelConfig=
64408
64500
  {
64409
64501
  Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
64410
- BGColor:"rgb(30,144,255)", YTextOffset:4,
64502
+ BGColor:"rgb(30,144,255)",
64411
64503
  LineColor:"rgba(255,215,0,0.8)",
64412
64504
  LineDash:[3,5],
64505
+
64506
+ Mergin:{ Left:5, Right:5, Top:5, Bottom:4 },
64507
+ LineSpace:5, //行间距
64508
+ TextAlign:1, //对齐方式 0=left 1=right
64413
64509
  }
64414
64510
 
64415
64511
  this.PointToValue_Backup=this.PointToValue;
@@ -64443,7 +64539,9 @@ function ChartDrawMonitorLine()
64443
64539
  if (item.BGColor) dest.BGColor=item.BGColor;
64444
64540
  if (item.LineColor) dest.LineColor=item.LineColor;
64445
64541
  if (item.LineDash) dest.LineDash=item.LineDash;
64446
- if (IFrameSplitOperator.IsNumber(item.YTextOffset)) dest.YTextOffset=item.YTextOffset;
64542
+ if (IFrameSplitOperator.IsNumber(item.LineSpace)) dest.LineSpace=item.LineSpace;
64543
+ if (IFrameSplitOperator.IsNumber(item.TextAlign)) dest.TextAlign=item.TextAlign;
64544
+ if (item.Mergin) CopyMerginConfig(dest.Mergin, item.Mergin);
64447
64545
  }
64448
64546
 
64449
64547
  if (option.FormatLabelTextCallback) this.FormatLabelTextCallback=option.FormatLabelTextCallback;
@@ -64557,6 +64655,7 @@ function ChartDrawMonitorLine()
64557
64655
  this.DrawLabel=function(labelInfo)
64558
64656
  {
64559
64657
  if (!this.FormatLabelTextCallback) return;
64658
+ labelInfo.Config=this.LabelConfig;
64560
64659
  this.FormatLabelTextCallback(labelInfo);
64561
64660
  if (!IFrameSplitOperator.IsNonEmptyArray(labelInfo.AryText)) return;
64562
64661
  if (!IFrameSplitOperator.IsNumber(labelInfo.YValue)) return;
@@ -64573,54 +64672,14 @@ function ChartDrawMonitorLine()
64573
64672
  ]
64574
64673
  */
64575
64674
 
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
- }
64675
+ this.CalculateLabelSize(labelInfo);
64594
64676
 
64595
- var rtBG={ Left:labelInfo.Left+1, Top:y, Width:maxWidth+4, Height:lineHeight*lineCount+4 };
64677
+ var y=this.Frame.GetYFromData(labelInfo.YValue,false);
64678
+ var rtBG={ Left:labelInfo.Left+1, Top:y, Width:labelInfo.Width, Height:labelInfo.Height };
64596
64679
  rtBG.Right=rtBG.Left+rtBG.Width;
64597
64680
  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
- }
64681
+
64682
+ this.DrawDefaultLabel(labelInfo, rtBG);
64624
64683
  }
64625
64684
  }
64626
64685
 
@@ -68442,6 +68501,139 @@ function ChartDateRange()
68442
68501
  }
68443
68502
  }
68444
68503
 
68504
+ //线段信息统计
68505
+ function ChartInfoLine()
68506
+ {
68507
+ this.newMethod=IChartDrawPicture; //派生
68508
+ this.newMethod();
68509
+ delete this.newMethod;
68510
+
68511
+ this.ClassName='ChartInfoLine';
68512
+ this.PointCount=2;
68513
+ this.Font=12*GetDevicePixelRatio() +"px 微软雅黑";
68514
+
68515
+ this.IsPointIn=this.IsPointIn_XYValue_Line;
68516
+ this.GetXYCoordinate=this.GetXYCoordinate_default;
68517
+ this.IsShowYCoordinate=false;
68518
+ this.CopyData=this.CopyData_default;
68519
+ this.OnlyMoveXIndex=true;
68520
+ this.IsSupportMagnet=true;
68521
+
68522
+ this.LabelConfig=
68523
+ {
68524
+ Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
68525
+ BGColor:"rgba(135, 206 ,250,0.95)",
68526
+ Mergin:{ Left:10, Right:10, Top:10, Bottom:8 },
68527
+ LineSpace:5, //行间距
68528
+ TextAlign:1, //对齐方式 0=left 1=right
68529
+ }
68530
+
68531
+ this.FormatLabelTextCallback=null;
68532
+
68533
+ this.SetOption=function(option)
68534
+ {
68535
+ if (option.LineColor) this.LineColor=option.LineColor;
68536
+ if (option.Label)
68537
+ {
68538
+ var item=option.Label;
68539
+ var dest=this.LabelConfig
68540
+ if (item.Font) dest.Font=item.Font;
68541
+ if (item.BGColor) dest.BGColor=item.BGColor;
68542
+ if (IFrameSplitOperator.IsNumber(item.LineSpace)) dest.LineSpace=item.LineSpace;
68543
+ if (IFrameSplitOperator.IsNumber(item.TextAlign)) dest.TextAlign=item.TextAlign;
68544
+ if (item.Mergin) CopyMerginConfig(dest.Mergin, item.Mergin);
68545
+ }
68546
+
68547
+ if (option.FormatLabelTextCallback) this.FormatLabelTextCallback=option.FormatLabelTextCallback;
68548
+ }
68549
+
68550
+ this.Draw=function()
68551
+ {
68552
+ this.LinePoint=[];
68553
+ if (this.IsFrameMinSize()) return;
68554
+ if (!this.IsShow) return;
68555
+
68556
+ var drawPoint=this.CalculateDrawPoint( {IsCheckX:true, IsCheckY:false} );
68557
+ if (!drawPoint) return;
68558
+ if (drawPoint.length!=2) return;
68559
+
68560
+ this.ClipFrame();
68561
+
68562
+ var ptStart=drawPoint[0];
68563
+ var ptEnd=drawPoint[1];
68564
+
68565
+ this.SetLineWidth();
68566
+ this.Canvas.strokeStyle=this.LineColor;
68567
+ this.Canvas.beginPath();
68568
+ this.Canvas.moveTo(ptStart.X,ptStart.Y);
68569
+ this.Canvas.lineTo(ptEnd.X,ptEnd.Y);
68570
+ this.Canvas.stroke();
68571
+ this.RestoreLineWidth();
68572
+
68573
+ var line={Start:ptStart, End:ptEnd};
68574
+ this.LinePoint.push(line);
68575
+
68576
+ this.DrawPoint(drawPoint); //画点
68577
+
68578
+ var labelInfo={ };
68579
+ labelInfo.Config=this.LabelConfig;
68580
+ labelInfo.PtStart=ptStart;
68581
+ labelInfo.PtEnd=ptEnd;
68582
+
68583
+ this.DrawLabel(labelInfo);
68584
+
68585
+ this.Canvas.restore();
68586
+ }
68587
+
68588
+ this.DrawLabel=function(labelInfo)
68589
+ {
68590
+ if (!this.FormatLabelTextCallback) return;
68591
+
68592
+ labelInfo.AryPoint=this.Point;
68593
+ if (this.Status!=10)
68594
+ {
68595
+ labelInfo.AryValue=this.PointToKLine(this.Point);
68596
+ }
68597
+ else
68598
+ {
68599
+ labelInfo.AryValue=this.Value;
68600
+ }
68601
+
68602
+ labelInfo.Data=this.Frame.Data; //数据
68603
+
68604
+ this.FormatLabelTextCallback(labelInfo);
68605
+ if (!IFrameSplitOperator.IsNonEmptyArray(labelInfo.AryText)) return;
68606
+
68607
+ this.CalculateLabelSize(labelInfo);
68608
+
68609
+ var ptStart=labelInfo.PtStart;
68610
+ var ptEnd=labelInfo.PtEnd;
68611
+ if (ptStart.X>ptEnd.X)
68612
+ {
68613
+ ptStart=labelInfo.PtEnd;
68614
+ ptEnd=labelInfo.PtStart;
68615
+ }
68616
+
68617
+ var config=labelInfo.Config;
68618
+ var xCenter=labelInfo.PtStart.X+(labelInfo.PtEnd.X-labelInfo.PtStart.X)/2;
68619
+ var yCenter=labelInfo.PtStart.Y+(labelInfo.PtEnd.Y-labelInfo.PtStart.Y)/2;
68620
+ if (ptStart.Y<ptEnd.Y)
68621
+ {
68622
+ var rtBG={ Left:xCenter, Bottom:yCenter, Width:labelInfo.Width, Height:labelInfo.Height };
68623
+ rtBG.Right=rtBG.Left+rtBG.Width;
68624
+ rtBG.Top=rtBG.Bottom-rtBG.Height;
68625
+ }
68626
+ else
68627
+ {
68628
+ var rtBG={ Left:xCenter, Top:yCenter, Width:labelInfo.Width, Height:labelInfo.Height };
68629
+ rtBG.Right=rtBG.Left+rtBG.Width;
68630
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
68631
+ }
68632
+
68633
+ this.DrawDefaultLabel(labelInfo, rtBG);
68634
+ }
68635
+ }
68636
+
68445
68637
 
68446
68638
  function ChartDrawStorage()
68447
68639
  {
@@ -73170,6 +73362,30 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
73170
73362
  }
73171
73363
  }
73172
73364
 
73365
+ this.ShowAllKLine=function()
73366
+ {
73367
+ var chart=this.ChartPaint[0];
73368
+ if (!chart) return false;
73369
+ var kData=chart.Data;
73370
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return false;
73371
+
73372
+ var xCount=kData.Data.length+this.RightSpaceCount;
73373
+ for(var i=0;i<this.Frame.SubFrame.length;++i)
73374
+ {
73375
+ var item =this.Frame.SubFrame[i].Frame;
73376
+ item.XPointCount=xCount;
73377
+ }
73378
+
73379
+ kData.DataOffset=0;
73380
+ this.CursorIndex=0;
73381
+
73382
+ this.UpdataDataoffset(); //更新数据偏移
73383
+ this.UpdateFrameMaxMin(); //调整坐标最大 最小值
73384
+ this.Frame.SetSizeChage(true);
73385
+ this.UpdatePointByCursorIndex(2); //取消十字光标
73386
+ this.Draw();
73387
+ }
73388
+
73173
73389
  this.UpdateMainData=function(hisData, lastDataCount)
73174
73390
  {
73175
73391
  var frameHisdata=null;
@@ -132906,7 +133122,7 @@ function ScrollBarBGChart()
132906
133122
 
132907
133123
 
132908
133124
 
132909
- var HQCHART_VERSION="1.1.13334";
133125
+ var HQCHART_VERSION="1.1.13338";
132910
133126
 
132911
133127
  function PrintHQChartVersion()
132912
133128
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var HQCHART_VERSION="1.1.13334";
8
+ var HQCHART_VERSION="1.1.13338";
9
9
 
10
10
  function PrintHQChartVersion()
11
11
  {