hqchart 1.1.14617 → 1.1.14621

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.
@@ -15655,6 +15655,14 @@ function ToFixed(number, precision)
15655
15655
  return s;
15656
15656
  }
15657
15657
 
15658
+ function IsRectOverlap(rt, rt2)
15659
+ {
15660
+ if (Math.max(rt.Left,rt2.Left)<Math.min(rt.Right,rt2.Right) && Math.max(rt.Top,rt2.Top)<Math.min(rt.Bottom, rt2.Bottom))
15661
+ return true;
15662
+
15663
+ return false;
15664
+ }
15665
+
15658
15666
  Number.prototype.toFixed2=Number.prototype.toFixed; //备份下老的
15659
15667
  Number.prototype.toFixed = function( precision )
15660
15668
  {
@@ -38948,6 +38956,326 @@ function ChartScatterPlot()
38948
38956
 
38949
38957
  }
38950
38958
 
38959
+ //散点图
38960
+ function ChartScatterPlotV2()
38961
+ {
38962
+ this.newMethod=IChartPainting; //派生
38963
+ this.newMethod();
38964
+ delete this.newMethod;
38965
+
38966
+ this.ClassName='ChartScatterPlotV2'; //类名
38967
+
38968
+ //默认点配置
38969
+ this.Color=g_JSChartResource.ChartScatterPlotV2.Color; //点颜色
38970
+ this.TextColor=g_JSChartResource.ChartScatterPlotV2.TextColor;
38971
+ this.Radius=g_JSChartResource.ChartScatterPlotV2.Radius;
38972
+ this.Font=g_JSChartResource.ChartScatterPlotV2.Font; //半径
38973
+
38974
+ this.TooltipData=[];
38975
+ this.MapCache=null; //key=date/date-time value={ Data:[] }
38976
+ this.AryPoint=[ ]; //[{ Value:, Radius:半径(可选), Color:颜色(可选),ColorBorder:边框颜色(可选),
38977
+ // Text:{ Text:显示文字, Color:"rgb(0,30,100)", BaseLine:1, YOffset:5, Align:2 }; }]
38978
+ // BaseLine: 0=圆点上面 1=圆点下面 Align: 2=居中 1=左 3=右
38979
+
38980
+ this.GetKValue=ChartData.GetKValue;
38981
+ this.TextHeight=10;
38982
+ this.AryDrawRect=[];
38983
+
38984
+ this.ReloadResource=function(resource)
38985
+ {
38986
+ this.Color=g_JSChartResource.ChartScatterPlotV2.Color; //点颜色
38987
+ this.TextColor=g_JSChartResource.ChartScatterPlotV2.TextColor;
38988
+ this.Radius=g_JSChartResource.ChartScatterPlotV2.Radius;
38989
+ this.Font=g_JSChartResource.ChartScatterPlotV2.Font;
38990
+ }
38991
+
38992
+ this.BuildCacheData=function()
38993
+ {
38994
+ var mapData=new Map();
38995
+ this.MapCache=mapData;
38996
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryPoint)) return;
38997
+
38998
+ for(var i=0;i<this.AryPoint.length;++i)
38999
+ {
39000
+ var item=this.AryPoint[i];
39001
+ var key=this.BuildKey(item);
39002
+ if (mapData.has(key))
39003
+ {
39004
+ var mapItem=mapData.get(key);
39005
+ mapItem.Data.push(item);
39006
+ }
39007
+ else
39008
+ {
39009
+ mapData.set(key,{ Data:[item] });
39010
+ }
39011
+ }
39012
+ }
39013
+
39014
+ this.Draw=function()
39015
+ {
39016
+ this.TooltipData=[];
39017
+ this.AryDrawRect=[];
39018
+ if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
39019
+ if (this.IsShowIndexTitleOnly()) return;
39020
+ if (this.IsHideScriptIndex()) return;
39021
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryPoint)) return;
39022
+ if (!this.MapCache || this.MapCache.size<=0) return;
39023
+ if(!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
39024
+
39025
+ this.DrawScatterPlot();
39026
+ this.AryDrawRect=[];
39027
+ }
39028
+
39029
+ this.DrawScatterPlot=function()
39030
+ {
39031
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
39032
+ var isMinute=this.IsMinuteFrame();
39033
+ var dataWidth=this.ChartFrame.DataWidth;
39034
+ var distanceWidth=this.ChartFrame.DistanceWidth;
39035
+ var xPointCount=this.ChartFrame.XPointCount;
39036
+
39037
+ if (bHScreen)
39038
+ {
39039
+ var border=this.ChartBorder.GetHScreenBorder();
39040
+ var chartright=border.BottomEx;
39041
+ var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
39042
+ }
39043
+ else
39044
+ {
39045
+ var border=this.ChartBorder.GetBorder();
39046
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
39047
+ var chartright=border.RightEx;
39048
+ }
39049
+
39050
+ var lockRect=this.GetLockRect();
39051
+ if (lockRect)
39052
+ {
39053
+ if (bHScreen) chartright=lockRect.Top;
39054
+ else chartright=lockRect.Left;
39055
+ }
39056
+
39057
+ this.Canvas.save();
39058
+ this.ClipClient(bHScreen);
39059
+
39060
+ this.Canvas.font=this.Font;
39061
+ this.Canvas.textAlign = "left";
39062
+ this.Canvas.textBaseline = "bottom";
39063
+ this.TextHeight=this.GetFontHeight();
39064
+ for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
39065
+ {
39066
+ var kItem=this.Data.Data[i];
39067
+ if (!kItem) continue;
39068
+
39069
+ var key=this.BuildKey(kItem);
39070
+ if (!this.MapCache.has(key)) continue;
39071
+ var mapItem=this.MapCache.get(key);
39072
+ if (!IFrameSplitOperator.IsNonEmptyArray(mapItem.Data)) continue;
39073
+
39074
+ if (isMinute)
39075
+ {
39076
+ var x=this.ChartFrame.GetXFromIndex(j);
39077
+ }
39078
+ else
39079
+ {
39080
+ var left=xOffset;
39081
+ var right=xOffset+dataWidth;
39082
+ if (right>chartright) break;
39083
+ var x=left+(right-left)/2;
39084
+ }
39085
+
39086
+ if (x>chartright) break;
39087
+
39088
+ for(var k=0;k<mapItem.Data.length;++k)
39089
+ {
39090
+ var item=mapItem.Data[k];
39091
+ this.DrawItem(kItem, item, x);
39092
+ }
39093
+ }
39094
+
39095
+ this.Canvas.restore();
39096
+ }
39097
+
39098
+ this.DrawItem=function(kItem, item, x)
39099
+ {
39100
+ var dataWidth=this.ChartFrame.DataWidth;
39101
+ var maxRadius=dataWidth/2;
39102
+ if (!item) return;
39103
+ var price=item.Value;
39104
+ if (IFrameSplitOperator.IsString(item.Value)) price=this.GetKValue(kItem,item.Value);
39105
+ if (!IFrameSplitOperator.IsNumber(price)) return;
39106
+
39107
+ var y=this.GetYFromData(price,false);
39108
+
39109
+ var radius=this.Radius;
39110
+ if (item.Radius) radius=item.Radius;
39111
+ if (!IFrameSplitOperator.IsNumber(radius)) return;
39112
+ if (radius>maxRadius) radius=maxRadius;
39113
+
39114
+ this.Canvas.beginPath();
39115
+ this.Canvas.arc(x, y, radius, 0, 2 * Math.PI);
39116
+
39117
+ var color=this.Color;
39118
+ if (item.Color) color=item.Color;
39119
+ if (color)
39120
+ {
39121
+ this.Canvas.fillStyle=color;
39122
+ this.Canvas.fill();
39123
+ }
39124
+
39125
+ if (item.ColorBorder)
39126
+ {
39127
+ this.Canvas.strokeStyle=item.ColorBorder;
39128
+ this.Canvas.stroke()
39129
+ }
39130
+
39131
+ if (dataWidth>this.TextHeight)
39132
+ {
39133
+ this.DrawText(item.Text,x,y,radius);
39134
+ }
39135
+
39136
+ var itemTooltip={ X:x, Y:y, Radius:radius, Data:item };
39137
+ this.TooltipData.push(itemTooltip);
39138
+ }
39139
+
39140
+ this.DrawText=function(item, x, y, radius)
39141
+ {
39142
+ if (!item || !item.Text) return;
39143
+
39144
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
39145
+ if (bHScreen) return;
39146
+
39147
+ var text=item.Text;
39148
+ var textWidth=this.Canvas.measureText(text).width;
39149
+
39150
+ var baseLine=1; //1=上 2=下
39151
+ var align=2;
39152
+ var yOffset=2;
39153
+ var xText=x;
39154
+ if (IFrameSplitOperator.IsNumber(item.YOffset)) yOffset=item.YOffset; //Y偏移
39155
+ if (IFrameSplitOperator.IsNumber(item.BaseLine)) baseLine=item.BaseLine;
39156
+ var yText=y-radius-yOffset;
39157
+ if (baseLine==2) yText=y+radius+this.TextHeight+yOffset; //下
39158
+
39159
+ if (IFrameSplitOperator.IsNumber(item.Align)) align=item.Align; //左中右
39160
+ if (align==1) xText=x-textWidth;
39161
+ else if (align==2) xText=x-textWidth/2;
39162
+
39163
+ var rtText=null;
39164
+ if (item.BG && item.BG.Color)
39165
+ {
39166
+ var bgItem=item.BG;
39167
+ var marginLeft=2, marginRight=2, yBGOffset=1, marginBottom=0, marginTop=0;
39168
+ if (IFrameSplitOperator.IsNumber(bgItem.MarginLeft)) marginLeft=bgItem.MarginLeft;
39169
+ if (IFrameSplitOperator.IsNumber(bgItem.MarginRight)) marginRight=bgItem.MarginRight;
39170
+ if (IFrameSplitOperator.IsNumber(bgItem.MarginBottom)) marginBottom=bgItem.MarginBottom;
39171
+ if (IFrameSplitOperator.IsNumber(bgItem.MarginTop)) marginTop=bgItem.MarginTop;
39172
+ if (IFrameSplitOperator.IsNumber(bgItem.YOffset)) yBGOffset=bgItem.YOffset;
39173
+
39174
+ var rtBG={ Left:xText-marginLeft, Bottom:yText+yBGOffset+marginBottom, Width:textWidth+marginLeft+marginRight, Height:this.TextHeight+marginBottom+marginTop };
39175
+ rtBG.Right=rtBG.Left+rtBG.Width;
39176
+ rtBG.Top=rtBG.Bottom-rtBG.Height;
39177
+
39178
+ if (this.IsTextOverlap(rtBG)) return;
39179
+
39180
+ this.Canvas.fillStyle=bgItem.Color;
39181
+ this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
39182
+
39183
+ rtText=rtBG;
39184
+ }
39185
+ else
39186
+ {
39187
+ rtText={ Left:xText, Bottom:yText, Width:textWidth, Height:this.TextHeight };
39188
+ rtText.Right=rtText.Left+rtText.Width;
39189
+ rtText.Top=rtText.Bottom-rtText.Height;
39190
+
39191
+ if (this.IsTextOverlap(rtText)) return;
39192
+ }
39193
+
39194
+ if (item.Color) this.Canvas.fillStyle=item.Color;
39195
+ else this.Canvas.fillStyle=this.TextColor;
39196
+ this.Canvas.fillText(text, xText, yText);
39197
+
39198
+ this.AryDrawRect.push(rtText);
39199
+ }
39200
+
39201
+ this.IsTextOverlap=function(rtText)
39202
+ {
39203
+ for(var i=0; i<this.AryDrawRect.length; ++i)
39204
+ {
39205
+ var item=this.AryDrawRect[i];
39206
+ if (IsRectOverlap(rtText,item)) return true;
39207
+ }
39208
+
39209
+ return false;
39210
+ }
39211
+
39212
+ this.GetMaxMin=function()
39213
+ {
39214
+ var range={Min:null, Max:null };
39215
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryPoint)) return range;
39216
+ if (!this.MapCache || this.MapCache.size<=0) return range;
39217
+ if(!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return range;
39218
+
39219
+ var xPointCount=this.ChartFrame.XPointCount;
39220
+ var start=this.Data.DataOffset;
39221
+ if (this.ChartFrame.GlobalOption && this.ChartFrame.GlobalOption.IsValueFullRange)
39222
+ {
39223
+ start=0;
39224
+ xPointCount=this.Data.Data.length;
39225
+ }
39226
+
39227
+ for(var i=start,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j)
39228
+ {
39229
+ var kItem=this.Data.Data[i];
39230
+ if (!kItem) continue;
39231
+
39232
+ var key=this.BuildKey(kItem);
39233
+ if (!this.MapCache.has(key)) continue;
39234
+ var mapItem=this.MapCache.get(key);
39235
+ if (!IFrameSplitOperator.IsNonEmptyArray(mapItem.Data)) continue;
39236
+
39237
+ for(k=0;k<mapItem.Data.length;++k)
39238
+ {
39239
+ var item=mapItem.Data[k];
39240
+ var value=item.Value;
39241
+ if (IFrameSplitOperator.IsString(item.Value)) value=this.GetKValue(kItem,item.Value);
39242
+ if (!IFrameSplitOperator.IsNumber(value)) continue;
39243
+
39244
+ if (range.Max==null) range.Max=value;
39245
+ else if (range.Max<value) range.Max=value;
39246
+ if (range.Min==null) range.Min=value;
39247
+ else if (range.Min>value) range.Min=value;
39248
+ }
39249
+ }
39250
+
39251
+ return range;
39252
+ }
39253
+
39254
+ this.GetTooltipData=function(x,y,tooltip)
39255
+ {
39256
+ if (!this.IsShow) return false;
39257
+
39258
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.TooltipData)) return false;
39259
+
39260
+ for(var i=this.TooltipData.length-1; i>=0; --i)
39261
+ {
39262
+ var item=this.TooltipData[i];
39263
+
39264
+ this.Canvas.beginPath();
39265
+ this.Canvas.arc(item.X, item.Y, item.Radius, 0, 2 * Math.PI);
39266
+ if (this.Canvas.isPointInPath(x,y))
39267
+ {
39268
+ JSConsole.Chart.Log('[ChartScatterPlotV2::GetTooltipData] point', item);
39269
+ tooltip.Data=item;
39270
+ tooltip.ChartPaint=this;
39271
+ tooltip.Type=6; //散点图
39272
+ return true;
39273
+ }
39274
+ }
39275
+ }
39276
+
39277
+ }
39278
+
38951
39279
  //子线段
