hqchart 1.1.13003 → 1.1.13014

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.
@@ -4965,7 +4965,8 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
4965
4965
  if (item.TimeFormat) chart.TitlePaint[0].TimeFormat=item.TimeFormat;
4966
4966
  }
4967
4967
 
4968
- if (option.CorssCursorTouchEnd===true) chart.CorssCursorTouchEnd = option.CorssCursorTouchEnd;
4968
+ if (IFrameSplitOperator.IsBool(option.CorssCursorTouchEnd)) chart.CorssCursorTouchEnd = option.CorssCursorTouchEnd;
4969
+ if (IFrameSplitOperator.IsBool(option.IsClickShowCorssCursor)) chart.IsClickShowCorssCursor=option.IsClickShowCorssCursor;
4969
4970
  if (option.IsShowBeforeData===true) chart.IsShowBeforeData=option.IsShowBeforeData;
4970
4971
 
4971
4972
  //分钟数据指标从第3个指标窗口设置
@@ -40567,7 +40568,7 @@ function ChartMultiSVGIcon()
40567
40568
  if (item.Color) this.Canvas.fillStyle = item.Color;
40568
40569
  else this.Canvas.fillStyle = this.Color;
40569
40570
 
40570
- var textWidth=this.Canvas.measureText(item.Text).width;
40571
+ var textWidth=this.Canvas.measureText(item.Symbol).width;
40571
40572
  this.Canvas.textAlign='center';
40572
40573
  var rtIcon=new Rect(x-fontSize/2,y-fontSize/2,fontSize,fontSize);
40573
40574
  if (x+textWidth/2>=right)
@@ -40702,6 +40703,300 @@ function ChartMultiSVGIcon()
40702
40703
  }
40703
40704
  }
40704
40705
 
