hqchart 1.1.14299 → 1.1.14307

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.
@@ -35732,109 +35732,156 @@ function ChartSimpleTable()
35732
35732
 
35733
35733
 
35734
35734
  //饼图
35735
- function ChartPie()
35735
+ function ChartSimplePie()
35736
35736
  {
35737
35737
  this.newMethod=IChartPainting; //派生
35738
35738
  this.newMethod();
35739
35739
  delete this.newMethod;
35740
35740
 
35741
- this.Radius = 100; //半径默认值
35742
- this.Width=40;
35743
- this.Height=50;
35744
-
35745
- //this.Distance = 30; //指示线超出圆饼的距离
35746
- //this.txtLine = 20; // 文本下划线
35747
- //this.paddingX = 20 / 3;// 设置文本的移动
35748
-
35741
+ this.ClassName='ChartSimplePie'; //类名
35749
35742
 
35743
+ this.BorderColor=g_JSChartResource.ChartSimplePie.BorderColor;
35744
+ this.Offset=CloneData(g_JSChartResource.ChartSimplePie.Offset);
35745
+ this.LineExtendWidth=10;
35746
+ this.TextFontConfig=CloneData(g_JSChartResource.ChartSimplePie.TextFont);
35750
35747
 
35751
35748
  this.RectClient={ };
35752
-
35753
- this.Draw=function()
35749
+ this.TotalValue=1;
35750
+ this.Radius = 50; //半径默认值
35751
+ this.TextFont;
35752
+
35753
+
35754
+ this.ReloadResource=function(resource)
35754
35755
  {
35755
- if (!this.Data || !this.Data.Data || !(this.Data.Data.length>0)) return this.DrawEmptyData();
35756
+ this.BorderColor=g_JSChartResource.ChartSimplePie.BorderColor;
35757
+ this.Offset=CloneData(g_JSChartResource.ChartSimplePie.Offset);
35758
+ this.TextFontConfig=CloneData(g_JSChartResource.ChartSimplePie.TextFont);
35759
+ }
35756
35760
 
35761
+ this.CalculateSize=function()
35762
+ {
35763
+ var border=this.ChartFrame.GetBorder();
35764
+ var pixelRatio=GetDevicePixelRatio();
35765
+ this.TextFont=`${this.TextFontConfig.Size*pixelRatio}px ${ this.TextFontConfig.Name}`;
35766
+ this.LineExtendWidth=this.GetFontHeight(this.TextFont,"擎")+1;
35757
35767
 
35758
35768
 
35759
- let left=this.ChartBorder.GetLeft();
35760
- let right=this.ChartBorder.GetRight();
35761
- let top=this.ChartBorder.GetTop();
35762
- let bottom=this.ChartBorder.GetBottom();
35763
- let width=this.ChartBorder.GetWidth();
35764
- let height=this.ChartBorder.GetHeight();
35769
+ this.RectClient={ Width:this.Radius*2*pixelRatio, Height:this.Radius*2*pixelRatio };
35765
35770
 
35766
- if(isNaN(this.Radius)){
35767
- let str = this.Radius.replace("%","");
35768
- str = str/100;
35769
- if(width >= height){
35770
- this.Radius = str*height;
35771
- }
35772
- if(width < height) this.Radius = str*width;
35771
+ this.RectClient.Right=border.Right+this.Offset.X;
35772
+ this.RectClient.Top=border.TopEx+this.Offset.Y;
35773
+ this.RectClient.Left=this.RectClient.Right-this.RectClient.Width;
35774
+ this.RectClient.Bottom=this.RectClient.Top+this.RectClient.Height;
35775
+ }
35776
+
35777
+ this.CalculateTotalValue=function()
35778
+ {
35779
+ var totalValue=0;
35780
+ for(var i=0; i<this.Data.Data.length; ++i)
35781
+ {
35782
+ var item=this.Data.Data[i];
35783
+ if (!IFrameSplitOperator.IsPlusNumber(item.Value)) continue;
35784
+ totalValue += item.Value;
35773
35785
  }
35774
35786
 
35787
+ this.TotalValue=totalValue;
35788
+ }
35775
35789
 
35776
- this.Canvas.save();
35777
- this.Canvas.translate(width/2,height/2);
35790
+ this.DrawPie=function()
35791
+ {
35792
+ this.Canvas.font=this.TextFont;
35793
+ this.Canvas.textBaseline='bottom';
35794
+ this.Canvas.textAlign = 'left';
35778
35795
 
35779
- let totalValue=0; //求和
35780
- for(let i in this.Data.Data)
35796
+ var aryText=[];
35797
+ var maxTextWidth=0;
35798
+ for(var i=0;i<this.Data.Data.length;++i)
35781
35799
  {
35782
- totalValue += this.Data.Data[i].Value;
35800
+ var item=this.Data.Data[i];
35801
+ if (!IFrameSplitOperator.IsPlusNumber(item.Value)) continue;
35802
+ if (!item.Text) continue;
35803
+ var textWidth=this.Canvas.measureText(item.Text).width;
35804
+
35805
+ aryText[i]={ Width:textWidth };
35806
+
35807
+ if (maxTextWidth<textWidth) maxTextWidth=textWidth;
35783
35808
  }
35784
- let start = 0;
35785
- let end = 0;
35786
- //画饼图
35787
- for(let i in this.Data.Data)
35809
+
35810
+ var xOffset=maxTextWidth+this.LineExtendWidth;
35811
+ this.RectClient.Left-=xOffset;
35812
+ this.RectClient.Right-=xOffset;
35813
+
35814
+
35815
+ var start=0, end=0;
35816
+ var x=this.RectClient.Left+this.Radius;
35817
+ var y=this.RectClient.Top+this.Radius;
35818
+
35819
+ for(var i=0;i<this.Data.Data.length;++i)
35788
35820
  {
35789
- let item =this.Data.Data[i];
35790
- let rate=(item.Value/totalValue).toFixed(2); //占比
35791
- //JSConsole.Chart.Log('[ChartPie::Draw]', i, rate, item);
35821
+ var item=this.Data.Data[i];
35822
+ if (!IFrameSplitOperator.IsPlusNumber(item.Value)) continue;
35823
+
35824
+ var rate=item.Value/this.TotalValue;
35792
35825
 
35793
35826
  // 绘制扇形
35794
35827
  this.Canvas.beginPath();
35795
- this.Canvas.moveTo(0,0);
35796
-
35828
+ this.Canvas.moveTo(x,y);
35829
+
35797
35830
  end += rate*2*Math.PI;//终止角度
35798
- this.Canvas.strokeStyle = "white";
35831
+ this.Canvas.strokeStyle = this.BorderColor;
35799
35832
  this.Canvas.fillStyle = item.Color;
35800
- this.Canvas.arc(0,0,this.Radius,start,end);
35833
+ this.Canvas.arc(x,y,this.Radius,start,end);
35801
35834
  this.Canvas.fill();
35802
35835
  this.Canvas.closePath();
35803
- this.Canvas.stroke();
35804
-
35805
- // 绘制直线
35806
- this.Canvas.beginPath();
35807
- this.Canvas.strokeStyle = item.Color;
35808
- this.Canvas.moveTo(0,0);
35809
- let x = (this.Radius + this.Distance)*Math.cos(end- (end-start)/2);
35810
- let y = (this.Radius + this.Distance)*Math.sin(end - (end-start)/2);
35811
- this.Canvas.lineTo(x,y);
35812
- // JSConsole.Chart.Log(x,y,"xy")
35813
-
35814
- // 绘制横线
35815
- let txtLine = this.txtLine;
35816
- let paddingX = this.paddingX;
35817
- this.Canvas.textAlign = 'left';
35818
- if( end - (end-start)/2 < 1.5*Math.PI && end - (end-start)/2 > 0.5*Math.PI ){
35819
-
35820
- txtLine = - this.txtLine;
35821
- paddingX = - this.paddingX;
35822
- this.Canvas.textAlign = 'right';
35823
- }
35824
- this.Canvas.lineTo( x + txtLine, y );
35825
35836
  this.Canvas.stroke();
35826
35837
 
35827
- // 写文字
35828
- if(item.Text){
35829
- this.Canvas.fillText( item.Text, x + txtLine + paddingX, y );
35830
- }else{
35831
- let text = `${item.Name}:${item.Value}`;
35832
- this.Canvas.fillText( text, x + txtLine + paddingX, y );
35833
- }
35834
-
35838
+ if (item.Text)
35839
+ {
35840
+ // 绘制直线
35841
+ var xLine=this.Radius*Math.cos(end- (end-start)/2)+x;
35842
+ var yLine=this.Radius*Math.sin(end - (end-start)/2)+y;
35843
+ var xEnd = (this.Radius + this.LineExtendWidth)*Math.cos(end- (end-start)/2)+x;
35844
+ var yEnd = (this.Radius + this.LineExtendWidth)*Math.sin(end - (end-start)/2)+y;
35845
+
35846
+ this.Canvas.beginPath();
35847
+ if (item.LineColor) this.Canvas.strokeStyle =item.LineColor;
35848
+ else this.Canvas.strokeStyle = item.Color;
35849
+ this.Canvas.moveTo(xLine,yLine);
35850
+ this.Canvas.lineTo(xEnd,yEnd);
35851
+
35852
+ var textWidth=aryText[i].Width;
35853
+ var yText=xEnd;
35854
+ if( end - (end-start)/2 < 1.5*Math.PI && end - (end-start)/2 > 0.5*Math.PI )
35855
+ {
35856
+ this.Canvas.lineTo( xEnd - textWidth, yEnd );
35857
+ yText=xEnd - textWidth;
35858
+ }
35859
+ else
35860
+ {
35861
+ this.Canvas.lineTo( xEnd + textWidth, yEnd );
35862
+ }
35863
+ this.Canvas.stroke();
35864
+
35865
+ if (item.TextColor) this.Canvas.fillStyle = item.TextColor;
35866
+ else this.Canvas.fillStyle=item.Color;
35867
+ this.Canvas.fillText(item.Text, yText, yEnd);
35868
+ }
35835
35869
 
35836
35870
  start += rate*2*Math.PI;//起始角度
35837
35871
  }
35872
+ }
35873
+
35874
+ this.Draw=function()
35875
+ {
35876
+ if (!this.Data || !this.Data.Data || !(this.Data.Data.length>0)) return this.DrawEmptyData();
35877
+
35878
+ this.CalculateTotalValue();
35879
+ if (!IFrameSplitOperator.IsPlusNumber(this.TotalValue)) this.DrawEmptyData();
35880
+ this.CalculateSize();
35881
+
35882
+ this.Canvas.save();
35883
+
35884
+ this.DrawPie();
35838
35885
 
35839
35886
  this.Canvas.restore();
35840
35887
  }
@@ -35842,7 +35889,7 @@ function ChartPie()
35842
35889
  //空数据
35843
35890
  this.DrawEmptyData=function()
35844
35891
  {
35845
- JSConsole.Chart.Log('[ChartPie::DrawEmptyData]')
35892
+ JSConsole.Chart.Log('[ChartSimplePie::DrawEmptyData]')
35846
35893
  }
35847
35894
 
35848
35895
  this.GetMaxMin=function()
@@ -40408,6 +40455,7 @@ function ChartMinutePriceLine()
40408
40455
  var pointCount=0;
40409
40456
 
40410
40457
  this.Canvas.save();
40458
+ this.ClipClient(isHScreen);
40411
40459
  if (IFrameSplitOperator.IsPlusNumber(this.LineWidth>0)) this.Canvas.lineWidth=this.LineWidth;
40412
40460
  for(var i=data.DataOffset,j=0;i<data.Data.length && j<xPointCount;++i,++j)
40413
40461
  {
@@ -43913,8 +43961,8 @@ function ChartTextLine()
43913
43961
 
43914
43962
  this.ClassName="ChartTextLine";
43915
43963
 
43916
- this.Text; //Text=内容 Color
43917
- this.Line; //Type=线段类型 0=不画 1=直线 2=虚线, Color
43964
+ this.Text; //{ Title:内容, Color: YOffset:, }
43965
+ this.Line; //{ Type=线段类型 0=不画 1=直线 2=虚线, Color:, Width:, LineDash:[] }
43918
43966
  this.Price;
43919
43967
 
43920
43968
  this.Draw=function()
@@ -43928,6 +43976,10 @@ function ChartTextLine()
43928
43976
  var bottom=this.ChartBorder.GetBottomEx();
43929
43977
  var top=this.ChartBorder.GetTopEx();
43930
43978
  var y=this.ChartFrame.GetYFromData(this.Price);
43979
+
43980
+ this.Canvas.save();
43981
+ this.ClipClient(this.IsHScreen);
43982
+
43931
43983
  var textWidth=0;
43932
43984
  if (this.Text.Title)
43933
43985
  {
@@ -43957,23 +44009,22 @@ function ChartTextLine()
43957
44009
  {
43958
44010
  if (this.Line.Type==2) //虚线
43959
44011
  {
43960
- this.Canvas.save();
43961
- this.Canvas.setLineDash([3,5]); //虚线
44012
+ if (IFrameSplitOperator.IsNonEmptyArray(this.Line.LineDash)) this.Canvas.setLineDash(this.Line.LineDash)
44013
+ else this.Canvas.setLineDash([3,5]); //虚线
43962
44014
  }
43963
44015
 
44016
+ if (IFrameSplitOperator.IsNumber(this.Line.Width)) this.Canvas.lineWidth=this.Line.Width;
44017
+
43964
44018
  var x=left+textWidth;
43965
44019
  this.Canvas.strokeStyle=this.Line.Color;
43966
44020
  this.Canvas.beginPath();
43967
44021
  this.Canvas.moveTo(x,ToFixedPoint(y));
43968
44022
  this.Canvas.lineTo(right,ToFixedPoint(y));
43969
44023
  this.Canvas.stroke();
43970
-
43971
- if (this.Line.Type==2)
43972
- {
43973
- this.Canvas.restore();
43974
- }
43975
44024
  }
43976
44025
 
44026
+
44027
+ this.Canvas.restore();
43977
44028
  }
43978
44029
 
43979
44030
  this.GetMaxMin=function()
@@ -45375,6 +45426,7 @@ function ChartDrawSVG()
45375
45426
  this.Family;
45376
45427
  this.TextFont;
45377
45428
  this.Texts=[]; //[ { Index:, Value:, Symbol:, Text:, Size: } ] SVG:图标 Text:文字 Size:图标大小
45429
+ //this.Data; 存K线数据
45378
45430
  this.IsHScreen=false; //是否横屏
45379
45431
  this.IsDestroy=false; //是否已销毁
45380
45432
  this.EnableTooltip=true;
@@ -45384,8 +45436,38 @@ function ChartDrawSVG()
45384
45436
 
45385
45437
  this.AryDrawRect=[]; //已经绘制的区域
45386
45438
  this.AutoYOffset=0;
45387
-
45388
- //this.Data; 存K线数据
45439
+
45440
+ this.BuildKeyCallback=null;
45441
+ this.MapCache=null; //key=date/date-time value={ Data:[] }
45442
+
45443
+ this.BuildKey=function(item)
45444
+ {
45445
+ if (this.BuildKeyCallback) return this.BuildKeyCallback(item);
45446
+
45447
+ if (IFrameSplitOperator.IsNumber(item.Time)) return `${item.Date}-${item.Time}`;
45448
+ else return `${item.Date}`;
45449
+ }
45450
+
45451
+ this.BuildCacheData=function()
45452
+ {
45453
+ var mapData=new Map();
45454
+ this.MapCache=mapData;
45455
+ for(var i=0; i<this.Texts.length;++i)
45456
+ {
45457
+ var item=this.Texts[i];
45458
+ var key=this.BuildKey(item);
45459
+
45460
+ if (mapData.has(key))
45461
+ {
45462
+ var mapItem=mapData.get(key);
45463
+ mapItem.Data.push(item);
45464
+ }
45465
+ else
45466
+ {
45467
+ mapData.set(key,{ Date:item.Date, Time:item.Time, Data:[item] });
45468
+ }
45469
+ }
45470
+ }
45389
45471
 
45390
45472
  this.Draw=function()
45391
45473
  {
@@ -45396,8 +45478,9 @@ function ChartDrawSVG()
45396
45478
  if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
45397
45479
  if (this.IsShowIndexTitleOnly()) return;
45398
45480
  if (this.IsHideScriptIndex()) return;
45481
+ if (!this.MapCache || this.MapCache.size<=0) return;
45399
45482
 
45400
- this.DrawSVG();
45483
+ this.DrawSVGV2();
45401
45484
  }
45402
45485
 
45403
45486
  this.DrawDetail=function(rtSVG, data, svgItem)
@@ -45626,6 +45709,221 @@ function ChartDrawSVG()
45626
45709
  return false;
45627
45710
  }
45628
45711
 
45712
+ this.GetKValue=function(kItem, valueName)
45713
+ {
45714
+ switch(valueName)
45715
+ {
45716
+ case "HIGH":
45717
+ case "H":
45718
+ return kItem.High;
45719
+ case "L":
45720
+ case "LOW":
45721
+ return kItem.Low;
45722
+ case "C":
45723
+ case "CLOSE":
45724
+ return kItem.Close;
45725
+ case "O":
45726
+ case "OPEN":
45727
+ return KItem.Open;
45728
+ default:
45729
+ return null;
45730
+ }
45731
+ }
45732
+
45733
+ this.DrawSVGV2=function()
45734
+ {
45735
+ if (!this.IsShow || this.ChartFrame.IsMinSize) return;
45736
+ if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
45737
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Texts)) return;
45738
+ if (!this.Family) return;
45739
+
45740
+ this.IsHScreen=(this.ChartFrame.IsHScreen===true);
45741
+ if (this.IsHScreen) return;
45742
+
45743
+ var xPointCount=this.ChartFrame.XPointCount;
45744
+ var dataWidth=this.ChartFrame.DataWidth;
45745
+ var distanceWidth=this.ChartFrame.DistanceWidth;
45746
+ var isMinute=this.IsMinuteFrame();
45747
+ var border=this.GetBorder();
45748
+ var pixelRatio = GetDevicePixelRatio();
45749
+
45750
+ if (this.IsHScreen)
45751
+ {
45752
+
45753
+ }
45754
+ else
45755
+ {
45756
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
45757
+ var chartright=border.RightEx;
45758
+ var chartLeft=border.LeftEx;
45759
+ }
45760
+
45761
+ var x,y,price;
45762
+ for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
45763
+ {
45764
+ var kItem=this.Data.Data[i];
45765
+ var key=this.BuildKey(kItem);
45766
+ if (!this.MapCache.has(key)) continue;
45767
+ var mapItem=this.MapCache.get(key);
45768
+
45769
+ if (isMinute)
45770
+ {
45771
+ x=this.ChartFrame.GetXFromIndex(j);
45772
+ }
45773
+ else
45774
+ {
45775
+ var left=xOffset;
45776
+ var right=xOffset+dataWidth;
45777
+ if (right>chartright) break;
45778
+ x=left+(right-left)/2;
45779
+ }
45780
+
45781
+ for(var j=0;j<mapItem.Data.length;++j)
45782
+ {
45783
+ var item=mapItem.Data[j];
45784
+
45785
+ if (item.Value=="Top") y=top;
45786
+ else if (item.Value=="Bottom") y=bottom;
45787
+ else
45788
+ {
45789
+ if (IFrameSplitOperator.IsString(item.Value)) price=this.GetKValue(kItem,item.Value);
45790
+ else price=item.Value;
45791
+
45792
+ y=this.ChartFrame.GetYFromData(price, false);
45793
+ }
45794
+ if (IFrameSplitOperator.IsNumber(item.YOffset)) y+=item.YOffset; //Y轴偏移
45795
+
45796
+ var svgItem=item.SVG;
45797
+ if (IFrameSplitOperator.IsNumber(svgItem.YOffset)) y+=svgItem.YOffset;
45798
+
45799
+ if (this.AutoPosition)
45800
+ {
45801
+ var pt={ X:x, Y:y };
45802
+ this.CalculateShowPosition(item, pt); //重新计算位置
45803
+ x=pt.X;
45804
+ y=pt.Y;
45805
+ }
45806
+
45807
+ var fontSVG=`${svgItem.Size}px ${this.Family}`;
45808
+ this.Canvas.font=fontSVG;
45809
+ var halfSize=svgItem.Size/2;
45810
+ var textBaseline='bottom';
45811
+ var rtSVG={ Left:x-halfSize, Right:x+halfSize, Top:y-svgItem.Size, Bottom:y, Height:svgItem.Size, Width:svgItem.Size };
45812
+ if (svgItem.VAlign===0)
45813
+ {
45814
+ textBaseline="top";
45815
+ rtSVG.Top=y;
45816
+ rtSVG.Bottom=rtSVG.Top+svgItem.Size;
45817
+ }
45818
+ else if (svgItem.VAlign===1)
45819
+ {
45820
+ textBaseline='middle';
45821
+ rtSVG.Top=y-svgItem.Size/2;
45822
+ rtSVG.Bottom=rtSVG.Top+svgItem.Size;
45823
+ }
45824
+
45825
+ if (rtSVG.Top<0)
45826
+ {
45827
+ rtSVG.Top=0;
45828
+ rtSVG.Bottom=svgItem.Size;
45829
+ y=rtSVG.Bottom;
45830
+ }
45831
+
45832
+ this.Canvas.textBaseline=textBaseline;
45833
+ this.Canvas.textAlign='center';
45834
+ this.Canvas.fillStyle = svgItem.Color;
45835
+ this.Canvas.fillText(svgItem.Symbol, x, y);
45836
+
45837
+ this.AryDrawRect.push( {Left:rtSVG.Left, Top:rtSVG.Top, Right:rtSVG.Right, Bottom:rtSVG.Bottom, Type:"SVG", Data:item } );
45838
+
45839
+ if (this.EnableTooltip) this.TooltipRect.push({ Rect:rtSVG, Index:i, Item:item });
45840
+
45841
+ //文字
45842
+ if (item.Text && item.Text.Content && this.TextFont)
45843
+ {
45844
+ var textItem=item.Text;
45845
+ this.Canvas.font=this.TextFont;
45846
+ this.Canvas.fillStyle=textItem.Color;
45847
+ var yText=y;
45848
+ if (IFrameSplitOperator.IsNumber(textItem.YOffset)) yText+=textItem.YOffset;
45849
+ this.Canvas.fillText(textItem.Content, x, yText);
45850
+ }
45851
+
45852
+ if (item.Detail)
45853
+ {
45854
+ this.DrawDetail(rtSVG,item.Detail, item);
45855
+ }
45856
+
45857
+ //连线
45858
+ if (item.Line)
45859
+ {
45860
+ var lineItem=item.Line;
45861
+ var price=null, yPrice=null;
45862
+ if (lineItem.Value=="Bottom")
45863
+ {
45864
+ yPrice=bottom;
45865
+ }
45866
+ else if (lineItem.Value=="Top")
45867
+ {
45868
+ yPrice=top;
45869
+ }
45870
+ else
45871
+ {
45872
+ if (IFrameSplitOperator.IsString(lineItem.Value))
45873
+ price=this.GetKValue(kItem,lineItem.Value);
45874
+
45875
+ if (!IFrameSplitOperator.IsNumber(price)) continue;
45876
+ yPrice=this.ChartFrame.GetYFromData(price);
45877
+ }
45878
+
45879
+ if (yPrice>=rtSVG.Top && yPrice<=rtSVG.Bottom) continue;
45880
+
45881
+ var yText;
45882
+ if (yPrice<rtSVG.Top)
45883
+ {
45884
+ yText=rtSVG.Top;
45885
+ if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
45886
+ {
45887
+ //yPrice+=lineItem.Blank;
45888
+ yText-=lineItem.SVGBlank;
45889
+ }
45890
+ }
45891
+ else
45892
+ {
45893
+ yText=rtSVG.Bottom;
45894
+ if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
45895
+ {
45896
+ //yPrice-=lineItem.Blank;
45897
+ yText+=lineItem.SVGBlank;
45898
+ }
45899
+ }
45900
+
45901
+ if (lineItem.Dash) this.Canvas.setLineDash(lineItem.Dash); //虚线
45902
+ var lineWidth=1*pixelRatio;
45903
+ if (lineItem.Width>0) lineWidth=lineItem.Width*pixelRatio;
45904
+ this.Canvas.lineWidth=lineWidth; //线宽
45905
+ this.Canvas.strokeStyle = lineItem.Color;
45906
+ this.Canvas.beginPath();
45907
+
45908
+ if (this.IsHScreen)
45909
+ {
45910
+ this.Canvas.moveTo(yText, ToFixedPoint(x));
45911
+ this.Canvas.lineTo(yPrice,ToFixedPoint(x));
45912
+ }
45913
+ else
45914
+ {
45915
+ this.Canvas.moveTo(ToFixedPoint2(lineWidth,x),yText);
45916
+ this.Canvas.lineTo(ToFixedPoint2(lineWidth,x),yPrice);
45917
+ }
45918
+
45919
+ this.Canvas.stroke();
45920
+ this.Canvas.setLineDash([]);
45921
+ }
45922
+ }
45923
+ }
45924
+ }
45925
+
45926
+ /*
45629
45927
  this.DrawSVG=function()
45630
45928
  {
45631
45929
  if (!this.IsShow || this.ChartFrame.IsMinSize) return;
@@ -45800,26 +46098,35 @@ function ChartDrawSVG()
45800
46098
  }
45801
46099
  }
45802
46100
  }
46101
+ */
45803
46102
 
