hqchart 1.1.13707 → 1.1.13711

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.
@@ -39939,6 +39939,303 @@ function ChartMACD()
39939
39939
  }
39940
39940
  }
39941
39941
 
39942
+ function ChartClipColorStick()
39943
+ {
39944
+ this.newMethod=IChartPainting; //派生
39945
+ this.newMethod();
39946
+ delete this.newMethod;
39947
+
39948
+ this.ClassName="ChartClipColorStick";
39949
+ this.UpColor=g_JSChartResource.UpBarColor;
39950
+ this.DownColor=g_JSChartResource.DownBarColor;
39951
+ this.LineWidth=1;
39952
+ //差值线
39953
+ this.DownDiffColor=g_JSChartResource.DownBarColor;
39954
+ this.UpDiffColor=g_JSChartResource.UpBarColor;
39955
+
39956
+ this.BaseLineColor; //基准线
39957
+
39958
+ this.BaseValue=0;
39959
+ this.Super_GetMaxMin=this.GetMaxMin; //父类的方法
39960
+
39961
+ this.SetOption=function(option)
39962
+ {
39963
+ if (!option) return;
39964
+
39965
+ if (option.UpColor) this.UpColor=option.UpColor;
39966
+ if (option.DownColor) this.DownColor=option.DownColor;
39967
+ if (option.DownDiffColor) this.DownDiffColor=option.DownDiffColor;
39968
+ if (option.UpDiffColor) this.UpDiffColor=option.UpDiffColor;
39969
+ if (option.BaseLineColor) this.BaseLineColor=option.BaseLineColor;
39970
+ if (IFrameSplitOperator.IsNumber(option.BaseValue)) this.BaseValue=option.BaseValue;
39971
+ }
39972
+
39973
+ this.Draw=function()
39974
+ {
39975
+ if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
39976
+ if (this.IsShowIndexTitleOnly()) return;
39977
+ if (this.IsHideScriptIndex()) return;
39978
+
39979
+ if (this.NotSupportMessage)
39980
+ {
39981
+ this.DrawNotSupportmessage();
39982
+ return;
39983
+ }
39984
+
39985
+ this.Canvas.save();
39986
+ var dataWidth=this.ChartFrame.DataWidth;
39987
+ var lineWidth=this.LineWidth*GetDevicePixelRatio();
39988
+ if (this.LineWidth==50) lineWidth=dataWidth;
39989
+ else if (lineWidth>dataWidth) lineWidth=dataWidth;
39990
+
39991
+ if (IFrameSplitOperator.IsNumber(this.BaseValue) && this.BaseValue!=0)
39992
+ {
39993
+ this.DrawBaseLine();
39994
+
39995
+ if (this.BaseValue>0) this.DrawBars(lineWidth, true);
39996
+ else this.DrawBars(lineWidth, false);
39997
+ }
39998
+ else
39999
+ {
40000
+ //上下分开画
40001
+ this.DrawBars(lineWidth, true);
40002
+ this.DrawBars(lineWidth, false);
40003
+ }
40004
+
40005
+
40006
+ this.Canvas.restore();
40007
+ }
40008
+
40009
+ this.DrawBars=function(lineWidth, bUpBar)
40010
+ {
40011
+ var isMinute=this.IsMinuteFrame();
40012
+ var dataWidth=this.ChartFrame.DataWidth;
40013
+ var distanceWidth=this.ChartFrame.DistanceWidth;
40014
+ var xPointCount=this.ChartFrame.XPointCount;
40015
+ var isHSCreen=this.ChartFrame.IsHScreen===true;
40016
+
40017
+ if (isHSCreen)
40018
+ {
40019
+ var border=this.ChartBorder.GetHScreenBorder();
40020
+ var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
40021
+ var chartright=border.BottomEx;
40022
+ var lockRect=this.GetLockRect();
40023
+ if (lockRect) chartright=lockRect.Top;
40024
+ }
40025
+ else
40026
+ {
40027
+ var border=this.ChartBorder.GetBorder();
40028
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
40029
+
40030
+ var chartright=border.RightEx;
40031
+ var lockRect=this.GetLockRect();
40032
+ if (lockRect) chartright=lockRect.Left;
40033
+ }
40034
+
40035
+ var yBottom=this.ChartFrame.GetYFromData(this.BaseValue);
40036
+ var aryBar=[], aryDiffBar=[];
40037
+ for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
40038
+ {
40039
+ var value=this.Data.Data[i];
40040
+ if (value==null) continue;
40041
+ if (bUpBar)
40042
+ {
40043
+ if (value<0) continue;
40044
+ }
40045
+ else
40046
+ {
40047
+ if (value>=0) continue;
40048
+ }
40049
+
40050
+ if (isMinute)
40051
+ {
40052
+ var x=this.ChartFrame.GetXFromIndex(j);
40053
+ }
40054
+ else
40055
+ {
40056
+ var left=xOffset;
40057
+ var right=xOffset+dataWidth;
40058
+ if (right>chartright) break;
40059
+ var x=left+(right-left)/2;
40060
+ }
40061
+
40062
+ if (x>chartright) break;
40063
+
40064
+ var bDiffBar=false;
40065
+ var diffValue=null;
40066
+ if (this.BaseValue>0)
40067
+ {
40068
+ if (value<this.BaseValue)
40069
+ {
40070
+ bDiffBar=true;
40071
+ diffValue=this.BaseValue-(this.BaseValue-value);
40072
+ }
40073
+ }
40074
+ else if (this.BaseValue<0)
40075
+ {
40076
+ if (value>this.BaseValue)
40077
+ {
40078
+ bDiffBar=true;
40079
+ diffValue=this.BaseValue+(value-this.BaseValue)
40080
+ }
40081
+ }
40082
+
40083
+ if (!bDiffBar)
40084
+ {
40085
+ var y=this.ChartFrame.GetYFromData(value);
40086
+ aryBar.push({X:x, Y:y});
40087
+ }
40088
+ else
40089
+ {
40090
+ var y=this.ChartFrame.GetYFromData(diffValue);
40091
+ aryDiffBar.push({X:x, Y:y});
40092
+ }
40093
+ }
40094
+
40095
+ this.Canvas.lineWidth=lineWidth;
40096
+ if (bUpBar) this.Canvas.strokeStyle=this.UpColor;
40097
+ else this.Canvas.strokeStyle=this.DownColor;
40098
+
40099
+ this.DrawStick(aryBar,lineWidth,yBottom);
40100
+
40101
+ if (this.BaseValue>0)
40102
+ {
40103
+ this.Canvas.strokeStyle=this.UpDiffColor;
40104
+ this.DrawStick(aryDiffBar,lineWidth,yBottom);
40105
+ }
40106
+ else if (this.BaseValue<0)
40107
+ {
40108
+ this.Canvas.strokeStyle=this.DownDiffColor;
40109
+ this.DrawStick(aryDiffBar,lineWidth,yBottom);
40110
+ }
40111
+
40112
+ }
40113
+
40114
+ this.DrawStick=function(aryData, lineWidth, yBottom)
40115
+ {
40116
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryData)) return;
40117
+
40118
+ var isHSCreen=this.ChartFrame.IsHScreen===true;
40119
+ var drawCount=0;
40120
+ this.Canvas.beginPath();
40121
+ for(var i=0; i<aryData.length; ++i)
40122
+ {
40123
+ var item=aryData[i];
40124
+ var y=item.Y;
40125
+ var xFix=ToFixedPoint2(lineWidth, item.X); //毛边修正
40126
+
40127
+ if (isHSCreen)
40128
+ {
40129
+ this.Canvas.moveTo(yBottom,ToFixedPoint(x));
40130
+ this.Canvas.lineTo(y,ToFixedPoint(x));
40131
+ }
40132
+ else
40133
+ {
40134
+ this.Canvas.moveTo(xFix,yBottom);
40135
+ this.Canvas.lineTo(xFix,y);
40136
+ }
40137
+
40138
+ ++drawCount;
40139
+ }
40140
+
40141
+ if (drawCount>0) this.Canvas.stroke();
40142
+ }
40143
+
40144
+ this.DrawBaseLine=function()
40145
+ {
40146
+ if (!IFrameSplitOperator.IsNumber(this.BaseValue) || this.BaseValue==0) return;
40147
+ if (!this.BaseLineColor) return;
40148
+
40149
+ var isHSCreen=this.ChartFrame.IsHScreen===true;
40150
+ var border=this.ChartFrame.GetBorder();
40151
+ var y=this.ChartFrame.GetYFromData(this.BaseValue);
40152
+
40153
+ this.Canvas.strokeStyle=this.BaseLineColor;
40154
+ this.Canvas.lineWidth=1*GetDevicePixelRatio();
40155
+
40156
+ if (isHSCreen)
40157
+ {
40158
+
40159
+ }
40160
+ else
40161
+ {
40162
+ var yFix=ToFixedPoint(y);
40163
+ this.Canvas.beginPath();
40164
+ this.Canvas.moveTo(border.Left,yFix);
40165
+ this.Canvas.lineTo(border.Right,yFix);
40166
+ this.Canvas.stroke();
40167
+ }
40168
+ }
40169
+
40170
+ this.GetMaxMin=function()
40171
+ {
40172
+ if (!IFrameSplitOperator.IsNumber(this.BaseValue) || this.BaseValue==0)
40173
+ return this.Super_GetMaxMin();
40174
+
40175
+ var xPointCount=this.ChartFrame.XPointCount;
40176
+ var start=this.Data.DataOffset;
40177
+ if (this.ChartFrame.GlobalOption && this.ChartFrame.GlobalOption.IsValueFullRange)
40178
+ {
40179
+ start=0;
40180
+ xPointCount=this.Data.Data.length;
40181
+ }
40182
+
40183
+ var range={ Min:null, Max:null }, maxDiffValue=null; //基准值的差值
40184
+ if(!this.Data || !this.Data.Data) return range;
40185
+
40186
+ if (this.BaseValue>0) range.Min=this.BaseValue;
40187
+ else range.Max=this.BaseValue;
40188
+
40189
+ for(var i=start,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j)
40190
+ {
40191
+ var value=this.Data.Data[i];
40192
+ if (value==null || isNaN(value)) continue;
40193
+
40194
+ if (this.BaseValue>0)
40195
+ {
40196
+ if (value<0) continue;
40197
+
40198
+ if (value<this.BaseValue)
40199
+ {
40200
+ var diffValue=this.BaseValue-value;
40201
+ if (maxDiffValue==null || maxDiffValue<diffValue) maxDiffValue=diffValue;
40202
+ continue;
40203
+ }
40204
+ }
40205
+ else
40206
+ {
40207
+ if (value>0) continue;
40208
+
40209
+ if (value>this.BaseValue)
40210
+ {
40211
+ var diffValue=value-this.BaseValue;
40212
+ if (maxDiffValue==null || maxDiffValue<diffValue) maxDiffValue=diffValue;
40213
+ continue;
40214
+ }
40215
+ }
40216
+
40217
+ if (range.Max==null) range.Max=value;
40218
+ if (range.Min==null) range.Min=value;
40219
+
40220
+ if (range.Max<value) range.Max=value;
40221
+ if (range.Min>value) range.Min=value;
40222
+ }
40223
+
40224
+ if (this.BaseValue>0)
40225
+ {
40226
+ if (IFrameSplitOperator.IsNumber(maxDiffValue) && IFrameSplitOperator.IsNumber(range.Min))
40227
+ range.Min-=maxDiffValue;
40228
+ }
40229
+ else
40230
+ {
40231
+ if (IFrameSplitOperator.IsNumber(maxDiffValue) && IFrameSplitOperator.IsNumber(range.Max))
40232
+ range.Max+=maxDiffValue;
40233
+ }
40234
+
40235
+ return range;
40236
+ }
40237
+ }
40238
+
39942
40239
  //柱子
