hqchart 1.1.14635 → 1.1.14639

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.
@@ -36984,7 +36984,7 @@ function ChartKLineTable()
36984
36984
 
36985
36985
  if (rtBG.Width>5)
36986
36986
  {
36987
- this.AryCellRect.push({ Item:{ Cell:item, Colunm:data, RowIndex:i, SubCell:subItem, SubIndex:j, Tooltip:subItem.Tooltip, Type:2 }, Rect:rtBG });
36987
+ this.AryCellRect.push({ Item:{ Cell:item, Colunm:data, RowIndex:i, SubCell:subItem, SubIndex:j, Tooltip:subItem.Tooltip, Type:2 }, Rect:rtSubBG });
36988
36988
  }
36989
36989
 
36990
36990
  xCell+=subCellWidth;
@@ -38914,7 +38914,7 @@ function ChartArea()
38914
38914
  }
38915
38915
  }
38916
38916
 
38917
- //散点图
38917
+ //散点图 建议使用新版本 ChartScatterPlotV2
38918
38918
  function ChartScatterPlot()
38919
38919
  {
38920
38920
  this.newMethod=IChartPainting; //派生
@@ -39119,7 +39119,7 @@ function ChartScatterPlot()
39119
39119
 
39120
39120
  }
39121
39121
 
39122
- //散点图
39122
+ //散点图 2.0
39123
39123
  function ChartScatterPlotV2()
39124
39124
  {
39125
39125
  this.newMethod=IChartPainting; //派生
@@ -48096,6 +48096,9 @@ function ChartDrawSVG()
48096
48096
  this.BuildKeyCallback=null;
48097
48097
  this.MapCache=null; //key=date/date-time value={ Data:[] }
48098
48098
 
48099
+ this.AryDrawDetail=[]; //需要绘制的文字信息
48100
+ this.EnalbeDetailOnVerlap=false; //详情重叠不显示
48101
+
48099
48102
  this.BuildKey=function(item)
48100
48103
  {
48101
48104
  if (this.BuildKeyCallback) return this.BuildKeyCallback(item);
@@ -48130,6 +48133,7 @@ function ChartDrawSVG()
48130
48133
  {
48131
48134
  this.TooltipRect=[];
48132
48135
  this.AryDrawRect=[];
48136
+ this.AryDrawDetail=[];
48133
48137
  this.AutoYOffset=0;
48134
48138
 
48135
48139
  if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
@@ -48138,6 +48142,10 @@ function ChartDrawSVG()
48138
48142
  if (!this.MapCache || this.MapCache.size<=0) return;
48139
48143
 
48140
48144
  this.DrawSVGV2();
48145
+
48146
+ if (this.EnalbeDetailOnVerlap) this.DrawOnVerlapDetail();
48147
+
48148
+ this.AryDrawDetail=[];
48141
48149
  }
48142
48150
 
48143
48151
  this.DrawDetail=function(rtSVG, data, svgItem)
@@ -48204,6 +48212,21 @@ function ChartDrawSVG()
48204
48212
  }
48205
48213
  }
48206
48214
 
48215
+ if (this.EnalbeDetailOnVerlap) //启动重叠不会 先不画只计算位置, 后面统一画
48216
+ {
48217
+ this.AryDrawDetail.push({ Rect:rtBorder, AryText:aryText, Data:svgItem });
48218
+ return;
48219
+ }
48220
+
48221
+ this.DrawDetailText(data,aryText,rtBorder);
48222
+
48223
+ this.AryDrawRect.push( {Left:rtBorder.Left, Top:rtBorder.Top, Right:rtBorder.Right, Bottom:rtBorder.Bottom, Type:"Detail", Data:svgItem } );
48224
+ }
48225
+
48226
+ this.DrawDetailText=function(data, aryText, rtBorder)
48227
+ {
48228
+ if (!data) return;
48229
+
48207
48230
  if (data.BGColor)
48208
48231
  {
48209
48232
  this.Canvas.fillStyle=data.BGColor;
@@ -48220,12 +48243,27 @@ function ChartDrawSVG()
48220
48243
  for(var i=0;i<aryText.length;++i)
48221
48244
  {
48222
48245
  var item=aryText[i];
48223
-
48246
+
48224
48247
  this.Canvas.fillStyle = item.Data.Color;
48225
48248
  this.Canvas.fillText(item.Data.Text, item.X, item.Y);
48226
48249
  }
48250
+ }
48227
48251
 
48228
- this.AryDrawRect.push( {Left:rtBorder.Left, Top:rtBorder.Top, Right:rtBorder.Right, Bottom:rtBorder.Bottom, Type:"Detail", Data:svgItem } );
48252
+ this.DrawOnVerlapDetail=function()
48253
+ {
48254
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryDrawDetail)) return;
48255
+
48256
+ for(var i=this.AryDrawDetail.length-1;i>=0; --i)
48257
+ {
48258
+ var drawItem=this.AryDrawDetail[i];
48259
+ var rtBorder=drawItem.Rect;
48260
+
48261
+ if (this.IsRectOverlap(rtBorder)) continue;
48262
+
48263
+ this.DrawDetailText(drawItem.Data.Detail, drawItem.AryText, rtBorder);
48264
+
48265
+ this.AryDrawRect.push( {Left:rtBorder.Left, Top:rtBorder.Top, Right:rtBorder.Right, Bottom:rtBorder.Bottom, Type:"Detail", Data:drawItem.Data } );
48266
+ }
48229
48267
  }