45804
46103
  this.GetMaxMin=function()
45805
46104
  {
46105
+ this.IsHScreen=(this.ChartFrame.IsHScreen===true);
45806
46106
  var range={ Min:null, Max:null };
46107
+ if(!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return range;
46108
+ if (!this.MapCache || this.MapCache.size<=0) return;
45807
46109
  var xPointCount=this.ChartFrame.XPointCount;
45808
- var start=this.Data.DataOffset;
45809
- var end=start+xPointCount;
45810
- if (!IFrameSplitOperator.IsNonEmptyArray(this.Texts)) return range;
45811
46110
 
45812
- for(var i=0; i<this.Texts.length; ++i)
46111
+ for(var i=this.Data.DataOffset,j=0, k=0;i<this.Data.Data.length && j<xPointCount;++i,++j)
45813
46112
  {
45814
- var item=this.Texts[i];
45815
- if (!IFrameSplitOperator.IsNumber(item.Index)) continue;
45816
- if (item.Index>=start && item.Index<end)
46113
+ var kItem=this.Data.Data[i];
46114
+ var key=this.BuildKey(kItem);
46115
+ if (!this.MapCache.has(key)) continue;
46116
+ var mapItem=this.MapCache.get(key);
46117
+ if (!IFrameSplitOperator.IsNonEmptyArray(mapItem.Data)) continue;
46118
+
46119
+ for(k=0;k<mapItem.Data.length;++k)
45817
46120
  {
45818
- if(!IFrameSplitOperator.IsNumber(item.Value)) continue;
45819
- if (range.Max==null) range.Max=item.Value;
45820
- else if (range.Max<item.Value) range.Max=item.Value;
45821
- if (range.Min==null) range.Min=item.Value;
45822
- else if (range.Min>item.Value) range.Min=item.Value;
46121
+ var item=mapItem.Data[k];
46122
+ var value=item.Value;
46123
+ if (IFrameSplitOperator.IsString(item.Value)) value=this.GetKValue(kItem,item.Value);
46124
+ if (!IFrameSplitOperator.IsNumber(value)) continue;
46125
+
46126
+ if (range.Max==null) range.Max=value;
46127
+ else if (range.Max<value) range.Max=value;
46128
+ if (range.Min==null) range.Min=value;
46129
+ else if (range.Min>value) range.Min=value;
45823
46130
  }
45824
46131
  }
45825
46132
 
@@ -45835,11 +46142,10 @@ function ChartDrawSVG()
45835
46142
  var item=this.TooltipRect[i];
45836
46143
  if (!item.Rect) continue;
45837
46144
  var rect=item.Rect;
45838
- this.Canvas.beginPath();
45839
- this.Canvas.rect(rect.Left,rect.Top,rect.Width,rect.Height);
45840
- if (this.Canvas.isPointInPath(x,y))
46145
+
46146
+ if (x>=rect.Left && x<=rect.Right && y>=rect.Top && y<=rect.Bottom)
45841
46147
  {
45842
- var data=this.Texts[item.Index];
46148
+ var data=item.Item;
45843
46149
  JSConsole.Chart.Log('[ChartDrawSVG::GetTooltipData] svg icon.', item);
45844
46150
  tooltip.Data={ Rect:item.Rect, Item:data, Index:item.Index };
45845
46151
  tooltip.ChartPaint=this;
@@ -74462,6 +74768,13 @@ function JSChartResource()
74462
74768
  BorderColor:"rgb(217,217,217)",
74463
74769
  }
74464
74770
 
74771
+ this.ChartSimplePie=
74772
+ {
74773
+ TextFont:{ Family:'微软雅黑' , Size:12 },
74774
+ BorderColor:"rgb(169,169,169)",
74775
+ Offset:{ X:-5, Y:5 }
74776
+ }
74777
+
74465
74778
  //手机端tooltip
74466
74779
  this.TooltipPaint = {
74467
74780
  BGColor:'rgba(250,250,250,0.8)', //背景色
@@ -75691,6 +76004,7 @@ function JSChartResource()
75691
76004
  }
75692
76005
 
75693
76006
  if (style.ChartSimpleTable) this.SetChartSimpleTable(style.ChartSimpleTable);
76007
+ if (style.ChartSimplePie) this.SetChartSimplePie(style.ChartSimplePie);
75694
76008
 
75695
76009
  if (style.DRAWICON)
75696
76010
  {
@@ -76763,6 +77077,27 @@ function JSChartResource()
76763
77077
  }
76764
77078
  }
76765
77079
 
77080
+ this.SetChartSimplePie=function(style)
77081
+ {
77082
+ var dest=this.ChartSimplePie;
77083
+
77084
+ if (style.TextFont)
77085
+ {
77086
+ var item=style.TextFont;
77087
+ if (item.Name) dest.TextFont.Name=item.Name;
77088
+ if (IFrameSplitOperator.IsNumber(item.Size)) dest.TextFont.Size=item.Size;
77089
+ }
77090
+
77091
+ if (style.BorderColor) dest.BorderColor=style.BorderColor;
77092
+
77093
+ if (style.Offset)
77094
+ {
77095
+ var item=style.Offset;
77096
+ if (IFrameSplitOperator.IsNumber(item.X)) dest.Offset.X=item.X;
77097
+ if (IFrameSplitOperator.IsNumber(item.Y)) dest.Offset.Y=item.Y;
77098
+ }
77099
+ }
77100
+
76766
77101
  }
