hqchart 1.1.14635 → 1.1.14641

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.
@@ -32888,7 +32888,7 @@ function ChartKLineTable()
32888
32888
 
32889
32889
  if (rtBG.Width>5)
32890
32890
  {
32891
- this.AryCellRect.push({ Item:{ Cell:item, Colunm:data, RowIndex:i, SubCell:subItem, SubIndex:j, Tooltip:subItem.Tooltip, Type:2 }, Rect:rtBG });
32891
+ this.AryCellRect.push({ Item:{ Cell:item, Colunm:data, RowIndex:i, SubCell:subItem, SubIndex:j, Tooltip:subItem.Tooltip, Type:2 }, Rect:rtSubBG });
32892
32892
  }
32893
32893
 
32894
32894
  xCell+=subCellWidth;
@@ -34818,7 +34818,7 @@ function ChartArea()
34818
34818
  }
34819
34819
  }
34820
34820
 
34821
- //散点图
34821
+ //散点图 建议使用新版本 ChartScatterPlotV2
34822
34822
  function ChartScatterPlot()
34823
34823
  {
34824
34824
  this.newMethod=IChartPainting; //派生
@@ -35023,7 +35023,7 @@ function ChartScatterPlot()
35023
35023
 
35024
35024
  }
35025
35025
 
35026
- //散点图
35026
+ //散点图 2.0
35027
35027
  function ChartScatterPlotV2()
35028
35028
  {
35029
35029
  this.newMethod=IChartPainting; //派生
@@ -44000,6 +44000,9 @@ function ChartDrawSVG()
44000
44000
  this.BuildKeyCallback=null;
44001
44001
  this.MapCache=null; //key=date/date-time value={ Data:[] }
44002
44002
 
44003
+ this.AryDrawDetail=[]; //需要绘制的文字信息
44004
+ this.EnalbeDetailNoOverlap=false; //详情重叠不显示
44005
+
44003
44006
  this.BuildKey=function(item)
44004
44007
  {
44005
44008
  if (this.BuildKeyCallback) return this.BuildKeyCallback(item);
@@ -44034,6 +44037,7 @@ function ChartDrawSVG()
44034
44037
  {
44035
44038
  this.TooltipRect=[];
44036
44039
  this.AryDrawRect=[];
44040
+ this.AryDrawDetail=[];
44037
44041
  this.AutoYOffset=0;
44038
44042
 
44039
44043
  if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
@@ -44042,6 +44046,10 @@ function ChartDrawSVG()
44042
44046
  if (!this.MapCache || this.MapCache.size<=0) return;
44043
44047
 
44044
44048
  this.DrawSVGV2();
44049
+
44050
+ if (this.EnalbeDetailNoOverlap) this.DrawOnVerlapDetail();
44051
+
44052
+ this.AryDrawDetail=[];
44045
44053
  }
44046
44054
 
44047
44055
  this.DrawDetail=function(rtSVG, data, svgItem)
@@ -44108,6 +44116,21 @@ function ChartDrawSVG()
44108
44116
  }
44109
44117
  }
44110
44118
 
44119
+ if (this.EnalbeDetailNoOverlap) //启动重叠不会 先不画只计算位置, 后面统一画
44120
+ {
44121
+ this.AryDrawDetail.push({ Rect:rtBorder, AryText:aryText, Data:svgItem });
44122
+ return;
44123
+ }
44124
+
44125
+ this.DrawDetailText(data,aryText,rtBorder);
44126
+
44127
+ this.AryDrawRect.push( {Left:rtBorder.Left, Top:rtBorder.Top, Right:rtBorder.Right, Bottom:rtBorder.Bottom, Type:"Detail", Data:svgItem } );
44128
+ }
44129
+
44130
+ this.DrawDetailText=function(data, aryText, rtBorder)
44131
+ {
44132
+ if (!data) return;
44133
+
44111
44134
  if (data.BGColor)
44112
44135
  {
44113
44136
  this.Canvas.fillStyle=data.BGColor;
@@ -44124,12 +44147,27 @@ function ChartDrawSVG()
44124
44147
  for(var i=0;i<aryText.length;++i)
44125
44148
  {
44126
44149
  var item=aryText[i];
44127
-
44150
+
44128
44151
  this.Canvas.fillStyle = item.Data.Color;
44129
44152
  this.Canvas.fillText(item.Data.Text, item.X, item.Y);
44130
44153
  }
44154
+ }
44131
44155
 
44132
- this.AryDrawRect.push( {Left:rtBorder.Left, Top:rtBorder.Top, Right:rtBorder.Right, Bottom:rtBorder.Bottom, Type:"Detail", Data:svgItem } );
44156
+ this.DrawOnVerlapDetail=function()
44157
+ {
44158
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryDrawDetail)) return;
44159
+
44160
+ for(var i=this.AryDrawDetail.length-1;i>=0; --i)
44161
+ {
44162
+ var drawItem=this.AryDrawDetail[i];
44163
+ var rtBorder=drawItem.Rect;
44164
+
44165
+ if (this.IsRectOverlap(rtBorder)) continue;
44166
+
44167
+ this.DrawDetailText(drawItem.Data.Detail, drawItem.AryText, rtBorder);
44168
+
44169
+ this.AryDrawRect.push( {Left:rtBorder.Left, Top:rtBorder.Top, Right:rtBorder.Right, Bottom:rtBorder.Bottom, Type:"Detail", Data:drawItem.Data } );
44170
+ }
44133
44171
  }
