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.
@@ -35688,109 +35688,156 @@ function ChartSimpleTable()
35688
35688
 
35689
35689
 
35690
35690
  //饼图
35691
- function ChartPie()
35691
+ function ChartSimplePie()
35692
35692
  {
35693
35693
  this.newMethod=IChartPainting; //派生
35694
35694
  this.newMethod();
35695
35695
  delete this.newMethod;
35696
35696
 
35697
- this.Radius = 100; //半径默认值
35698
- this.Width=40;
35699
- this.Height=50;
35700
-
35701
- //this.Distance = 30; //指示线超出圆饼的距离
35702
- //this.txtLine = 20; // 文本下划线
35703
- //this.paddingX = 20 / 3;// 设置文本的移动
35704
-
35697
+ this.ClassName='ChartSimplePie'; //类名
35705
35698
 
35699
+ this.BorderColor=g_JSChartResource.ChartSimplePie.BorderColor;
35700
+ this.Offset=CloneData(g_JSChartResource.ChartSimplePie.Offset);
35701
+ this.LineExtendWidth=10;
35702
+ this.TextFontConfig=CloneData(g_JSChartResource.ChartSimplePie.TextFont);
35706
35703
 
35707
35704
  this.RectClient={ };
35708
-
35709
- this.Draw=function()
35705
+ this.TotalValue=1;
35706
+ this.Radius = 50; //半径默认值
35707
+ this.TextFont;
35708
+
35709
+
35710
+ this.ReloadResource=function(resource)
35710
35711
  {
35711
- if (!this.Data || !this.Data.Data || !(this.Data.Data.length>0)) return this.DrawEmptyData();
35712
+ this.BorderColor=g_JSChartResource.ChartSimplePie.BorderColor;
35713
+ this.Offset=CloneData(g_JSChartResource.ChartSimplePie.Offset);
35714
+ this.TextFontConfig=CloneData(g_JSChartResource.ChartSimplePie.TextFont);
35715
+ }
35712
35716
 
35717
+ this.CalculateSize=function()
35718
+ {
35719
+ var border=this.ChartFrame.GetBorder();
35720
+ var pixelRatio=GetDevicePixelRatio();
35721
+ this.TextFont=`${this.TextFontConfig.Size*pixelRatio}px ${ this.TextFontConfig.Name}`;
35722
+ this.LineExtendWidth=this.GetFontHeight(this.TextFont,"擎")+1;
35713
35723
 
35714
35724
 
35715
- let left=this.ChartBorder.GetLeft();
35716
- let right=this.ChartBorder.GetRight();
35717
- let top=this.ChartBorder.GetTop();
35718
- let bottom=this.ChartBorder.GetBottom();
35719
- let width=this.ChartBorder.GetWidth();
35720
- let height=this.ChartBorder.GetHeight();
35725
+ this.RectClient={ Width:this.Radius*2*pixelRatio, Height:this.Radius*2*pixelRatio };
35721
35726
 
35722
- if(isNaN(this.Radius)){
35723
- let str = this.Radius.replace("%","");
35724
- str = str/100;
35725
- if(width >= height){
35726
- this.Radius = str*height;
35727
- }
35728
- if(width < height) this.Radius = str*width;
35727
+ this.RectClient.Right=border.Right+this.Offset.X;
35728
+ this.RectClient.Top=border.TopEx+this.Offset.Y;
35729
+ this.RectClient.Left=this.RectClient.Right-this.RectClient.Width;
35730
+ this.RectClient.Bottom=this.RectClient.Top+this.RectClient.Height;
35731
+ }
35732
+
35733
+ this.CalculateTotalValue=function()
35734
+ {
35735
+ var totalValue=0;
35736
+ for(var i=0; i<this.Data.Data.length; ++i)
35737
+ {
35738
+ var item=this.Data.Data[i];
35739
+ if (!IFrameSplitOperator.IsPlusNumber(item.Value)) continue;
35740
+ totalValue += item.Value;
35729
35741
  }
35730
35742
 
35743
+ this.TotalValue=totalValue;
35744
+ }
35731
35745
 
35732
- this.Canvas.save();
35733
- this.Canvas.translate(width/2,height/2);
35746
+ this.DrawPie=function()
35747
+ {
35748
+ this.Canvas.font=this.TextFont;
35749
+ this.Canvas.textBaseline='bottom';
35750
+ this.Canvas.textAlign = 'left';
35734
35751
 
35735
- let totalValue=0; //求和
35736
- for(let i in this.Data.Data)
35752
+ var aryText=[];
35753
+ var maxTextWidth=0;
35754
+ for(var i=0;i<this.Data.Data.length;++i)
35737
35755
  {
35738
- totalValue += this.Data.Data[i].Value;
35756
+ var item=this.Data.Data[i];
35757
+ if (!IFrameSplitOperator.IsPlusNumber(item.Value)) continue;
35758
+ if (!item.Text) continue;
35759
+ var textWidth=this.Canvas.measureText(item.Text).width;
35760
+
35761
+ aryText[i]={ Width:textWidth };
35762
+
35763
+ if (maxTextWidth<textWidth) maxTextWidth=textWidth;
35739
35764
  }
35740
- let start = 0;
35741
- let end = 0;
35742
- //画饼图
35743
- for(let i in this.Data.Data)
35765
+
35766
+ var xOffset=maxTextWidth+this.LineExtendWidth;
35767
+ this.RectClient.Left-=xOffset;
35768
+ this.RectClient.Right-=xOffset;
35769
+
35770
+
35771
+ var start=0, end=0;
35772
+ var x=this.RectClient.Left+this.Radius;
35773
+ var y=this.RectClient.Top+this.Radius;
35774
+
35775
+ for(var i=0;i<this.Data.Data.length;++i)
35744
35776
  {
35745
- let item =this.Data.Data[i];
35746
- let rate=(item.Value/totalValue).toFixed(2); //占比
35747
- //JSConsole.Chart.Log('[ChartPie::Draw]', i, rate, item);
35777
+ var item=this.Data.Data[i];
35778
+ if (!IFrameSplitOperator.IsPlusNumber(item.Value)) continue;
35779
+
35780
+ var rate=item.Value/this.TotalValue;
35748
35781
 
35749
35782
  // 绘制扇形
35750
35783
  this.Canvas.beginPath();
35751
- this.Canvas.moveTo(0,0);
35752
-
35784
+ this.Canvas.moveTo(x,y);
35785
+
35753
35786
  end += rate*2*Math.PI;//终止角度
35754
- this.Canvas.strokeStyle = "white";
35787
+ this.Canvas.strokeStyle = this.BorderColor;
35755
35788
  this.Canvas.fillStyle = item.Color;
35756
- this.Canvas.arc(0,0,this.Radius,start,end);
35789
+ this.Canvas.arc(x,y,this.Radius,start,end);
35757
35790
  this.Canvas.fill();
35758
35791
  this.Canvas.closePath();
35759
- this.Canvas.stroke();
35760
-
35761
- // 绘制直线
35762
- this.Canvas.beginPath();
35763
- this.Canvas.strokeStyle = item.Color;
35764
- this.Canvas.moveTo(0,0);
35765
- let x = (this.Radius + this.Distance)*Math.cos(end- (end-start)/2);
35766
- let y = (this.Radius + this.Distance)*Math.sin(end - (end-start)/2);
35767
- this.Canvas.lineTo(x,y);
35768
- // JSConsole.Chart.Log(x,y,"xy")
35769
-
35770
- // 绘制横线
35771
- let txtLine = this.txtLine;
35772
- let paddingX = this.paddingX;
35773
- this.Canvas.textAlign = 'left';
35774
- if( end - (end-start)/2 < 1.5*Math.PI && end - (end-start)/2 > 0.5*Math.PI ){
35775
-
35776
- txtLine = - this.txtLine;
35777
- paddingX = - this.paddingX;
35778
- this.Canvas.textAlign = 'right';
35779
- }
35780
- this.Canvas.lineTo( x + txtLine, y );
35781
35792
  this.Canvas.stroke();
35782
35793
 
35783
- // 写文字
35784
- if(item.Text){
35785
- this.Canvas.fillText( item.Text, x + txtLine + paddingX, y );
35786
- }else{
35787
- let text = `${item.Name}:${item.Value}`;
35788
- this.Canvas.fillText( text, x + txtLine + paddingX, y );
35789
- }
35790
-
35794
+ if (item.Text)
35795
+ {
35796
+ // 绘制直线
35797
+ var xLine=this.Radius*Math.cos(end- (end-start)/2)+x;
35798
+ var yLine=this.Radius*Math.sin(end - (end-start)/2)+y;
35799
+ var xEnd = (this.Radius + this.LineExtendWidth)*Math.cos(end- (end-start)/2)+x;
35800
+ var yEnd = (this.Radius + this.LineExtendWidth)*Math.sin(end - (end-start)/2)+y;
35801
+
35802
+ this.Canvas.beginPath();
35803
+ if (item.LineColor) this.Canvas.strokeStyle =item.LineColor;
35804
+ else this.Canvas.strokeStyle = item.Color;
35805
+ this.Canvas.moveTo(xLine,yLine);
35806
+ this.Canvas.lineTo(xEnd,yEnd);
35807
+
35808
+ var textWidth=aryText[i].Width;
35809
+ var yText=xEnd;
35810
+ if( end - (end-start)/2 < 1.5*Math.PI && end - (end-start)/2 > 0.5*Math.PI )
35811
+ {
35812
+ this.Canvas.lineTo( xEnd - textWidth, yEnd );
35813
+ yText=xEnd - textWidth;
35814
+ }
35815
+ else
35816
+ {
35817
+ this.Canvas.lineTo( xEnd + textWidth, yEnd );
35818
+ }
35819
+ this.Canvas.stroke();
35820
+
35821
+ if (item.TextColor) this.Canvas.fillStyle = item.TextColor;
35822
+ else this.Canvas.fillStyle=item.Color;
35823
+ this.Canvas.fillText(item.Text, yText, yEnd);
35824
+ }
35791
35825
 
35792
35826
  start += rate*2*Math.PI;//起始角度
35793
35827
  }
35828
+ }
35829
+
35830
+ this.Draw=function()
35831
+ {
35832
+ if (!this.Data || !this.Data.Data || !(this.Data.Data.length>0)) return this.DrawEmptyData();
35833
+
35834
+ this.CalculateTotalValue();
35835
+ if (!IFrameSplitOperator.IsPlusNumber(this.TotalValue)) this.DrawEmptyData();
35836
+ this.CalculateSize();
35837
+
35838
+ this.Canvas.save();
35839
+
35840
+ this.DrawPie();
35794
35841
 
35795
35842
  this.Canvas.restore();
35796
35843
  }
@@ -35798,7 +35845,7 @@ function ChartPie()
35798
35845
  //空数据
35799
35846
  this.DrawEmptyData=function()
35800
35847
  {
35801
- JSConsole.Chart.Log('[ChartPie::DrawEmptyData]')
35848
+ JSConsole.Chart.Log('[ChartSimplePie::DrawEmptyData]')
35802
35849
  }
35803
35850
 
35804
35851
  this.GetMaxMin=function()
@@ -40364,6 +40411,7 @@ function ChartMinutePriceLine()
40364
40411
  var pointCount=0;
40365
40412
 
40366
40413
  this.Canvas.save();
40414
+ this.ClipClient(isHScreen);
40367
40415
  if (IFrameSplitOperator.IsPlusNumber(this.LineWidth>0)) this.Canvas.lineWidth=this.LineWidth;
40368
40416
  for(var i=data.DataOffset,j=0;i<data.Data.length && j<xPointCount;++i,++j)
40369
40417
  {
@@ -43869,8 +43917,8 @@ function ChartTextLine()
43869
43917
 
43870
43918
  this.ClassName="ChartTextLine";
43871
43919
 
43872
- this.Text; //Text=内容 Color
43873
- this.Line; //Type=线段类型 0=不画 1=直线 2=虚线, Color
43920
+ this.Text; //{ Title:内容, Color: YOffset:, }
43921
+ this.Line; //{ Type=线段类型 0=不画 1=直线 2=虚线, Color:, Width:, LineDash:[] }
43874
43922
  this.Price;
43875
43923
 
43876
43924
  this.Draw=function()
@@ -43884,6 +43932,10 @@ function ChartTextLine()
43884
43932
  var bottom=this.ChartBorder.GetBottomEx();
43885
43933
  var top=this.ChartBorder.GetTopEx();
43886
43934
  var y=this.ChartFrame.GetYFromData(this.Price);
43935
+
43936
+ this.Canvas.save();
43937
+ this.ClipClient(this.IsHScreen);
43938
+
43887
43939
  var textWidth=0;
43888
43940
  if (this.Text.Title)
43889
43941
  {
@@ -43913,23 +43965,22 @@ function ChartTextLine()
43913
43965
  {
43914
43966
  if (this.Line.Type==2) //虚线
43915
43967
  {
43916
- this.Canvas.save();
43917
- this.Canvas.setLineDash([3,5]); //虚线
43968
+ if (IFrameSplitOperator.IsNonEmptyArray(this.Line.LineDash)) this.Canvas.setLineDash(this.Line.LineDash)
43969
+ else this.Canvas.setLineDash([3,5]); //虚线
43918
43970
  }
43919
43971
 
43972
+ if (IFrameSplitOperator.IsNumber(this.Line.Width)) this.Canvas.lineWidth=this.Line.Width;
43973
+
43920
43974
  var x=left+textWidth;
43921
43975
  this.Canvas.strokeStyle=this.Line.Color;
43922
43976
  this.Canvas.beginPath();
43923
43977
  this.Canvas.moveTo(x,ToFixedPoint(y));
43924
43978
  this.Canvas.lineTo(right,ToFixedPoint(y));
43925
43979
  this.Canvas.stroke();
43926
-
43927
- if (this.Line.Type==2)
43928
- {
43929
- this.Canvas.restore();
43930
- }
43931
43980
  }
43932
43981
 
43982
+
43983
+ this.Canvas.restore();
43933
43984
  }
43934
43985
 
43935
43986
  this.GetMaxMin=function()
@@ -45331,6 +45382,7 @@ function ChartDrawSVG()
45331
45382
  this.Family;
45332
45383
  this.TextFont;
45333
45384
  this.Texts=[]; //[ { Index:, Value:, Symbol:, Text:, Size: } ] SVG:图标 Text:文字 Size:图标大小
45385
+ //this.Data; 存K线数据
45334
45386
  this.IsHScreen=false; //是否横屏
45335
45387
  this.IsDestroy=false; //是否已销毁
45336
45388
  this.EnableTooltip=true;
@@ -45340,8 +45392,38 @@ function ChartDrawSVG()
45340
45392
 
45341
45393
  this.AryDrawRect=[]; //已经绘制的区域
45342
45394
  this.AutoYOffset=0;
45343
-
45344
- //this.Data; 存K线数据
45395
+
45396
+ this.BuildKeyCallback=null;
45397
+ this.MapCache=null; //key=date/date-time value={ Data:[] }
45398
+
45399
+ this.BuildKey=function(item)
45400
+ {
45401
+ if (this.BuildKeyCallback) return this.BuildKeyCallback(item);
45402
+
45403
+ if (IFrameSplitOperator.IsNumber(item.Time)) return `${item.Date}-${item.Time}`;
45404
+ else return `${item.Date}`;
45405
+ }
45406
+
45407
+ this.BuildCacheData=function()
45408
+ {
45409
+ var mapData=new Map();
45410
+ this.MapCache=mapData;
45411
+ for(var i=0; i<this.Texts.length;++i)
45412
+ {
45413
+ var item=this.Texts[i];
45414
+ var key=this.BuildKey(item);
45415
+
45416
+ if (mapData.has(key))
45417
+ {
45418
+ var mapItem=mapData.get(key);
45419
+ mapItem.Data.push(item);
45420
+ }
45421
+ else
45422
+ {
45423
+ mapData.set(key,{ Date:item.Date, Time:item.Time, Data:[item] });
45424
+ }
45425
+ }
45426
+ }
45345
45427
 
45346
45428
  this.Draw=function()
45347
45429
  {
@@ -45352,8 +45434,9 @@ function ChartDrawSVG()
45352
45434
  if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
45353
45435
  if (this.IsShowIndexTitleOnly()) return;
45354
45436
  if (this.IsHideScriptIndex()) return;
45437
+ if (!this.MapCache || this.MapCache.size<=0) return;
45355
45438
 
45356
- this.DrawSVG();
45439
+ this.DrawSVGV2();
45357
45440
  }
45358
45441
 
45359
45442
  this.DrawDetail=function(rtSVG, data, svgItem)
@@ -45582,6 +45665,221 @@ function ChartDrawSVG()
45582
45665
  return false;
45583
45666
  }
45584
45667
 
45668
+ this.GetKValue=function(kItem, valueName)
45669
+ {
45670
+ switch(valueName)
45671
+ {
45672
+ case "HIGH":
45673
+ case "H":
45674
+ return kItem.High;
45675
+ case "L":
45676
+ case "LOW":
45677
+ return kItem.Low;
45678
+ case "C":
45679
+ case "CLOSE":
45680
+ return kItem.Close;
45681
+ case "O":
45682
+ case "OPEN":
45683
+ return KItem.Open;
45684
+ default:
45685
+ return null;
45686
+ }
45687
+ }
45688
+
45689
+ this.DrawSVGV2=function()
45690
+ {
45691
+ if (!this.IsShow || this.ChartFrame.IsMinSize) return;
45692
+ if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
45693
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Texts)) return;
45694
+ if (!this.Family) return;
45695
+
45696
+ this.IsHScreen=(this.ChartFrame.IsHScreen===true);
45697
+ if (this.IsHScreen) return;
45698
+
45699
+ var xPointCount=this.ChartFrame.XPointCount;
45700
+ var dataWidth=this.ChartFrame.DataWidth;
45701
+ var distanceWidth=this.ChartFrame.DistanceWidth;
45702
+ var isMinute=this.IsMinuteFrame();
45703
+ var border=this.GetBorder();
45704
+ var pixelRatio = GetDevicePixelRatio();
45705
+
45706
+ if (this.IsHScreen)
45707
+ {
45708
+
45709
+ }
45710
+ else
45711
+ {
45712
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
45713
+ var chartright=border.RightEx;
45714
+ var chartLeft=border.LeftEx;
45715
+ }
45716
+
45717
+ var x,y,price;
45718
+ for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
45719
+ {
45720
+ var kItem=this.Data.Data[i];
45721
+ var key=this.BuildKey(kItem);
45722
+ if (!this.MapCache.has(key)) continue;
45723
+ var mapItem=this.MapCache.get(key);
45724
+
45725
+ if (isMinute)
45726
+ {
45727
+ x=this.ChartFrame.GetXFromIndex(j);
45728
+ }
45729
+ else
45730
+ {
45731
+ var left=xOffset;
45732
+ var right=xOffset+dataWidth;
45733
+ if (right>chartright) break;
45734
+ x=left+(right-left)/2;
45735
+ }
45736
+
45737
+ for(var j=0;j<mapItem.Data.length;++j)
45738
+ {
45739
+ var item=mapItem.Data[j];
45740
+
45741
+ if (item.Value=="Top") y=top;
45742
+ else if (item.Value=="Bottom") y=bottom;
45743
+ else
45744
+ {
45745
+ if (IFrameSplitOperator.IsString(item.Value)) price=this.GetKValue(kItem,item.Value);
45746
+ else price=item.Value;
45747
+
45748
+ y=this.ChartFrame.GetYFromData(price, false);
45749
+ }
45750
+ if (IFrameSplitOperator.IsNumber(item.YOffset)) y+=item.YOffset; //Y轴偏移
45751
+
45752
+ var svgItem=item.SVG;
45753
+ if (IFrameSplitOperator.IsNumber(svgItem.YOffset)) y+=svgItem.YOffset;
45754
+
45755
+ if (this.AutoPosition)
45756
+ {
45757
+ var pt={ X:x, Y:y };
45758
+ this.CalculateShowPosition(item, pt); //重新计算位置
45759
+ x=pt.X;
45760
+ y=pt.Y;
45761
+ }
45762
+
45763
+ var fontSVG=`${svgItem.Size}px ${this.Family}`;
45764
+ this.Canvas.font=fontSVG;
45765
+ var halfSize=svgItem.Size/2;
45766
+ var textBaseline='bottom';
45767
+ var rtSVG={ Left:x-halfSize, Right:x+halfSize, Top:y-svgItem.Size, Bottom:y, Height:svgItem.Size, Width:svgItem.Size };
45768
+ if (svgItem.VAlign===0)
45769
+ {
45770
+ textBaseline="top";
45771
+ rtSVG.Top=y;
45772
+ rtSVG.Bottom=rtSVG.Top+svgItem.Size;
45773
+ }
45774
+ else if (svgItem.VAlign===1)
45775
+ {
45776
+ textBaseline='middle';
45777
+ rtSVG.Top=y-svgItem.Size/2;
45778
+ rtSVG.Bottom=rtSVG.Top+svgItem.Size;
45779
+ }
45780
+
45781
+ if (rtSVG.Top<0)
45782
+ {
45783
+ rtSVG.Top=0;
45784
+ rtSVG.Bottom=svgItem.Size;
45785
+ y=rtSVG.Bottom;
45786
+ }
45787
+
45788
+ this.Canvas.textBaseline=textBaseline;
45789
+ this.Canvas.textAlign='center';
45790
+ this.Canvas.fillStyle = svgItem.Color;
45791
+ this.Canvas.fillText(svgItem.Symbol, x, y);
45792
+
45793
+ this.AryDrawRect.push( {Left:rtSVG.Left, Top:rtSVG.Top, Right:rtSVG.Right, Bottom:rtSVG.Bottom, Type:"SVG", Data:item } );
45794
+
45795
+ if (this.EnableTooltip) this.TooltipRect.push({ Rect:rtSVG, Index:i, Item:item });
45796
+
45797
+ //文字
45798
+ if (item.Text && item.Text.Content && this.TextFont)
45799
+ {
45800
+ var textItem=item.Text;
45801
+ this.Canvas.font=this.TextFont;
45802
+ this.Canvas.fillStyle=textItem.Color;
45803
+ var yText=y;
45804
+ if (IFrameSplitOperator.IsNumber(textItem.YOffset)) yText+=textItem.YOffset;
45805
+ this.Canvas.fillText(textItem.Content, x, yText);
45806
+ }
45807
+
45808
+ if (item.Detail)
45809
+ {
45810
+ this.DrawDetail(rtSVG,item.Detail, item);
45811
+ }
45812
+
45813
+ //连线
45814
+ if (item.Line)
45815
+ {
45816
+ var lineItem=item.Line;
45817
+ var price=null, yPrice=null;
45818
+ if (lineItem.Value=="Bottom")
45819
+ {
45820
+ yPrice=bottom;
45821
+ }
45822
+ else if (lineItem.Value=="Top")
45823
+ {
45824
+ yPrice=top;
45825
+ }
45826
+ else
45827
+ {
45828
+ if (IFrameSplitOperator.IsString(lineItem.Value))
45829
+ price=this.GetKValue(kItem,lineItem.Value);
45830
+
45831
+ if (!IFrameSplitOperator.IsNumber(price)) continue;
45832
+ yPrice=this.ChartFrame.GetYFromData(price);
45833
+ }
45834
+
45835
+ if (yPrice>=rtSVG.Top && yPrice<=rtSVG.Bottom) continue;
45836
+
45837
+ var yText;
45838
+ if (yPrice<rtSVG.Top)
45839
+ {
45840
+ yText=rtSVG.Top;
45841
+ if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
45842
+ {
45843
+ //yPrice+=lineItem.Blank;
45844
+ yText-=lineItem.SVGBlank;
45845
+ }
45846
+ }
45847
+ else
45848
+ {
45849
+ yText=rtSVG.Bottom;
45850
+ if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
45851
+ {
45852
+ //yPrice-=lineItem.Blank;
45853
+ yText+=lineItem.SVGBlank;
45854
+ }
45855
+ }
45856
+
45857
+ if (lineItem.Dash) this.Canvas.setLineDash(lineItem.Dash); //虚线
45858
+ var lineWidth=1*pixelRatio;
45859
+ if (lineItem.Width>0) lineWidth=lineItem.Width*pixelRatio;
45860
+ this.Canvas.lineWidth=lineWidth; //线宽
45861
+ this.Canvas.strokeStyle = lineItem.Color;
45862
+ this.Canvas.beginPath();
45863
+
45864
+ if (this.IsHScreen)
45865
+ {
45866
+ this.Canvas.moveTo(yText, ToFixedPoint(x));
45867
+ this.Canvas.lineTo(yPrice,ToFixedPoint(x));
45868
+ }
45869
+ else
45870
+ {
45871
+ this.Canvas.moveTo(ToFixedPoint2(lineWidth,x),yText);
45872
+ this.Canvas.lineTo(ToFixedPoint2(lineWidth,x),yPrice);
45873
+ }
45874
+
45875
+ this.Canvas.stroke();
45876
+ this.Canvas.setLineDash([]);
45877
+ }
45878
+ }
45879
+ }
45880
+ }
45881
+
45882
+ /*
45585
45883
  this.DrawSVG=function()
45586
45884
  {
45587
45885
  if (!this.IsShow || this.ChartFrame.IsMinSize) return;
@@ -45756,26 +46054,35 @@ function ChartDrawSVG()
45756
46054
  }
45757
46055
  }
45758
46056
  }
46057
+ */
45759
46058
 