39943
40240
  function ChartBar()
39944
40241
  {
@@ -118068,6 +118365,8 @@ var SCRIPT_CHART_NAME=
118068
118365
  OVERLAY_BARS:"OVERLAY_BARS", //叠加柱子图
118069
118366
  KLINE_TABLE:"KLINE_TABLE",
118070
118367
  SCATTER_PLOT:"SCATTER_PLOT", //散点图
118368
+
118369
+ CLIP_COLOR_STICK:"CLIP_COLOR_STICK", //上下柱子 裁剪
118071
118370
  }
118072
118371
 
118073
118372
 
@@ -119826,6 +120125,33 @@ function ScriptIndex(name,script,args,option)
119826
120125
  hqChart.ChartPaint.push(chart);
119827
120126
  }
119828
120127
 
120128
+ this.CreateClipColorStick=function(hqChart,windowIndex,varItem,id)
120129
+ {
120130
+ var chart=new ChartClipColorStick();
120131
+ chart.Canvas=hqChart.Canvas;
120132
+ chart.Name=varItem.Name;
120133
+ chart.ChartBorder=hqChart.Frame.SubFrame[windowIndex].Frame.ChartBorder;
120134
+ chart.ChartFrame=hqChart.Frame.SubFrame[windowIndex].Frame;
120135
+ chart.HQChart=hqChart;
120136
+ chart.Identify=this.Guid;
120137
+
120138
+ chart.Data.Data=varItem.Draw.DrawData;
120139
+ if (varItem.Option && chart.SetOption) chart.SetOption(varItem.Option);
120140
+ hqChart.ChartPaint.push(chart);
120141
+
120142
+ var titleIndex=windowIndex+1;
120143
+ if (varItem.IsShowTitle===false)
120144
+ {
120145
+
120146
+ }
120147
+ else
120148
+ {
120149
+ var clrTitle=this.GetDefaultColor(id);
120150
+ if (varItem.Option && varItem.Option.TitleColor) clrTitle=this.GetColor(varItem.Option.TitleColor);
120151
+ hqChart.TitlePaint[titleIndex].Data[id]=new DynamicTitleData(chart.Data,varItem.Name,clrTitle);
120152
+ }
120153
+ }
120154
+
119829
120155
  this.CreateColorKLine=function(hqChart,windowIndex,varItem,i)