44134
44172
 
44135
44173
  this.GetDetailPosition=function(rtSVG, data)
@@ -44491,183 +44529,6 @@ function ChartDrawSVG()
44491
44529
  }
44492
44530
  }
44493
44531
 
44494
- /*
44495
- this.DrawSVG=function()
44496
- {
44497
- if (!this.IsShow || this.ChartFrame.IsMinSize) return;
44498
- if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
44499
- if (!IFrameSplitOperator.IsNonEmptyArray(this.Texts)) return;
44500
- if (!this.Family) return;
44501
-
44502
- this.IsHScreen=(this.ChartFrame.IsHScreen===true);
44503
- var xPointCount=this.ChartFrame.XPointCount;
44504
- var offset=this.Data.DataOffset;
44505
- var top=this.ChartBorder.GetTopEx();
44506
- var bottom=this.ChartBorder.GetBottomEx();
44507
- var pixelRatio = GetDevicePixelRatio();
44508
-
44509
- var x=0,y=0;
44510
- for(var i=0; i<this.Texts.length; ++i)
44511
- {
44512
- var item=this.Texts[i];
44513
-
44514
- if (!item.SVG || !item.SVG.Symbol) continue;
44515
- if (!IFrameSplitOperator.IsNumber(item.Index)) continue;
44516
-
44517
- var isMinuteFrame=this.IsMinuteFrame();
44518
- var index=item.Index-offset;
44519
- var kItem=this.Data.Data[item.Index];
44520
- if (index<0 || index>=xPointCount) continue;
44521
-
44522
- x=this.ChartFrame.GetXFromIndex(index);
44523
- if (item.Value=="Top") y=top;
44524
- else if (item.Value=="Bottom") y=bottom;
44525
- else y=this.ChartFrame.GetYFromData(item.Value, false);
44526
- if (IFrameSplitOperator.IsNumber(item.YOffset)) y+=item.YOffset; //Y轴偏移
44527
-
44528
- var svgItem=item.SVG;
44529
- if (IFrameSplitOperator.IsNumber(svgItem.YOffset)) y+=svgItem.YOffset;
44530
-
44531
- if (this.AutoPosition)
44532
- {
44533
- var pt={ X:x, Y:y };
44534
- this.CalculateShowPosition(item, pt); //重新计算位置
44535
- x=pt.X;
44536
- y=pt.Y;
44537
- }
44538
-
44539
-
44540
- var fontSVG=`${svgItem.Size}px ${this.Family}`;
44541
- this.Canvas.font=fontSVG;
44542
- var halfSize=svgItem.Size/2;
44543
- var textBaseline='bottom';
44544
- var rtSVG={ Left:x-halfSize, Right:x+halfSize, Top:y-svgItem.Size, Bottom:y, Height:svgItem.Size, Width:svgItem.Size };
44545
- if (svgItem.VAlign===0)
44546
- {
44547
- textBaseline="top";
44548
- rtSVG.Top=y;
44549
- rtSVG.Bottom=rtSVG.Top+svgItem.Size;
44550
- }
44551
- else if (svgItem.VAlign===1)
44552
- {
44553
- textBaseline='middle';
44554
- rtSVG.Top=y-svgItem.Size/2;
44555
- rtSVG.Bottom=rtSVG.Top+svgItem.Size;
44556
- }
44557
-
44558
- if (rtSVG.Top<0)
44559
- {
44560
- rtSVG.Top=0;
44561
- rtSVG.Bottom=svgItem.Size;
44562
- y=rtSVG.Bottom;
44563
- }
44564
-
44565
- this.Canvas.textBaseline=textBaseline;
44566
- this.Canvas.textAlign='center';
44567
- this.Canvas.fillStyle = svgItem.Color;
44568
- this.Canvas.fillText(svgItem.Symbol, x, y);
44569
-
44570
- this.AryDrawRect.push( {Left:rtSVG.Left, Top:rtSVG.Top, Right:rtSVG.Right, Bottom:rtSVG.Bottom, Type:"SVG", Data:item } );
44571
-
44572
- if (this.EnableTooltip) this.TooltipRect.push({ Rect:rtSVG,Index:i });
44573
-
44574
- //文字
44575
- if (item.Text && item.Text.Content && this.TextFont)
44576
- {
44577
- var textItem=item.Text;
44578
- this.Canvas.font=this.TextFont;
44579
- this.Canvas.fillStyle=textItem.Color;
44580
- var yText=y;
44581
- if (IFrameSplitOperator.IsNumber(textItem.YOffset)) yText+=textItem.YOffset;
44582
- this.Canvas.fillText(textItem.Content, x, yText);
44583
- }
44584
-
44585
- if (item.Detail)
44586
- {
44587
- this.DrawDetail(rtSVG,item.Detail, item);
44588
- }
44589
-
44590
- //连线
44591
- if (item.Line)
44592
- {
44593
- var lineItem=item.Line;
44594
- var price=null, yPrice=null;
44595
- var kItem=this.Data.Data[item.Index];
44596
- if (lineItem.Value=="Bottom")
44597
- {
44598
- yPrice=bottom;
44599
- }
44600
- else if (lineItem.Value=="Top")
44601
- {
44602
- yPrice=top;
44603
- }
44604
- else
44605
- {
44606
- switch(lineItem.Value)
44607
- {
44608
- case "C":
44609
- price=kItem.Close;
44610
- break;
44611
- case "H":
44612
- price=kItem.High;
44613
- break;
44614
- case "L":
44615
- price=kItem.Low;
44616
- break;
44617
- }
44618
-
44619
- if (!IFrameSplitOperator.IsNumber(price)) continue;
44620
-
44621
- yPrice=this.ChartFrame.GetYFromData(price);
44622
- }
44623
-
44624
- if (yPrice>=rtSVG.Top && yPrice<=rtSVG.Bottom) continue;
44625
-
44626
- var yText;
44627
- if (yPrice<rtSVG.Top)
44628
- {
44629
- yText=rtSVG.Top;
44630
- if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
44631
- {
44632
- //yPrice+=lineItem.Blank;
44633
- yText-=lineItem.SVGBlank;
44634
- }
44635
- }
44636
- else
44637
- {
44638
- yText=rtSVG.Bottom;
44639
- if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
44640
- {
44641
- //yPrice-=lineItem.Blank;
44642
- yText+=lineItem.SVGBlank;
44643
- }
44644
- }
44645
-
44646
- if (lineItem.Dash) this.Canvas.setLineDash(lineItem.Dash); //虚线
44647
- var lineWidth=1*pixelRatio;
44648
- if (lineItem.Width>0) lineWidth=lineItem.Width*pixelRatio;
44649
- this.Canvas.lineWidth=lineWidth; //线宽
44650
- this.Canvas.strokeStyle = lineItem.Color;
44651
- this.Canvas.beginPath();
44652
-
44653
- if (this.IsHScreen)
44654
- {
44655
- this.Canvas.moveTo(yText, ToFixedPoint(x));
44656
- this.Canvas.lineTo(yPrice,ToFixedPoint(x));
44657
- }
44658
- else
44659
- {
44660
- this.Canvas.moveTo(ToFixedPoint2(lineWidth,x),yText);
44661
- this.Canvas.lineTo(ToFixedPoint2(lineWidth,x),yPrice);
44662
- }
44663
-
44664
- this.Canvas.stroke();
44665
- this.Canvas.setLineDash([]);
44666
- }
44667
- }
44668
- }
44669
- */
44670
-
44671
44532
  this.GetMaxMin=function()