76767
77102
 
76768
77103
  var g_JSChartResource=new JSChartResource();
@@ -91691,7 +92026,7 @@ MinuteChartContainer.JsonDataToMinuteData=function(data,isBeforeData)
91691
92026
  return aryMinuteData;
91692
92027
  }
91693
92028
 
91694
- //分钟增量数据 stock: [ { date:, yclose:, yclearing: , minute:[ [],]} 0=日期 1=时间 2=开 3=高 4=低 5=收 6=均价 7=量 8=金额 9=涨幅 10=涨跌 11=领先指标 ]
92029
+ //分钟增量数据 stock: [ { date:, yclose:, yclearing: , minute:[ [],]} 0=日期 1=时间 2=开 3=高 4=低 5=收 6=均价 7=量 8=金额 9=涨幅 10=涨跌 11=领先指标 12=持仓 ]
91695
92030
  MinuteChartContainer.JsonDataToUpdateMinuteData=function(data)
91696
92031
  {
91697
92032
  if (!data || !data.stock) return null;
@@ -91729,16 +92064,17 @@ MinuteChartContainer.JsonDataToUpdateMinuteData=function(data)
91729
92064
  if (IFrameSplitOperator.IsNumber(jsData[9])) item.Increase=jsData[9];
91730
92065
  if (IFrameSplitOperator.IsNumber(jsData[10])) item.Risefall=jsData[10];
91731
92066
  if (IFrameSplitOperator.IsNumber(jsData[11])) item.Lead=jsData[11];
91732
-
92067
+ if (IFrameSplitOperator.IsNumber(jsData[12])) item.Position=jsData[12];
91733
92068
 
91734
92069
  if (jsData[extendDataIndex]) item.ExtendData=jsData[extendDataIndex];
91735
- item.DateTime=item.Date.toString()+" "+item.Time.toString();
92070
+
92071
+ item.DateTime=`${item.Date} ${item.Time}`;
91736
92072
 
91737
92073
  if (IFrameSplitOperator.IsNumber(minuteData.YClose) && item.Close)
91738
- item.Increase=(item.Close-minuteData.YClose)/minuteData.YClose*100; //涨幅 (最新价格-昨收)/昨收*100;
92074
+ item.Increase=(item.Close-minuteData.YClose)/minuteData.YClose*100; //涨幅 (最新价格-昨收)/昨收*100;
91739
92075
 
91740
92076
  if (isFutures && minuteData.YClearing && item.Close)
91741
- item.Increase=(item.Close-minuteData.YClearing)/minuteData.YClearing*100; //涨幅 (最新价格-昨结算价)/昨结算价*100;
92077
+ item.Increase=(item.Close-minuteData.YClearing)/minuteData.YClearing*100; //涨幅 (最新价格-昨结算价)/昨结算价*100;
91742
92078
 
91743
92079
 
91744
92080
  minuteData.Data.push(item);
@@ -111992,6 +112328,30 @@ function JSDraw(errorHandler,symbolData)
111992
112328
 
111993
112329
  return result={ DrawData:{ TableData:tableData }, DrawType:'DRAW_SIMPLE_TABLE' };
111994
112330
  }
