hqchart 1.1.13318 → 1.1.13327

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hqchart",
3
- "version": "1.1.13318",
3
+ "version": "1.1.13327",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -18,6 +18,9 @@ var JS_DRAWTOOL_MENU_ID=
18
18
  CMD_ERASE_DRAW_CHART_ID:4,
19
19
  CMD_ENABLE_MAGNET_ID:5, //画图工具磁体功能
20
20
  CMD_DELETE_DRAW_CHART_ID:6,
21
+
22
+ CMD_CHANGE_FONT_COLOR_ID:7, //切换字体颜色
23
+ CMD_CHANGE_BG_COLOR_ID:8 //切换背景色
21
24
  };
22
25
 
23
26
  function JSDialogDrawTool()
@@ -545,16 +548,23 @@ function JSDialogModifyDraw()
545
548
  this.DivDialog=null;
546
549
  this.HQChart;
547
550
  this.ChartPicture;
551
+ //按钮
548
552
  this.ColorButton=null;
553
+ this.BGColorButton=null;
554
+ this.FontColorButton=null;
555
+
556
+ this.RandomLineColor=["rgb(255,69,0)", "rgb(173,255,47)", "rgb(238,154,73)", "rgb(255,105,180)"]; //线段颜色
557
+ this.RandomBGColor=["rgba(210,251,209,0.8)", "rgb(217,217,253)", "rgb(255,208,204)", "rgb(252,249,206)"]; //背景颜色
558
+ this.RandomFontColor=["rgb(0,0,0)", "rgb(255, 0, 0)", "rgb(20, 255, 0)", "rgb(255, 0, 255)"]; //文字颜色
549
559
 
550
- this.RandomLineColor=["rgb(255,69,0)", "rgb(173,255,47)", "rgb(238,154,73)", "rgb(255,105,180)"];
551
560
  this.AryButton=
552
561
  [
553
- { Title:"点击切换颜色", ClassName: 'hqchart_drawtool icon-fangkuai', Type:2, Data:{ ID:JS_DRAWTOOL_MENU_ID.CMD_CHANGE_LINE_COLOR_ID }},
562
+ { Title:"点击线段颜色", ClassName: 'hqchart_drawtool icon-huabi', Type:2, Data:{ ID:JS_DRAWTOOL_MENU_ID.CMD_CHANGE_LINE_COLOR_ID }},
563
+ { Title:"点击字体颜色", ClassName: 'hqchart_drawtool icon-zitiyanse', Type:2, Data:{ ID:JS_DRAWTOOL_MENU_ID.CMD_CHANGE_FONT_COLOR_ID }},
564
+ { Title:"点击背景色", ClassName: 'hqchart_drawtool icon-zitibeijingse', Type:2, Data:{ ID:JS_DRAWTOOL_MENU_ID.CMD_CHANGE_BG_COLOR_ID }},
554
565
  { Title:"删除", ClassName: 'hqchart_drawtool icon-recycle_bin', Type:2, Data:{ ID:JS_DRAWTOOL_MENU_ID.CMD_DELETE_DRAW_CHART_ID }}
555
566
  ];
556
-
557
-
567
+
558
568
  this.Inital=function(hqchart)
559
569
  {
560
570
  this.HQChart=hqchart;
@@ -605,11 +615,23 @@ function JSDialogModifyDraw()
605
615
  spanDom.classList.add("UMyChart_DrawTool_Span");
606
616
  divItem.appendChild(spanDom);
607
617
 
608
- var data={ Span:spanDom, Parent:parentDivDom, Item:item };
618
+ var data={ Div:divItem, Span:spanDom, Parent:parentDivDom, Item:item };
609
619
  divItem.onmousedown=(e)=> { this.OnClickButton(e, data); }; //点击
610
620
 
611
- if (item.Data.ID==JS_DRAWTOOL_MENU_ID.CMD_CHANGE_LINE_COLOR_ID)
612
- this.ColorButton=data;
621
+ switch(item.Data.ID)
622
+ {
623
+ case JS_DRAWTOOL_MENU_ID.CMD_CHANGE_LINE_COLOR_ID:
624
+ this.ColorButton=data;
625
+ break;
626
+ case JS_DRAWTOOL_MENU_ID.CMD_CHANGE_BG_COLOR_ID:
627
+ this.BGColorButton=data;
628
+ divItem.style.display="none";
629
+ break;
630
+ case JS_DRAWTOOL_MENU_ID.CMD_CHANGE_FONT_COLOR_ID:
631
+ this.FontColorButton=data;
632
+ divItem.style.display="none";
633
+ break;
634
+ }
613
635
 
614
636
  parentDivDom.appendChild(divItem);
615
637
  }