48230
48268
 
48231
48269
  this.GetDetailPosition=function(rtSVG, data)
@@ -48587,183 +48625,6 @@ function ChartDrawSVG()
48587
48625
  }
48588
48626
  }
48589
48627
 
48590
- /*
48591
- this.DrawSVG=function()
48592
- {
48593
- if (!this.IsShow || this.ChartFrame.IsMinSize) return;
48594
- if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
48595
- if (!IFrameSplitOperator.IsNonEmptyArray(this.Texts)) return;
48596
- if (!this.Family) return;
48597
-
48598
- this.IsHScreen=(this.ChartFrame.IsHScreen===true);
48599
- var xPointCount=this.ChartFrame.XPointCount;
48600
- var offset=this.Data.DataOffset;
48601
- var top=this.ChartBorder.GetTopEx();
48602
- var bottom=this.ChartBorder.GetBottomEx();
48603
- var pixelRatio = GetDevicePixelRatio();
48604
-
48605
- var x=0,y=0;
48606
- for(var i=0; i<this.Texts.length; ++i)
48607
- {
48608
- var item=this.Texts[i];
48609
-
48610
- if (!item.SVG || !item.SVG.Symbol) continue;
48611
- if (!IFrameSplitOperator.IsNumber(item.Index)) continue;
48612
-
48613
- var isMinuteFrame=this.IsMinuteFrame();
48614
- var index=item.Index-offset;
48615
- var kItem=this.Data.Data[item.Index];
48616
- if (index<0 || index>=xPointCount) continue;
48617
-
48618
- x=this.ChartFrame.GetXFromIndex(index);
48619
- if (item.Value=="Top") y=top;
48620
- else if (item.Value=="Bottom") y=bottom;
48621
- else y=this.ChartFrame.GetYFromData(item.Value, false);
48622
- if (IFrameSplitOperator.IsNumber(item.YOffset)) y+=item.YOffset; //Y轴偏移
48623
-
48624
- var svgItem=item.SVG;
48625
- if (IFrameSplitOperator.IsNumber(svgItem.YOffset)) y+=svgItem.YOffset;
48626
-
48627
- if (this.AutoPosition)
48628
- {
48629
- var pt={ X:x, Y:y };
48630
- this.CalculateShowPosition(item, pt); //重新计算位置
48631
- x=pt.X;
48632
- y=pt.Y;
48633
- }
48634
-
48635
-
48636
- var fontSVG=`${svgItem.Size}px ${this.Family}`;
48637
- this.Canvas.font=fontSVG;
48638
- var halfSize=svgItem.Size/2;
48639
- var textBaseline='bottom';
48640
- var rtSVG={ Left:x-halfSize, Right:x+halfSize, Top:y-svgItem.Size, Bottom:y, Height:svgItem.Size, Width:svgItem.Size };
48641
- if (svgItem.VAlign===0)
48642
- {
48643
- textBaseline="top";
48644
- rtSVG.Top=y;
48645
- rtSVG.Bottom=rtSVG.Top+svgItem.Size;
48646
- }
48647
- else if (svgItem.VAlign===1)
48648
- {
48649
- textBaseline='middle';
48650
- rtSVG.Top=y-svgItem.Size/2;
48651
- rtSVG.Bottom=rtSVG.Top+svgItem.Size;
48652
- }
48653
-
48654
- if (rtSVG.Top<0)
48655
- {
48656
- rtSVG.Top=0;
48657
- rtSVG.Bottom=svgItem.Size;
48658
- y=rtSVG.Bottom;
48659
- }
48660
-
48661
- this.Canvas.textBaseline=textBaseline;
48662
- this.Canvas.textAlign='center';
48663
- this.Canvas.fillStyle = svgItem.Color;
48664
- this.Canvas.fillText(svgItem.Symbol, x, y);
48665
-
48666
- this.AryDrawRect.push( {Left:rtSVG.Left, Top:rtSVG.Top, Right:rtSVG.Right, Bottom:rtSVG.Bottom, Type:"SVG", Data:item } );
48667
-
48668
- if (this.EnableTooltip) this.TooltipRect.push({ Rect:rtSVG,Index:i });
48669
-
48670
- //文字
48671
- if (item.Text && item.Text.Content && this.TextFont)
48672
- {
48673
- var textItem=item.Text;
48674
- this.Canvas.font=this.TextFont;
48675
- this.Canvas.fillStyle=textItem.Color;
48676
- var yText=y;
48677
- if (IFrameSplitOperator.IsNumber(textItem.YOffset)) yText+=textItem.YOffset;
48678
- this.Canvas.fillText(textItem.Content, x, yText);
48679
- }
48680
-
48681
- if (item.Detail)
48682
- {
48683
- this.DrawDetail(rtSVG,item.Detail, item);
48684
- }
48685
-
48686
- //连线
48687
- if (item.Line)
48688
- {
48689
- var lineItem=item.Line;
48690
- var price=null, yPrice=null;
48691
- var kItem=this.Data.Data[item.Index];
48692
- if (lineItem.Value=="Bottom")
48693
- {
48694
- yPrice=bottom;
48695
- }
48696
- else if (lineItem.Value=="Top")
48697
- {
48698
- yPrice=top;
48699
- }
48700
- else
48701
- {
48702
- switch(lineItem.Value)
48703
- {
48704
- case "C":
48705
- price=kItem.Close;
48706
- break;
48707
- case "H":
48708
- price=kItem.High;
48709
- break;
48710
- case "L":
48711
- price=kItem.Low;
48712
- break;
48713
- }
48714
-
48715
- if (!IFrameSplitOperator.IsNumber(price)) continue;
48716
-
48717
- yPrice=this.ChartFrame.GetYFromData(price);
48718
- }
48719
-
48720
- if (yPrice>=rtSVG.Top && yPrice<=rtSVG.Bottom) continue;
48721
-
48722
- var yText;
48723
- if (yPrice<rtSVG.Top)
48724
- {
48725
- yText=rtSVG.Top;
48726
- if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
48727
- {
48728
- //yPrice+=lineItem.Blank;
48729
- yText-=lineItem.SVGBlank;
48730
- }
48731
- }
48732
- else
48733
- {
48734
- yText=rtSVG.Bottom;
48735
- if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
48736
- {
48737
- //yPrice-=lineItem.Blank;
48738
- yText+=lineItem.SVGBlank;
48739
- }
48740
- }
48741
-
48742
- if (lineItem.Dash) this.Canvas.setLineDash(lineItem.Dash); //虚线
48743
- var lineWidth=1*pixelRatio;
48744
- if (lineItem.Width>0) lineWidth=lineItem.Width*pixelRatio;
48745
- this.Canvas.lineWidth=lineWidth; //线宽
48746
- this.Canvas.strokeStyle = lineItem.Color;
48747
- this.Canvas.beginPath();
48748
-
48749
- if (this.IsHScreen)
48750
- {
48751
- this.Canvas.moveTo(yText, ToFixedPoint(x));
48752
- this.Canvas.lineTo(yPrice,ToFixedPoint(x));
48753
- }
48754
- else
48755
- {
48756
- this.Canvas.moveTo(ToFixedPoint2(lineWidth,x),yText);
48757
- this.Canvas.lineTo(ToFixedPoint2(lineWidth,x),yPrice);
48758
- }
48759
-
48760
- this.Canvas.stroke();
48761
- this.Canvas.setLineDash([]);
48762
- }
48763
- }
48764
- }
48765
- */
48766
-
48767
48628
  this.GetMaxMin=function()