112331
+
112332
+ //饼图
112333
+ this.PIE_CELL=function(value, color, text, textColor, lineColor)
112334
+ {
112335
+ var cellItem={ Value:value, Color:color };
112336
+ if (text) cellItem.Text=text;
112337
+ if (textColor) cellItem.TextColor=textColor;
112338
+ if (lineColor) cellItem.LineColor=lineColor;
112339
+
112340
+ return cellItem
112341
+ }
112342
+
112343
+ //0=Radius半径
112344
+ this.DRAWPIE=function(aryData)
112345
+ {
112346
+ var radius=aryData[0];
112347
+ var aryCell=[];
112348
+ for(var i=1;i<aryData.length;++i)
112349
+ {
112350
+ aryCell.push(aryData[i]);
112351
+ }
112352
+
112353
+ return result={ DrawData:{ Data:aryCell, Radius:radius }, DrawType:"DRAW_SIMPLE_PIE" };
112354
+ }
111995
112355
  }
111996
112356
 
111997
112357
 
@@ -112046,7 +112406,7 @@ JSDraw.prototype.IsDrawFunction=function(name)
112046
112406
  'DRAWOVERLAYLINE',"FILLRGN", "FILLRGN2","FILLTOPRGN", "FILLBOTTOMRGN", "FILLVERTICALRGN","FLOATRGN","DRAWSL", "DRAWGBK2","DRAWGBK_DIV",
