hqchart 1.1.13313 → 1.1.13324

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.
@@ -5541,6 +5541,7 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
5541
5541
 
5542
5542
  //画图工具
5543
5543
  if (option.EnableDrawToolDialogV2===true) chart.InitalDrawToolDialog();
5544
+ if (option.EnableModifyDrawDialogV2===true) chart.InitalModifyDrawDialog();
5544
5545
 
5545
5546
  //注册事件
5546
5547
  if (option.EventCallback)
@@ -6803,6 +6804,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
6803
6804
  this.IsShowRightMenu=true; //显示右键菜单
6804
6805
 
6805
6806
  this.DialogDrawTool; //画图工具
6807
+ this.DialogModifyDraw; //画图修改
6806
6808
 
6807
6809
 
6808
6810
  this.ClearStockCache=function()
@@ -6827,6 +6829,15 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
6827
6829
  this.DialogDrawTool.Create();
6828
6830
  }
6829
6831
 
6832
+ this.InitalModifyDrawDialog=function()
6833
+ {
6834
+ if ( this.DialogModifyDraw) return;
6835
+
6836
+ this.DialogModifyDraw=new JSDialogModifyDraw();
6837
+ this.DialogModifyDraw.Inital(this);
6838
+ this.DialogModifyDraw.Create();
6839
+ }
6840
+
6830
6841
  this.ShowDrawToolDialog=function(x,y)
6831
6842
  {
6832
6843
  if (!this.DialogDrawTool) return;
@@ -6849,6 +6860,31 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
6849
6860
  return this.DialogDrawTool.IsShow();
6850
6861
  }
6851
6862
 
6863
+ this.ShowModifyDrawDialog=function(chart, x,y)
6864
+ {
6865
+ if (!this.DialogModifyDraw) return;
6866
+
6867
+ this.DialogModifyDraw.SetChartPicture(chart);
6868
+ if (this.DialogModifyDraw.IsShow()) return;
6869
+
6870
+ var rtClient=this.UIElement.getBoundingClientRect();
6871
+ var rtScroll=GetScrollPosition();
6872
+
6873
+ var top=this.UIElement.offsetTop+15;
6874
+ var left=(this.UIElement.offsetWidth-this.DialogModifyDraw.DivDialog.offsetWidth)/2;
6875
+ left+=rtClient.left+rtScroll.Left;
6876
+ top+=rtClient.top+rtScroll.Top;
6877
+
6878
+ this.DialogModifyDraw.Show(left, top);
6879
+ }
6880
+
6881
+ this.CloseModifyDrawDialog=function()
6882
+ {
6883
+ if (!this.DialogModifyDraw) return;
6884
+
6885
+ this.DialogModifyDraw.Close();
6886
+ }
6887
+
6852
6888
  //obj={ Element:, Canvas: }
6853
6889
  this.SetCorssCursorElement=function(obj)
6854
6890
  {
@@ -7528,6 +7564,9 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
7528
7564
  }
7529
7565
  }
7530
7566
 
7567
+
7568
+ if (!this.SelectChartDrawPicture) this.CloseModifyDrawDialog(); //当前没有选中画图 隐藏画图修改框
7569
+
7531
7570
  document.onmousemove=(e)=>{ this.DocOnMouseMove(e); }
7532
7571
  document.onmouseup=(e)=> { this.DocOnMouseUp(e); }
7533
7572
 
@@ -10222,6 +10261,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10222
10261
  this.SelectChartDrawPicture=null;
10223
10262
  if (this.ChartPictureMenu) this.ChartPictureMenu.Hide();
10224
10263
  this.ClearChartDrawPicture(drawPicture); //删除选中的画图工具
10264
+ this.CloseModifyDrawDialog();
10225
10265
  }
10226
10266
  else if (this.SelectedChart && this.SelectedChart.Selected.Identify)
10227
10267
  {
@@ -11928,11 +11968,23 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
11928
11968
  this.OnSelectChartPicture=function(chart)
11929
11969
  {
11930
11970
  JSConsole.Chart.Log('[JSChartContainer::OnSelectChartPicture]',chart);
11931
- if (!this.ChartPictureMenu) this.ChartPictureMenu=g_DialogFactory.Create('ChartPictureSettingMenu', this.UIElement.parentNode);
11932
- if (!this.ChartPictureMenu) return;
11933
11971
 
11934
- var event={ data: { ChartPicture:chart, HQChart:this}};
11935
- this.ChartPictureMenu.DoModal(event);
11972
+ if (!this.DialogModifyDraw) return;
11973
+
11974
+ if (chart.ClassName=="ChartDrawPictureText" || chart.ClassName=='ChartDrawVolProfile')
11975
+ {
11976
+ this.CloseModifyDrawDialog();
11977
+
11978
+ if (!this.ChartPictureMenu) this.ChartPictureMenu=g_DialogFactory.Create('ChartPictureSettingMenu', this.UIElement.parentNode);
11979
+ if (!this.ChartPictureMenu) return;
11980
+
11981
+ var event={ data: { ChartPicture:chart, HQChart:this}};
11982
+ this.ChartPictureMenu.DoModal(event);
11983
+ }
11984
+ else
11985
+ {
11986
+ this.ShowModifyDrawDialog(chart);
11987
+ }
11936
11988
  }
11937
11989
 
11938
11990
  this.FinishMoveChartDrawPicture=function()
@@ -64359,7 +64411,6 @@ function ChartDrawMonitorLine()
64359
64411
  LineDash:[3,5],
64360
64412
  }