40706
+
40707
+ //图标集合(2.0) 支持横屏
40708
+ function ChartMultiSVGIconV2()
40709
+ {
40710
+ this.newMethod=IChartPainting; //派生
40711
+ this.newMethod();
40712
+ delete this.newMethod;
40713
+
40714
+ this.ClassName="ChartMultiSVGIconV2";
40715
+ this.AryIcon; //[ {Index:, Value:, Symbol:, Color:, Baseline:, Line:{ Color:, Dash:[虚线点], KData:"H/L", Offset:[5,10], Width:线粗细 } } ]
40716
+ this.IconSize=
40717
+ {
40718
+ Max: g_JSChartResource.DRAWICON.Icon.MaxSize, Min:g_JSChartResource.DRAWICON.Icon.MinSize , //图标的最大最小值
40719
+ Zoom:{ Type:g_JSChartResource.DRAWICON.Icon.Zoom.Type , Value:g_JSChartResource.DRAWICON.Icon.Zoom.Value } //放大倍数
40720
+ };
40721
+ this.Family;
40722
+ this.Color=g_JSChartResource.DefaultTextColor;
40723
+ this.IsHScreen=false;
40724
+ this.IconRect=[]; //0=序号,1=区域
40725
+
40726
+ this.MapCache=null; //key=date/date-time value={ Data:[] }
40727
+
40728
+ this.BuildKey=function(item)
40729
+ {
40730
+ if (IFrameSplitOperator.IsNumber(item.Time)) return `${item.Date}-${item.Time}`;
40731
+ else return item.Date;
40732
+ }
40733
+
40734
+ this.BuildCacheData=function()
40735
+ {
40736
+ var mapData=new Map();
40737
+ this.MapCache=mapData;
40738
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryIcon)) return;
40739
+
40740
+ for(var i=0;i<this.AryIcon.length;++i)
40741
+ {
40742
+ var item=this.AryIcon[i];
40743
+ var key=this.BuildKey(item);
40744
+ if (mapData.has(key))
40745
+ {
40746
+ var mapItem=mapData.get(key);
40747
+ mapItem.Data.push(item);
40748
+ }
40749
+ else
40750
+ {
40751
+ mapData.set(key,{ Data:[item] });
40752
+ }
40753
+ }
40754
+ }
40755
+
40756
+ this.Draw=function()
40757
+ {
40758
+ this.IconRect=[];
40759
+ if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
40760
+ if (this.IsShowIndexTitleOnly()) return;
40761
+ if (this.IsHideScriptIndex()) return;
40762
+ if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return; //k线数据
40763
+ if (!this.Family) return;
40764
+ if (!this.MapCache || this.MapCache.size<=0) return;
40765
+
40766
+ this.IsHScreen=(this.ChartFrame.IsHScreen===true);
40767
+ var xPointCount=this.ChartFrame.XPointCount;
40768
+ var dataWidth=this.ChartFrame.DataWidth;
40769
+ var distanceWidth=this.ChartFrame.DistanceWidth;
40770
+ var isMinute=this.IsMinuteFrame();
40771
+
40772
+ var border=this.GetBorder();
40773
+ if (this.IsHScreen)
40774
+ {
40775
+ var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
40776
+ var chartright=border.BottomEx;
40777
+ var chartLeft=border.TopEx;
40778
+ }
40779
+ else
40780
+ {
40781
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
40782
+ var chartright=border.RightEx;
40783
+ var chartLeft=border.LeftEx;
40784
+ }
40785
+
40786
+ var fontSize=this.GetDynamicIconSize(dataWidth,distanceWidth,this.IconSize.Max,this.IconSize.Min,this.IconSize.Zoom);
40787
+ this.Canvas.font=fontSize+'px '+this.Family;
40788
+
40789
+ var drawInfo={ Left:chartLeft, Right:chartright, FontSize:fontSize, DataWidth:dataWidth, DistanceWidth:distanceWidth };
40790
+
40791
+ for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
40792
+ {
40793
+ var kItem=this.Data.Data[i];
40794
+ var key=this.BuildKey(kItem);
40795
+ if (!this.MapCache.has(key)) continue;
40796
+ var mapItem=this.MapCache.get(key);
40797
+
40798
+ if (isMinute)
40799
+ {
40800
+ var x=this.ChartFrame.GetXFromIndex(j);
40801
+ }
40802
+ else
40803
+ {
40804
+ var left=xOffset;
40805
+ var right=xOffset+dataWidth;
40806
+ if (right>chartright) break;
40807
+ var x=left+(right-left)/2;
40808
+ }
40809
+
40810
+ this.DrawItem(mapItem, kItem, x, drawInfo);
40811
+ }
40812
+ }
40813
+
40814
+ this.GetKValue=function(kItem, valueName)
40815
+ {
40816
+ switch(valueName)
40817
+ {
40818
+ case "HIGH":
40819
+ case "H":
40820
+ return kItem.High;
40821
+ case "L":
40822
+ case "LOW":
40823
+ return kItem.Low;
40824
+ case "C":
40825
+ case "CLOSE":
40826
+ return kItem.Close;
40827
+ case "O":
40828
+ case "OPEN":
40829
+ return KItem.Open;
40830
+ default:
40831
+ return null;
40832
+ }
40833
+ }
40834
+
40835
+ this.DrawItem=function(groupItem, kItem, x, drawInfo)
40836
+ {
40837
+ if (!IFrameSplitOperator.IsNonEmptyArray(groupItem.Data)) return;
40838
+
40839
+ var fontSize=drawInfo.FontSize;
40840
+ var left=drawInfo.Left, right=drawInfo.Right;
40841
+ var dataWidth=drawInfo.DataWidth;
40842
+ //var distanceWidth=drawInfo.DistanceWidth;
40843
+
40844
+ for(var i=0;i<groupItem.Data.length;++i)
40845
+ {
40846
+ var item=groupItem.Data[i];
40847
+ var value=item.Value;
40848
+ if (IFrameSplitOperator.IsString(item.Value)) value=this.GetKValue(kItem,item.Value);
40849
+ if (!IFrameSplitOperator.IsNumber(value)) continue;
40850
+
40851
+ var y=this.ChartFrame.GetYFromData(item.Value,false);
40852
+
40853
+ if (item.Color) this.Canvas.fillStyle = item.Color;
40854
+ else this.Canvas.fillStyle = this.Color;
40855
+
40856
+ var textWidth=this.Canvas.measureText(item.Symbol).width;
40857
+ this.Canvas.textAlign='center';
40858
+ var rtIcon=new Rect(x-fontSize/2,y-fontSize/2,fontSize,fontSize);
40859
+ if (x+textWidth/2>=right)
40860
+ {
40861
+ this.Canvas.textAlign='right';
40862
+ x+=dataWidth/2;
40863
+ rtIcon.X=x-fontSize;
40864
+ }
40865
+ else if (x-textWidth/2<left)
40866
+ {
40867
+ this.Canvas.textAlign = 'left';
40868
+ x-=dataWidth/2;
40869
+ rtIcon.X=x;
40870
+ }
40871
+
40872
+ if (item.Baseline==1)
40873
+ {
40874
+ this.Canvas.textBaseline='top';
40875
+ rtIcon.Y=y;
40876
+ }
40877
+ else if (item.Baseline==2)
40878
+ {
40879
+ this.Canvas.textBaseline='bottom';
40880
+ rtIcon.Y=y-fontSize;
40881
+ }
40882
+ else
40883
+ {
40884
+ this.Canvas.textBaseline = 'middle';
40885
+ rtIcon.Y=y-fontSize/2;
40886
+ }
40887
+
40888
+ if (this.IsHScreen)
40889
+ {
40890
+ this.Canvas.save();
40891
+ this.Canvas.translate(y, x);
40892
+ this.Canvas.rotate(90 * Math.PI / 180);
40893
+ this.Canvas.fillText(item.Symbol,0,0);
40894
+ this.Canvas.restore();
40895
+ }
40896
+ else
40897
+ {
40898
+ if (IFrameSplitOperator.IsNumber(item.YMove)) y+=item.YMove;
40899
+ this.Canvas.fillText(item.Symbol, x, y);
40900
+ if (item.Text) this.IconRect.push({ Rect:rtIcon , Item:item, KItem:kItem });
40901
+ }
40902
+
40903
+ if (item.Line)
40904
+ {
40905
+ var price=item.Line.KData=="H"? kItem.High:kItem.Low;
40906
+ var yPrice=this.ChartFrame.GetYFromData(price, false);
40907
+ var yText=y;
40908
+ if (Array.isArray(item.Line.Offset) && item.Line.Offset.length==2)
40909
+ {
40910
+ if (yText>yPrice) //文字在下方
40911
+ {
40912
+ yText-=item.Line.Offset[1];
40913
+ yPrice+=item.Line.Offset[0]
40914
+ }
40915
+ else if (yText<yPrice)
40916
+ {
40917
+ yText+=item.Line.Offset[1];
40918
+ yPrice-=item.Line.Offset[0]
40919
+ }
40920
+ }
40921
+ this.Canvas.save();
40922
+ if (item.Line.Dash) this.Canvas.setLineDash(item.Line.Dash); //虚线
40923
+ if (item.Line.Width>0) this.Canvas.lineWidth=item.Line.Width; //线宽
40924
+ this.Canvas.strokeStyle = item.Line.Color;
40925
+ this.Canvas.beginPath();
40926
+ if (this.IsHScreen)
40927
+ {
40928
+ this.Canvas.moveTo(yText, ToFixedPoint(x));
40929
+ this.Canvas.lineTo(yPrice,ToFixedPoint(x));
40930
+ }
40931
+ else
40932
+ {
40933
+ this.Canvas.moveTo(ToFixedPoint(x),yText);
40934
+ this.Canvas.lineTo(ToFixedPoint(x),yPrice);
40935
+ }
40936
+
40937
+ this.Canvas.stroke();
40938
+ this.Canvas.restore();
40939
+ }
40940
+ }
40941
+ }
40942
+
40943
+ this.GetTooltipData=function(x,y,tooltip)
40944
+ {
40945
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.IconRect)) return false;
40946
+ for(var i=0; i<this.IconRect.length; ++i)
40947
+ {
40948
+ var item=this.IconRect[i];
40949
+ if (!item.Rect) continue;
40950
+ var rect=item.Rect;
40951
+ this.Canvas.beginPath();
40952
+ this.Canvas.rect(rect.X,rect.Y,rect.Width,rect.Height);
40953
+ if (this.Canvas.isPointInPath(x,y))
40954
+ {
40955
+ JSConsole.Chart.Log('[ChartMultiSVGIconV2::GetTooltipData] icon ', item);
40956
+ tooltip.Data=item;
40957
+ tooltip.ChartPaint=this;
40958
+ tooltip.Type=4; //指标
40959
+ return true;
40960
+ }
40961
+ }
40962
+
40963
+ return false;
40964
+ }
40965
+
40966
+ this.GetMaxMin=function()
40967
+ {
40968
+ this.IsHScreen=(this.ChartFrame.IsHScreen===true);
40969
+ var range={ Min:null, Max:null };
40970
+ if(!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return range;
40971
+ if (!this.MapCache || this.MapCache.size<=0) return;
40972
+ var xPointCount=this.ChartFrame.XPointCount;
40973
+
40974
+ for(var i=this.Data.DataOffset,j=0, k=0;i<this.Data.Data.length && j<xPointCount;++i,++j)
40975
+ {
40976
+ var kItem=this.Data.Data[i];
40977
+ var key=this.BuildKey(kItem);
40978
+ if (!this.MapCache.has(key)) continue;
40979
+ var mapItem=this.MapCache.get(key);
40980
+ if (!IFrameSplitOperator.IsNonEmptyArray(mapItem.Data)) continue;
40981
+
40982
+ for(k=0;k<mapItem.Data.length;++k)
40983
+ {
40984
+ var item=mapItem.Data[k];
40985
+ var value=item.Value;
40986
+ if (IFrameSplitOperator.IsString(item.Value)) value=this.GetKValue(kItem,item.Value);
40987
+ if (!IFrameSplitOperator.IsNumber(value)) continue;
40988
+
40989
+ if (range.Max==null) range.Max=value;
40990
+ else if (range.Max<value) range.Max=value;
40991
+ if (range.Min==null) range.Min=value;
40992
+ else if (range.Min>value) range.Min=value;
40993
+ }
40994
+ }
40995
+
40996
+ return range;
40997
+ }
40998
+ }
40999
+
40705
41000
  // 多dom节点