@@ -628,6 +650,12 @@ function JSDialogModifyDraw()
628
650
  case JS_DRAWTOOL_MENU_ID.CMD_DELETE_DRAW_CHART_ID:
629
651
  this.DeleteDrawPicture();
630
652
  break;
653
+ case JS_DRAWTOOL_MENU_ID.CMD_CHANGE_BG_COLOR_ID:
654
+ this.ModifyBGColor();
655
+ break;
656
+ case JS_DRAWTOOL_MENU_ID.CMD_CHANGE_FONT_COLOR_ID:
657
+ this.ModifyFontColor();
658
+ break;
631
659
  }
632
660
  }
633
661
 
@@ -655,23 +683,35 @@ function JSDialogModifyDraw()
655
683
  this.Close();
656
684
  }
657
685
 
658
- this.ModifyLineColor=function()
686
+ this.ShowButton=function(dom, diaplay)
659
687
  {
660
- if (!this.ChartPicture || !this.HQChart) return;
688
+ if (dom.style.display==diaplay) return;
689
+ dom.style.display=diaplay;
690
+ }
661
691
 
662
- var color=this.ChartPicture.LineColor;
692
+ this.GetRandomColor=function(currentColor, randomLineColor)
693
+ {
663
694
  var colorIndex=0;
664
- for(var i=0;i<this.RandomLineColor.length;++i)
695
+ for(var i=0;i<randomLineColor.length;++i)
665
696
  {
666
- if (color==this.RandomLineColor[i])
697
+ if (currentColor==randomLineColor[i])
667
698
  {
668
699
  colorIndex=i+1;
669
700
  break;
670
701
  }
671
702
  }
672
703
 
673
- colorIndex=colorIndex%this.RandomLineColor.length;
674
- color=this.RandomLineColor[colorIndex];
704
+ colorIndex=colorIndex%randomLineColor.length;
705
+ var color=randomLineColor[colorIndex];
706
+
707
+ return color;
708
+ }
709
+
710
+ this.ModifyLineColor=function()
711
+ {
712
+ if (!this.ChartPicture || !this.HQChart) return;
713
+
714
+ var color=this.GetRandomColor(this.ChartPicture.LineColor, this.RandomLineColor);
675
715
 
676
716
  this.ChartPicture.LineColor = color;
677
717
  this.ChartPicture.PointColor = color;
@@ -683,6 +723,32 @@ function JSDialogModifyDraw()
683
723
  this.HQChart.Draw();
684
724
  }
685
725
 
726
+ this.ModifyFontColor=function()
727
+ {
728
+ if (!this.ChartPicture || !this.HQChart) return;
729
+
730
+ var color=this.GetRandomColor(this.ChartPicture.TextColor, this.RandomFontColor);
731
+ this.ChartPicture.TextColor=color;
732
+
733
+ if (this.FontColorButton) this.FontColorButton.Span.style['color']=color;
734
+
735
+ if (this.HQChart.ChartDrawStorage) this.HQChart.ChartDrawStorage.SaveDrawData(this.ChartPicture); //保存下
736
+
737
+ this.HQChart.Draw();
738
+ }
739
+
740
+ this.ModifyBGColor=function()
741
+ {
742
+ if (!this.ChartPicture || !this.HQChart) return;
743
+ var color=this.GetRandomColor(this.ChartPicture.BGColor, this.RandomBGColor);
744
+
745
+ this.ChartPicture.BGColor=color;
746
+ if (this.BGColorButton) this.BGColorButton.Span.style['color']=color;
747
+ if (this.HQChart.ChartDrawStorage) this.HQChart.ChartDrawStorage.SaveDrawData(this.ChartPicture); //保存下
748
+
749
+ this.HQChart.Draw();
750
+ }
751
+
686
752
  this.Show=function(x, y)