45760
46059
  this.GetMaxMin=function()
45761
46060
  {
46061
+ this.IsHScreen=(this.ChartFrame.IsHScreen===true);
45762
46062
  var range={ Min:null, Max:null };
46063
+ if(!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return range;
46064
+ if (!this.MapCache || this.MapCache.size<=0) return;
45763
46065
  var xPointCount=this.ChartFrame.XPointCount;
45764
- var start=this.Data.DataOffset;
45765
- var end=start+xPointCount;
45766
- if (!IFrameSplitOperator.IsNonEmptyArray(this.Texts)) return range;
45767
46066
 
45768
- for(var i=0; i<this.Texts.length; ++i)
46067
+ for(var i=this.Data.DataOffset,j=0, k=0;i<this.Data.Data.length && j<xPointCount;++i,++j)
45769
46068
  {
45770
- var item=this.Texts[i];
45771
- if (!IFrameSplitOperator.IsNumber(item.Index)) continue;
45772
- if (item.Index>=start && item.Index<end)
46069
+ var kItem=this.Data.Data[i];
46070
+ var key=this.BuildKey(kItem);
46071
+ if (!this.MapCache.has(key)) continue;
46072
+ var mapItem=this.MapCache.get(key);
46073
+ if (!IFrameSplitOperator.IsNonEmptyArray(mapItem.Data)) continue;
46074
+
46075
+ for(k=0;k<mapItem.Data.length;++k)
45773
46076
  {
45774
- if(!IFrameSplitOperator.IsNumber(item.Value)) continue;
45775
- if (range.Max==null) range.Max=item.Value;
45776
- else if (range.Max<item.Value) range.Max=item.Value;
45777
- if (range.Min==null) range.Min=item.Value;
45778
- else if (range.Min>item.Value) range.Min=item.Value;
46077
+ var item=mapItem.Data[k];
46078
+ var value=item.Value;
46079
+ if (IFrameSplitOperator.IsString(item.Value)) value=this.GetKValue(kItem,item.Value);
46080
+ if (!IFrameSplitOperator.IsNumber(value)) continue;
46081
+
46082
+ if (range.Max==null) range.Max=value;
46083
+ else if (range.Max<value) range.Max=value;
46084
+ if (range.Min==null) range.Min=value;
46085
+ else if (range.Min>value) range.Min=value;
45779
46086
  }
45780
46087
  }
45781
46088
 
@@ -45791,11 +46098,10 @@ function ChartDrawSVG()
45791
46098
  var item=this.TooltipRect[i];
45792
46099
  if (!item.Rect) continue;
45793
46100
  var rect=item.Rect;
45794
- this.Canvas.beginPath();
45795
- this.Canvas.rect(rect.Left,rect.Top,rect.Width,rect.Height);
45796
- if (this.Canvas.isPointInPath(x,y))
46101
+
46102
+ if (x>=rect.Left && x<=rect.Right && y>=rect.Top && y<=rect.Bottom)
45797
46103
  {
45798
- var data=this.Texts[item.Index];
46104
+ var data=item.Item;
45799
46105
  JSConsole.Chart.Log('[ChartDrawSVG::GetTooltipData] svg icon.', item);
45800
46106
  tooltip.Data={ Rect:item.Rect, Item:data, Index:item.Index };
45801
46107
  tooltip.ChartPaint=this;
@@ -74418,6 +74724,13 @@ function JSChartResource()
74418
74724
  BorderColor:"rgb(217,217,217)",
74419
74725
  }
74420
74726
 
74727
+ this.ChartSimplePie=
74728
+ {
74729
+ TextFont:{ Family:'微软雅黑' , Size:12 },
74730
+ BorderColor:"rgb(169,169,169)",
74731
+ Offset:{ X:-5, Y:5 }
74732
+ }
74733
+
74421
74734
  //手机端tooltip
74422
74735
  this.TooltipPaint = {
74423
74736
  BGColor:'rgba(250,250,250,0.8)', //背景色
@@ -75647,6 +75960,7 @@ function JSChartResource()
75647
75960
  }
75648
75961
 
75649
75962
  if (style.ChartSimpleTable) this.SetChartSimpleTable(style.ChartSimpleTable);
75963
+ if (style.ChartSimplePie) this.SetChartSimplePie(style.ChartSimplePie);
75650
75964
 
75651
75965
  if (style.DRAWICON)
75652
75966
  {
@@ -76719,6 +77033,27 @@ function JSChartResource()
76719
77033
  }
76720
77034
  }
76721
77035
 
77036
+ this.SetChartSimplePie=function(style)
77037
+ {
77038
+ var dest=this.ChartSimplePie;
77039
+
77040
+ if (style.TextFont)
77041
+ {
77042
+ var item=style.TextFont;
77043
+ if (item.Name) dest.TextFont.Name=item.Name;
77044
+ if (IFrameSplitOperator.IsNumber(item.Size)) dest.TextFont.Size=item.Size;
77045
+ }
77046
+
77047
+ if (style.BorderColor) dest.BorderColor=style.BorderColor;
77048
+
77049
+ if (style.Offset)
77050
+ {
77051
+ var item=style.Offset;
77052
+ if (IFrameSplitOperator.IsNumber(item.X)) dest.Offset.X=item.X;
77053
+ if (IFrameSplitOperator.IsNumber(item.Y)) dest.Offset.Y=item.Y;
77054
+ }
77055
+ }
77056
+
76722
77057
  }