38952
39280
  function ChartSubLine()
38953
39281
  {
@@ -77688,6 +78016,14 @@ function JSChartResource()
77688
78016
  DiffValueBGColor:"rgb(251,140,1)"
77689
78017
  }
77690
78018
 
78019
+ this.ChartScatterPlotV2=
78020
+ {
78021
+ Color:"rgb(0,0,255)",
78022
+ TextColor:"rgb(0,0,0)",
78023
+ Radius:3,
78024
+ Font:`${10*GetDevicePixelRatio()}px 微软雅黑`
78025
+ }
78026
+
77691
78027
  //筹码分布图
77692
78028
  this.StockChip=
77693
78029
  {
@@ -79088,6 +79424,7 @@ function JSChartResource()
79088
79424
  if (style.KLineToolbar) this.SetKLineToolbar(style.KLineToolbar);
79089
79425
 
79090
79426
  if (style.IndexLock) this.SetIndexLock(style.IndexLock);
79427
+ if (style.ChartScatterPlotV2) this.SetChartScatterPlotV2(style.ChartScatterPlotV2);
79091
79428
  }
79092
79429
 
79093
79430
 
@@ -79786,6 +80123,17 @@ function JSChartResource()
79786
80123
  if (item.Title) dest.Title=item.Title;
79787
80124
  }
