hqchart 1.1.14081 → 1.1.14093

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.14081",
3
+ "version": "1.1.14093",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
 
9
9
  jones_2000@163.com
10
10
 
11
- 内置指标搜索对话框
11
+ 内置指标搜索对话框 修改指标参数对话框
12
12
  */
13
13
 
14
14
 
@@ -22,7 +22,7 @@ function JSDialogSearchIndex()
22
22
 
23
23
  this.HQChart=null;
24
24
 
25
- //{ WindowIndex:窗口索引, OpType:1=切换主图指标 2=添加叠加指标, Title: };
25
+ //{ WindowIndex:窗口索引, OpType:1=切换主图指标 2=添加叠加指标 3=新增指标窗口, Title: };
26
26
  this.OpData=null;
27
27
 
28
28
  this.TitleColor=g_JSChartResource.DialogSearchIndex.TitleColor;
@@ -48,6 +48,7 @@ function JSDialogSearchIndex()
48
48
  {
49
49
  if (IFrameSplitOperator.IsNumber(option.Style)) this.Style=option.Style;
50
50
  if (option.IndexData) this.IndexData=option.IndexData;
51
+ if (IFrameSplitOperator.IsNumber(option.MaxRowCount)) this.MaxRowCount=option.MaxRowCount;
51
52
  }
52
53
  }
53
54
 
@@ -57,7 +58,8 @@ function JSDialogSearchIndex()
57
58
  this.AryGroup=[];
58
59
  this.IndexData=null;
59
60
  this.InputDom=null;
60
-
61
+ this.HQChart=null;
62
+
61
63
  if (this.DivDialog)
62
64
  {
63
65
  document.body.removeChild(this.DivDialog);
@@ -324,6 +326,24 @@ function JSDialogSearchIndex()
324
326
  this.HQChart.AddOverlayIndex(obj);
325
327
  }
326
328
  }
329
+ else if (this.OpData.OpType==3) //新增加指标窗口
330
+ {
331
+ var indexItem=cellItem.IndexItem;
332
+ if (indexItem.Type==0) //系统指标
333
+ {
334
+ this.HQChart.AddIndexWindow(indexItem.ID, this.OpData);
335
+ }
336
+ else if (indexItem.Type==1) //自定义脚本指标
337
+ {
338
+ var indexData={ ID:indexItem.ID, Name:indexItem.Name, Script:indexItem.Script, Args:indexItem.Args };
339
+ this.HQChart.AddScriptIndexWindow(indexData, this.OpData);
340
+ }
341
+ else if (indexItem.Type==2) //api指标
342
+ {
343
+ var indexData={ API: { ID:indexItem.ID, Name:indexItem.Name, Args:indexItem.Args, Url:'local'} };
344
+ this.HQChart.AddAPIIndexWindow(indexData, this.OpData);
345
+ }
346
+ }
327
347
 
328
348
  }
329
349
 
@@ -596,7 +616,7 @@ JSDialogSearchIndex.GetDefaultIndexData=function()
596
616
  ]
597
617
  },
598
618
 
599
- /*
619
+
600
620
  {
601
621
  Group:{ ID:"自定义", Name:"自定义"} ,
602
622
  AryIndex:
@@ -605,7 +625,7 @@ JSDialogSearchIndex.GetDefaultIndexData=function()
605
625
  { Name:"高低均价(自定义脚本)", ID:"HIGH_LOW_AV", Type:1, Args:null , Script:"均价:(H+L)/2;高:H;低:L;", Args:[ { Name:'N', Value:20}, { Name:'M', Value:6}]},
606
626
  ]
607
627
  }
608
- */
628
+
609
629
  ]
610
630
 
611
631
  }
@@ -615,4 +635,408 @@ JSDialogSearchIndex.GetDefaultIndexData=function()
615
635
 
616
636
 
617
637
 