76723
77058
 
76724
77059
  var g_JSChartResource=new JSChartResource();
@@ -91647,7 +91982,7 @@ MinuteChartContainer.JsonDataToMinuteData=function(data,isBeforeData)
91647
91982
  return aryMinuteData;
91648
91983
  }
91649
91984
 
91650
- //分钟增量数据 stock: [ { date:, yclose:, yclearing: , minute:[ [],]} 0=日期 1=时间 2=开 3=高 4=低 5=收 6=均价 7=量 8=金额 9=涨幅 10=涨跌 11=领先指标 ]
91985
+ //分钟增量数据 stock: [ { date:, yclose:, yclearing: , minute:[ [],]} 0=日期 1=时间 2=开 3=高 4=低 5=收 6=均价 7=量 8=金额 9=涨幅 10=涨跌 11=领先指标 12=持仓 ]
91651
91986
  MinuteChartContainer.JsonDataToUpdateMinuteData=function(data)
91652
91987
  {
91653
91988
  if (!data || !data.stock) return null;
@@ -91685,16 +92020,17 @@ MinuteChartContainer.JsonDataToUpdateMinuteData=function(data)
91685
92020
  if (IFrameSplitOperator.IsNumber(jsData[9])) item.Increase=jsData[9];
91686
92021
  if (IFrameSplitOperator.IsNumber(jsData[10])) item.Risefall=jsData[10];
91687
92022
  if (IFrameSplitOperator.IsNumber(jsData[11])) item.Lead=jsData[11];
91688
-
92023
+ if (IFrameSplitOperator.IsNumber(jsData[12])) item.Position=jsData[12];
91689
92024
 
91690
92025
  if (jsData[extendDataIndex]) item.ExtendData=jsData[extendDataIndex];
91691
- item.DateTime=item.Date.toString()+" "+item.Time.toString();
92026
+
92027
+ item.DateTime=`${item.Date} ${item.Time}`;
91692
92028
 
91693
92029
  if (IFrameSplitOperator.IsNumber(minuteData.YClose) && item.Close)
91694
- item.Increase=(item.Close-minuteData.YClose)/minuteData.YClose*100; //涨幅 (最新价格-昨收)/昨收*100;
92030
+ item.Increase=(item.Close-minuteData.YClose)/minuteData.YClose*100; //涨幅 (最新价格-昨收)/昨收*100;
91695
92031
 
91696
92032
  if (isFutures && minuteData.YClearing && item.Close)
91697
- item.Increase=(item.Close-minuteData.YClearing)/minuteData.YClearing*100; //涨幅 (最新价格-昨结算价)/昨结算价*100;
92033
+ item.Increase=(item.Close-minuteData.YClearing)/minuteData.YClearing*100; //涨幅 (最新价格-昨结算价)/昨结算价*100;
91698
92034
 
91699
92035
 
91700
92036
  minuteData.Data.push(item);
@@ -111948,6 +112284,30 @@ function JSDraw(errorHandler,symbolData)
111948
112284
 
111949
112285
  return result={ DrawData:{ TableData:tableData }, DrawType:'DRAW_SIMPLE_TABLE' };
111950
112286
  }
