hqchart 1.1.13330 → 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
  {
@@ -15677,6 +15695,7 @@ function AverageWidthFrame()
15677
15695
  {
15678
15696
  var text=IFrameSplitOperator.FormatDateString(kItem.Date,null);
15679
15697
  if (ChartData.IsMinutePeriod(option.Period)) text+=" " + IFrameSplitOperator.FormatTimeString(kItem.Time, "HH:MM");
15698
+ else if (ChartData.IsMilliSecondPeriod(option.Period)) text+=" " + IFrameSplitOperator.FormatTimeString(kItem.Time, "HH:MM:SS.fff");
15680
15699
  var textWidth=this.Canvas.measureText(text).width+2;
15681
15700
 
15682
15701
  var textLeft=item.X-textWidth/2;
@@ -58294,7 +58313,7 @@ function IChartDrawPicture()
58294
58313
  var isHScreen=this.Frame.IsHScreen;
58295
58314
  if (isHScreen)
58296
58315
  {
58297
- for(var i in this.Point)
58316
+ for(var i=0; i<this.Point.length; ++i)
58298
58317
  {
58299
58318
  var item=this.Point[i];
58300
58319
  var xValue=parseInt(this.Frame.GetXData(item.Y,false))+data.DataOffset;
@@ -58310,7 +58329,7 @@ function IChartDrawPicture()
58310
58329
  }
58311
58330
  else
58312
58331
  {
58313
- for(var i in this.Point)
58332
+ for(var i=0; i<this.Point.length; ++i)
58314
58333
  {
58315
58334
  var item=this.Point[i];
58316
58335
  var xValue=parseInt(this.Frame.GetXData(item.X,false))+data.DataOffset;
@@ -59405,6 +59424,79 @@ function IChartDrawPicture()
59405
59424
  //复制
59406
59425
  //this.CopyData=function() { }
59407
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
+ }
59408
59500
  }
59409
59501
 
59410
59502
  IChartDrawPicture.ColorToRGBA=function(color,opacity)
@@ -59543,7 +59635,8 @@ IChartDrawPicture.ArrayDrawPricture=
59543
59635
  { Name:"FibRetracement", ClassName:"ChartFibRetracement", Create:function() { return new ChartFibRetracement(); }}, //斐波那契回测
59544
59636
  { Name:"FibSpeedResistanceFan", ClassName:"ChartFibSpeedResistanceFan", Create:function() { return new ChartFibSpeedResistanceFan(); }}, //斐波那契扇形
59545
59637
  { Name:"PriceRange", ClassName:"ChartPriceRange", Create:function() { return new ChartPriceRange(); }},
59546
- { 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(); }},
59547
59640
  ];
59548
59641
 
59549
59642
  IChartDrawPicture.MapIonFont=new Map(
@@ -64406,9 +64499,33 @@ function ChartDrawMonitorLine()
64406
64499
  this.LabelConfig=
64407
64500
  {
64408
64501
  Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
64409
- BGColor:"rgb(30,144,255)", YTextOffset:4,
64502
+ BGColor:"rgb(30,144,255)",
64410
64503
  LineColor:"rgba(255,215,0,0.8)",
64411
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
64509
+ }
64510
+
64511
+ this.PointToValue_Backup=this.PointToValue;
64512
+
64513
+ this.PointToValue=function()
64514
+ {
64515
+ if (!this.PointToValue_Backup()) return false;
64516
+
64517
+ if (this.Frame.IsKLineFrame(false))
64518
+ {
64519
+ if (this.Frame.Identify===0)
64520
+ {
64521
+ var dataIndex=this.Value[0].XValue;
64522
+ var data=this.Frame.Data;
64523
+ var kItem=data.Data[dataIndex];
64524
+ this.Value[0].YValue=kItem.Close; //使用收盘价
64525
+ }
64526
+ }
64527
+
64528
+ return true;
64412
64529
  }
64413
64530
 
64414
64531
  this.SetOption=function(option)
@@ -64422,7 +64539,9 @@ function ChartDrawMonitorLine()
64422
64539
  if (item.BGColor) dest.BGColor=item.BGColor;
64423
64540
  if (item.LineColor) dest.LineColor=item.LineColor;
64424
64541
  if (item.LineDash) dest.LineDash=item.LineDash;
64425
- 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);
64426
64545
  }