687
753
  {
688
754
  if (!this.DivDialog) this.Create();
@@ -695,10 +761,48 @@ function JSDialogModifyDraw()
695
761
  this.SetChartPicture=function(chart)
696
762
  {
697
763
  this.ChartPicture=chart;
764
+
765
+ var bShowLineColor=true, bShowBGColor=false, bShowFontColor=false;
766
+ var bgColor=null, fontColor=null;
767
+ var ARRAY_TEXT_CHART=['ChartDrawPriceLabel', "ChartDrawAnchoredText","ChartDrawPriceNote","ChartDrawNote"];
768
+ if (ARRAY_TEXT_CHART.includes(chart.ClassName))
769
+ {
770
+ bShowBGColor=true;
771
+ bShowFontColor=true;
772
+ bgColor=chart.BGColor;
773
+ fontColor=chart.TextColor;
774
+ }
775
+
698
776
  if (this.ColorButton)
699
777
  {
700
- this.ColorButton.Span.style['color']=chart.LineColor;
778
+ var item=this.ColorButton;
779
+ this.ShowButton(item.Div, bShowLineColor?"block":"none");
780
+ if (bShowLineColor)
781
+ {
782
+ item.Span.style['color']=chart.LineColor;
783
+ }
784
+ }
785
+
786
+ if (this.BGColorButton)
787
+ {
788
+ var item=this.BGColorButton;
789
+ this.ShowButton(item.Div, bShowBGColor?"block":"none");
790
+ if (bShowBGColor)
791
+ {
792
+ item.Span.style['color']=bgColor;
793
+ }
794
+ }
795
+
796
+ if (this.FontColorButton)
797
+ {
798
+ var item=this.FontColorButton;
799
+ this.ShowButton(item.Div, bShowFontColor?"block":"none");
800
+ if (bShowFontColor)
801
+ {
802
+ item.Span.style['color']=fontColor;
803
+ }
701
804
  }
805
+
702
806
  }
703
807
 
704
808
  this.OnMouseDownTitle=function(e)
@@ -4847,6 +4847,35 @@ function JSAlgorithm(errorHandler,symbolData)
4847
4847
  return result;
4848
4848
  }
4849
4849
 
4850
+ //反向过滤连续出现的信号.
4851
+ //用法:FILTERX(X,N):X满足条件后,将其前N周期内的数据置为0,N为常量.
4852
+ //例如:FILTERX(CLOSE>OPEN,5)查找阳线,前5天内出现过的阳线不被记录在内
4853
+ this.FILTERX=function(data, n, node)
4854
+ {
4855
+ var result=[];
4856
+ for(let i=0,j=0; i<data.length; ++i)
4857
+ {
4858
+ if (data[i])
4859
+ {
4860
+ result[i]=1;
4861
+ for(j=0;j<n && i-j-1>=0;++j)
4862
+ {
4863
+ result[i-j-1]=0;
4864
+ }
4865
+ i+=n;
4866
+ }
4867
+ else
4868
+ {
4869
+ result[i]=0;
4870
+ }
4871
+ }
4872
+
4873
+ return result;
4874
+ }
4875
+
4876
+ //上一次条件成立到当前的周期数.
4877
+ //用法:BARSLAST(X):上一次X不为0到现在的周期数
4878
+ //例如:BARSLAST(CLOSE/REF(CLOSE,1)>=1.1)表示上一个涨停板到当前的周期数
4850
4879
  this.BARSLAST=function(data)
4851
4880
  {
4852
4881
  var result=[];
@@ -4866,6 +4895,52 @@ function JSAlgorithm(errorHandler,symbolData)
4866
4895
  return result;
4867
4896
  }
4868
4897
 