112287
+
112288
+ //饼图
112289
+ this.PIE_CELL=function(value, color, text, textColor, lineColor)
112290
+ {
112291
+ var cellItem={ Value:value, Color:color };
112292
+ if (text) cellItem.Text=text;
112293
+ if (textColor) cellItem.TextColor=textColor;
112294
+ if (lineColor) cellItem.LineColor=lineColor;
112295
+
112296
+ return cellItem
112297
+ }
112298
+
112299
+ //0=Radius半径
112300
+ this.DRAWPIE=function(aryData)
112301
+ {
112302
+ var radius=aryData[0];
112303
+ var aryCell=[];
112304
+ for(var i=1;i<aryData.length;++i)
112305
+ {
112306
+ aryCell.push(aryData[i]);
112307
+ }
112308
+
112309
+ return result={ DrawData:{ Data:aryCell, Radius:radius }, DrawType:"DRAW_SIMPLE_PIE" };
112310
+ }
111951
112311
  }
111952
112312
 
111953
112313
 
@@ -112002,7 +112362,7 @@ JSDraw.prototype.IsDrawFunction=function(name)
112002
112362
  'DRAWOVERLAYLINE',"FILLRGN", "FILLRGN2","FILLTOPRGN", "FILLBOTTOMRGN", "FILLVERTICALRGN","FLOATRGN","DRAWSL", "DRAWGBK2","DRAWGBK_DIV",