64427
64546
 
64428
64547
  if (option.FormatLabelTextCallback) this.FormatLabelTextCallback=option.FormatLabelTextCallback;
@@ -64536,6 +64655,7 @@ function ChartDrawMonitorLine()
64536
64655
  this.DrawLabel=function(labelInfo)
64537
64656
  {
64538
64657
  if (!this.FormatLabelTextCallback) return;
64658
+ labelInfo.Config=this.LabelConfig;
64539
64659
  this.FormatLabelTextCallback(labelInfo);
64540
64660
  if (!IFrameSplitOperator.IsNonEmptyArray(labelInfo.AryText)) return;
64541
64661
  if (!IFrameSplitOperator.IsNumber(labelInfo.YValue)) return;
@@ -64552,54 +64672,14 @@ function ChartDrawMonitorLine()
64552
64672
  ]
64553
64673
  */
64554
64674
 
64555
- var y=this.Frame.GetYFromData(labelInfo.YValue,false);
64556
- this.Canvas.font=this.LabelConfig.Font;
64557
- this.Canvas.textAlign="left";
64558
- this.Canvas.textBaseline="top";
64559
- var lineHeight=this.Canvas.measureText("擎").width+2;
64560
- var maxWidth=0, lineCount=0;
64561
- for(var i=0;i<labelInfo.AryText.length;++i)
64562
- {
64563
- var item=labelInfo.AryText[i];
64564
- item.NameWidth=0;
64565
- item.TextWidth=0;
64566
- if (item.Name) item.NameWidth=this.Canvas.measureText(item.Name).width+2;
64567
- if (item.Text) item.TextWidth=this.Canvas.measureText(item.Text).width+2;
64568
-
64569
- var itemWidth=item.NameWidth+item.TextWidth;
64570
- if (maxWidth<itemWidth) maxWidth=itemWidth;
64571
- ++lineCount;
64572
- }
64675
+ this.CalculateLabelSize(labelInfo);
64573
64676
 
64574
- 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 };
64575
64679
  rtBG.Right=rtBG.Left+rtBG.Width;
64576
64680
  rtBG.Bottom=rtBG.Top+rtBG.Height;
64577
- if (this.LabelConfig.BGColor)
64578
- {
64579
- this.Canvas.fillStyle=this.LabelConfig.BGColor
64580
- this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));
64581
- }
64582
-
64583
- var xText=rtBG.Left+2;
64584
- var yText=rtBG.Top+this.LabelConfig.YTextOffset;
64585
- for(var i=0;i<labelInfo.AryText.length;++i)
64586
- {
64587
- var item=labelInfo.AryText[i];
64588
-
64589
- if (item.Name)
64590
- {
64591
- this.Canvas.fillStyle=item.NameColor;
64592
- this.Canvas.fillText(item.Name,xText,yText);
64593
- }
64594
-
64595
- if (item.Text)
64596
- {
64597
- this.Canvas.fillStyle=item.TextColor;
64598
- this.Canvas.fillText(item.Text,xText+item.NameWidth ,yText);
64599
- }
64600
-
64601
- yText+=lineHeight;
64602
- }
64681
+
64682
+ this.DrawDefaultLabel(labelInfo, rtBG);
64603
64683
  }
64604
64684
  }
64605
64685
 
@@ -68421,6 +68501,139 @@ function ChartDateRange()
68421
68501
  }
68422
68502
  }
68423
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
+
68424
68637
 
68425
68638
  function ChartDrawStorage()
68426
68639
  {
@@ -73149,6 +73362,30 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
73149
73362
  }
73150
73363
  }
73151
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
+
73152
73389
  this.UpdateMainData=function(hisData, lastDataCount)
73153
73390
  {
73154
73391
  var frameHisdata=null;
@@ -132885,7 +133122,7 @@ function ScrollBarBGChart()
132885
133122
 
132886
133123
 
132887
133124
 
132888
- var HQCHART_VERSION="1.1.13329";
133125
+ var HQCHART_VERSION="1.1.13338";
132889
133126
 
132890
133127
  function PrintHQChartVersion()
132891
133128
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var HQCHART_VERSION="1.1.13329";
8
+ var HQCHART_VERSION="1.1.13338";
9
9
 
10
10
  function PrintHQChartVersion()
11
11
  {