hqchart 1.1.13395 → 1.1.13401

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.
@@ -27565,6 +27565,14 @@ function ChartKLine()
27565
27565
  RightMargin:g_JSChartResource.OrderFlow_Style4.RightMargin,
27566
27566
  }
27567
27567
 
27568
+ this.OrderFlow_Style5=
27569
+ {
27570
+ AskBarColor:g_JSChartResource.OrderFlow_Style5.AskBarColor, //左
27571
+ BidBarColor:g_JSChartResource.OrderFlow_Style5.BidBarColor, //右
27572
+ LeftMargin:g_JSChartResource.OrderFlow_Style5.LeftMargin,
27573
+ RightMargin:g_JSChartResource.OrderFlow_Style5.RightMargin,
27574
+ }
27575
+
27568
27576
  this.IsShowOrderText=false;
27569
27577
 
27570
27578
  this.AryOrderFlowBorder=[]; //订单流边框 临时变量
@@ -31743,7 +31751,175 @@ function ChartKLine()
31743
31751
  //订单流样式5
31744
31752
  this.DrawOrderFlow_Style5=function()
31745
31753
  {
31754
+ var isHScreen=(this.ChartFrame.IsHScreen===true);
31755
+ var dataWidth=this.ChartFrame.DataWidth;
31756
+ var distanceWidth=this.ChartFrame.DistanceWidth;
31757
+ var border=this.ChartBorder.GetBorder();
31758
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
31759
+ var chartright=border.RightEx;
31760
+ var xPointCount=this.ChartFrame.XPointCount;
31761
+ this.AryOrderFlowBorder=[];
31762
+
31763
+ if (isHScreen)
31764
+ {
31765
+ var border=this.ChartBorder.GetHScreenBorder();
31766
+ xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
31767
+ chartright=border.BottomEx;
31768
+ }
31769
+
31770
+ var upColor=this.OrderFlow_Style2.UpColor;
31771
+ var downColor=this.OrderFlow_Style2.DownColor;
31772
+ var unchagneColor=this.OrderFlow_Style2.UnchagneColor;
31773
+ var barWidth=ToFixedRect(this.OrderFlow_Style2.BarWidth);
31774
+ var textWidth=dataWidth-barWidth;
31775
+ if (textWidth/7<barWidth) barWidth=textWidth/7;
31776
+ if (barWidth<=1) barWidth=2;
31777
+
31778
+ this.ShowRange.Start=this.Data.DataOffset;
31779
+ this.ShowRange.End=this.ShowRange.Start;
31780
+ this.ShowRange.DataCount=0;
31781
+ this.ShowRange.ShowCount=xPointCount;
31782
+ this.DrawKRange.Start=this.Data.DataOffset;
31783
+
31784
+ this.DrawOrderFlowHBar(); //横向柱子
31785
+
31786
+ for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth),++this.ShowRange.DataCount)
31787
+ {
31788
+ var data=this.Data.Data[i];
31789
+ this.ShowRange.End=i;
31790
+ if (data.Open==null || data.High==null || data.Low==null || data.Close==null) continue;
31791
+
31792
+ var left=xOffset;
31793
+ var right=xOffset+dataWidth;
31794
+ if (right>chartright) break;
31795
+ var x=left+(right-left)/2;
31796
+ var yLow=this.GetYFromData(data.Low, false);
31797
+ var yHigh=this.GetYFromData(data.High, false);
31798
+ var yOpen=this.GetYFromData(data.Open, false);
31799
+ var yClose=this.GetYFromData(data.Close, false);
31800
+ var y=yHigh;
31801
+
31802
+ this.DrawKRange.End=i;
31803
+
31804
+ var barTop=Math.min(yOpen,yClose);
31805
+ var barBottom=Math.max(yOpen,yClose);
31806
+ var barLeft=ToFixedRect(left);
31807
+ var barRight=barLeft+barWidth
31808
+ if (data.Open<data.Close) this.Canvas.fillStyle=upColor;
31809
+ else if (data.Open>data.Close) this.Canvas.fillStyle=downColor;
31810
+ else this.Canvas.fillStyle=unchagneColor;
31811
+
31812
+ var cellHeight=0;
31813
+ if (data.OrderFlow && IFrameSplitOperator.IsNumber(data.OrderFlow.PriceOffset)) cellHeight=this.GetPriceYOffset(data.OrderFlow.PriceOffset);
31814
+
31815
+ this.Canvas.fillRect(barLeft,ToFixedRect(barTop-cellHeight/2),barWidth,ToFixedRect(barBottom-barTop+cellHeight));
31816
+ var yKline={ Low:yLow, High:yHigh, Open:yOpen, Close:yClose };
31817
+ var xKLine={ Left:barRight, Center:x, Right:right, DataWidth:(right-barRight) };
31818
+ xKLine.Center=xKLine.Left+xKLine.DataWidth/2;
31819
+ this.DrawOrderFlowBar_Style5(data.OrderFlow, data, xKLine, yKline, isHScreen);
31820
+ }
31821
+ }
31822
+
31823
+ this.DrawOrderFlowBar_Style5=function(orderFlow, kItem, xKLine, yKline, isHScreen)
31824
+ {
31825
+ var top=Math.min(yKline.Open, yKline.Close)
31826
+ var bottom=Math.max(yKline.Open, yKline.Close);
31827
+ var barHeight=Math.abs(yKline.Open-yKline.Close);
31828
+ var cellHeight=0;
31829
+ if (orderFlow && IFrameSplitOperator.IsNumber(orderFlow.PriceOffset)) cellHeight=this.GetPriceYOffset(orderFlow.PriceOffset);
31830
+ var textFont=this.GetDynamicOrderFlowFont(cellHeight, xKLine.DataWidth/2);
31831
+ this.IsShowOrderText=(cellHeight>5 && xKLine.DataWidth>10);
31832
+ if (this.OrderFlow.AlwaysShowOrderText) this.IsShowOrderText=true;
31833
+
31834
+ this.Canvas.textBaseline='middle';
31835
+
31836
+ this.Canvas.font=textFont;
31837
+ var textWidth=xKLine.DataWidth/2;
31838
+ if (orderFlow && IFrameSplitOperator.IsNonEmptyArray(orderFlow.Order))
31839
+ {
31840
+ var maxValue=orderFlow.MaxValue;
31841
+ for(var i=0;i<orderFlow.Order.length;++i)
31842
+ {
31843
+ var item=orderFlow.Order[i];
31844
+ var yPrice=this.GetYFromData(item.Price, false);
31845
+
31846
+ var rect={ Left:xKLine.Left, Right:xKLine.Center, Bottom:yPrice+cellHeight/2, Top:yPrice-cellHeight/2 };
31847
+ rect.Width=rect.Right-rect.Left;
31848
+ rect.Height=rect.Bottom-rect.Top;
31849
+
31850
+ if (IFrameSplitOperator.IsNumber(item.Ask.Value))
31851
+ {
31852
+ var color=this.OrderFlow_Style5.AskBarColor;
31853
+ if (item.Ask.BG) color=item.Ask.BG;
31854
+ this.Canvas.fillStyle=color;
31855
+ var barWidth=rect.Width*item.Ask.Value/maxValue;
31856
+ this.Canvas.fillRect(ToFixedRect(rect.Right),ToFixedRect(rect.Top),ToFixedRect(-barWidth),ToFixedRect(rect.Height));
31857
+
31858
+ var text=null;
31859
+ if (IFrameSplitOperator.IsString(item.Ask.Text)) text=item.Ask.Text;
31860
+ else text=item.Ask.Value.toString();
31861
+ if (text && this.IsShowOrderText)
31862
+ {
31863
+ var textColor=this.OrderFlow.Text.Color;
31864
+ if (item.Ask.Color) textColor=item.Ask.Color;
31865
+
31866
+ this.Canvas.fillStyle=textColor;
31867
+ this.Canvas.textAlign='right';
31868
+ var xText=rect.Right-this.OrderFlow_Style5.LeftMargin;
31869
+ if (item.Ask.Font)
31870
+ {
31871
+ var itemFont=this.GetDynamicOrderFlowFont(cellHeight, xKLine.DataWidth/2, item.Ask.Font);
31872
+ this.Canvas.font=itemFont;
31873
+ this.Canvas.fillText(text,xText,yPrice);
31874
+ this.Canvas.font=textFont;
31875
+ }
31876
+ else
31877
+ {
31878
+ this.Canvas.fillText(text,xText,yPrice);
31879
+ }
31880
+ }
31881
+ }
31746
31882
 
31883
+
31884
+ var rect={ Left:xKLine.Center, Right:xKLine.Right, Bottom:yPrice+cellHeight/2, Top:yPrice-cellHeight/2 };
31885
+ rect.Width=rect.Right-rect.Left;
31886
+ rect.Height=rect.Bottom-rect.Top;
31887
+
31888
+ if (IFrameSplitOperator.IsNumber(item.Bid.Value))
31889
+ {
31890
+ var color=this.OrderFlow_Style5.BidBarColor;
31891
+ if (item.Bid.BG) color=item.Bid.BG;
31892
+ this.Canvas.fillStyle=color;
31893
+ var barWidth=rect.Width*item.Bid.Value/maxValue;
31894
+ this.Canvas.fillRect(ToFixedRect(rect.Left),ToFixedRect(rect.Top),ToFixedRect(barWidth),ToFixedRect(rect.Height));
31895
+
31896
+ var text=null;
31897
+ if (IFrameSplitOperator.IsString(item.Bid.Text)) text=item.Bid.Text;
31898
+ else text=item.Bid.Value.toString();
31899
+ if (text && this.IsShowOrderText)
31900
+ {
31901
+ var textColor=this.OrderFlow.Text.Color;
31902
+ if (item.Bid.Color)textColor=item.Bid.Color;
31903
+
31904
+ this.Canvas.fillStyle=textColor;
31905
+ this.Canvas.textAlign='left';
31906
+ var xText=rect.Left+this.OrderFlow_Style5.RightMargin
31907
+ if (item.Bid.Font)
31908
+ {
31909
+ var itemFont=this.GetDynamicOrderFlowFont(cellHeight, xKLine.DataWidth/2, item.Bid.Font);
31910
+ this.Canvas.font=itemFont;
31911
+ this.Canvas.fillText(text,xText,yPrice);
31912
+ this.Canvas.font=textFont;
31913
+ }
31914
+ else
31915
+ {
31916
+ this.Canvas.fillText(text,xText,yPrice);
31917
+ }
31918
+
31919
+ }
31920
+ }
31921
+ }
31922
+ }
31747
31923
  }