112003
112363
  "VERTLINE","HORLINE","TIPICON",
112004
112364
  "BUY","SELL","SELLSHORT","BUYSHORT",
112005
- "DRAWLASTBARICON","DRAWLASTBARNUMBER", "DRAWLASTBARTEXT","DRAWTABLE",
112365
+ "DRAWLASTBARICON","DRAWLASTBARNUMBER", "DRAWLASTBARTEXT","DRAWTABLE","DRAWPIE",
112006
112366
  ]);
112007
112367
  if (setFunctionName.has(name)) return true;
112008
112368
 
@@ -118883,6 +119243,14 @@ function JSExecute(ast,option)
118883
119243
  node.Draw=this.Draw.DRAWTABLE(args);
118884
119244
  node.Out=[];
118885
119245
  break;
119246
+ //饼图
119247
+ case "PIE_CELL":
119248
+ node.Out=this.Draw.PIE_CELL(args[0],args[1],args[2],args[3],args[4]);
119249
+ break;
119250
+ case "DRAWPIE":
119251
+ node.Draw=this.Draw.DRAWPIE(args);
119252
+ node.Out=[];
119253
+ break;
118886
119254
 
118887
119255
  default:
118888
119256
  node.Out=this.Algorithm.CallFunction(funcName, args, node, this.SymbolData);