4898
+ //倒数第N次成立时距今的周期数.
4899
+ //用法:BARSLASTS(X,N):X倒数第N满足到现在的周期数,N支持变量
4900
+ this.BARSLASTS=function(data, n, node)
4901
+ {
4902
+ var result=[];
4903
+ if (!data) return result;
4904
+ if (n<=0) n=data.length;
4905
+
4906
+ var day=null;
4907
+ var SingleValue=0; //单词数
4908
+ var periodCount=0;
4909
+ for(let i=0;i<data.length;++i)
4910
+ {
4911
+ result[i]=null;
4912
+ var value=data[i];
4913
+
4914
+ if (value>0)
4915
+ {
4916
+ if (day==null)
4917
+ {
4918
+ day=0;
4919
+ ++periodCount;
4920
+ }
4921
+ else
4922
+ {
4923
+ ++periodCount;
4924
+ if (periodCount>n) day-=SingleValue;
4925
+ }
4926
+
4927
+ SingleValue=0;
4928
+ }
4929
+ else
4930
+ {
4931
+ if (day!=null)
4932
+ {
4933
+ ++day;
4934
+ ++SingleValue;
4935
+ }
4936
+ }
4937
+
4938
+ if (day!=null) result[i]=day;
4939
+ }
4940
+
4941
+ return result;
4942
+ }
4943
+
4869
4944
  /*
4870
4945
  N周期内第一个条件成立到当前的周期数.
4871
4946
  用法:
@@ -8887,10 +8962,15 @@ function JSAlgorithm(errorHandler,symbolData)
8887
8962
  return this.FILTER(args[0],args[1]);
8888
8963
  case 'TFILTER':
8889
8964
  return this.TFILTER(args[0],args[1],args[2]);
8965
+ case "FILTERX":
8966
+ return this.FILTERX(args[0],args[1],node);
8890
8967
  case 'SLOPE':
8891
8968
  return this.SLOPE(args[0],args[1]);
8892
8969
  case 'BARSLAST':
8893
8970
  return this.BARSLAST(args[0]);
8971
+ case "BARSLASTS":
8972
+ //this.ThrowUnexpectedNode(node,`函数'BARSLASTS'还在开发中`, name);
8973
+ return this.BARSLASTS(args[0],args[1],node);
8894
8974
  case 'BARSCOUNT':
8895
8975
  return this.BARSCOUNT(args[0]);
8896
8976
  case 'BARSSINCEN':
@@ -18341,6 +18421,7 @@ function JSExplainer(ast,option)
18341
18421
  this.JobList=[]; //执行的任务队列
18342
18422
  this.VarTable=new Map(); //变量表
18343
18423
  this.OutVarTable=[]; //输出变量
18424
+ this.MaxValueLength=150; //最长的字符
18344
18425
 
18345
18426
  //脚本自动变量表, 只读
18346
18427
  this.ConstVarTable=new Map(
@@ -19290,7 +19371,7 @@ function JSExplainer(ast,option)
19290
19371
 
19291
19372
  this.ConvertToShortValue=function(value)
19292
19373
  {
19293
- var maxLength=80;
19374
+ var maxLength=this.MaxValueLength;
19294
19375
  if (value && value.length>=maxLength)
19295
19376
  {
19296
19377
  var shortValue=value.slice(0, maxLength-10);
@@ -54,6 +54,24 @@
54
54
  <div class="content unicode" style="display: block;">
55
55
  <ul class="icon_lists dib-box">
56
56
 
57
+ <li class="dib">
58
+ <span class="icon hqchart_drawtool">&#xe656;</span>
59
+ <div class="name">字体背景色</div>
60
+ <div class="code-name">&amp;#xe656;</div>
61
+ </li>
62
+
63
+ <li class="dib">
64
+ <span class="icon hqchart_drawtool">&#xe686;</span>
65
+ <div class="name">字体颜色</div>
66
+ <div class="code-name">&amp;#xe686;</div>
67
+ </li>
68
+
69
+ <li class="dib">
70
+ <span class="icon hqchart_drawtool">&#xe663;</span>
71
+ <div class="name">画笔</div>
72
+ <div class="code-name">&amp;#xe663;</div>
73
+ </li>
74
+
57
75
  <li class="dib">
58
76
  <span class="icon hqchart_drawtool">&#xe6ff;</span>
59
77
  <div class="name">拖动</div>
@@ -414,9 +432,9 @@
414
432
  <pre><code class="language-css"
415
433
  >@font-face {
416
434
  font-family: 'hqchart_drawtool';
417
- src: url('iconfont.woff2?t=1715878738024') format('woff2'),
418
- url('iconfont.woff?t=1715878738024') format('woff'),
419
- url('iconfont.ttf?t=1715878738024') format('truetype');
435
+ src: url('iconfont.woff2?t=1716173088340') format('woff2'),
436
+ url('iconfont.woff?t=1716173088340') format('woff'),
437
+ url('iconfont.ttf?t=1716173088340') format('truetype');
420
438
  }
421
439
  </code></pre>
422
440
  <h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
@@ -442,6 +460,33 @@
442
460
  <div class="content font-class">
443
461
  <ul class="icon_lists dib-box">
444
462
 
463
+ <li class="dib">
464
+ <span class="icon hqchart_drawtool icon-zitibeijingse"></span>
465
+ <div class="name">
466
+ 字体背景色
467
+ </div>
468
+ <div class="code-name">.icon-zitibeijingse
469
+ </div>
470
+ </li>
471
+
472
+ <li class="dib">
473
+ <span class="icon hqchart_drawtool icon-zitiyanse"></span>
474
+ <div class="name">
475
+ 字体颜色
476
+ </div>
477
+ <div class="code-name">.icon-zitiyanse
478
+ </div>
479
+ </li>
480
+
481
+ <li class="dib">
482
+ <span class="icon hqchart_drawtool icon-huabi"></span>
483
+ <div class="name">
484
+ 画笔
485
+ </div>
486
+ <div class="code-name">.icon-huabi
487
+ </div>
488
+ </li>
489
+
445
490
  <li class="dib">
446
491
  <span class="icon hqchart_drawtool icon-tuodong"></span>
447
492
  <div class="name">
@@ -982,6 +1027,30 @@
982
1027
  <div class="content symbol">
983
1028
  <ul class="icon_lists dib-box">
984
1029
 
1030
+ <li class="dib">
1031
+ <svg class="icon svg-icon" aria-hidden="true">
1032
+ <use xlink:href="#icon-zitibeijingse"></use>
1033
+ </svg>
1034
+ <div class="name">字体背景色</div>
1035
+ <div class="code-name">#icon-zitibeijingse</div>
1036
+ </li>
1037
+
1038
+ <li class="dib">
1039
+ <svg class="icon svg-icon" aria-hidden="true">
1040
+ <use xlink:href="#icon-zitiyanse"></use>
1041
+ </svg>
1042
+ <div class="name">字体颜色</div>
1043
+ <div class="code-name">#icon-zitiyanse</div>
1044
+ </li>
1045
+
1046
+ <li class="dib">
1047
+ <svg class="icon svg-icon" aria-hidden="true">
1048
+ <use xlink:href="#icon-huabi"></use>
1049
+ </svg>
1050
+ <div class="name">画笔</div>
1051
+ <div class="code-name">#icon-huabi</div>
1052
+ </li>
1053
+
985
1054
  <li class="dib">
986
1055
  <svg class="icon svg-icon" aria-hidden="true">
987
1056
  <use xlink:href="#icon-tuodong"></use>
@@ -1,8 +1,8 @@
1
1
  @font-face {
2
2
  font-family: "hqchart_drawtool"; /* Project id 4529603 */
3
- src: url('iconfont.woff2?t=1715878738024') format('woff2'),
4
- url('iconfont.woff?t=1715878738024') format('woff'),
5
- url('iconfont.ttf?t=1715878738024') format('truetype');
3
+ src: url('iconfont.woff2?t=1716173088340') format('woff2'),
4
+ url('iconfont.woff?t=1716173088340') format('woff'),
5
+ url('iconfont.ttf?t=1716173088340') format('truetype');
6
6
  }
7
7
 
8
8
  .hqchart_drawtool {
@@ -13,6 +13,18 @@
13
13
  -moz-osx-font-smoothing: grayscale;
14
14
  }
15
15
 
16
+ .icon-zitibeijingse:before {
17
+ content: "\e656";
18
+ }
19
+
20
+ .icon-zitiyanse:before {
21
+ content: "\e686";
22
+ }
23
+
24
+ .icon-huabi:before {
25
+ content: "\e663";
26
+ }
27
+
16
28
  .icon-tuodong:before {
17
29
  content: "\e6ff";
18
30
  }