119830
120156
  {
119831
120157
  let chart=new ChartColorKline();
@@ -120143,6 +120469,9 @@ function ScriptIndex(name,script,args,option)
120143
120469
  case SCRIPT_CHART_NAME.SCATTER_PLOT:
120144
120470
  this.CreateScatterPlot(hqChart,windowIndex,item,i);
120145
120471
  break;
120472
+ case SCRIPT_CHART_NAME.CLIP_COLOR_STICK:
120473
+ this.CreateClipColorStick(hqChart,windowIndex,item,i);
120474
+ break;
120146
120475
  default:
120147
120476
  {
120148
120477
  var find=g_ScriptIndexChartFactory.Get(item.Draw.DrawType); //外部挂接
@@ -122578,6 +122907,20 @@ function APIScriptIndex(name,script,args,option, isOverlay)
122578
122907
 
122579
122908
  result.push(outVarItem);
122580
122909
  }
122910
+ else if (draw.DrawType==SCRIPT_CHART_NAME.CLIP_COLOR_STICK)
122911
+ {
122912
+ drawItem.Name=draw.Name;
122913
+ drawItem.Type=draw.Type;
122914
+ drawItem.DrawType=draw.DrawType;
122915
+ drawItem.DrawData=this.FittingArray(draw.Data,date,time,hqChart);
122916
+
122917
+ outVarItem.Draw=drawItem;
122918
+ if (draw.LineWidth) outVarItem.LineWidth=draw.LineWidth;
122919
+ if (draw.UpColor) outVarItem.UpColor=draw.UpColor;
122920
+ if (draw.DownColor) outVarItem.DownColor=draw.DownColor;
122921
+
122922
+ result.push(outVarItem);
122923
+ }
122581
122924
  else
122582
122925
  {
122583
122926
  var find=g_ScriptIndexChartFactory.Get(draw.DrawType); //外部挂接
@@ -122780,7 +123123,8 @@ function APIScriptIndex(name,script,args,option, isOverlay)
122780
123123
  for(var i=0;i<outVar.length;++i)
122781
123124
  {
122782
123125
  var item=outVar[i];
122783
- var outVarItem={Name:item.name,Type:item.type}
123126
+ var outVarItem={ Name:item.name,Type:item.type };
123127
+ if (IFrameSplitOperator.IsBool(item.IsShowTitle)) outVarItem.IsShowTitle = item.IsShowTitle; //是否显示指标标题
122784
123128
  if (item.data)
122785
123129
  {
122786
123130
  outVarItem.Data=this.FittingMinuteArray(item.data,date,time,hqChart);
@@ -122842,6 +123186,17 @@ function APIScriptIndex(name,script,args,option, isOverlay)
122842
123186
 
122843
123187
  result.push(outVarItem);
122844
123188
  }
123189
+ else if (draw.DrawType==SCRIPT_CHART_NAME.CLIP_COLOR_STICK)
123190
+ {
123191
+ drawItem.Name=draw.Name;
123192
+ drawItem.Type=draw.Type;
123193
+ drawItem.DrawType=draw.DrawType;
123194
+ drawItem.DrawData=this.FittingMinuteArray(draw.Data,date,time,hqChart);
123195
+
123196
+ outVarItem.Draw=drawItem;
123197
+ if (draw.Option) outVarItem.Option=draw.Option;
123198
+ result.push(outVarItem);
123199
+ }
122845
123200
  else if (draw.DrawType=='MULTI_LINE')
122846
123201
  {
122847
123202
  drawItem.Text=draw.Text;
@@ -142299,7 +142654,7 @@ function HQChartScriptWorker()
142299
142654
 
142300
142655
 
142301
142656
 
142302
- var HQCHART_VERSION="1.1.13706";
142657
+ var HQCHART_VERSION="1.1.13710";
142303
142658
 
142304
142659
  function PrintHQChartVersion()
142305
142660
  {