@@ -121876,6 +122244,29 @@ function ScriptIndex(name,script,args,option)
121876
122244
  hqChart.ChartPaint.push(chart);
121877
122245
  }
121878
122246
 
122247
+ this.CreateSimplePie=function(hqChart,windowIndex,varItem,id)
122248
+ {
122249
+ var chart=new ChartSimplePie();
122250
+ chart.Canvas=hqChart.Canvas;
122251
+ chart.Name=varItem.Name;
122252
+ chart.ChartBorder=hqChart.Frame.SubFrame[windowIndex].Frame.ChartBorder;
122253
+ chart.ChartFrame=hqChart.Frame.SubFrame[windowIndex].Frame;
122254
+
122255
+ if (varItem.Draw && varItem.Draw.DrawData)
122256
+ {
122257
+ var drawData=varItem.Draw.DrawData;
122258
+ if (drawData.Data) chart.Data.Data=drawData.Data;
122259
+ if (drawData.BorderColor) chart.BorderColor=drawData.BorderColor;
122260
+ if (drawData.TextFont) chart.TextFontConfig=drawData.TextFont;
122261
+ if (drawData.TextColor) chart.TextColor=drawData.TextColor;
122262
+ if (IFrameSplitOperator.IsNumber(drawData.XOffset)) chart.Offset.X=drawData.XOffset;
122263
+ if (IFrameSplitOperator.IsNumber(drawData.YOffset)) chart.Offset.Y=drawData.YOffset;
122264
+ if (IFrameSplitOperator.IsPlusNumber(drawData.Radius)) chart.Radius=drawData.Radius;
122265
+ }
122266
+
122267
+ hqChart.ChartPaint.push(chart);
122268
+ }
122269
+
121879
122270
  this.CreateTradeIcon=function(hqChart,windowIndex,varItem,id)