31748
31924
 
31749
31925
  //////////////////////////////////////////////////////////////
@@ -41523,6 +41699,8 @@ function ChartMultiText()
41523
41699
  var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
41524
41700
  var left=this.ChartBorder.GetTop();
41525
41701
  var right=this.ChartBorder.GetBottom();
41702
+ var top=border.RightEx;
41703
+ var bottom=border.LeftEx;
41526
41704
  }
41527
41705
  else
41528
41706
  {
@@ -41531,6 +41709,8 @@ function ChartMultiText()
41531
41709
  var chartright=border.RightEx;
41532
41710
  var left=this.ChartBorder.GetLeft();
41533
41711
  var right=this.ChartBorder.GetRight();
41712
+ var top=border.TopEx;
41713
+ var bottom=border.BottomEx;
41534
41714
  }
41535
41715
 
41536
41716
  for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
@@ -41665,6 +41845,8 @@ function ChartMultiText()
41665
41845
  for(var i in this.Texts)
41666
41846
  {
41667
41847
  var item=this.Texts[i];
41848
+ if (!IFrameSplitOperator.IsNumber(item.Value)) continue;
41849
+
41668
41850
  if (item.Index>=start && item.Index<end)
41669
41851
  {
41670
41852
  if (range.Max==null) range.Max=item.Value;
@@ -50270,7 +50452,7 @@ function FrameSplitKLinePriceY()
50270
50452
  this.Frame.HorizontalInfo[i]= new CoordinateInfo();
50271
50453
  this.Frame.HorizontalInfo[i].Value=value;
50272
50454
  if (this.IsShowLeftText) this.Frame.HorizontalInfo[i].Message[0]=value.toFixed(floatPrecision);
50273
- if (this.IsShowRightText) this.Frame.HorizontalInfo[i].Message[1]=value.toFixed(floatPrecision);
50455
+ if (this.IsShowRightText) this.Frame.HorizontalInfo[i].Message[1]=value.toFixed(floatPrecision);
50274
50456
  }
50275
50457
  }