79788
80125
 
80126
+ this.SetChartScatterPlotV2=function(style)
80127
+ {
80128
+ var item=style;
80129
+ var dest=this.ChartScatterPlotV2;
80130
+
80131
+ if (item.Color) dest.Color=item.Color;
80132
+ if (item.TextColor) dest.TextColor=item.TextColor;
80133
+ if (item.Font) dest.Font=item.Font;
80134
+ if (IFrameSplitOperator.IsNumber(item.Radius)) dest.Radius=item.Radius
80135
+ }
80136
+
79789
80137
  }
79790
80138
 
79791
80139
  var g_JSChartResource=new JSChartResource();
@@ -124225,7 +124573,9 @@ var SCRIPT_CHART_NAME=
124225
124573
  {
124226
124574
  OVERLAY_BARS:"OVERLAY_BARS", //叠加柱子图
124227
124575
  KLINE_TABLE:"KLINE_TABLE",
124228
- SCATTER_PLOT:"SCATTER_PLOT", //散点图
124576
+ SCATTER_PLOT:"SCATTER_PLOT", //散点图
124577
+ SCATTER_PLOT_V2:"SCATTER_PLOT_V2", //散点图V2
124578
+
124229
124579
 
124230
124580
  CLIP_COLOR_STICK:"CLIP_COLOR_STICK", //上下柱子 裁剪
124231
124581
 
@@ -126232,6 +126582,34 @@ function ScriptIndex(name,script,args,option)
126232
126582
  hqChart.ChartPaint.push(chart);
126233
126583
  }