112047
112407
  "VERTLINE","HORLINE","TIPICON",
112048
112408
  "BUY","SELL","SELLSHORT","BUYSHORT",
112049
- "DRAWLASTBARICON","DRAWLASTBARNUMBER", "DRAWLASTBARTEXT","DRAWTABLE",
112409
+ "DRAWLASTBARICON","DRAWLASTBARNUMBER", "DRAWLASTBARTEXT","DRAWTABLE","DRAWPIE",
112050
112410
  ]);
112051
112411
  if (setFunctionName.has(name)) return true;
112052
112412
 
@@ -118927,6 +119287,14 @@ function JSExecute(ast,option)
118927
119287
  node.Draw=this.Draw.DRAWTABLE(args);
118928
119288
  node.Out=[];
118929
119289
  break;
119290
+ //饼图
119291
+ case "PIE_CELL":
119292
+ node.Out=this.Draw.PIE_CELL(args[0],args[1],args[2],args[3],args[4]);
119293
+ break;
119294
+ case "DRAWPIE":
119295
+ node.Draw=this.Draw.DRAWPIE(args);
119296
+ node.Out=[];
119297
+ break;
118930
119298
 
118931
119299
  default:
118932
119300
  node.Out=this.Algorithm.CallFunction(funcName, args, node, this.SymbolData);