48768
48629
  {
48769
48630
  this.IsHScreen=(this.ChartFrame.IsHScreen===true);
@@ -126672,6 +126533,7 @@ function ScriptIndex(name,script,args,option)
126672
126533
  chart.Data=hqChart.GetKData()
126673
126534
  if (IFrameSplitOperator.IsBool(varItem.Draw.DrawData.EnableTooltip)) chart.EnableTooltip=varItem.Draw.DrawData.EnableTooltip;
126674
126535
  if (IFrameSplitOperator.IsBool(varItem.Draw.DrawData.IsDrawFirst)) chart.IsDrawFirst=varItem.Draw.DrawData.IsDrawFirst;
126536
+ if (IFrameSplitOperator.IsBool(varItem.Draw.EnalbeDetailOnVerlap)) chart.EnalbeDetailOnVerlap=varItem.Draw.EnalbeDetailOnVerlap;
126675
126537
  if (varItem.Draw.BuildKeyCallback) chart.BuildKeyCallback=varItem.Draw.BuildKeyCallback;
126676
126538
  chart.Family=varItem.Draw.DrawData.Family;
126677
126539
  chart.TextFont=varItem.Draw.DrawData.TextFont;
@@ -128583,6 +128445,7 @@ function OverlayScriptIndex(name,script,args,option)
128583
128445
  chart.TextFont=varItem.Draw.DrawData.TextFont;
128584
128446
  chart.Texts= varItem.Draw.DrawData.Data;
128585
128447
  if (varItem.Draw.AutoPosition) chart.AutoPosition=varItem.Draw.AutoPosition;
128448
+ if (IFrameSplitOperator.IsBool(varItem.Draw.EnalbeDetailOnVerlap)) chart.EnalbeDetailOnVerlap=varItem.Draw.EnalbeDetailOnVerlap;
128586
128449
 
128587
128450
  this.ReloadChartResource(hqChart, windowIndex, chart);
128588
128451
 
@@ -129789,6 +129652,7 @@ function APIScriptIndex(name,script,args,option, isOverlay)
129789
129652
  drawItem.Name=draw.Name;
129790
129653
  drawItem.DrawType=draw.DrawType;
129791
129654
  if (draw.AutoPosition) drawItem.AutoPosition=draw.AutoPosition;
129655
+ drawItem.EnalbeDetailOnVerlap=draw.EnalbeDetailOnVerlap;
129792
129656
  if (draw.BuildKeyCallback) drawItem.BuildKeyCallback=draw.BuildKeyCallback;
129793
129657
  drawItem.DrawData={ Data:draw.Data, Family:draw.Family, TextFont:draw.TextFont, EnableTooltip:draw.EnableTooltip, IsDrawFirst:draw.IsDrawFirst };
129794
129658
  outVarItem.Draw=drawItem;
@@ -146681,7 +146545,7 @@ function ScrollBarBGChart()
146681
146545
 
146682
146546
 
146683
146547
 
146684
- var HQCHART_VERSION="1.1.14634";
146548
+ var HQCHART_VERSION="1.1.14638";
146685
146549
 
146686
146550
  function PrintHQChartVersion()
146687
146551
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var HQCHART_VERSION="1.1.14634";
8
+ var HQCHART_VERSION="1.1.14638";
9
9
 
10
10
  function PrintHQChartVersion()
11
11
  {
@@ -57547,6 +57547,8 @@ HQData.Report_APIIndex=function(data, callback)
57547
57547
  HQData.APIIndex_TITLE(data, callback);
57548
57548
  else if (request.Data.indexname=="API_SCATTER_PLOT_V2")
57549
57549
  HQData.APIIndex_SCATTER_PLOT_V2(data, callback);
57550
+ else if (request.Data.indexname=="API_KLINE_TABLE")
57551
+ HQData.APIIndex_KLINE_TABLE(data, callback);
57550
57552
  }
57551
57553
 
57552
57554
 
@@ -58608,6 +58610,116 @@ HQData.APIIndex_SCATTER_PLOT_V2=function(data, callback)
58608
58610
  callback(apiData);
58609
58611
  }