126234
126584
 
126585
+ this.CreateScatterPlotV2=function(hqChart,windowIndex,varItem,i)
126586
+ {
126587
+ var chart=new ChartScatterPlotV2();
126588
+ chart.Canvas=hqChart.Canvas;
126589
+ chart.Name=varItem.Name;
126590
+ chart.ChartBorder=hqChart.Frame.SubFrame[windowIndex].Frame.ChartBorder;
126591
+ chart.ChartFrame=hqChart.Frame.SubFrame[windowIndex].Frame;
126592
+ chart.HQChart=hqChart;
126593
+ chart.Identify=this.Guid;
126594
+
126595
+ chart.Data=hqChart.GetKData(); //绑定K线
126596
+ chart.AryPoint=varItem.Draw.DrawData;
126597
+
126598
+ var config=varItem.Draw.Config;
126599
+ if (config)
126600
+ {
126601
+ if (config.Color) chart.Color=config.Color;
126602
+ if (IFrameSplitOperator.IsNumber(config.Radius)) chart.Radius=config.Radius;
126603
+ if (config.TextColor) chart.TextColor=config.TextColor;
126604
+ if (config.Font) chart.Font=config.Font;
126605
+ }
126606
+
126607
+ chart.BuildCacheData();
126608
+
126609
+ hqChart.ChartPaint.push(chart);
126610
+ }
126611
+
126612
+
126235
126613
  this.CreateClipColorStick=function(hqChart,windowIndex,varItem,id)