44672
44533
  {
44673
44534
  this.IsHScreen=(this.ChartFrame.IsHScreen===true);
@@ -2015,6 +2015,8 @@ HQData.Report_APIIndex=function(data, callback)
2015
2015
  HQData.APIIndex_TITLE(data, callback);
2016
2016
  else if (request.Data.indexname=="API_SCATTER_PLOT_V2")
2017
2017
  HQData.APIIndex_SCATTER_PLOT_V2(data, callback);
2018
+ else if (request.Data.indexname=="API_KLINE_TABLE")
2019
+ HQData.APIIndex_KLINE_TABLE(data, callback);
2018
2020
  }
2019
2021
 
2020
2022
 
@@ -3076,6 +3078,116 @@ HQData.APIIndex_SCATTER_PLOT_V2=function(data, callback)
3076
3078
  callback(apiData);
3077
3079
  }
3078
3080
 
3081
+ HQData.APIIndex_KLINE_TABLE=function(data, callback)
3082
+ {
3083
+ data.PreventDefault=true;
3084
+ var hqchart=data.HQChart;
3085
+ var kData=data.HQChart.GetKData(); //hqchart图形的分钟数据
3086
+
3087
+ var tableData=
3088
+ {
3089
+ name:'KLINE_TABLE', type:1,
3090
+ Draw:
3091
+ {
3092
+ DrawType:'KLINE_TABLE',
3093
+ DrawData:[ ] , //数据 [ [ { Text, Color: BGColor }, ...... ], [],]
3094
+ RowCount:4,
3095
+ RowName:[ {Name:"账户1",TextAlign:"center"}, {Name:"账户2",TextAlign:"center"}, {Name:"账户3",TextAlign:"center"},{Name:"账户4", TextAlign:"center"}],
3096
+
3097
+ Config:
3098
+ {
3099
+ BGColor:"rgb(0,0,0)",
3100
+ BorderColor:"rgb(220,220,220)",
3101
+ TextColor:"rgb(250,250,250)",
3102
+ ItemMergin:{ Left:2, Right:2, Top:4, Bottom:4, YOffset:3 },
3103
+ RowNamePosition:3,
3104
+ TextFont:{ Family:'微软雅黑' , FontMaxSize:14*GetDevicePixelRatio(), },
3105
+ RowHeightType:1,
3106
+ }
3107
+ },
3108
+
3109
+ };
3110
+
3111
+ var ACCOUNT_TEST_DATA=
3112
+ [
3113
+ { Name:"账户1", DayCount:5, OperatorID:0 },
3114
+ { Name:"账户2", DayCount:10, OperatorID:0 },
3115
+ { Name:"账户3", DayCount:4, OperatorID:0 },
3116
+ { Name:"账户4", DayCount:8, OperatorID:0 },
3117
+ ]
3118
+
3119
+ for(var i=0;i<kData.Data.length;++i)
3120
+ {
3121
+ var kItem=kData.Data[i];
3122
+
3123
+ //一列数据
3124
+ var colItem={ Date:kItem.Date, Time:kItem.Time, Data:[ ] };
3125
+
3126
+ for(var j=0;j<ACCOUNT_TEST_DATA.length;++j)
3127
+ {
3128
+ var accountItem=ACCOUNT_TEST_DATA[j];
3129
+ if (i%accountItem.DayCount==0)
3130
+ {
3131
+ accountItem.OperatorID++;
3132
+ if (accountItem.OperatorID>=3) accountItem.OperatorID=0;
3133
+
3134
+ if (accountItem.OperatorID==1)
3135
+ {
3136
+ colItem.Data[j]=
3137
+ {
3138
+ Text:"买", Color:"rgb(250,250,250)", BGColor:'rgb(250,0,0)', TextAlign:"center",
3139
+ Tooltip:
3140
+ {
3141
+ AryText:
3142
+ [
3143
+ {Title:"日期", Text:`${kItem.Date}`},
3144
+ {Title:"买入价", Text:`${kItem.Close.toFixed(2)}`, TextColor:"rgb(250,0,0)"},
3145
+ {Title:"数量", Text:`${HQData.GetRandomTestData(100,400).toFixed(0)}`,TextColor:"rgb(255,165,0)" },
3146
+ ]
3147
+ }
3148
+ };
3149
+ }
3150
+ else if (accountItem.OperatorID==2)
3151
+ {
3152
+ colItem.Data[j]=
3153
+ {
3154
+ Text:"卖", Color:"rgb(250,250,250)", BGColor:'rgb(34,139,34)', TextAlign:"center",
3155
+ Tooltip:
3156
+ {
3157
+ AryText:
3158
+ [
3159
+ {Title:"日期", Text:`${kItem.Date}`},
3160
+ {Title:"卖入价", Text:`${kItem.Close.toFixed(2)}`, TextColor:"rgb(34,139,34)"},
3161
+ {Title:"数量", Text:`${HQData.GetRandomTestData(100,400).toFixed(0)}`,TextColor:"rgb(255,165,0)" },
3162
+ ]
3163
+ }
3164
+ };
3165
+ }
3166
+
3167
+ }
3168
+ else
3169
+ {
3170
+ if (accountItem.OperatorID==0) continue; //空闲
3171
+
3172
+ if (accountItem.OperatorID==1)
3173
+ colItem.Data[j]= {Text:"持", Color:"rgb(250,250,250)", BGColor:'rgb(255,140,0)',TextAlign:"center"};
3174
+ }
3175
+ }
3176
+
3177
+ tableData.Draw.DrawData.push(colItem);
3178
+ }
3179
+
3180
+ var apiData=
3181
+ {
3182
+ code:0,
3183
+ stock:{ name:hqchart.Name, symbol:hqchart.Symbol },
3184
+ outdata: { date:kData.GetDate(), time:kData.GetTime(), outvar:[tableData] }
3185
+ };
3186
+
3187
+ console.log('[KLineChart::APIIndex_KLINE_TABLE] apiData ', apiData);
3188
+ callback(apiData);
3189
+ }
3190
+
3079
3191
 
3080
3192
  HQData.RequestVolumeProfileData=function(data, callback)
3081
3193
  {