58610
58612
 
58613
+ HQData.APIIndex_KLINE_TABLE=function(data, callback)
58614
+ {
58615
+ data.PreventDefault=true;
58616
+ var hqchart=data.HQChart;
58617
+ var kData=data.HQChart.GetKData(); //hqchart图形的分钟数据
58618
+
58619
+ var tableData=
58620
+ {
58621
+ name:'KLINE_TABLE', type:1,
58622
+ Draw:
58623
+ {
58624
+ DrawType:'KLINE_TABLE',
58625
+ DrawData:[ ] , //数据 [ [ { Text, Color: BGColor }, ...... ], [],]
58626
+ RowCount:4,
58627
+ RowName:[ {Name:"账户1",TextAlign:"center"}, {Name:"账户2",TextAlign:"center"}, {Name:"账户3",TextAlign:"center"},{Name:"账户4", TextAlign:"center"}],
58628
+
58629
+ Config:
58630
+ {
58631
+ BGColor:"rgb(0,0,0)",
58632
+ BorderColor:"rgb(220,220,220)",
58633
+ TextColor:"rgb(250,250,250)",
58634
+ ItemMergin:{ Left:2, Right:2, Top:4, Bottom:4, YOffset:3 },
58635
+ RowNamePosition:3,
58636
+ TextFont:{ Family:'微软雅黑' , FontMaxSize:14*GetDevicePixelRatio(), },
58637
+ RowHeightType:1,
58638
+ }
58639
+ },
58640
+
58641
+ };
58642
+
58643
+ var ACCOUNT_TEST_DATA=
58644
+ [
58645
+ { Name:"账户1", DayCount:5, OperatorID:0 },
58646
+ { Name:"账户2", DayCount:10, OperatorID:0 },
58647
+ { Name:"账户3", DayCount:4, OperatorID:0 },
58648
+ { Name:"账户4", DayCount:8, OperatorID:0 },
58649
+ ]
58650
+
58651
+ for(var i=0;i<kData.Data.length;++i)
58652
+ {
58653
+ var kItem=kData.Data[i];
58654
+
58655
+ //一列数据
58656
+ var colItem={ Date:kItem.Date, Time:kItem.Time, Data:[ ] };
58657
+
58658
+ for(var j=0;j<ACCOUNT_TEST_DATA.length;++j)
58659
+ {
58660
+ var accountItem=ACCOUNT_TEST_DATA[j];
58661
+ if (i%accountItem.DayCount==0)
58662
+ {
58663
+ accountItem.OperatorID++;
58664
+ if (accountItem.OperatorID>=3) accountItem.OperatorID=0;
58665
+
58666
+ if (accountItem.OperatorID==1)
58667
+ {
58668
+ colItem.Data[j]=
58669
+ {
58670
+ Text:"买", Color:"rgb(250,250,250)", BGColor:'rgb(250,0,0)', TextAlign:"center",
58671
+ Tooltip:
58672
+ {
58673
+ AryText:
58674
+ [
58675
+ {Title:"日期", Text:`${kItem.Date}`},
58676
+ {Title:"买入价", Text:`${kItem.Close.toFixed(2)}`, TextColor:"rgb(250,0,0)"},
58677
+ {Title:"数量", Text:`${HQData.GetRandomTestData(100,400).toFixed(0)}`,TextColor:"rgb(255,165,0)" },
58678
+ ]
58679
+ }
58680
+ };
58681
+ }
58682
+ else if (accountItem.OperatorID==2)
58683
+ {
58684
+ colItem.Data[j]=
58685
+ {
58686
+ Text:"卖", Color:"rgb(250,250,250)", BGColor:'rgb(34,139,34)', TextAlign:"center",
58687
+ Tooltip:
58688
+ {
58689
+ AryText:
58690
+ [
58691
+ {Title:"日期", Text:`${kItem.Date}`},
58692
+ {Title:"卖入价", Text:`${kItem.Close.toFixed(2)}`, TextColor:"rgb(34,139,34)"},
58693
+ {Title:"数量", Text:`${HQData.GetRandomTestData(100,400).toFixed(0)}`,TextColor:"rgb(255,165,0)" },
58694
+ ]
58695
+ }
58696
+ };
58697
+ }
58698
+
58699
+ }
58700
+ else
58701
+ {
58702
+ if (accountItem.OperatorID==0) continue; //空闲
58703
+
58704
+ if (accountItem.OperatorID==1)
58705
+ colItem.Data[j]= {Text:"持", Color:"rgb(250,250,250)", BGColor:'rgb(255,140,0)',TextAlign:"center"};
58706
+ }
58707
+ }
58708
+
58709
+ tableData.Draw.DrawData.push(colItem);
58710
+ }
58711
+
58712
+ var apiData=
58713
+ {
58714
+ code:0,
58715
+ stock:{ name:hqchart.Name, symbol:hqchart.Symbol },
58716
+ outdata: { date:kData.GetDate(), time:kData.GetTime(), outvar:[tableData] }
58717
+ };
58718
+
58719
+ console.log('[KLineChart::APIIndex_KLINE_TABLE] apiData ', apiData);
58720
+ callback(apiData);
58721
+ }
58722
+
58611
58723
 
58612
58724
  HQData.RequestVolumeProfileData=function(data, callback)
58613
58725
  {