50276
50458
 
@@ -60704,6 +60886,8 @@ function ChartDrawHLine()
60704
60886
 
60705
60887
  this.TextMargin={ Left:0, Right:0 };
60706
60888
 
60889
+ this.AlwaysShowLab=false; //总是显示标签
60890
+
60707
60891
  this.Button=
60708
60892
  {
60709
60893
  CloseIcon: { Text:'\ue62b', Color:'rgb(255,255,255)', Family:"iconfont", Size:16, ID:JSCHART_BUTTON_ID.DRAW_PICTURE_DELETE, TooltipText:null, Margin:{ Left:2, Right:2 } },
@@ -60750,7 +60934,9 @@ function ChartDrawHLine()
60750
60934
  if (option.ButtonBGColor) this.ButtonBGColor=option.ButtonBGColor;
60751
60935
  if (IFrameSplitOperator.IsNumber(option.ButtonPosition)) this.ButtonPosition=option.ButtonPosition;
60752
60936
  if (IFrameSplitOperator.IsNumber(option.RightSpaceWidth)) this.RightSpaceWidth=option.RightSpaceWidth;
60937
+ if (IFrameSplitOperator.IsBool(option.AlwaysShowLab)) this.AlwaysShowLab=option.AlwaysShowLab;
60753
60938
 
60939
+
60754
60940
  if (option.Button)
60755
60941
  {
60756
60942
  var item=option.Button;
@@ -60878,7 +61064,8 @@ function ChartDrawHLine()
60878
61064
  if (!drawPoint || drawPoint.length!=1) return;
60879
61065
  if (!this.Frame) return;
60880
61066
  if (this.Value.length!=1) return;
60881
- if (!this.IsYValueInFrame(this.Value[0].YValue)) return null;
61067
+ var bVisibleRange=this.IsYValueInFrame(this.Value[0].YValue); //是否在可视范围
61068
+ if (!this.AlwaysShowLab && !bVisibleRange) return;
60882
61069
 
60883
61070
  var isHScreen=this.Frame.IsHScreen;
60884
61071
  var left=this.Frame.ChartBorder.GetLeft();
@@ -60888,71 +61075,80 @@ function ChartDrawHLine()
60888
61075
  left=this.Frame.ChartBorder.GetTop();
60889
61076
  right=this.Frame.ChartBorder.GetBottom();
60890
61077
  }
61078
+
60891
61079
  this.ClipFrame();
60892
61080
 
60893
61081
  //画线段
60894
- this.Canvas.strokeStyle=this.LineColor;
60895
- this.SetLineWidth();
60896
- this.Canvas.beginPath();
60897
- if (isHScreen)
60898
- {
60899
- this.Canvas.moveTo(drawPoint[0].X,left);
60900
- this.Canvas.lineTo(drawPoint[0].X,right);
60901
- }
60902
- else
61082
+ if (bVisibleRange)
60903
61083
  {
60904
- this.Canvas.moveTo(left,ToFixedPoint(drawPoint[0].Y));
60905
- this.Canvas.lineTo(right,ToFixedPoint(drawPoint[0].Y));
61084
+ this.Canvas.strokeStyle=this.LineColor;
61085
+ this.SetLineWidth();
61086
+ this.Canvas.beginPath();
61087
+ if (isHScreen)
61088
+ {
61089
+ this.Canvas.moveTo(drawPoint[0].X,left);
61090
+ this.Canvas.lineTo(drawPoint[0].X,right);
61091
+ }
61092
+ else
61093
+ {
61094
+ this.Canvas.moveTo(left,ToFixedPoint(drawPoint[0].Y));
61095
+ this.Canvas.lineTo(right,ToFixedPoint(drawPoint[0].Y));
61096
+ }
61097
+ this.Canvas.stroke();
61098
+ this.RestoreLineWidth();
60906
61099
  }
60907
- this.Canvas.stroke();
60908
- this.RestoreLineWidth();
60909
61100
 
60910
61101
  //画水平线段
60911
- var line={Start:new Point(), End:new Point()};
60912
- if (isHScreen)
60913
- {
60914
- line.Start.X=drawPoint[0].X;
60915
- line.Start.Y=left;
60916
- line.End.X=drawPoint[0].X;
60917
- line.End.Y=right;
60918
- }
60919
- else
60920
- {
60921
- line.Start.X=left;
60922
- line.Start.Y=drawPoint[0].Y;
60923
- line.End.X=right;
60924
- line.End.Y=drawPoint[0].Y;
60925
- }
60926
- this.LinePoint.push(line);
60927
-
60928
- var yValue=this.Frame.GetYData(drawPoint[0].Y);
60929
- var strPrice=yValue.toFixed(this.Precision);
60930
- if (this.ShowPriceTextConfig.IsShow[0])
61102
+ if (bVisibleRange)
60931
61103
  {
60932
- this.DrawPriceText(strPrice, line.Start, line.End, 0);
60933
- }
60934
-
60935
- if (this.ShowPriceTextConfig.IsShow[1])
60936
- {
60937
- this.DrawPriceText(strPrice, line.Start, line.End, 1);
61104
+ var line={Start:new Point(), End:new Point()};
61105
+ if (isHScreen)
61106
+ {
61107
+ line.Start.X=drawPoint[0].X;
61108
+ line.Start.Y=left;
61109
+ line.End.X=drawPoint[0].X;
61110
+ line.End.Y=right;
61111
+ }
61112
+ else
61113
+ {
61114
+ line.Start.X=left;
61115
+ line.Start.Y=drawPoint[0].Y;
61116
+ line.End.X=right;
61117
+ line.End.Y=drawPoint[0].Y;
61118
+ }
61119
+ this.LinePoint.push(line);
61120
+
61121
+ var yValue=this.Frame.GetYData(drawPoint[0].Y, false);
61122
+ var strPrice=yValue.toFixed(this.Precision);
61123
+ if (this.ShowPriceTextConfig.IsShow[0])
61124
+ {
61125
+ this.DrawPriceText(strPrice, line.Start, line.End, 0);
61126
+ }
61127
+
61128
+ if (this.ShowPriceTextConfig.IsShow[1])
61129
+ {
61130
+ this.DrawPriceText(strPrice, line.Start, line.End, 1);
61131
+ }
60938
61132
  }
60939
-
61133
+
60940
61134
  var labInfo;
60941
61135
  if (this.GetLabelCallback) labInfo=this.GetLabelCallback(this);
60942
61136
 
60943
61137
  this.AryShowButton=this.GetShowButton(); //获取按钮
60944
61138
 
60945
- //描述信息
60946
- if (labInfo)
61139
+ //框架内的描述信息
61140
+ if (labInfo && bVisibleRange)
60947
61141
  this.DrawLab(labInfo, drawPoint[0].Y);
60948
61142
 
60949
61143
  //画中心点
60950
- var xCenter=left+(right-left)/2;
60951
- var point={ X:xCenter, Y: drawPoint[0].Y };
60952
- this.DrawPoint([point]);
61144
+ if (bVisibleRange)
61145
+ {
61146
+ var xCenter=left+(right-left)/2;
61147
+ var point={ X:xCenter, Y: drawPoint[0].Y };
61148
+ this.DrawPoint([point]);
61149
+ }
60953
61150
 
60954
61151
  this.Canvas.restore();
60955
-
60956
61152
 
60957
61153
  //外部右侧显示价格
60958
61154
  if (this.ShowPriceTextConfig.IsShow[2])
@@ -60961,9 +61157,8 @@ function ChartDrawHLine()
60961
61157
  this.CalculateButtonSize();
60962
61158
  this.DrawValueText(drawPoint[0].Y, rtDraw, labInfo);
60963
61159
  if (labInfo) this.DrawRightLab(labInfo, rtDraw);
60964
- if (labInfo) this.DrawCustomHLine(labInfo, drawPoint[0].Y);
61160
+ if (labInfo && bVisibleRange) this.DrawCustomHLine(labInfo, drawPoint[0].Y);
60965
61161
  }