64361
64413
 
64362
-
64363
64414
  this.SetOption=function(option)
64364
64415
  {
64365
64416
  if (option.LineColor) this.LineColor=option.LineColor;
@@ -64373,8 +64424,8 @@ function ChartDrawMonitorLine()
64373
64424
  if (item.LineDash) dest.LineDash=item.LineDash;
64374
64425
  if (IFrameSplitOperator.IsNumber(item.YTextOffset)) dest.YTextOffset=item.YTextOffset;
64375
64426
  }
64376
-
64377
- if (option.FormatLabelText) this.FormatLabelTextCallback=option.FormatLabelText;
64427
+
64428
+ if (option.FormatLabelTextCallback) this.FormatLabelTextCallback=option.FormatLabelTextCallback;
64378
64429
  }
64379
64430
 
64380
64431
  this.Draw=function()
@@ -100278,6 +100329,35 @@ function JSAlgorithm(errorHandler,symbolData)
100278
100329
  return result;
100279
100330
  }
100280
100331
 
100332
+ //反向过滤连续出现的信号.
100333
+ //用法:FILTERX(X,N):X满足条件后,将其前N周期内的数据置为0,N为常量.
100334
+ //例如:FILTERX(CLOSE>OPEN,5)查找阳线,前5天内出现过的阳线不被记录在内
100335
+ this.FILTERX=function(data, n, node)
100336
+ {
100337
+ var result=[];
100338
+ for(let i=0,j=0; i<data.length; ++i)
100339
+ {
100340
+ if (data[i])
100341
+ {
100342
+ result[i]=1;
100343
+ for(j=0;j<n && i-j-1>=0;++j)
100344
+ {
100345
+ result[i-j-1]=0;
100346
+ }
100347
+ i+=n;
100348
+ }
100349
+ else
100350
+ {
100351
+ result[i]=0;
100352
+ }
100353
+ }
100354
+
100355
+ return result;
100356
+ }
100357
+
100358
+ //上一次条件成立到当前的周期数.
100359
+ //用法:BARSLAST(X):上一次X不为0到现在的周期数
100360
+ //例如:BARSLAST(CLOSE/REF(CLOSE,1)>=1.1)表示上一个涨停板到当前的周期数
100281
100361
  this.BARSLAST=function(data)
100282
100362
  {
100283
100363
  var result=[];
@@ -100297,6 +100377,52 @@ function JSAlgorithm(errorHandler,symbolData)
100297
100377
  return result;
100298
100378
  }
100299
100379
 