121880
122271
  {
121881
122272
  var chart=new ChartTradeIcon();
@@ -122082,11 +122473,12 @@ function ScriptIndex(name,script,args,option)
122082
122473
  for(var j=0;j<drawData.length;++j)
122083
122474
  {
122084
122475
  var item=drawData[j];
122476
+ var kItem=chart.Data.Data[j];
122085
122477
  if (!IFrameSplitOperator.IsNumber(item)) continue;
122086
122478
 
122087
122479
  var svgItem=
122088
122480
  {
122089
- Index:j, Value:item,
122481
+ Value:item, Date:kItem.Date, Time:kItem.Time,
122090
122482
  SVG:{ Symbol:varItem.Draw.Icon.Symbol, Size:svgSize, Color:svgColor, YOffset:svgYOffset, VAlign:svgVAlign }
122091
122483
  };
122092
122484
 
@@ -122106,6 +122498,7 @@ function ScriptIndex(name,script,args,option)
122106
122498
  chart.Texts= aryData;
122107
122499
  }
122108
122500
 
122501
+ chart.BuildCacheData();
122109
122502
  hqChart.ChartPaint.push(chart);
122110
122503
  }
122111
122504
 
@@ -122329,6 +122722,8 @@ function ScriptIndex(name,script,args,option)
122329
122722
  chart.Family=varItem.Draw.DrawData.Family;
122330
122723
  chart.TextFont=varItem.Draw.DrawData.TextFont;
122331
122724
  chart.Texts= varItem.Draw.DrawData.Data;
122725
+ chart.BuildCacheData();
122726
+ this.SetChartIndexName(chart);
122332
122727
  hqChart.ChartPaint.push(chart);
122333
122728
  }
122334
122729
 
@@ -122744,6 +123139,8 @@ function ScriptIndex(name,script,args,option)
122744
123139
  case "DRAW_SIMPLE_TABLE":
122745
123140
  this.CreateSimpleTable(hqChart,windowIndex,item,i);
122746
123141
  break;
123142
+ case "DRAW_SIMPLE_PIE":
123143
+ this.CreateSimplePie(hqChart,windowIndex,item,i);
122747
123144
  case "BUY":
122748
123145
  case "SELL":
122749
123146
  case "SELLSHORT":
@@ -123094,6 +123491,8 @@ function OverlayScriptIndex(name,script,args,option)
123094
123491
  case "DRAW_SIMPLE_TABLE":
123095
123492
  this.CreateSimpleTable(hqChart,windowIndex,item,i);
123096
123493
  break;
123494
+ case "DRAW_SIMPLE_PIE":
123495
+ this.CreateSimplePie(hqChart,windowIndex,item,i);
123097
123496
 
123098
123497
  case "KLINE_BG":
123099
123498
  this.CreateBackgroud(hqChart,windowIndex,item,i);
@@ -123845,11 +124244,12 @@ function OverlayScriptIndex(name,script,args,option)
123845
124244
  for(var j=0;j<drawData.length;++j)
123846
124245
  {
123847
124246
  var item=drawData[j];
124247
+ var kItem=chart.Data.Data[j];
123848
124248
  if (!IFrameSplitOperator.IsNumber(item)) continue;
123849
124249
 
123850
124250
  var svgItem=
123851
124251
  {
123852
- Index:j, Value:item,
124252
+ Value:item, Date:kItem.Date, Time:kItem.Time,
123853
124253
  SVG:{ Symbol:varItem.Draw.Icon.Symbol, Size:svgSize, Color:svgColor, YOffset:svgYOffset, VAlign:svgVAlign }
123854
124254
  };
123855
124255
 
@@ -123869,6 +124269,7 @@ function OverlayScriptIndex(name,script,args,option)
123869
124269
  chart.Texts= aryData;
123870
124270
  }
123871
124271
 
124272
+ chart.BuildCacheData();
123872
124273
  frame.ChartPaint.push(chart);
123873
124274
  }
123874
124275
 
@@ -124080,7 +124481,8 @@ function OverlayScriptIndex(name,script,args,option)
124080
124481
  if (varItem.Draw.AutoPosition) chart.AutoPosition=varItem.Draw.AutoPosition;