@@ -121920,6 +122288,29 @@ function ScriptIndex(name,script,args,option)
121920
122288
  hqChart.ChartPaint.push(chart);
121921
122289
  }
121922
122290
 
122291
+ this.CreateSimplePie=function(hqChart,windowIndex,varItem,id)
122292
+ {
122293
+ var chart=new ChartSimplePie();
122294
+ chart.Canvas=hqChart.Canvas;
122295
+ chart.Name=varItem.Name;
122296
+ chart.ChartBorder=hqChart.Frame.SubFrame[windowIndex].Frame.ChartBorder;
122297
+ chart.ChartFrame=hqChart.Frame.SubFrame[windowIndex].Frame;
122298
+
122299
+ if (varItem.Draw && varItem.Draw.DrawData)
122300
+ {
122301
+ var drawData=varItem.Draw.DrawData;
122302
+ if (drawData.Data) chart.Data.Data=drawData.Data;
122303
+ if (drawData.BorderColor) chart.BorderColor=drawData.BorderColor;
122304
+ if (drawData.TextFont) chart.TextFontConfig=drawData.TextFont;
122305
+ if (drawData.TextColor) chart.TextColor=drawData.TextColor;
122306
+ if (IFrameSplitOperator.IsNumber(drawData.XOffset)) chart.Offset.X=drawData.XOffset;
122307
+ if (IFrameSplitOperator.IsNumber(drawData.YOffset)) chart.Offset.Y=drawData.YOffset;
122308
+ if (IFrameSplitOperator.IsPlusNumber(drawData.Radius)) chart.Radius=drawData.Radius;
122309
+ }
122310
+
122311
+ hqChart.ChartPaint.push(chart);
122312
+ }
122313
+
121923
122314
  this.CreateTradeIcon=function(hqChart,windowIndex,varItem,id)