100380
+ //倒数第N次成立时距今的周期数.
100381
+ //用法:BARSLASTS(X,N):X倒数第N满足到现在的周期数,N支持变量
100382
+ this.BARSLASTS=function(data, n, node)
100383
+ {
100384
+ var result=[];
100385
+ if (!data) return result;
100386
+ if (n<=0) n=data.length;
100387
+
100388
+ var day=null;
100389
+ var SingleValue=0; //单词数
100390
+ var periodCount=0;
100391
+ for(let i=0;i<data.length;++i)
100392
+ {
100393
+ result[i]=null;
100394
+ var value=data[i];
100395
+
100396
+ if (value>0)
100397
+ {
100398
+ if (day==null)
100399
+ {
100400
+ day=0;
100401
+ ++periodCount;
100402
+ }
100403
+ else
100404
+ {
100405
+ ++periodCount;
100406
+ if (periodCount>n) day-=SingleValue;
100407
+ }
100408
+
100409
+ SingleValue=0;
100410
+ }
100411
+ else
100412
+ {
100413
+ if (day!=null)
100414
+ {
100415
+ ++day;
100416
+ ++SingleValue;
100417
+ }
100418
+ }
100419
+
100420
+ if (day!=null) result[i]=day;
100421
+ }
100422
+
100423
+ return result;
100424
+ }
100425
+
100300
100426
  /*
100301
100427
  N周期内第一个条件成立到当前的周期数.
100302
100428
  用法:
@@ -104318,10 +104444,15 @@ function JSAlgorithm(errorHandler,symbolData)
104318
104444
  return this.FILTER(args[0],args[1]);
104319
104445
  case 'TFILTER':
104320
104446
  return this.TFILTER(args[0],args[1],args[2]);
104447
+ case "FILTERX":
104448
+ return this.FILTERX(args[0],args[1],node);
104321
104449
  case 'SLOPE':
104322
104450
  return this.SLOPE(args[0],args[1]);
104323
104451
  case 'BARSLAST':
104324
104452
  return this.BARSLAST(args[0]);
104453
+ case "BARSLASTS":
104454
+ //this.ThrowUnexpectedNode(node,`函数'BARSLASTS'还在开发中`, name);
104455
+ return this.BARSLASTS(args[0],args[1],node);
104325
104456
  case 'BARSCOUNT':
104326
104457
  return this.BARSCOUNT(args[0]);
104327
104458
  case 'BARSSINCEN':
@@ -111744,6 +111875,7 @@ JSSymbolData.prototype.JsonDataToFinance=function(data)
111744
111875
 
111745
111876
  var JS_EXECUTE_DEBUG_LOG=false;
111746
111877
 
111878
+
111747
111879
  var JS_EXECUTE_JOB_ID=
111748
111880
  {
111749
111881
  JOB_DOWNLOAD_SYMBOL_DATA:1, //下载股票的K线数据
@@ -113771,6 +113903,7 @@ function JSExplainer(ast,option)
113771
113903
  this.JobList=[]; //执行的任务队列
113772
113904
  this.VarTable=new Map(); //变量表
113773
113905
  this.OutVarTable=[]; //输出变量
113906
+ this.MaxValueLength=150; //最长的字符
113774
113907
 
113775
113908
  //脚本自动变量表, 只读
113776
113909
  this.ConstVarTable=new Map(
@@ -113871,9 +114004,10 @@ function JSExplainer(ast,option)
113871
114004
  if (!this.AST) this.ThrowError();
113872
114005
  if (!this.AST.Body) this.ThrowError();
113873
114006
 
113874
- for(let i in this.AST.Body)
114007
+ for(var i=0; i<this.AST.Body.length; ++i)
113875
114008
  {
113876
- let item =this.AST.Body[i];
114009
+ //console.log(`[JSExplainer::RunAST] ${i}`);
114010
+ var item =this.AST.Body[i];
113877
114011
  this.VisitNode(item);
113878
114012
 
113879
114013
  //输出变量
@@ -113996,7 +114130,7 @@ function JSExplainer(ast,option)
113996
114130
  {
113997
114131
  varName=itemExpression.Left.Name;
113998
114132
  let varValue=this.VarTable.get(varName);
113999
- this.VarTable.set(varName,varValue); //把常量放到变量表里
114133
+ this.VarTable.set(varName,this.ConvertToShortValue(varValue)); //把常量放到变量表里
114000
114134
  }
114001
114135
  else if (itemExpression.Type==Syntax.Identifier)
114002
114136
  {
@@ -114034,7 +114168,7 @@ function JSExplainer(ast,option)
114034
114168
  let varValue=this.ReadVariable(varName,itemExpression);
114035
114169
  varName="__temp_si_"+i+"__";
114036
114170
  isNoneName=true;
114037
- this.VarTable.set(varName,varValue); //放到变量表里
114171
+ this.VarTable.set(varName,this.ConvertToShortValue(varValue)); //放到变量表里
114038
114172
  }
114039
114173
  }
114040
114174
  else if(itemExpression.Type==Syntax.Literal) //常量
@@ -114239,7 +114373,7 @@ function JSExplainer(ast,option)
114239
114373
  return node.Out;
114240
114374
  }
114241
114375
 
114242
- JSConsole.Complier.Log('[JSExplainer::VisitCallExpression]' , funcName, '(', args.toString() ,')');
114376
+ if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitCallExpression]' , funcName, '(', args.toString() ,')');
114243
114377
 
114244
114378
  if (g_JSComplierResource.IsCustomFunction(funcName))
114245
114379
  {
@@ -114266,6 +114400,8 @@ function JSExplainer(ast,option)
114266
114400
  ["BARSLASTCOUNT", { Name:"BARSLASTCOUNT", Param:{ Count:1 }, ToString:function(args) { return `条件${args[0]}连续成立次数`; } } ],
114267
114401
  ["BARSCOUNT", { Name:"BARSCOUNT", Param:{ Count:1 }, ToString:function(args) { return `${args[0]}有效数据周期数`; } } ],
114268
114402
  ["BARSLAST", { Name:"BARSLAST", Param:{ Count:1 }, ToString:function(args) { return `上次${args[0]}不为0距今天数`; } } ],
114403
+ ["BARSLASTS", { Name:"BARSLASTS", Param:{ Count:2 }, ToString:function(args) { return `倒数第N次成立时距今的周期数`; } } ],
114404
+
114269
114405
  ["BARSNEXT", { Name:"BARSNEXT", Param:{ Count:1 }, ToString:function(args) { return `下次${args[0]}不为0距今天数`; } } ],
114270
114406
  ["BARSSINCEN", { Name:"BARSSINCEN", Param:{ Count:2 }, ToString:function(args) { return `在${args[1]}周期内首次${args[0]}距今天数`; } } ],
114271
114407
  ["BARSSINCE", { Name:"BARSSINCE", Param:{ Count:1 }, ToString:function(args) { return `首次${args[0]}距今天数`; } } ],
@@ -114433,7 +114569,7 @@ function JSExplainer(ast,option)
114433
114569
  if (item.Param.Count!=args.length)
114434
114570
  this.ThrowUnexpectedNode(node,`函数${funcName}参数个数不正确. 需要${item.Param.Count}个参数`);
114435
114571
  }
114436
-
114572
+
114437
114573
  return item.ToString(args);
114438
114574
  }
114439
114575
 
@@ -114710,8 +114846,22 @@ function JSExplainer(ast,option)
114710
114846
  else if (right.Type==Syntax.UnaryExpression)
114711
114847
  value=this.VisitUnaryExpression(right);
114712
114848
 
114713
- JSConsole.Complier.Log('[JSExplainer::VisitAssignmentExpression]' , varName, ' = ',value);
114714
- this.VarTable.set(varName,value);
114849
+ if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitAssignmentExpression]' , varName, ' = ',value);
114850
+
114851
+ this.VarTable.set(varName,this.ConvertToShortValue(value));
114852
+ }
114853
+
114854
+ this.ConvertToShortValue=function(value)
114855
+ {
114856
+ var maxLength=this.MaxValueLength;
114857
+ if (value && value.length>=maxLength)
114858
+ {
114859
+ var shortValue=value.slice(0, maxLength-10);
114860
+ shortValue+="......";
114861
+ return shortValue;
114862
+ }
114863
+
114864
+ return value;
114715
114865
  }
114716
114866
 
114717
114867
  this.ReadMemberVariable=function(node)
@@ -114771,7 +114921,7 @@ function JSExplainer(ast,option)
114771
114921
  let leftValue=this.GetNodeValue(value.Left);
114772
114922
  let rightValue=this.GetNodeValue(value.Right);
114773
114923
 
114774
- JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] BinaryExpression',value , leftValue, rightValue);
114924
+ if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] BinaryExpression',value , leftValue, rightValue);
114775
114925
  value.Out=null; //保存中间值
114776
114926
 
114777
114927
  value.Out=`(${leftValue} ${value.Operator} ${rightValue})`;
@@ -114788,14 +114938,14 @@ function JSExplainer(ast,option)
114788
114938
  else if (value.Operator=="=") value.Out='(平盘)';
114789
114939
  }
114790
114940
 
114791
- JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] BinaryExpression',value);
114941
+ if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] BinaryExpression',value);
114792
114942
  }
114793
114943
  else if (value.Type==Syntax.LogicalExpression)
114794
114944
  {
114795
114945
  let leftValue=this.GetNodeValue(value.Left);
114796
114946
  let rightValue=this.GetNodeValue(value.Right);
114797
114947
 
114798
- JSConsole.Complier.Log('[JSExecute::VisitBinaryExpression] LogicalExpression',value , leftValue, rightValue);
114948
+ if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExecute::VisitBinaryExpression] LogicalExpression',value , leftValue, rightValue);
114799
114949
  value.Out=null; //保存中间值
114800
114950
 
114801
114951
  switch(value.Operator)
@@ -114810,7 +114960,7 @@ function JSExplainer(ast,option)
114810
114960
  break;
114811
114961
  }
114812
114962
 
114813
- JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] LogicalExpression',value);
114963
+ if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] LogicalExpression',value);
114814
114964
  }
114815
114965
 
114816
114966
  node=temp;
@@ -132735,7 +132885,7 @@ function ScrollBarBGChart()
132735
132885
 
132736
132886
 
132737
132887
 
132738
- var HQCHART_VERSION="1.1.13312";
132888
+ var HQCHART_VERSION="1.1.13323";
132739
132889
 
132740
132890
  function PrintHQChartVersion()
132741
132891
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var HQCHART_VERSION="1.1.13312";
8
+ var HQCHART_VERSION="1.1.13323";
9
9
 
10
10
  function PrintHQChartVersion()
11
11
  {