hqchart 1.1.13754 → 1.1.13760

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.
@@ -62520,7 +62520,7 @@ function ChartDrawHLine()
62520
62520
  this.ButtonBGColor='rgb(190,190,190)';
62521
62521
  this.ButtonSpace=3;
62522
62522
 
62523
- this.TextMargin={ Left:0, Right:0 };
62523
+ this.TextMargin={ Left:0, Right:0, Top:0, Bottom:0, YOffset:4*GetDevicePixelRatio() };
62524
62524
 
62525
62525
  this.AlwaysShowLab=false; //总是显示标签
62526
62526
 
@@ -62544,7 +62544,9 @@ function ChartDrawHLine()
62544
62544
  `${12*GetDevicePixelRatio()}px 微软雅黑`,
62545
62545
  `${12*GetDevicePixelRatio()}px 微软雅黑`,
62546
62546
  ],
62547
- };
62547
+ };
62548
+
62549
+ this.LableInfo; //{ Position:2=右侧外部 }
62548
62550
 
62549
62551
  //内部变量
62550
62552
  this.ColseButtonSize=0;
@@ -62552,7 +62554,7 @@ function ChartDrawHLine()
62552
62554
  this.ButtonBGWidth=0;
62553
62555
  this.VerticalButtonInfo={ Width:0, Height:0 }; //垂直按钮信息
62554
62556
 
62555
-
62557
+ this.IsPointIn=this.IsPointIn_XYValue_Line;
62556
62558
 
62557
62559
  this.SetOption=function(option)
62558
62560
  {
@@ -62613,6 +62615,9 @@ function ChartDrawHLine()
62613
62615
  var item=option.TextMargin;
62614
62616
  if (IFrameSplitOperator.IsNumber(item.Left)) this.TextMargin.Left=item.Left;
62615
62617
  if (IFrameSplitOperator.IsNumber(item.Right)) this.TextMargin.Right=item.Right;
62618
+ if (IFrameSplitOperator.IsNumber(item.Top)) this.TextMargin.Top=item.Top;
62619
+ if (IFrameSplitOperator.IsNumber(item.Bottom)) this.TextMargin.Bottom=item.Bottom;
62620
+ if (IFrameSplitOperator.IsNumber(item.YOffset)) this.TextMargin.YOffset=item.YOffset;
62616
62621
  }
62617
62622
  }
62618
62623
  }
@@ -62629,10 +62634,6 @@ function ChartDrawHLine()
62629
62634
  return storageData;
62630
62635
  }
62631
62636
 