40706
41001
  function ChartMultiHtmlDom()
40707
41002
  {
@@ -77072,6 +77367,8 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
77072
77367
 
77073
77368
  if (this.EnableScrollUpDown==false)
77074
77369
  T_ShowCorssCursor(); //移动十字光标
77370
+ else if (this.IsClickShowCorssCursor)
77371
+ T_ShowCorssCursor();
77075
77372
  }
77076
77373
 
77077
77374
  if (this.EnableZoomIndexWindow)
@@ -114178,7 +114475,7 @@ function ScriptIndex(name,script,args,option)
114178
114475
 
114179
114476
  this.CreateMultiSVGIcon=function(hqChart,windowIndex,varItem,i)
114180
114477
  {
114181
- let chart=new ChartMultiSVGIcon();
114478
+ let chart=new ChartMultiSVGIconV2();
114182
114479
  chart.Canvas=hqChart.Canvas;
114183
114480
  chart.Name=varItem.Name;
114184
114481
  chart.ChartBorder=hqChart.Frame.SubFrame[windowIndex].Frame.ChartBorder;
@@ -114186,7 +114483,8 @@ function ScriptIndex(name,script,args,option)
114186
114483
 
114187
114484
  chart.Data=hqChart.ChartPaint[0].Data;//绑定K线
114188
114485
  chart.Family=varItem.Draw.DrawData.Family;
114189
- chart.Icon= varItem.Draw.DrawData.Icon;
114486
+ chart.AryIcon= varItem.Draw.DrawData.Icon;
114487
+ chart.BuildCacheData();
114190
114488
  hqChart.ChartPaint.push(chart);
114191
114489
  }