126236
126614
  {
126237
126615
  var chart=new ChartClipColorStick();
@@ -126594,6 +126972,9 @@ function ScriptIndex(name,script,args,option)
126594
126972
  case SCRIPT_CHART_NAME.SCATTER_PLOT:
126595
126973
  this.CreateScatterPlot(hqChart,windowIndex,item,i);
126596
126974
  break;
126975
+ case SCRIPT_CHART_NAME.SCATTER_PLOT_V2:
126976
+ this.CreateScatterPlotV2(hqChart,windowIndex,item,i);
126977
+ break;
126597
126978
  case SCRIPT_CHART_NAME.CLIP_COLOR_STICK:
126598
126979
  this.CreateClipColorStick(hqChart,windowIndex,item,i);
126599
126980
  break;
@@ -129155,6 +129536,16 @@ function APIScriptIndex(name,script,args,option, isOverlay)
129155
129536
 
129156
129537
  result.push(outVarItem);
129157
129538
  }
129539
+ else if (draw.DrawType==SCRIPT_CHART_NAME.SCATTER_PLOT_V2)
129540
+ {
129541
+ drawItem.Name=draw.Name;
129542
+ drawItem.Type=draw.Type;
129543
+ drawItem.DrawType=draw.DrawType;
129544
+ drawItem.DrawData=draw.DrawData;
129545
+ drawItem.Config=draw.Config;
129546
+ outVarItem.Draw=drawItem;
129547
+ result.push(outVarItem);
129548
+ }
129158
129549
  else if (draw.DrawType==SCRIPT_CHART_NAME.KLINE_TABLE)
129159
129550
  {
129160
129551
  drawItem.Name=draw.Name;
@@ -133250,6 +133641,14 @@ function JSReportChart(divElement)
133250
133641
  if (IFrameSplitOperator.IsBool(option.EnableDragHeader)) chart.EnableDragHeader=option.EnableDragHeader;
133251
133642
  if (IFrameSplitOperator.IsNumber(option.WheelPageType)) chart.WheelPageType=option.WheelPageType;
133252
133643
  if (IFrameSplitOperator.IsBool(option.PageUpDownCycle)) chart.PageUpDownCycle=option.PageUpDownCycle;
133644
+
133645
+ //数据下载提示信息
133646
+ if (IFrameSplitOperator.IsObject(option.SplashTitle))
133647
+ {
133648
+ var item=option.SplashTitle;
133649
+ if (item) chart.SplashTitle.StockList=item.StockList;
133650
+ if (item) chart.SplashTitle.MemberList=item.MemberList;
133651
+ }
133253
133652
 
133254
133653
 
133255
133654
  if (option.VScrollbar) chart.SetVScrollbar(option.VScrollbar);
@@ -156746,7 +157145,7 @@ function HQChartScriptWorker()
156746
157145
 
156747
157146
 
156748
157147
 
156749
- var HQCHART_VERSION="1.1.14616";
157148
+ var HQCHART_VERSION="1.1.14620";
156750
157149
 
156751
157150
  function PrintHQChartVersion()
156752
157151
  {