62632
-
62633
- this.IsPointIn=this.IsPointIn_XYValue_Line;
62634
-
62635
-
62636
62637
  /*
62637
62638
  this.GetXYCoordinate=function()
62638
62639
  {
@@ -62689,7 +62690,7 @@ function ChartDrawHLine()
62689
62690
  this.ColseButtonSize=0;
62690
62691
  this.SettingButtonSize=0;
62691
62692
  this.ButtonBGWidth=0;
62692
-
62693
+ this.LableInfo=null;
62693
62694
  this.VerticalButtonInfo.Width=0;
62694
62695
  this.VerticalButtonInfo.Height=0;
62695
62696
 
@@ -62752,7 +62753,7 @@ function ChartDrawHLine()
62752
62753
  }
62753
62754
  this.LinePoint.push(line);
62754
62755
 
62755
- if (bVisibleRange)
62756
+ if (bVisibleRange) //在可视范围内
62756
62757
  {
62757
62758
  var yValue=this.Frame.GetYData(drawPoint[0].Y, false);
62758
62759
  var strPrice=yValue.toFixed(this.Precision);
@@ -62766,15 +62767,11 @@ function ChartDrawHLine()
62766
62767
  this.DrawPriceText(strPrice, line.Start, line.End, 1);
62767
62768
  }
62768
62769
  }
62769
-
62770
- var labInfo;
62771
- if (this.GetLabelCallback) labInfo=this.GetLabelCallback(this);
62770
+
62771
+ if (this.GetLabelCallback) this.LableInfo=this.GetLabelCallback(this);
62772
62772
 
62773
62773
  this.AryShowButton=this.GetShowButton(); //获取按钮
62774
-
62775
- //框架内的描述信息
62776
- if (labInfo && bVisibleRange)
62777
- this.DrawLab(labInfo, drawPoint[0].Y);
62774
+ if (bVisibleRange) this.DrawInternalLabel(drawPoint[0].Y); //内部价格标签
62778
62775
 
62779
62776
  //画中心点
62780
62777
  if (bVisibleRange)
@@ -62791,11 +62788,11 @@ function ChartDrawHLine()
62791
62788
  {
62792
62789
  var rtDraw={ };
62793
62790
  this.CalculateButtonSize();
62794
- this.DrawValueText(drawPoint[0].Y, rtDraw, labInfo);
62795
- if (labInfo) this.DrawRightLab(labInfo, rtDraw);
62796
- if (labInfo && bVisibleRange) this.DrawCustomHLine(labInfo, drawPoint[0].Y);
62791
+ this.DrawRightLabel(drawPoint[0].Y);
62792
+ if (bVisibleRange) this.DrawCustomHLine(drawPoint[0].Y);
62797
62793
  }
62798
62794
 
62795
+
62799
62796
  //鼠标是否在按钮上
62800
62797
  if (moveonPoint && mouseStatus)
62801
62798
  {
@@ -62843,113 +62840,141 @@ function ChartDrawHLine()
62843
62840
  ++lineCount;
62844
62841
  }
62845
62842
 
62846
- var size={ Width:maxWidth, Height: lineCount*(lineHeight+lineSpace)+lineSpace, NameWidth:maxNameWidth, TextWidth:maxTextWidth, LineHeight:lineHeight };
62843
+ var size={ Width:maxWidth, Height:lineCount*lineHeight+(lineCount-1)*lineSpace, NameWidth:maxNameWidth, TextWidth:maxTextWidth, LineHeight:lineHeight };
62844
+ if (labInfo.LabelMargin)
62845
+ {
62846
+ var item=labInfo.LabelMargin;
62847
+ if (IFrameSplitOperator.IsNumber(item.Left)) size.Width+=item.Left;
62848
+ if (IFrameSplitOperator.IsNumber(item.Right)) size.Width+=item.Right;
62849
+ if (IFrameSplitOperator.IsNumber(item.Top)) size.Height+=item.Top;
62850
+ if (IFrameSplitOperator.IsNumber(item.Bottom)) size.Height+=item.Bottom;
62851
+ }
62847
62852
 
62848
62853
  return size;
62849
62854
  }
62850
62855
 
62851
- this.DrawLab=function(labInfo, y)
62856
+ //绘制窗口内部标签
62857
+ this.DrawInternalLabel=function(y)
62852
62858
  {
62853
- if (!labInfo) return;
62854
- if (!IFrameSplitOperator.IsNonEmptyArray(labInfo.AryText)) return;
62855
- if (labInfo.Position===2) return;
62859
+ if (!this.LableInfo || !IFrameSplitOperator.IsNonEmptyArray(this.LableInfo.AryText)) return;
62860
+ if (this.LableInfo.Position==2) return;
62856
62861
 
62857
- var left=this.Frame.ChartBorder.GetLeft();
62858
- var right=this.Frame.ChartBorder.GetRight();
62859
- var labSize=this.CalculateLabSize(labInfo);
62862
+ var border=this.Frame.GetBorder();
62863
+ var left=border.Left;
62864
+ var right=border.Right;
62865
+ var labSize=this.CalculateLabSize(this.LableInfo);
62860
62866
  var drawLeft=right-labSize.Width;
62867
+ var drawRight=drawLeft+labSize.Width;
62861
62868
  var drawTop=y-labSize.Height-1;
62869
+ if (drawTop<=border.TopEx) drawTop=y+1;
62862
62870
 
62863
- //背景色
62864
- if (labInfo.BGColor)
62865
- {
62866
- this.Canvas.fillStyle=labInfo.BGColor;
62867
- var rtTop=y-labSize.Height-4;
62868
- this.Canvas.fillRect(ToFixedRect(drawLeft),ToFixedRect(rtTop),ToFixedRect(right+drawLeft),ToFixedRect(y-rtTop));
62869
- }
62871
+ var rtLabel={ Left:drawLeft, Right:drawRight, Top:drawTop, Width:labSize.Width, Height:labSize.Height };
62872
+ rtLabel.Bottom=rtLabel.Top+rtLabel.Height;
62870
62873
 
62871
- var yText=drawTop;
62872
- for(var i=0;i<labInfo.AryText.length;++i)
62873
- {
62874
- var item=labInfo.AryText[i];
62875
- if (item.Name)
62876
- {
62877
- this.Canvas.fillStyle=item.NameColor;
62878
- this.Canvas.fillText(item.Name,drawLeft+1,yText+1);
62879
- }
62880
-
62881
- if (item.Text)
62882
- {
62883
- this.Canvas.fillStyle=item.TextColor;
62884
- this.Canvas.fillText(item.Text,drawLeft+labSize.NameWidth+1,yText+1);
62885
- }
62886
-
62887
- yText+=labSize.LineHeight;
62888
- }
62874
+ this.DrawLabel(this.LableInfo, labSize, rtLabel);
62889
62875
  }
62890
62876
 
62891
- this.DrawRightLab=function(labInfo, rtLeftDraw)
62877
+ //绘制标签页
62878
+ this.DrawLabel=function(labelInfo, labelSize, rtLabel)
62892
62879
  {
62893
- if (!labInfo) return;
62894
- if (!IFrameSplitOperator.IsNonEmptyArray(labInfo.AryText)) return;
62895
- if (labInfo.Position!=2) return;
62896
- var labSize=this.CalculateLabSize(labInfo);
62880
+ //背景色
62881
+ if (labelInfo.BGColor)
62882
+ {
62883
+ this.Canvas.fillStyle=labelInfo.BGColor;
62884
+ this.Canvas.fillRect(ToFixedRect(rtLabel.Left),ToFixedRect(rtLabel.Top),ToFixedRect(rtLabel.Width),ToFixedRect(rtLabel.Height));
62885
+ }
62897
62886
 
62898
- var drawLeft=rtLeftDraw.Right-labSize.Width;
62899
- if (drawLeft<rtLeftDraw.Left) drawLeft=rtLeftDraw.Left;
62900
- var drawRight=drawLeft+labSize.Width;
62901
- var drawTop=rtLeftDraw.Bottom;
62887
+ var labelMargin=labelInfo.LabelMargin;
62902
62888
  var lineSpace=0;
62903
- if (IFrameSplitOperator.IsNumber(labInfo.LineSpace)) lineSpace=labInfo.LineSpace;
62889
+ if (IFrameSplitOperator.IsNumber(labelInfo.LineSpace)) lineSpace=labelInfo.LineSpace;
62890
+
62891
+ var yText=rtLabel.Top;
62892
+ var xText=rtLabel.Left;
62893
+ var yRightText=rtLabel.Right;
62904
62894
 
62905
- //背景色
62906
- var rtLab={ Left:drawLeft, Top:drawTop, Width:labSize.Width, Height:labSize.Height }
62907
- rtLab.Right=rtLab.Left+rtLab.Width;
62908
- rtLab.Bottom=rtLab.Top+rtLab.Height;
62909
- if (labInfo.BGColor)
62895
+ if (labelMargin)
62910
62896
  {
62911
- this.Canvas.fillStyle=labInfo.BGColor;
62912
- this.Canvas.fillRect(ToFixedRect(rtLab.Left),ToFixedRect(rtLab.Top),ToFixedRect(rtLab.Width),ToFixedRect(rtLab.Height));
62897
+ if (IFrameSplitOperator.IsNumber(labelMargin.Left)) xText+=labelMargin.Left;
62898
+ if (IFrameSplitOperator.IsNumber(labelMargin.Right)) yRightText-=labelMargin.Right;
62899
+ if (IFrameSplitOperator.IsNumber(labelMargin.Top)) yText+=labelMargin.Top;
62900
+
62913
62901
  }
62914
62902
 
62915
- var yText=drawTop+1+lineSpace;
62903
+ this.Canvas.font=this.TextFont;
62916
62904
  this.Canvas.textBaseline="top";
62917
- for(var i=0;i<labInfo.AryText.length;++i)
62905
+ for(var i=0;i<labelInfo.AryText.length;++i)
62918
62906
  {
62919
- var item=labInfo.AryText[i];
62907
+ if (i>0) yText+=lineSpace;
62908
+ var item=labelInfo.AryText[i];
62920
62909
  if (item.Name)
62921
62910
  {
62922
62911
  this.Canvas.textAlign="left";
62923
62912
  this.Canvas.fillStyle=item.NameColor;
62924
- this.Canvas.fillText(item.Name,drawLeft+1,yText+1);
62913
+ this.Canvas.fillText(item.Name,xText,yText);
62925
62914
  }
62926
62915
 
62927
62916
  if (item.Text)
62928
62917
  {
62929
62918
  this.Canvas.textAlign="right";
62930
62919
  this.Canvas.fillStyle=item.TextColor;
62931
- this.Canvas.fillText(item.Text,drawRight-1,yText+1);
62920
+ this.Canvas.fillText(item.Text,yRightText,yText);
62932
62921
  }
62933
62922
 
62934
- yText+=labSize.LineHeight+lineSpace;
62923
+ yText+=labelSize.LineHeight;
62935
62924
  }
62925
+ }
62936
62926
 
62937
- this.DrawVerticalButton(rtLab);
62927
+ this.DrawRightLabel=function(y)
62928
+ {
62929
+ var rtDraw={ };
62930
+ if (!this.LableInfo || !IFrameSplitOperator.IsNonEmptyArray(this.LableInfo.AryText) || this.LableInfo.Position!=2)
62931
+ {
62932
+ this.DrawValueText(y, rtDraw);
62933
+ return;
62934
+ }
62935
+
62936
+ var priceSize=this.CalculateValueText(y);
62937
+ var labSize=this.CalculateLabSize(this.LableInfo);
62938
+ var border=this.Frame.GetBorder();
62939
+ var yTop=y-priceSize.Height/2;
62940
+ var totalHeight=priceSize.Height+labSize.Height;
62941
+ var yBottom=yTop+totalHeight;
62942
+ var option={ };
62943
+ if (yBottom>border.Bottom) //超过窗口底部, 标签位置不动
62944
+ {
62945
+ yBottom=border.Bottom;
62946
+ yTop=yBottom-totalHeight;
62947
+ option.Top=yTop;
62948
+ }
62949
+
62950
+ this.DrawValueText(y, rtDraw, option);
62951
+
62952
+ var drawLeft=rtDraw.Right-labSize.Width;
62953
+ if (drawLeft<rtDraw.Left) drawLeft=rtDraw.Left;
62954
+ var drawRight=drawLeft+labSize.Width;
62955
+ var drawTop=rtDraw.Bottom;
62956
+
62957
+ var rtLabel={ Left:drawLeft, Right:drawRight, Top:drawTop, Width:labSize.Width, Height:labSize.Height };
62958
+ rtLabel.Bottom=rtLabel.Top+rtLabel.Height;
62959
+
62960
+ this.DrawLabel(this.LableInfo, labSize, rtLabel);
62961
+
62962
+ this.DrawVerticalButton(rtLabel);
62938
62963
  }
62939
62964
 
62940
- this.DrawCustomHLine=function(labInfo, yLine)
62965
+ this.DrawCustomHLine=function(yLine)
62941
62966
  {
62942
- if (!labInfo) return;
62943
- if (!IFrameSplitOperator.IsNonEmptyArray(labInfo.AryLine)) return;
62967
+ if (!this.LableInfo) return;
62968
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.LableInfo.AryLine)) return;
62944
62969
 
62945
62970
  var left=this.Frame.ChartBorder.GetLeft();
62946
62971
  var right=this.Frame.ChartBorder.GetRight();
62947
62972
  var pixelRatio=GetDevicePixelRatio();
62948
62973
 
62949
62974
  var yMax=yLine, yMin=yLine;
62950
- for(var i=0;i<labInfo.AryLine.length;++i)
62975
+ for(var i=0;i<this.LableInfo.AryLine.length;++i)
62951
62976
  {
62952
- var item=labInfo.AryLine[i];
62977
+ var item=this.LableInfo.AryLine[i];
62953
62978
  if (!IFrameSplitOperator.IsNumber(item.Value)) continue;
62954
62979
  if (item.Width<0) continue;
62955
62980
 
@@ -62974,9 +62999,9 @@ function ChartDrawHLine()
62974
62999
  if (yMin>yFixed) yMin=yFixed;
62975
63000
  }
62976
63001
 
62977
- if (yMax!=yMin && labInfo.VLine)
63002
+ if (yMax!=yMin && this.LableInfo.VLine)
62978
63003
  {
62979
- var item=labInfo.VLine;
63004
+ var item=this.LableInfo.VLine;
62980
63005
  var x=left+20*pixelRatio;
62981
63006
  if (IFrameSplitOperator.IsNumber(item.XOffset)) x=left+item.XOffset*pixelRatio;
62982
63007
  x=ToFixedPoint(x);
@@ -62990,14 +63015,14 @@ function ChartDrawHLine()
62990
63015
  }
62991
63016
  }
62992
63017
 
62993
- this.DrawValueText=function(y, rtDraw, labInfo)
63018
+ this.DrawValueText=function(y, rtDraw, option)
62994
63019
  {
62995
63020
  var left=this.Frame.ChartBorder.GetLeft();
62996
63021
  var right=this.Frame.ChartBorder.GetRight();
62997
63022
  var top=this.Frame.ChartBorder.GetTopEx();
62998
63023
  var bottom=this.Frame.ChartBorder.GetBottomEx();
62999
63024
  var pixelTatio = GetDevicePixelRatio();
63000
-
63025
+ var labInfo=this.LabelInfo;
63001
63026
  if (labInfo && IFrameSplitOperator.IsNumber(labInfo.TopOffset)) top-=labInfo.TopOffset;
63002
63027
  if (labInfo && IFrameSplitOperator.IsNumber(labInfo.BottomOffset)) bottom+=labInfo.BottomOffset;
63003
63028
 
@@ -63032,12 +63057,21 @@ function ChartDrawHLine()
63032
63057
  this.Canvas.font=this.Font;
63033
63058
  var textWidth=this.Canvas.measureText(strValue).width;
63034
63059
  var lineHeight=this.GetFontHeight();
63035
- var rtBG={ Left:right+this.RightSpaceWidth, Top:y- lineHeight/2, Width:textWidth+4, Height:lineHeight };
63036
- //rtBG.Right=rtBG.Left+rtBG.Width;
63037
- rtBG.Bottom=rtBG.Top+rtBG.Height;
63060
+ var rtBG={ Left:right+this.RightSpaceWidth, YCenter:y, Width:textWidth, Height:lineHeight };
63061
+ rtBG.Height+=(this.TextMargin.Top+this.TextMargin.Bottom);
63038
63062
  rtBG.Width+=(this.TextMargin.Left+this.TextMargin.Right);
63039
63063
  rtBG.Right=rtBG.Left+rtBG.Width;
63040
- var xText=rtBG.Left+this.TextMargin.Left+2;
63064
+ rtBG.Top=rtBG.YCenter-rtBG.Height/2;
63065
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
63066
+
63067
+ if (option && IFrameSplitOperator.IsNumber(option.Top))
63068
+ {
63069
+ rtBG.Top=option.Top;
63070
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
63071
+ }
63072
+
63073
+ var xText=rtBG.Left+this.TextMargin.Left;
63074
+ var yText=rtBG.Top+this.TextMargin.Top+this.TextMargin.YOffset;
63041
63075
 
63042
63076
  if (this.ButtonPosition==1)
63043
63077
  {
@@ -63050,8 +63084,8 @@ function ChartDrawHLine()
63050
63084
 
63051
63085
  this.Canvas.fillStyle=this.ValueTextColor
63052
63086
  this.Canvas.textAlign="left";
63053
- this.Canvas.textBaseline="middle";
63054
- this.Canvas.fillText(strValue,xText,y);
63087
+ this.Canvas.textBaseline="top";
63088
+ this.Canvas.fillText(strValue,xText,yText);
63055
63089
 
63056
63090
  rtDraw.Left=rtBG.Left;
63057
63091
  rtDraw.Top=rtBG.Top;
@@ -63061,6 +63095,24 @@ function ChartDrawHLine()
63061
63095
  this.DrawButton(rtBG.Top, rtBG.Right, lineHeight, rtDraw);
63062
63096
  }
63063
63097
 
63098
+ //计算右侧价格标签大小
63099
+ this.CalculateValueText=function(y)
63100
+ {
63101
+ var yValue=this.Frame.GetYData(y,false);
63102
+ var strValue=yValue.toFixed(this.Precision);
63103
+ if (this.LableInfo &&this.LableInfo.PriceSuffixText) strValue+=this.LableInfo.PriceSuffixText;
63104
+
63105
+ this.Canvas.font=this.Font;
63106
+ var textWidth=this.Canvas.measureText(strValue).width;
63107
+ var lineHeight=this.GetFontHeight();
63108
+
63109
+ var size={ Width:textWidth, Height:lineHeight };
63110
+ size.Height+=(this.TextMargin.Top+this.TextMargin.Bottom);
63111
+ size.Width+=(this.TextMargin.Left+this.TextMargin.Right);
63112
+
63113
+ return size;
63114
+ }
63115
+
63064
63116
  this.DrawPriceText=function(text, ptStart, ptEnd, position)
63065
63117
  {
63066
63118
  if (position!=1 && position!=0) return;
@@ -143170,7 +143222,7 @@ function HQChartScriptWorker()
143170
143222
 
143171
143223
 
143172
143224
 
143173
- var HQCHART_VERSION="1.1.13753";
143225
+ var HQCHART_VERSION="1.1.13759";
143174
143226
 
143175
143227
  function PrintHQChartVersion()
143176
143228
  {