114192
114490
 
@@ -115842,7 +116140,7 @@ function OverlayScriptIndex(name,script,args,option)
115842
116140
  {
115843
116141
  var overlayIndex=this.OverlayIndex;
115844
116142
  var frame=overlayIndex.Frame;
115845
- let chart=new ChartMultiSVGIcon();
116143
+ let chart=new ChartMultiSVGIconV2();
115846
116144
  chart.Canvas=hqChart.Canvas;
115847
116145
  chart.Name=varItem.Name;
115848
116146
  chart.ChartBorder=frame.Frame.ChartBorder;
@@ -115851,7 +116149,8 @@ function OverlayScriptIndex(name,script,args,option)
115851
116149
 
115852
116150
  chart.Data=hqChart.ChartPaint[0].Data;//绑定K线
115853
116151
  chart.Family=varItem.Draw.DrawData.Family;
115854
- chart.Icon= varItem.Draw.DrawData.Icon;
116152
+ chart.AryIcon= varItem.Draw.DrawData.Icon;
116153
+ chart.BuildCacheData();
115855
116154
  frame.ChartPaint.push(chart);
115856
116155
  }
115857
116156
 
@@ -116941,8 +117240,7 @@ function APIScriptIndex(name,script,args,option, isOverlay)
116941
117240
  drawItem.Text=draw.Text;
116942
117241
  drawItem.Name=draw.Name;
116943
117242
  drawItem.DrawType=draw.DrawType;
116944
- drawItem.DrawData={ Icon:this.FittingMultiText(draw.DrawData.Icon,date,time,hqChart), Family:draw.DrawData.Family };
116945
- this.GetKLineData(drawItem.DrawData.Icon, hqChart);
117243
+ drawItem.DrawData={ Icon:draw.DrawData.Icon, Family:draw.DrawData.Family };
116946
117244
  outVarItem.Draw=drawItem;
116947
117245
 
116948
117246
  result.push(outVarItem);
@@ -117342,8 +117640,7 @@ function APIScriptIndex(name,script,args,option, isOverlay)
117342
117640
  drawItem.Text=draw.Text;
117343
117641
  drawItem.Name=draw.Name;
117344
117642
  drawItem.DrawType=draw.DrawType;
117345
- drawItem.DrawData={ Icon:this.FittingMultiText(draw.DrawData.Icon,date,time,hqChart), Family:draw.DrawData.Family };
117346
- this.GetKLineData(drawItem.DrawData.Icon, hqChart);
117643
+ drawItem.DrawData={ Icon:draw.DrawData.Icon, Family:draw.DrawData.Family };
117347
117644
  outVarItem.Draw=drawItem;
117348
117645
 
117349
117646
  result.push(outVarItem);
@@ -129715,7 +130012,7 @@ function HQChartScriptWorker()
129715
130012
 
129716
130013
 
129717
130014
 
129718
- var HQCHART_VERSION="1.1.13002";
130015
+ var HQCHART_VERSION="1.1.13013";
129719
130016
 
129720
130017
  function PrintHQChartVersion()
129721
130018
  {