121924
122315
  {
121925
122316
  var chart=new ChartTradeIcon();
@@ -122126,11 +122517,12 @@ function ScriptIndex(name,script,args,option)
122126
122517
  for(var j=0;j<drawData.length;++j)
122127
122518
  {
122128
122519
  var item=drawData[j];
122520
+ var kItem=chart.Data.Data[j];
122129
122521
  if (!IFrameSplitOperator.IsNumber(item)) continue;
122130
122522
 
122131
122523
  var svgItem=
122132
122524
  {
122133
- Index:j, Value:item,
122525
+ Value:item, Date:kItem.Date, Time:kItem.Time,
122134
122526
  SVG:{ Symbol:varItem.Draw.Icon.Symbol, Size:svgSize, Color:svgColor, YOffset:svgYOffset, VAlign:svgVAlign }
122135
122527
  };
122136
122528
 
@@ -122150,6 +122542,7 @@ function ScriptIndex(name,script,args,option)
122150
122542
  chart.Texts= aryData;
122151
122543
  }
122152
122544
 
122545
+ chart.BuildCacheData();
122153
122546
  hqChart.ChartPaint.push(chart);
122154
122547
  }
122155
122548
 
@@ -122373,6 +122766,8 @@ function ScriptIndex(name,script,args,option)
122373
122766
  chart.Family=varItem.Draw.DrawData.Family;
122374
122767
  chart.TextFont=varItem.Draw.DrawData.TextFont;
122375
122768
  chart.Texts= varItem.Draw.DrawData.Data;
122769
+ chart.BuildCacheData();
122770
+ this.SetChartIndexName(chart);
122376
122771
  hqChart.ChartPaint.push(chart);
122377
122772
  }
122378
122773
 
@@ -122788,6 +123183,8 @@ function ScriptIndex(name,script,args,option)
122788
123183
  case "DRAW_SIMPLE_TABLE":
122789
123184
  this.CreateSimpleTable(hqChart,windowIndex,item,i);
122790
123185
  break;
123186
+ case "DRAW_SIMPLE_PIE":
123187
+ this.CreateSimplePie(hqChart,windowIndex,item,i);
122791
123188
  case "BUY":
122792
123189
  case "SELL":
122793
123190
  case "SELLSHORT":
@@ -123138,6 +123535,8 @@ function OverlayScriptIndex(name,script,args,option)
123138
123535
  case "DRAW_SIMPLE_TABLE":
123139
123536
  this.CreateSimpleTable(hqChart,windowIndex,item,i);
123140
123537
  break;
123538
+ case "DRAW_SIMPLE_PIE":
123539
+ this.CreateSimplePie(hqChart,windowIndex,item,i);
123141
123540
 
123142
123541
  case "KLINE_BG":
123143
123542
  this.CreateBackgroud(hqChart,windowIndex,item,i);
@@ -123889,11 +124288,12 @@ function OverlayScriptIndex(name,script,args,option)
123889
124288
  for(var j=0;j<drawData.length;++j)
123890
124289
  {
123891
124290
  var item=drawData[j];
124291
+ var kItem=chart.Data.Data[j];
123892
124292
  if (!IFrameSplitOperator.IsNumber(item)) continue;
123893
124293
 
123894
124294
  var svgItem=
123895
124295
  {
123896
- Index:j, Value:item,
124296
+ Value:item, Date:kItem.Date, Time:kItem.Time,
123897
124297
  SVG:{ Symbol:varItem.Draw.Icon.Symbol, Size:svgSize, Color:svgColor, YOffset:svgYOffset, VAlign:svgVAlign }
123898
124298
  };
123899
124299
 
@@ -123913,6 +124313,7 @@ function OverlayScriptIndex(name,script,args,option)
123913
124313
  chart.Texts= aryData;
123914
124314
  }
123915
124315
 
124316
+ chart.BuildCacheData();
123916
124317
  frame.ChartPaint.push(chart);
123917
124318
  }
123918
124319
 
@@ -124124,7 +124525,8 @@ function OverlayScriptIndex(name,script,args,option)
124124
124525
  if (varItem.Draw.AutoPosition) chart.AutoPosition=varItem.Draw.AutoPosition;