60966
-
60967
61162
 
60968
61163
  //鼠标是否在按钮上
60969
61164
  if (moveonPoint && mouseStatus)
@@ -61163,9 +61358,32 @@ function ChartDrawHLine()
61163
61358
  {
61164
61359
  var left=this.Frame.ChartBorder.GetLeft();
61165
61360
  var right=this.Frame.ChartBorder.GetRight();
61361
+ var top=this.Frame.ChartBorder.GetTopEx();
61362
+ var bottom=this.Frame.ChartBorder.GetBottomEx();
61363
+ var pixelTatio = GetDevicePixelRatio();
61364
+
61365
+ if (IFrameSplitOperator.IsNumber(labInfo.TopOffset)) top-=labInfo.TopOffset;
61366
+ if (IFrameSplitOperator.IsNumber(labInfo.BottomOffset)) bottom+=labInfo.BottomOffset;
61367
+
61368
+ var yValue=this.Frame.GetYData(y,false);
61369
+ var strValue=yValue.toFixed(this.Precision);
61370
+ if (labInfo &&labInfo.PriceSuffixText) strValue+=labInfo.PriceSuffixText;
61371
+
61372
+ var bVisibleRange=true;
61373
+ if (y<top)
61374
+ {
61375
+ y=top;
61376
+ bVisibleRange=false;
61377
+ }
61378
+ else if (y>bottom)
61379
+ {
61380
+ y=bottom;
61381
+ bVisibleRange=false;
61382
+ }
61166
61383
 
61167
61384
  if (this.RightSpaceWidth>0)
61168
61385
  {
61386
+ if (!bVisibleRange) this.Canvas.setLineDash([2*pixelTatio,3*pixelTatio]); //虚线
61169
61387
  this.Canvas.strokeStyle=this.LineColor;
61170
61388
  this.Canvas.beginPath();
61171
61389
  this.Canvas.moveTo(right,ToFixedPoint(y));
@@ -61173,10 +61391,6 @@ function ChartDrawHLine()
61173
61391
  this.Canvas.stroke();
61174
61392
  }
61175
61393
 
61176
- var yValue=this.Frame.GetYData(y);
61177
- var strValue=yValue.toFixed(this.Precision);
61178
- if (labInfo &&labInfo.PriceSuffixText) strValue+=labInfo.PriceSuffixText;
61179
-
61180
61394
  this.Canvas.fillStyle=this.LineColor;
61181
61395
  this.Canvas.font=this.Font;
61182
61396
  var textWidth=this.Canvas.measureText(strValue).width;
@@ -69672,6 +69886,15 @@ function JSChartResource()
69672
69886
  LeftMargin:1,
69673
69887
  RightMargin:1
69674
69888
  };
69889
+
69890
+
69891
+ this.OrderFlow_Style5=
69892
+ {
69893
+ AskBarColor:"rgb(176,22,22)", //左
69894
+ BidBarColor:"rgb(98,126,176)", //右
69895
+ LeftMargin:3,
69896
+ RightMargin:2,
69897
+ };
69675
69898
 
69676
69899
 
69677
69900
  this.Index={};
@@ -137446,7 +137669,7 @@ function HQChartScriptWorker()
137446
137669
 
137447
137670
 
137448
137671
 
137449
- var HQCHART_VERSION="1.1.13395";
137672
+ var HQCHART_VERSION="1.1.13400";
137450
137673
 
137451
137674
  function PrintHQChartVersion()
137452
137675
  {