124081
124482
 
124082
124483
  this.ReloadChartResource(hqChart, windowIndex, chart);
124083
-
124484
+
124485
+ chart.BuildCacheData();
124084
124486
  this.SetChartIndexName(chart);
124085
124487
  frame.ChartPaint.push(chart);
124086
124488
  }
@@ -124131,6 +124533,33 @@ function OverlayScriptIndex(name,script,args,option)
124131
124533
  frame.ChartPaint.push(chart);
124132
124534
  }
124133
124535
 
124536
+ this.CreateSimplePie=function(hqChart,windowIndex,varItem,id)
124537
+ {
124538
+ var overlayIndex=this.OverlayIndex;
124539
+ var frame=overlayIndex.Frame;
124540
+ var chart=new ChartSimplePie();
124541
+ chart.Canvas=hqChart.Canvas;
124542
+ chart.Name=varItem.Name;
124543
+ chart.ChartBorder=frame.Frame.ChartBorder;
124544
+ chart.ChartFrame=frame.Frame;
124545
+ chart.Identify=overlayIndex.Identify;
124546
+ chart.HQChart=hqChart;
124547
+
124548
+ if (varItem.Draw && varItem.Draw.DrawData)
124549
+ {
124550
+ var drawData=varItem.Draw.DrawData;
124551
+ if (drawData.Data) chart.Data.Data=drawData.Data;
124552
+ if (drawData.BorderColor) chart.BorderColor=drawData.BorderColor;
124553
+ if (drawData.TextFont) chart.TextFontConfig=drawData.TextFont;
124554
+ if (drawData.TextColor) chart.TextColor=drawData.TextColor;
124555
+ if (IFrameSplitOperator.IsNumber(drawData.XOffset)) chart.Offset.X=drawData.XOffset;
124556
+ if (IFrameSplitOperator.IsNumber(drawData.YOffset)) chart.Offset.Y=drawData.YOffset;
124557
+ if (IFrameSplitOperator.IsPlusNumber(drawData.Radius)) chart.Radius=drawData.Radius;
124558
+ }
124559
+
124560
+ frame.ChartPaint.push(chart);
124561
+ }
124562
+
124134
124563
  this.CreateChartVericaltLine=function(hqChart,windowIndex,varItem,id)
124135
124564
  {
124136
124565
  var overlayIndex=this.OverlayIndex;
@@ -125192,8 +125621,7 @@ function APIScriptIndex(name,script,args,option, isOverlay)
125192
125621
  drawItem.Name=draw.Name;
125193
125622
  drawItem.DrawType=draw.DrawType;
125194
125623
  if (draw.AutoPosition) drawItem.AutoPosition=draw.AutoPosition;
125195
- drawItem.DrawData={ Data:this.FittingMultiText(draw.Data,date,time,hqChart), Family:draw.Family, TextFont:draw.TextFont, EnableTooltip:draw.EnableTooltip, IsDrawFirst:draw.IsDrawFirst };
125196
- this.GetKLineData(drawItem.DrawData.Data, hqChart);
125624
+ drawItem.DrawData={ Data:draw.Data, Family:draw.Family, TextFont:draw.TextFont, EnableTooltip:draw.EnableTooltip, IsDrawFirst:draw.IsDrawFirst };
125197
125625
  outVarItem.Draw=drawItem;
125198
125626
 
125199
125627
  result.push(outVarItem);
@@ -125333,6 +125761,17 @@ function APIScriptIndex(name,script,args,option, isOverlay)
125333
125761
  outVarItem.Draw=drawItem;
125334
125762
  result.push(outVarItem);
125335
125763
  }
125764
+ else if (draw.DrawType=="DRAW_SIMPLE_PIE")
125765
+ {
125766
+ drawItem.Name=draw.Name;
125767
+ drawItem.Type=draw.Type;
125768
+
125769
+ drawItem.DrawType=draw.DrawType;
125770
+ drawItem.DrawData=draw.DrawData; //{ Data:[ {Value, Color, Text: }, ], BorderColor:, TextFont:{ Size:, Name: } };
125771
+
125772
+ outVarItem.Draw=drawItem;
125773
+ result.push(outVarItem);
125774
+ }
125336
125775
  else
125337
125776
  {
125338
125777
  var find=g_ScriptIndexChartFactory.Get(draw.DrawType); //外部挂接
@@ -125673,8 +126112,7 @@ function APIScriptIndex(name,script,args,option, isOverlay)
125673
126112
  drawItem.Name=draw.Name;
125674
126113
  drawItem.DrawType=draw.DrawType;
125675
126114
  if (draw.AutoPosition) drawItem.AutoPosition=draw.AutoPosition;
125676
- drawItem.DrawData={ Data:this.FittingMultiText(draw.Data,date,time,hqChart), Family:draw.Family, TextFont:draw.TextFont ,EnableTooltip:draw.EnableTooltip,IsDrawFirst:draw.IsDrawFirst };
125677
- this.GetKLineData(drawItem.DrawData.Data, hqChart);
126115
+ drawItem.DrawData={ Data:draw.Data, Family:draw.Family, TextFont:draw.TextFont , EnableTooltip:draw.EnableTooltip, IsDrawFirst:draw.IsDrawFirst };
125678
126116
  outVarItem.Draw=drawItem;
125679
126117
 
125680
126118
  result.push(outVarItem);
@@ -126944,6 +127382,11 @@ function GetBlackStyle()
126944
127382
  BorderColor:"rgb(90,90,90)",
126945
127383
  },
126946
127384
 
127385
+ ChartSimplePie:
127386
+ {
127387
+ BorderColor:"rgb(220,220,220)",
127388
+ },
127389
+
126947
127390
  ChartDrawVolProfile:
126948
127391
  {
126949
127392
  BGColor:"rgba(244,250,254,0.3)",
@@ -141479,7 +141922,7 @@ function ScrollBarBGChart()
141479
141922
 
141480
141923
 
141481
141924
 
141482
- var HQCHART_VERSION="1.1.14298";
141925
+ var HQCHART_VERSION="1.1.14306";
141483
141926
 
141484
141927
  function PrintHQChartVersion()
141485
141928
  {