124125
124526
 
124126
124527
  this.ReloadChartResource(hqChart, windowIndex, chart);
124127
-
124528
+
124529
+ chart.BuildCacheData();
124128
124530
  this.SetChartIndexName(chart);
124129
124531
  frame.ChartPaint.push(chart);
124130
124532
  }
@@ -124175,6 +124577,33 @@ function OverlayScriptIndex(name,script,args,option)
124175
124577
  frame.ChartPaint.push(chart);
124176
124578
  }
124177
124579
 
124580
+ this.CreateSimplePie=function(hqChart,windowIndex,varItem,id)
124581
+ {
124582
+ var overlayIndex=this.OverlayIndex;
124583
+ var frame=overlayIndex.Frame;
124584
+ var chart=new ChartSimplePie();
124585
+ chart.Canvas=hqChart.Canvas;
124586
+ chart.Name=varItem.Name;
124587
+ chart.ChartBorder=frame.Frame.ChartBorder;
124588
+ chart.ChartFrame=frame.Frame;
124589
+ chart.Identify=overlayIndex.Identify;
124590
+ chart.HQChart=hqChart;
124591
+
124592
+ if (varItem.Draw && varItem.Draw.DrawData)
124593
+ {
124594
+ var drawData=varItem.Draw.DrawData;
124595
+ if (drawData.Data) chart.Data.Data=drawData.Data;
124596
+ if (drawData.BorderColor) chart.BorderColor=drawData.BorderColor;
124597
+ if (drawData.TextFont) chart.TextFontConfig=drawData.TextFont;
124598
+ if (drawData.TextColor) chart.TextColor=drawData.TextColor;
124599
+ if (IFrameSplitOperator.IsNumber(drawData.XOffset)) chart.Offset.X=drawData.XOffset;
124600
+ if (IFrameSplitOperator.IsNumber(drawData.YOffset)) chart.Offset.Y=drawData.YOffset;
124601
+ if (IFrameSplitOperator.IsPlusNumber(drawData.Radius)) chart.Radius=drawData.Radius;
124602
+ }
124603
+
124604
+ frame.ChartPaint.push(chart);
124605
+ }
124606
+
124178
124607
  this.CreateChartVericaltLine=function(hqChart,windowIndex,varItem,id)
124179
124608
  {
124180
124609
  var overlayIndex=this.OverlayIndex;
@@ -125236,8 +125665,7 @@ function APIScriptIndex(name,script,args,option, isOverlay)
125236
125665
  drawItem.Name=draw.Name;
125237
125666
  drawItem.DrawType=draw.DrawType;
125238
125667
  if (draw.AutoPosition) drawItem.AutoPosition=draw.AutoPosition;
125239
- drawItem.DrawData={ Data:this.FittingMultiText(draw.Data,date,time,hqChart), Family:draw.Family, TextFont:draw.TextFont, EnableTooltip:draw.EnableTooltip, IsDrawFirst:draw.IsDrawFirst };
125240
- this.GetKLineData(drawItem.DrawData.Data, hqChart);
125668
+ drawItem.DrawData={ Data:draw.Data, Family:draw.Family, TextFont:draw.TextFont, EnableTooltip:draw.EnableTooltip, IsDrawFirst:draw.IsDrawFirst };
125241
125669
  outVarItem.Draw=drawItem;
125242
125670
 
125243
125671
  result.push(outVarItem);
@@ -125377,6 +125805,17 @@ function APIScriptIndex(name,script,args,option, isOverlay)
125377
125805
  outVarItem.Draw=drawItem;
125378
125806
  result.push(outVarItem);
125379
125807
  }
125808
+ else if (draw.DrawType=="DRAW_SIMPLE_PIE")
125809
+ {
125810
+ drawItem.Name=draw.Name;
125811
+ drawItem.Type=draw.Type;
125812
+
125813
+ drawItem.DrawType=draw.DrawType;
125814
+ drawItem.DrawData=draw.DrawData; //{ Data:[ {Value, Color, Text: }, ], BorderColor:, TextFont:{ Size:, Name: } };
125815
+
125816
+ outVarItem.Draw=drawItem;
125817
+ result.push(outVarItem);
125818
+ }
125380
125819
  else
125381
125820
  {
125382
125821
  var find=g_ScriptIndexChartFactory.Get(draw.DrawType); //外部挂接
@@ -125717,8 +126156,7 @@ function APIScriptIndex(name,script,args,option, isOverlay)
125717
126156
  drawItem.Name=draw.Name;
125718
126157
  drawItem.DrawType=draw.DrawType;
125719
126158
  if (draw.AutoPosition) drawItem.AutoPosition=draw.AutoPosition;
125720
- drawItem.DrawData={ Data:this.FittingMultiText(draw.Data,date,time,hqChart), Family:draw.Family, TextFont:draw.TextFont ,EnableTooltip:draw.EnableTooltip,IsDrawFirst:draw.IsDrawFirst };
125721
- this.GetKLineData(drawItem.DrawData.Data, hqChart);
126159
+ drawItem.DrawData={ Data:draw.Data, Family:draw.Family, TextFont:draw.TextFont , EnableTooltip:draw.EnableTooltip, IsDrawFirst:draw.IsDrawFirst };
125722
126160
  outVarItem.Draw=drawItem;
125723
126161
 
125724
126162
  result.push(outVarItem);
@@ -126988,6 +127426,11 @@ function GetBlackStyle()
126988
127426
  BorderColor:"rgb(90,90,90)",
126989
127427
  },
126990
127428
 
127429
+ ChartSimplePie:
127430
+ {
127431
+ BorderColor:"rgb(220,220,220)",
127432
+ },
127433
+
126991
127434
  ChartDrawVolProfile:
126992
127435
  {
126993
127436
  BGColor:"rgba(244,250,254,0.3)",
@@ -151127,7 +151570,7 @@ function HQChartScriptWorker()
151127
151570
 
151128
151571
 
151129
151572
 
151130
- var HQCHART_VERSION="1.1.14298";
151573
+ var HQCHART_VERSION="1.1.14306";
151131
151574
 
151132
151575
  function PrintHQChartVersion()
151133
151576
  {