638
+ function JSDialogModifyIndexParam()
639
+ {
640
+ this.DivDialog=null;
641
+ this.DragTitle=null;
642
+ this.TitleBox=null; //{ DivTitle, DivName, DivName }
643
+ this.Style=0; //样式 预留
644
+
645
+ this.TitleColor=g_JSChartResource.DialogModifyIndexParam.TitleColor;
646
+ this.TitleBGColor=g_JSChartResource.DialogModifyIndexParam.TitleBGColor;
647
+ this.BGColor=g_JSChartResource.DialogModifyIndexParam.BGColor;
648
+ this.BorderColor=g_JSChartResource.DialogModifyIndexParam.BorderColor;
649
+ this.ParamNameColor=g_JSChartResource.DialogModifyIndexParam.ParamNameColor;
650
+ this.InputTextColor=g_JSChartResource.DialogModifyIndexParam.InputTextColor;
651
+
652
+ this.MaxRowCount=30; //行
653
+
654
+ this.HQChart=null;
655
+
656
+ this.AryData=[];
657
+ this.IndexData=null; //指标数据 { WindowsIndex:, Type:1=主图 2=叠加, Identify, IndexScript: }
658
+ this.Arguments=[]; //参数备份
659
+
660
+ this.Inital=function(hqchart, option)
661
+ {
662
+ this.HQChart=hqchart;
663
+ if (option)
664
+ {
665
+ if (IFrameSplitOperator.IsNumber(option.Style)) this.Style=option.Style;
666
+ if (IFrameSplitOperator.IsNumber(option.MaxRowCount)) this.MaxRowCount=option.MaxRowCount;
667
+ }
668
+ }
669
+
670
+
671
+ this.Destroy=function()
672
+ {
673
+ this.AryData=[];
674
+ this.HQChart=null;
675
+
676
+ if (this.DivDialog)
677
+ {
678
+ document.body.removeChild(this.DivDialog);
679
+ this.DivDialog=null;
680
+ }
681
+ }
682
+
683
+ this.Show=function(x,y)
684
+ {
685
+ if (!this.DivDialog) return;
686
+ //if (!this.HQChart) return;
687
+
688
+ this.UpdateParam();
689
+
690
+ if (this.IndexData && this.IndexData.Title) this.TitleBox.DivName.innerText=this.IndexData.Title;
691
+
692
+ if (!IFrameSplitOperator.IsNumber(x) || !IFrameSplitOperator.IsNumber(y)) //默认居中显示
693
+ {
694
+ var rtClient=this.HQChart.UIElement.getBoundingClientRect();
695
+ x=rtClient.left+(rtClient.right-rtClient.left-this.DivDialog.offsetWidth)/2;
696
+ y=rtClient.top+(rtClient.bottom-rtClient.top-this.DivDialog.offsetHeight)/2;
697
+ }
698
+
699
+ this.DivDialog.style.visibility='visible';
700
+ this.DivDialog.style.top = y + "px";
701
+ this.DivDialog.style.left = x + "px";
702
+ }
703
+
704
+ this.OnClickColseButton=function(e)
705
+ {
706
+ this.RestoreParam(); //还原参数
707
+ this.Close(e);
708
+ }
709
+
710
+ this.OnClickRestoreButton=function(e)
711
+ {
712
+ var aryText=this.Arguments;
713
+ if (!aryText) aryText=[];
714
+ this.UpdateParamTable(aryText);
715
+ this.RestoreParam();
716
+ }
717
+
718
+ this.OnClickOkButton=function(e)
719
+ {
720
+ this.Close(e);
721
+ }
722
+
723
+ this.Close=function(e)
724
+ {
725
+ this.IndexData=null;
726
+ this.Arguments=[];
727
+ if (!this.DivDialog) return;
728
+
729
+ this.DivDialog.style.visibility='hidden';
730
+ }
731
+
732
+ this.SetIndexData=function(data)
733
+ {
734
+ this.IndexData=data;
735
+ this.BackupParam();
736
+ }
737
+
738
+ this.OnMouseDownTitle=function(e)
739
+ {
740
+ if (!this.DivDialog) return;
741
+
742
+ var dragData={ X:e.clientX, Y:e.clientY };
743
+ dragData.YOffset=e.clientX - this.DivDialog.offsetLeft;
744
+ dragData.XOffset=e.clientY - this.DivDialog.offsetTop;
745
+ this.DragTitle=dragData;
746
+
747
+ document.onmousemove=(e)=>{ this.DocOnMouseMoveTitle(e); }
748
+ document.onmouseup=(e)=>{ this.DocOnMouseUpTitle(e); }
749
+ }
750
+
751
+ this.DocOnMouseMoveTitle=function(e)
752
+ {
753
+ if (!this.DragTitle) return;
754
+
755
+ var left = e.clientX - this.DragTitle.YOffset;
756
+ var top = e.clientY - this.DragTitle.XOffset;
757
+
758
+ var right=left+this.DivDialog.offsetWidth;
759
+ var bottom=top+ this.DivDialog.offsetHeight;
760
+
761
+ if ((right+5)>=window.innerWidth) left=window.innerWidth-this.DivDialog.offsetWidth-5;
762
+ if ((bottom+5)>=window.innerHeight) top=window.innerHeight-this.DivDialog.offsetHeight-5;
763
+
764
+ this.DivDialog.style.left = left + 'px';
765
+ this.DivDialog.style.top = top + 'px';
766
+
767
+ if(e.preventDefault) e.preventDefault();
768
+ }
769
+
770
+ this.DocOnMouseUpTitle=function(e)
771
+ {
772
+ this.DragTitle=null;
773
+ this.onmousemove = null;
774
+ this.onmouseup = null;
775
+ }
776
+
777
+ this.Create=function()
778
+ {
779
+ var divDom=document.createElement("div");
780
+ divDom.className='UMyChart_ModifyIndexParam_Dialog_Div';
781
+
782
+ //对话框标题栏
783
+ var divTitle=document.createElement("div");
784
+ divTitle.className='UMyChart_ModifyIndexParam_Title_Div';
785
+ divTitle.onmousedown=(e)=>{ this.OnMouseDownTitle(e);}
786
+ divDom.appendChild(divTitle);
787
+
788
+ var divName=document.createElement("div");
789
+ divName.className='UMyChart_ModifyIndexParam_Name_Div';
790
+ divName.innerText="指标参数修改";
791
+ divTitle.appendChild(divName);
792
+
793
+ var divClose=document.createElement("div");
794
+ divClose.className='UMyChart_ModifyIndexParam_Close_Div';
795
+ divClose.innerText="x";
796
+ divClose.onmousedown=(e)=>{ this.OnClickColseButton(e); }
797
+ divTitle.appendChild(divClose);
798
+
799
+ //整个框子
800
+ var divFrame=document.createElement("div");
801
+ divFrame.className="UMyChart_ModifyIndexParam_Frome_Div";
802
+ divDom.appendChild(divFrame);
803
+
804
+ //表格
805
+ var divTable=document.createElement("div");
806
+ divTable.className='UMyChart_ModifyIndexParam_Table_Div';
807
+ divFrame.appendChild(divTable);
808
+
809
+ var table=document.createElement("table");
810
+ table.className="UMyChart_ModifyIndexParam_Table";
811
+ divTable.appendChild(table);
812
+
813
+ /*
814
+ var thead=document.createElement("thead");
815
+ table.appendChild(thead);
816
+
817
+ var trDom=document.createElement("tr");
818
+ trDom.className='UMyChart_ModifyIndexParam_head_Tr';
819
+ thead.appendChild(trDom);
820
+
821
+ var thDom=document.createElement("th");
822
+ thDom.className="UMyChart_ModifyIndexParam_Th";
823
+ thDom.innerText="变量";
824
+ trDom.appendChild(thDom);
825
+
826
+ var thDom=document.createElement("th");
827
+ thDom.className="UMyChart_ModifyIndexParam_Th";
828
+ thDom.innerText="数值";
829
+ trDom.appendChild(thDom);
830
+
831
+ var thDom=document.createElement("th");
832
+ thDom.className="UMyChart_ModifyIndexParam_Th";
833
+ thDom.innerText="说明";
834
+ trDom.appendChild(thDom);
835
+ */
836
+
837
+
838
+ var tbody=document.createElement("tbody");
839
+ tbody.className="UMyChart_ModifyIndexParam_Tbody";
840
+ table.appendChild(tbody);
841
+
842
+ this.AryData=[];
843
+ for(var i=0;i<this.MaxRowCount;++i)
844
+ {
845
+ var rowItem=this.CreateRowDOM(i, tbody)
846
+
847
+ this.AryData.push(rowItem);
848
+ }
849
+
850
+ var divButton=document.createElement("div");
851
+ divButton.className='UMyChart_ModifyIndexParam_Button_Div';
852
+ divFrame.appendChild(divButton);
853
+
854
+ var btnRestore=document.createElement("button");
855
+ //btnRestore.className="UMyChart_ModifyIndexParam_button";
856
+ btnRestore.innerText="恢复默认";
857
+ btnRestore.addEventListener("mousedown", (e)=>{ this.OnClickRestoreButton(e); });
858
+ divButton.appendChild(btnRestore);
859
+
860
+ var btnOk=document.createElement("button");
861
+ //btnOk.className="UMyChart_ModifyIndexParam_button";
862
+ btnOk.innerText="确认";
863
+ btnOk.addEventListener("mousedown", (e)=>{ this.OnClickOkButton(e); })
864
+ divButton.appendChild(btnOk);
865
+
866
+ document.body.appendChild(divDom);
867
+
868
+ this.DivName=divName;
869
+ this.DivDialog=divDom;
870
+ this.TitleBox={ DivTitle:divTitle, DivName:divName, DivColor:divClose };
871
+
872
+ this.UpdateStyle();
873
+ }
874
+
875
+ this.CreateRowDOM=function(index, tbody)
876
+ {
877
+ var rowItem={ Tr:null, TdName:null, SpanName:null, TdValue:null, Input:null, ParamItem:null };
878
+
879
+ var trDom=document.createElement("tr");
880
+ trDom.className='UMyChart_ModifyIndexParam_Tr';
881
+ tbody.appendChild(trDom);
882
+ rowItem.Tr=trDom;
883
+
884
+ var tdDom=document.createElement("td");
885
+ tdDom.className="UMyChart_ModifyIndexParam_Name_Td"; //指标名称
886
+ trDom.appendChild(tdDom);
887
+ rowItem.TdName=tdDom;
888
+
889
+ var spanDom=document.createElement("span");
890
+ spanDom.className='UMyChart_ModifyIndexParam_Name_Span';
891
+ spanDom.innerText='参数';
892
+ tdDom.appendChild(spanDom);
893
+ rowItem.SpanName=spanDom;
894
+
895
+ var tdDom=document.createElement("td");
896
+ tdDom.className="UMyChart_ModifyIndexParam_Value_Td"; //指标名称
897
+ trDom.appendChild(tdDom);
898
+ rowItem.TdValue=tdDom;
899
+
900
+ var input=document.createElement("input");
901
+ input.className='UMyChart_ModifyIndexParam_Input';
902
+ input.type="number";
903
+ input.step=1;
904
+ input.addEventListener("mouseup", (e)=>{ this.OnParamMouseUp(e)});
905
+ input.addEventListener("keyup", (e)=>{ this.OnParamKeyUp(e)})
906
+ tdDom.appendChild(input);
907
+ rowItem.Input=input;
908
+
909
+ return rowItem;
910
+ }
911
+
912
+ this.UpdateStyle=function()
913
+ {
914
+ if (!this.DivDialog) return;
915
+
916
+ if (this.BGColor) this.DivDialog.style['background-color']=this.BGColor;
917
+ if (this.BorderColor) this.DivDialog.style['border-color']=this.BorderColor;
918
+
919
+ if (this.TitleBGColor) this.TitleBox.DivTitle.style['background-color']=this.TitleBGColor;
920
+ if (this.TitleColor) this.TitleBox.DivName.style['color']=this.TitleColor;
921
+ };
922
+
923
+ this.UpdateParamTable=function(aryText)
924
+ {
925
+ var index=0;
926
+ for(index=0; index<aryText.length && index<this.AryData.length; ++index)
927
+ {
928
+ var item=aryText[index];
929
+ var row=this.AryData[index];
930
+ row.SpanName.innerText=`${item.Name}: `;
931
+ row.SpanName.style.color=this.ParamNameColor;
932
+
933
+ row.Input.value=item.Value;
934
+ row.Input.style.color=this.InputTextColor;
935
+ row.Input.dataset.paramid=item.Index;
936
+
937
+ if (row.Tr.style.display=="none") row.Tr.style.display="";
938
+ }
939
+
940
+ for(; index<this.AryData.length; ++index)
941
+ {
942
+ var row=this.AryData[index];
943
+ row.Tr.style.display="none";
944
+ row.Input.dataset.paramid=-1;
945
+ }
946
+ }
947
+
948
+ this.UpdateParam=function()
949
+ {
950
+ var aryText=[];
951
+ var indexScript=this.IndexData.IndexScript;
952
+ if (indexScript && IFrameSplitOperator.IsNonEmptyArray(indexScript.Arguments))
953
+ {
954
+ for(var i=0;i<indexScript.Arguments.length;++i)
955
+ {
956
+ var item=indexScript.Arguments[i];
957
+ aryText.push({ Name:item.Name, Value:item.Value, Index:i });
958
+ }
959
+ }
960
+
961
+ this.UpdateParamTable(aryText);
962
+ }
963
+
964
+ this.RestoreParam=function()
965
+ {
966
+ if (!this.IndexData || !this.IndexData.IndexScript) return;
967
+ var indexScript=this.IndexData.IndexScript;
968
+
969
+ if (!IFrameSplitOperator.IsNonEmptyArray(indexScript.Arguments)) return;
970
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Arguments)) return;
971
+
972
+ var bUpdate=false;
973
+ for(var i=0;i<this.Arguments.length;++i)
974
+ {
975
+ var oldItem=this.Arguments[i];
976
+ var item=indexScript.Arguments[i];
977
+ if (oldItem.Value!=item.Value)
978
+ {
979
+ item.Value=oldItem.Value;
980
+ bUpdate=true;
981
+ }
982
+ }
983
+
984
+ if (!bUpdate) return;
985
+
986
+ if (this.IndexData.Type==1) this.HQChart.UpdateWindowIndex(this.IndexData.WindowIndex);
987
+ else if (this.IndexData.Type==2) this.HQChart.UpdateOverlayIndex(this.IndexData.Identify);
988
+ }
989
+
990
+ this.BackupParam=function()
991
+ {
992
+ this.Arguments=[];
993
+
994
+ if (!this.IndexData || !this.IndexData.IndexScript) return;
995
+ var indexScript=this.IndexData.IndexScript;
996
+ if (IFrameSplitOperator.IsNonEmptyArray(indexScript.Arguments))
997
+ {
998
+ for(var i=0;i<indexScript.Arguments.length;++i)
999
+ {
1000
+ var item=indexScript.Arguments[i];
1001
+ this.Arguments.push({Name:item.Name, Value:item.Value, Index:i});
1002
+ }
1003
+ }
1004
+ }
1005
+
1006
+ this.OnParamMouseUp=function(e)
1007
+ {
1008
+ var input=e.target;
1009
+ var value=input.value;
1010
+ var id=input.dataset.paramid;
1011
+
1012
+ this.ModifyParam(id, parseInt(value));
1013
+ }
1014
+
1015
+ this.OnParamKeyUp=function(e)
1016
+ {
1017
+ var input=e.target;
1018
+ var value=input.value;
1019
+ var id=input.dataset.paramid;
1020
+
1021
+ this.ModifyParam(id, parseInt(value));
1022
+ }
1023
+
1024
+ this.ModifyParam=function(id, value)
1025
+ {
1026
+ if (!this.IndexData || !this.IndexData.IndexScript) return;
1027
+
1028
+ var indexScript=this.IndexData.IndexScript;
1029
+ var item=indexScript.Arguments[id];
1030
+ if (!item) return;
1031
+ if (item.Value==value) return;
1032
+
1033
+ item.Value=value;
1034
+
1035
+ if (this.IndexData.Type==1) this.HQChart.UpdateWindowIndex(this.IndexData.WindowIndex);
1036
+ else if (this.IndexData.Type==2) this.HQChart.UpdateOverlayIndex(this.IndexData.Identify);
1037
+ }
1038
+ }
1039
+
1040
+
1041
+
618
1042
 
@@ -2441,7 +2441,7 @@ function ChartTReport()
2441
2441
  if (column.DefaultText) drawInfo.Text=column.DefaultText;
2442
2442
 
2443
2443
  var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
2444
- if (!fieldName) return;
2444
+ if (!data || !fieldName) return;
2445
2445
 
2446
2446
  var value=data[fieldName];
2447
2447
  if (!IFrameSplitOperator.IsNumber(value)) return;
@@ -2467,7 +2467,7 @@ function ChartTReport()
2467
2467
  if (column.DefaultText) drawInfo.Text=column.DefaultText;
2468
2468
 
2469
2469
  var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
2470
- if (!fieldName) return;
2470
+ if (!data || !fieldName) return;
2471
2471
 
2472
2472
  var item=data[fieldName];
2473
2473
  if (IFrameSplitOperator.IsObject(item))