hqchart 1.1.13311 → 1.1.13318
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/lib/umychart.vue.js +63 -41
- package/package.json +1 -1
- package/src/jscommon/umychart.DialogDrawTool.js +200 -2
- package/src/jscommon/umychart.complier.js +30 -12
- package/src/jscommon/umychart.js +273 -4
- package/src/jscommon/umychart.resource/css/tools.css +35 -0
- package/src/jscommon/umychart.resource/font/drawtool/demo_index.html +49 -3
- package/src/jscommon/umychart.resource/font/drawtool/iconfont.css +11 -3
- package/src/jscommon/umychart.resource/font/drawtool/iconfont.js +1 -1
- package/src/jscommon/umychart.resource/font/drawtool/iconfont.json +14 -0
- package/src/jscommon/umychart.resource/font/drawtool/iconfont.ttf +0 -0
- package/src/jscommon/umychart.resource/font/drawtool/iconfont.woff +0 -0
- package/src/jscommon/umychart.resource/font/drawtool/iconfont.woff2 +0 -0
- package/src/jscommon/umychart.uniapp.h5/umychart.uniapp.h5.js +304 -17
- package/src/jscommon/umychart.version.js +1 -1
- package/src/jscommon/umychart.vue/umychart.vue.js +504 -19
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ var JS_DRAWTOOL_MENU_ID=
|
|
|
17
17
|
CMD_DELETE_ALL_DRAW_CHART_ID:3,
|
|
18
18
|
CMD_ERASE_DRAW_CHART_ID:4,
|
|
19
19
|
CMD_ENABLE_MAGNET_ID:5, //画图工具磁体功能
|
|
20
|
+
CMD_DELETE_DRAW_CHART_ID:6,
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
function JSDialogDrawTool()
|
|
@@ -101,6 +102,7 @@ function JSDialogDrawTool()
|
|
|
101
102
|
[
|
|
102
103
|
{ Title: '价格范围', ClassName: 'hqchart_drawtool icon-shijianfanwei', Type:0, Data:{ ID:"PriceRange" } },
|
|
103
104
|
{ Title: '时间范围', ClassName: 'hqchart_drawtool icon-jiagefanwei', Type:0, Data:{ ID:"DateRange" } },
|
|
105
|
+
{ Title: "监测线", ClassName:"hqchart_drawtool icon-jiance", Type:0, Data:{ ID:"MonitorLine"} },
|
|
104
106
|
]
|
|
105
107
|
},
|
|
106
108
|
{
|
|
@@ -518,8 +520,10 @@ function JSDialogDrawTool()
|
|
|
518
520
|
if ((right+5)>=window.innerWidth) left=window.innerWidth-this.DivDialog.offsetWidth-5;
|
|
519
521
|
if ((bottom+5)>=window.innerHeight) top=window.innerHeight-this.DivDialog.offsetHeight-5;
|
|
520
522
|
|
|
521
|
-
this.DivDialog.style.left = left + 'px'
|
|
522
|
-
this.DivDialog.style.top = top + 'px'
|
|
523
|
+
this.DivDialog.style.left = left + 'px';
|
|
524
|
+
this.DivDialog.style.top = top + 'px';
|
|
525
|
+
|
|
526
|
+
if(e.preventDefault) e.preventDefault();
|
|
523
527
|
}
|
|
524
528
|
|
|
525
529
|
this.DocOnMouseUpTitle=function(e)
|
|
@@ -541,6 +545,200 @@ function JSDialogModifyDraw()
|
|
|
541
545
|
this.DivDialog=null;
|
|
542
546
|
this.HQChart;
|
|
543
547
|
this.ChartPicture;
|
|
548
|
+
this.ColorButton=null;
|
|
549
|
+
|
|
550
|
+
this.RandomLineColor=["rgb(255,69,0)", "rgb(173,255,47)", "rgb(238,154,73)", "rgb(255,105,180)"];
|
|
551
|
+
this.AryButton=
|
|
552
|
+
[
|
|
553
|
+
{ Title:"点击切换颜色", ClassName: 'hqchart_drawtool icon-fangkuai', Type:2, Data:{ ID:JS_DRAWTOOL_MENU_ID.CMD_CHANGE_LINE_COLOR_ID }},
|
|
554
|
+
{ Title:"删除", ClassName: 'hqchart_drawtool icon-recycle_bin', Type:2, Data:{ ID:JS_DRAWTOOL_MENU_ID.CMD_DELETE_DRAW_CHART_ID }}
|
|
555
|
+
];
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
this.Inital=function(hqchart)
|
|
559
|
+
{
|
|
560
|
+
this.HQChart=hqchart;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
this.Destroy=function()
|
|
564
|
+
{
|
|
565
|
+
this.ChartPicture=null;
|
|
566
|
+
this.ColorButton=null;
|
|
567
|
+
if (this.DivDialog)
|
|
568
|
+
{
|
|
569
|
+
document.body.remove(this.DivDialog);
|
|
570
|
+
this.DivDialog=null;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
this.Create=function()
|
|
575
|
+
{
|
|
576
|
+
var divDom=document.createElement("div");
|
|
577
|
+
divDom.className='UMyChart_Draw_Modify_Dialog_Div';
|
|
578
|
+
|
|
579
|
+
var drgDiv=document.createElement("div");
|
|
580
|
+
drgDiv.className="UMyChart_Draw_Modify_Dialog_Drag_Div";
|
|
581
|
+
drgDiv.onmousedown=(e)=>{ this.OnMouseDownTitle(e); }
|
|
582
|
+
divDom.appendChild(drgDiv);
|
|
583
|
+
|
|
584
|
+
var spanDom=document.createElement("span");
|
|
585
|
+
spanDom.className="hqchart_drawtool icon-tuodong";
|
|
586
|
+
spanDom.classList.add("UMyChart_DrawTool_Span");
|
|
587
|
+
drgDiv.appendChild(spanDom);
|
|
588
|
+
|
|
589
|
+
for(var i=0;i<this.AryButton.length;++i)
|
|
590
|
+
{
|
|
591
|
+
var item=this.AryButton[i];
|
|
592
|
+
this.CreateButtonItem(item, divDom);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
this.DivDialog=divDom;
|
|
596
|
+
document.body.appendChild(divDom);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
this.CreateButtonItem=function(item, parentDivDom)
|
|
600
|
+
{
|
|
601
|
+
var divItem=document.createElement("div");
|
|
602
|
+
divItem.className="UMyChart_Draw_Modify_Dialog_Button_Div";
|
|
603
|
+
var spanDom=document.createElement("span");
|
|
604
|
+
spanDom.className=item.ClassName;
|
|
605
|
+
spanDom.classList.add("UMyChart_DrawTool_Span");
|
|
606
|
+
divItem.appendChild(spanDom);
|
|
607
|
+
|
|
608
|
+
var data={ Span:spanDom, Parent:parentDivDom, Item:item };
|
|
609
|
+
divItem.onmousedown=(e)=> { this.OnClickButton(e, data); }; //点击
|
|
610
|
+
|
|
611
|
+
if (item.Data.ID==JS_DRAWTOOL_MENU_ID.CMD_CHANGE_LINE_COLOR_ID)
|
|
612
|
+
this.ColorButton=data;
|
|
613
|
+
|
|
614
|
+
parentDivDom.appendChild(divItem);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
this.OnClickButton=function(e, data)
|
|
618
|
+
{
|
|
619
|
+
console.log('[JSDialogModifyDraw::OnClickButton] ', data);
|
|
620
|
+
if (!data.Item || !data.Item.Data) return;
|
|
621
|
+
|
|
622
|
+
var id=data.Item.Data.ID;
|
|
623
|
+
switch(id)
|
|
624
|
+
{
|
|
625
|
+
case JS_DRAWTOOL_MENU_ID.CMD_CHANGE_LINE_COLOR_ID:
|
|
626
|
+
this.ModifyLineColor();
|
|
627
|
+
break;
|
|
628
|
+
case JS_DRAWTOOL_MENU_ID.CMD_DELETE_DRAW_CHART_ID:
|
|
629
|
+
this.DeleteDrawPicture();
|
|
630
|
+
break;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
this.Close=function(e)
|
|
635
|
+
{
|
|
636
|
+
if (!this.DivDialog) return;
|
|
637
|
+
|
|
638
|
+
this.ChartPicture=null;
|
|
639
|
+
this.DivDialog.style.visibility='hidden';
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
this.IsShow=function()
|
|
643
|
+
{
|
|
644
|
+
if (!this.DivDialog) return false;
|
|
645
|
+
return this.DivDialog.style.visibility==='visible';
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
this.DeleteDrawPicture=function()
|
|
649
|
+
{
|
|
650
|
+
if (this.ChartPicture && this.HQChart)
|
|
651
|
+
{
|
|
652
|
+
this.HQChart.ClearChartDrawPicture(this.ChartPicture);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
this.Close();
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
this.ModifyLineColor=function()
|
|
659
|
+
{
|
|
660
|
+
if (!this.ChartPicture || !this.HQChart) return;
|
|
661
|
+
|
|
662
|
+
var color=this.ChartPicture.LineColor;
|
|
663
|
+
var colorIndex=0;
|
|
664
|
+
for(var i=0;i<this.RandomLineColor.length;++i)
|
|
665
|
+
{
|
|
666
|
+
if (color==this.RandomLineColor[i])
|
|
667
|
+
{
|
|
668
|
+
colorIndex=i+1;
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
colorIndex=colorIndex%this.RandomLineColor.length;
|
|
674
|
+
color=this.RandomLineColor[colorIndex];
|
|
675
|
+
|
|
676
|
+
this.ChartPicture.LineColor = color;
|
|
677
|
+
this.ChartPicture.PointColor = color;
|
|
678
|
+
|
|
679
|
+
if (this.ColorButton) this.ColorButton.Span.style['color']=color;
|
|
680
|
+
|
|
681
|
+
if (this.HQChart.ChartDrawStorage) this.HQChart.ChartDrawStorage.SaveDrawData(this.ChartPicture); //保存下
|
|
682
|
+
|
|
683
|
+
this.HQChart.Draw();
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
this.Show=function(x, y)
|
|
687
|
+
{
|
|
688
|
+
if (!this.DivDialog) this.Create();
|
|
689
|
+
|
|
690
|
+
this.DivDialog.style.visibility='visible';
|
|
691
|
+
this.DivDialog.style.top = y + "px";
|
|
692
|
+
this.DivDialog.style.left = x + "px";
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
this.SetChartPicture=function(chart)
|
|
696
|
+
{
|
|
697
|
+
this.ChartPicture=chart;
|
|
698
|
+
if (this.ColorButton)
|
|
699
|
+
{
|
|
700
|
+
this.ColorButton.Span.style['color']=chart.LineColor;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
this.OnMouseDownTitle=function(e)
|
|
705
|
+
{
|
|
706
|
+
if (!this.DivDialog) return;
|
|
707
|
+
|
|
708
|
+
var dragData={ X:e.clientX, Y:e.clientY };
|
|
709
|
+
dragData.YOffset=e.clientX - this.DivDialog.offsetLeft;
|
|
710
|
+
dragData.XOffset=e.clientY - this.DivDialog.offsetTop;
|
|
711
|
+
this.DragTitle=dragData;
|
|
712
|
+
|
|
713
|
+
document.onmousemove=(e)=>{ this.DocOnMouseMoveTitle(e); }
|
|
714
|
+
document.onmouseup=(e)=>{ this.DocOnMouseUpTitle(e); }
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
this.DocOnMouseMoveTitle=function(e)
|
|
718
|
+
{
|
|
719
|
+
if (!this.DragTitle) return;
|
|
720
|
+
|
|
721
|
+
var left = e.clientX - this.DragTitle.YOffset;
|
|
722
|
+
var top = e.clientY - this.DragTitle.XOffset;
|
|
723
|
+
|
|
724
|
+
var right=left+this.DivDialog.offsetWidth;
|
|
725
|
+
var bottom=top+ this.DivDialog.offsetHeight;
|
|
726
|
+
|
|
727
|
+
if ((right+5)>=window.innerWidth) left=window.innerWidth-this.DivDialog.offsetWidth-5;
|
|
728
|
+
if ((bottom+5)>=window.innerHeight) top=window.innerHeight-this.DivDialog.offsetHeight-5;
|
|
729
|
+
|
|
730
|
+
this.DivDialog.style.left = left + 'px'
|
|
731
|
+
this.DivDialog.style.top = top + 'px'
|
|
732
|
+
|
|
733
|
+
if(e.preventDefault) e.preventDefault();
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
this.DocOnMouseUpTitle=function(e)
|
|
737
|
+
{
|
|
738
|
+
this.DragTitle=null;
|
|
739
|
+
this.onmousemove = null;
|
|
740
|
+
this.onmouseup = null;
|
|
741
|
+
}
|
|
544
742
|
}
|
|
545
743
|
|
|
546
744
|
|
|
@@ -16313,6 +16313,7 @@ JSSymbolData.prototype.JsonDataToFinance=function(data)
|
|
|
16313
16313
|
|
|
16314
16314
|
var JS_EXECUTE_DEBUG_LOG=false;
|
|
16315
16315
|
|
|
16316
|
+
|
|
16316
16317
|
var JS_EXECUTE_JOB_ID=
|
|
16317
16318
|
{
|
|
16318
16319
|
JOB_DOWNLOAD_SYMBOL_DATA:1, //下载股票的K线数据
|
|
@@ -18440,9 +18441,10 @@ function JSExplainer(ast,option)
|
|
|
18440
18441
|
if (!this.AST) this.ThrowError();
|
|
18441
18442
|
if (!this.AST.Body) this.ThrowError();
|
|
18442
18443
|
|
|
18443
|
-
for(
|
|
18444
|
+
for(var i=0; i<this.AST.Body.length; ++i)
|
|
18444
18445
|
{
|
|
18445
|
-
|
|
18446
|
+
//console.log(`[JSExplainer::RunAST] ${i}`);
|
|
18447
|
+
var item =this.AST.Body[i];
|
|
18446
18448
|
this.VisitNode(item);
|
|
18447
18449
|
|
|
18448
18450
|
//输出变量
|
|
@@ -18565,7 +18567,7 @@ function JSExplainer(ast,option)
|
|
|
18565
18567
|
{
|
|
18566
18568
|
varName=itemExpression.Left.Name;
|
|
18567
18569
|
let varValue=this.VarTable.get(varName);
|
|
18568
|
-
this.VarTable.set(varName,varValue); //把常量放到变量表里
|
|
18570
|
+
this.VarTable.set(varName,this.ConvertToShortValue(varValue)); //把常量放到变量表里
|
|
18569
18571
|
}
|
|
18570
18572
|
else if (itemExpression.Type==Syntax.Identifier)
|
|
18571
18573
|
{
|
|
@@ -18603,7 +18605,7 @@ function JSExplainer(ast,option)
|
|
|
18603
18605
|
let varValue=this.ReadVariable(varName,itemExpression);
|
|
18604
18606
|
varName="__temp_si_"+i+"__";
|
|
18605
18607
|
isNoneName=true;
|
|
18606
|
-
this.VarTable.set(varName,varValue); //放到变量表里
|
|
18608
|
+
this.VarTable.set(varName,this.ConvertToShortValue(varValue)); //放到变量表里
|
|
18607
18609
|
}
|
|
18608
18610
|
}
|
|
18609
18611
|
else if(itemExpression.Type==Syntax.Literal) //常量
|
|
@@ -18808,7 +18810,7 @@ function JSExplainer(ast,option)
|
|
|
18808
18810
|
return node.Out;
|
|
18809
18811
|
}
|
|
18810
18812
|
|
|
18811
|
-
JSConsole.Complier.Log('[JSExplainer::VisitCallExpression]' , funcName, '(', args.toString() ,')');
|
|
18813
|
+
if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitCallExpression]' , funcName, '(', args.toString() ,')');
|
|
18812
18814
|
|
|
18813
18815
|
if (g_JSComplierResource.IsCustomFunction(funcName))
|
|
18814
18816
|
{
|
|
@@ -18835,6 +18837,8 @@ function JSExplainer(ast,option)
|
|
|
18835
18837
|
["BARSLASTCOUNT", { Name:"BARSLASTCOUNT", Param:{ Count:1 }, ToString:function(args) { return `条件${args[0]}连续成立次数`; } } ],
|
|
18836
18838
|
["BARSCOUNT", { Name:"BARSCOUNT", Param:{ Count:1 }, ToString:function(args) { return `${args[0]}有效数据周期数`; } } ],
|
|
18837
18839
|
["BARSLAST", { Name:"BARSLAST", Param:{ Count:1 }, ToString:function(args) { return `上次${args[0]}不为0距今天数`; } } ],
|
|
18840
|
+
["BARSLASTS", { Name:"BARSLASTS", Param:{ Count:2 }, ToString:function(args) { return `倒数第N次成立时距今的周期数`; } } ],
|
|
18841
|
+
|
|
18838
18842
|
["BARSNEXT", { Name:"BARSNEXT", Param:{ Count:1 }, ToString:function(args) { return `下次${args[0]}不为0距今天数`; } } ],
|
|
18839
18843
|
["BARSSINCEN", { Name:"BARSSINCEN", Param:{ Count:2 }, ToString:function(args) { return `在${args[1]}周期内首次${args[0]}距今天数`; } } ],
|
|
18840
18844
|
["BARSSINCE", { Name:"BARSSINCE", Param:{ Count:1 }, ToString:function(args) { return `首次${args[0]}距今天数`; } } ],
|
|
@@ -19002,7 +19006,7 @@ function JSExplainer(ast,option)
|
|
|
19002
19006
|
if (item.Param.Count!=args.length)
|
|
19003
19007
|
this.ThrowUnexpectedNode(node,`函数${funcName}参数个数不正确. 需要${item.Param.Count}个参数`);
|
|
19004
19008
|
}
|
|
19005
|
-
|
|
19009
|
+
|
|
19006
19010
|
return item.ToString(args);
|
|
19007
19011
|
}
|
|
19008
19012
|
|
|
@@ -19279,8 +19283,22 @@ function JSExplainer(ast,option)
|
|
|
19279
19283
|
else if (right.Type==Syntax.UnaryExpression)
|
|
19280
19284
|
value=this.VisitUnaryExpression(right);
|
|
19281
19285
|
|
|
19282
|
-
JSConsole.Complier.Log('[JSExplainer::VisitAssignmentExpression]' , varName, ' = ',value);
|
|
19283
|
-
|
|
19286
|
+
if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitAssignmentExpression]' , varName, ' = ',value);
|
|
19287
|
+
|
|
19288
|
+
this.VarTable.set(varName,this.ConvertToShortValue(value));
|
|
19289
|
+
}
|
|
19290
|
+
|
|
19291
|
+
this.ConvertToShortValue=function(value)
|
|
19292
|
+
{
|
|
19293
|
+
var maxLength=80;
|
|
19294
|
+
if (value && value.length>=maxLength)
|
|
19295
|
+
{
|
|
19296
|
+
var shortValue=value.slice(0, maxLength-10);
|
|
19297
|
+
shortValue+="......";
|
|
19298
|
+
return shortValue;
|
|
19299
|
+
}
|
|
19300
|
+
|
|
19301
|
+
return value;
|
|
19284
19302
|
}
|
|
19285
19303
|
|
|
19286
19304
|
this.ReadMemberVariable=function(node)
|
|
@@ -19340,7 +19358,7 @@ function JSExplainer(ast,option)
|
|
|
19340
19358
|
let leftValue=this.GetNodeValue(value.Left);
|
|
19341
19359
|
let rightValue=this.GetNodeValue(value.Right);
|
|
19342
19360
|
|
|
19343
|
-
JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] BinaryExpression',value , leftValue, rightValue);
|
|
19361
|
+
if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] BinaryExpression',value , leftValue, rightValue);
|
|
19344
19362
|
value.Out=null; //保存中间值
|
|
19345
19363
|
|
|
19346
19364
|
value.Out=`(${leftValue} ${value.Operator} ${rightValue})`;
|
|
@@ -19357,14 +19375,14 @@ function JSExplainer(ast,option)
|
|
|
19357
19375
|
else if (value.Operator=="=") value.Out='(平盘)';
|
|
19358
19376
|
}
|
|
19359
19377
|
|
|
19360
|
-
JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] BinaryExpression',value);
|
|
19378
|
+
if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] BinaryExpression',value);
|
|
19361
19379
|
}
|
|
19362
19380
|
else if (value.Type==Syntax.LogicalExpression)
|
|
19363
19381
|
{
|
|
19364
19382
|
let leftValue=this.GetNodeValue(value.Left);
|
|
19365
19383
|
let rightValue=this.GetNodeValue(value.Right);
|
|
19366
19384
|
|
|
19367
|
-
JSConsole.Complier.Log('[JSExecute::VisitBinaryExpression] LogicalExpression',value , leftValue, rightValue);
|
|
19385
|
+
if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExecute::VisitBinaryExpression] LogicalExpression',value , leftValue, rightValue);
|
|
19368
19386
|
value.Out=null; //保存中间值
|
|
19369
19387
|
|
|
19370
19388
|
switch(value.Operator)
|
|
@@ -19379,7 +19397,7 @@ function JSExplainer(ast,option)
|
|
|
19379
19397
|
break;
|
|
19380
19398
|
}
|
|
19381
19399
|
|
|
19382
|
-
JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] LogicalExpression',value);
|
|
19400
|
+
if (JS_EXECUTE_DEBUG_LOG) JSConsole.Complier.Log('[JSExplainer::VisitBinaryExpression] LogicalExpression',value);
|
|
19383
19401
|
}
|
|
19384
19402
|
|
|
19385
19403
|
node=temp;
|
package/src/jscommon/umychart.js
CHANGED
|
@@ -1649,6 +1649,7 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
|
|
|
1649
1649
|
|
|
1650
1650
|
//画图工具
|
|
1651
1651
|
if (option.EnableDrawToolDialogV2===true) chart.InitalDrawToolDialog();
|
|
1652
|
+
if (option.EnableModifyDrawDialogV2===true) chart.InitalModifyDrawDialog();
|
|
1652
1653
|
|
|
1653
1654
|
//注册事件
|
|
1654
1655
|
if (option.EventCallback)
|
|
@@ -2911,6 +2912,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
2911
2912
|
this.IsShowRightMenu=true; //显示右键菜单
|
|
2912
2913
|
|
|
2913
2914
|
this.DialogDrawTool; //画图工具
|
|
2915
|
+
this.DialogModifyDraw; //画图修改
|
|
2914
2916
|
|
|
2915
2917
|
|
|
2916
2918
|
this.ClearStockCache=function()
|
|
@@ -2935,6 +2937,15 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
2935
2937
|
this.DialogDrawTool.Create();
|
|
2936
2938
|
}
|
|
2937
2939
|
|
|
2940
|
+
this.InitalModifyDrawDialog=function()
|
|
2941
|
+
{
|
|
2942
|
+
if ( this.DialogModifyDraw) return;
|
|
2943
|
+
|
|
2944
|
+
this.DialogModifyDraw=new JSDialogModifyDraw();
|
|
2945
|
+
this.DialogModifyDraw.Inital(this);
|
|
2946
|
+
this.DialogModifyDraw.Create();
|
|
2947
|
+
}
|
|
2948
|
+
|
|
2938
2949
|
this.ShowDrawToolDialog=function(x,y)
|
|
2939
2950
|
{
|
|
2940
2951
|
if (!this.DialogDrawTool) return;
|
|
@@ -2957,6 +2968,31 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
2957
2968
|
return this.DialogDrawTool.IsShow();
|
|
2958
2969
|
}
|
|
2959
2970
|
|
|
2971
|
+
this.ShowModifyDrawDialog=function(chart, x,y)
|
|
2972
|
+
{
|
|
2973
|
+
if (!this.DialogModifyDraw) return;
|
|
2974
|
+
|
|
2975
|
+
this.DialogModifyDraw.SetChartPicture(chart);
|
|
2976
|
+
if (this.DialogModifyDraw.IsShow()) return;
|
|
2977
|
+
|
|
2978
|
+
var rtClient=this.UIElement.getBoundingClientRect();
|
|
2979
|
+
var rtScroll=GetScrollPosition();
|
|
2980
|
+
|
|
2981
|
+
var top=this.UIElement.offsetTop+15;
|
|
2982
|
+
var left=(this.UIElement.offsetWidth-this.DialogModifyDraw.DivDialog.offsetWidth)/2;
|
|
2983
|
+
left+=rtClient.left+rtScroll.Left;
|
|
2984
|
+
top+=rtClient.top+rtScroll.Top;
|
|
2985
|
+
|
|
2986
|
+
this.DialogModifyDraw.Show(left, top);
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
this.CloseModifyDrawDialog=function()
|
|
2990
|
+
{
|
|
2991
|
+
if (!this.DialogModifyDraw) return;
|
|
2992
|
+
|
|
2993
|
+
this.DialogModifyDraw.Close();
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2960
2996
|
//obj={ Element:, Canvas: }
|
|
2961
2997
|
this.SetCorssCursorElement=function(obj)
|
|
2962
2998
|
{
|
|
@@ -3636,6 +3672,9 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
3636
3672
|
}
|
|
3637
3673
|
}
|
|
3638
3674
|
|
|
3675
|
+
|
|
3676
|
+
if (!this.SelectChartDrawPicture) this.CloseModifyDrawDialog(); //当前没有选中画图 隐藏画图修改框
|
|
3677
|
+
|
|
3639
3678
|
document.onmousemove=(e)=>{ this.DocOnMouseMove(e); }
|
|
3640
3679
|
document.onmouseup=(e)=> { this.DocOnMouseUp(e); }
|
|
3641
3680
|
|
|
@@ -6330,6 +6369,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
6330
6369
|
this.SelectChartDrawPicture=null;
|
|
6331
6370
|
if (this.ChartPictureMenu) this.ChartPictureMenu.Hide();
|
|
6332
6371
|
this.ClearChartDrawPicture(drawPicture); //删除选中的画图工具
|
|
6372
|
+
this.CloseModifyDrawDialog();
|
|
6333
6373
|
}
|
|
6334
6374
|
else if (this.SelectedChart && this.SelectedChart.Selected.Identify)
|
|
6335
6375
|
{
|
|
@@ -8036,11 +8076,23 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
|
|
|
8036
8076
|
this.OnSelectChartPicture=function(chart)
|
|
8037
8077
|
{
|
|
8038
8078
|
JSConsole.Chart.Log('[JSChartContainer::OnSelectChartPicture]',chart);
|
|
8039
|
-
if (!this.ChartPictureMenu) this.ChartPictureMenu=g_DialogFactory.Create('ChartPictureSettingMenu', this.UIElement.parentNode);
|
|
8040
|
-
if (!this.ChartPictureMenu) return;
|
|
8041
8079
|
|
|
8042
|
-
|
|
8043
|
-
|
|
8080
|
+
if (!this.DialogModifyDraw) return;
|
|
8081
|
+
|
|
8082
|
+
if (chart.ClassName=="ChartDrawPictureText" || chart.ClassName=='ChartDrawVolProfile')
|
|
8083
|
+
{
|
|
8084
|
+
this.CloseModifyDrawDialog();
|
|
8085
|
+
|
|
8086
|
+
if (!this.ChartPictureMenu) this.ChartPictureMenu=g_DialogFactory.Create('ChartPictureSettingMenu', this.UIElement.parentNode);
|
|
8087
|
+
if (!this.ChartPictureMenu) return;
|
|
8088
|
+
|
|
8089
|
+
var event={ data: { ChartPicture:chart, HQChart:this}};
|
|
8090
|
+
this.ChartPictureMenu.DoModal(event);
|
|
8091
|
+
}
|
|
8092
|
+
else
|
|
8093
|
+
{
|
|
8094
|
+
this.ShowModifyDrawDialog(chart);
|
|
8095
|
+
}
|
|
8044
8096
|
}
|
|
8045
8097
|
|
|
8046
8098
|
this.FinishMoveChartDrawPicture=function()
|
|
@@ -55587,6 +55639,8 @@ IChartDrawPicture.ArrayDrawPricture=
|
|
|
55587
55639
|
|
|
55588
55640
|
{ Name:"水平线2", ClassName:"ChartDrawHLine", Create:function() { return new ChartDrawHLine(); }},
|
|
55589
55641
|
|
|
55642
|
+
{ Name:"MonitorLine", ClassName:"ChartDrawMonitorLine", Create:function() { return new ChartDrawMonitorLine(); }},
|
|
55643
|
+
|
|
55590
55644
|
|
|
55591
55645
|
//trading view样式
|
|
55592
55646
|
{ Name:"Note", ClassName:"ChartDrawNote", Create:function() { return new ChartDrawNote(); } },
|
|
@@ -60442,6 +60496,221 @@ function ChartDrawCrosshair()
|
|
|
60442
60496
|
}
|
|
60443
60497
|
}
|
|
60444
60498
|
|
|
60499
|
+
//画图工具-监测线
|
|
60500
|
+
function ChartDrawMonitorLine()
|
|
60501
|
+
{
|
|
60502
|
+
this.newMethod=IChartDrawPicture; //派生
|
|
60503
|
+
this.newMethod();
|
|
60504
|
+
delete this.newMethod;
|
|
60505
|
+
|
|
60506
|
+
this.ClassName='ChartDrawMonitorLine';
|
|
60507
|
+
this.PointCount=1;
|
|
60508
|
+
this.IsPointIn=this.IsPointIn_XYValue_Line;
|
|
60509
|
+
this.IsHScreen=false;
|
|
60510
|
+
this.GetXYCoordinate=this.GetXYCoordinate_default;
|
|
60511
|
+
this.FormatLabelTextCallback=null;
|
|
60512
|
+
|
|
60513
|
+
this.LineColor='rgb(255,215,0)'
|
|
60514
|
+
this.LabelConfig=
|
|
60515
|
+
{
|
|
60516
|
+
Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
|
|
60517
|
+
BGColor:"rgb(30,144,255)", YTextOffset:4,
|
|
60518
|
+
LineColor:"rgba(255,215,0,0.8)",
|
|
60519
|
+
LineDash:[3,5],
|
|
60520
|
+
}
|
|
60521
|
+
|
|
60522
|
+
this.SetOption=function(option)
|
|
60523
|
+
{
|
|
60524
|
+
if (option.LineColor) this.LineColor=option.LineColor;
|
|
60525
|
+
if (option.Label)
|
|
60526
|
+
{
|
|
60527
|
+
var item=option.Label;
|
|
60528
|
+
var dest=this.LabelConfig
|
|
60529
|
+
if (item.Font) dest.Font=item.Font;
|
|
60530
|
+
if (item.BGColor) dest.BGColor=item.BGColor;
|
|
60531
|
+
if (item.LineColor) dest.LineColor=item.LineColor;
|
|
60532
|
+
if (item.LineDash) dest.LineDash=item.LineDash;
|
|
60533
|
+
if (IFrameSplitOperator.IsNumber(item.YTextOffset)) dest.YTextOffset=item.YTextOffset;
|
|
60534
|
+
}
|
|
60535
|
+
|
|
60536
|
+
if (option.FormatLabelTextCallback) this.FormatLabelTextCallback=option.FormatLabelTextCallback;
|
|
60537
|
+
}
|
|
60538
|
+
|
|
60539
|
+
this.Draw=function()
|
|
60540
|
+
{
|
|
60541
|
+
this.LinePoint=[];
|
|
60542
|
+
if (this.IsFrameMinSize()) return;
|
|
60543
|
+
if (!this.IsShow) return;
|
|
60544
|
+
|
|
60545
|
+
if (!this.Frame || !this.Frame.Data) return;
|
|
60546
|
+
var data=this.Frame.Data;
|
|
60547
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(data.Data)) return;
|
|
60548
|
+
|
|
60549
|
+
if (this.Point.length!=1) return;
|
|
60550
|
+
if (this.Value.length!=1) return;
|
|
60551
|
+
this.IsHScreen=this.Frame.IsHScreen;
|
|
60552
|
+
if (this.IsHScreen) return;
|
|
60553
|
+
|
|
60554
|
+
if (this.Status==20) this.DrawMoveLine();
|
|
60555
|
+
else if (this.Status==10) this.DrawMonitorLine(data);
|
|
60556
|
+
}
|
|
60557
|
+
|
|
60558
|
+
this.DrawMoveLine=function()
|
|
60559
|
+
{
|
|
60560
|
+
var border=this.Frame.ChartBorder.GetBorder();
|
|
60561
|
+
var pt=this.Point[0];
|
|
60562
|
+
var x=ToFixedPoint(pt.X);
|
|
60563
|
+
this.ClipFrame();
|
|
60564
|
+
|
|
60565
|
+
this.Canvas.strokeStyle=this.LineColor;
|
|
60566
|
+
this.Canvas.beginPath();
|
|
60567
|
+
this.Canvas.moveTo(x,border.TopEx);
|
|
60568
|
+
this.Canvas.lineTo(x,border.BottomEx);
|
|
60569
|
+
this.Canvas.stroke();
|
|
60570
|
+
|
|
60571
|
+
this.Canvas.restore();
|
|
60572
|
+
}
|
|
60573
|
+
|
|
60574
|
+
this.DrawMonitorLine=function(data)
|
|
60575
|
+
{
|
|
60576
|
+
var isMinute=this.Frame.IsMinuteFrame();
|
|
60577
|
+
var dataWidth=this.Frame.DataWidth;
|
|
60578
|
+
var distanceWidth=this.Frame.DistanceWidth;
|
|
60579
|
+
var xPointCount=this.Frame.XPointCount;
|
|
60580
|
+
|
|
60581
|
+
if (this.IsHScreen)
|
|
60582
|
+
{
|
|
60583
|
+
//var border=this.Frame.ChartBorder.GetHScreenBorder();
|
|
60584
|
+
//var chartright=border.BottomEx;
|
|
60585
|
+
//var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
|
|
60586
|
+
}
|
|
60587
|
+
else
|
|
60588
|
+
{
|
|
60589
|
+
var border=this.Frame.ChartBorder.GetBorder();
|
|
60590
|
+
var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
|
|
60591
|
+
var chartright=border.RightEx;
|
|
60592
|
+
}
|
|
60593
|
+
|
|
60594
|
+
var ptData=this.Value[0];
|
|
60595
|
+
this.ClipFrame();
|
|
60596
|
+
|
|
60597
|
+
var labelInfo=null;
|
|
60598
|
+
for(var i=data.DataOffset,j=0;i<data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
|
|
60599
|
+
{
|
|
60600
|
+
var item=data.Data[i];
|
|
60601
|
+
|
|
60602
|
+
if (isMinute)
|
|
60603
|
+
{
|
|
60604
|
+
var x=this.Frame.GetXFromIndex(j);
|
|
60605
|
+
}
|
|
60606
|
+
else
|
|
60607
|
+
{
|
|
60608
|
+
var left=xOffset;
|
|
60609
|
+
var right=xOffset+dataWidth;
|
|
60610
|
+
if (right>chartright) break;
|
|
60611
|
+
var x=left+(right-left)/2;
|
|
60612
|
+
}
|
|
60613
|
+
|
|
60614
|
+
if (i==ptData.XValue) //起始
|
|
60615
|
+
{
|
|
60616
|
+
this.Canvas.strokeStyle=this.LineColor;
|
|
60617
|
+
this.Canvas.beginPath();
|
|
60618
|
+
this.Canvas.moveTo(x,border.TopEx);
|
|
60619
|
+
this.Canvas.lineTo(x,border.BottomEx);
|
|
60620
|
+
this.Canvas.stroke();
|
|
60621
|
+
|
|
60622
|
+
var line={Start:{X:x, Y:border.TopEx}, End:{X:x, Y:border.BottomEx}};
|
|
60623
|
+
this.LinePoint.push(line);
|
|
60624
|
+
}
|
|
60625
|
+
else if (i==data.Data.length-1) //结束
|
|
60626
|
+
{
|
|
60627
|
+
if (this.LabelConfig.LineDash) this.Canvas.setLineDash(this.LabelConfig.LineDash);
|
|
60628
|
+
this.Canvas.strokeStyle=this.LabelConfig.LineColor;
|
|
60629
|
+
this.Canvas.beginPath();
|
|
60630
|
+
this.Canvas.moveTo(x,border.TopEx);
|
|
60631
|
+
this.Canvas.lineTo(x,border.BottomEx);
|
|
60632
|
+
this.Canvas.stroke();
|
|
60633
|
+
if (this.LabelConfig.LineDash) this.Canvas.setLineDash([]);
|
|
60634
|
+
|
|
60635
|
+
labelInfo={ Left:right, Data:data, StartIndex:ptData.XValue, AryText:[] };
|
|
60636
|
+
}
|
|
60637
|
+
}
|
|
60638
|
+
|
|
60639
|
+
this.Canvas.restore();
|
|
60640
|
+
|
|
60641
|
+
if (labelInfo) this.DrawLabel(labelInfo);
|
|
60642
|
+
}
|
|
60643
|
+
|
|
60644
|
+
this.DrawLabel=function(labelInfo)
|
|
60645
|
+
{
|
|
60646
|
+
if (!this.FormatLabelTextCallback) return;
|
|
60647
|
+
this.FormatLabelTextCallback(labelInfo);
|
|
60648
|
+
if (!IFrameSplitOperator.IsNonEmptyArray(labelInfo.AryText)) return;
|
|
60649
|
+
if (!IFrameSplitOperator.IsNumber(labelInfo.YValue)) return;
|
|
60650
|
+
|
|
60651
|
+
/*
|
|
60652
|
+
labelInfo.YValue=7.15;
|
|
60653
|
+
labelInfo.AryText=
|
|
60654
|
+
[
|
|
60655
|
+
{ Name:"标题1:", Text:"6666", NameColor:"rgb(255,255,255)", TextColor:"rgb(30,10,30)" },
|
|
60656
|
+
{ Name:"标题2:", Text:"08.00", NameColor:"rgb(255,255,255)", TextColor:"rgb(30,10,30)" },
|
|
60657
|
+
{ Name:"标题3:", Text:"999.1", NameColor:"rgb(255,255,255)", TextColor:"rgb(30,10,30)" },
|
|
60658
|
+
{ Name:"标题4:", Text:"320" , NameColor:"rgb(255,255,255)", TextColor:"rgb(30,10,30)"},
|
|
60659
|
+
{ Name:"标题5:", Text:"77775.77", NameColor:"rgb(255,255,255)", TextColor:"rgb(30,10,30)" }
|
|
60660
|
+
]
|
|
60661
|
+
*/
|
|
60662
|
+
|
|
60663
|
+
var y=this.Frame.GetYFromData(labelInfo.YValue,false);
|
|
60664
|
+
this.Canvas.font=this.LabelConfig.Font;
|
|
60665
|
+
this.Canvas.textAlign="left";
|
|
60666
|
+
this.Canvas.textBaseline="top";
|
|
60667
|
+
var lineHeight=this.Canvas.measureText("擎").width+2;
|
|
60668
|
+
var maxWidth=0, lineCount=0;
|
|
60669
|
+
for(var i=0;i<labelInfo.AryText.length;++i)
|
|
60670
|
+
{
|
|
60671
|
+
var item=labelInfo.AryText[i];
|
|
60672
|
+
item.NameWidth=0;
|
|
60673
|
+
item.TextWidth=0;
|
|
60674
|
+
if (item.Name) item.NameWidth=this.Canvas.measureText(item.Name).width+2;
|
|
60675
|
+
if (item.Text) item.TextWidth=this.Canvas.measureText(item.Text).width+2;
|
|
60676
|
+
|
|
60677
|
+
var itemWidth=item.NameWidth+item.TextWidth;
|
|
60678
|
+
if (maxWidth<itemWidth) maxWidth=itemWidth;
|
|
60679
|
+
++lineCount;
|
|
60680
|
+
}
|
|
60681
|
+
|
|
60682
|
+
var rtBG={ Left:labelInfo.Left+1, Top:y, Width:maxWidth+4, Height:lineHeight*lineCount+4 };
|
|
60683
|
+
rtBG.Right=rtBG.Left+rtBG.Width;
|
|
60684
|
+
rtBG.Bottom=rtBG.Top+rtBG.Height;
|
|
60685
|
+
if (this.LabelConfig.BGColor)
|
|
60686
|
+
{
|
|
60687
|
+
this.Canvas.fillStyle=this.LabelConfig.BGColor
|
|
60688
|
+
this.Canvas.fillRect(ToFixedRect(rtBG.Left),ToFixedRect(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));
|
|
60689
|
+
}
|
|
60690
|
+
|
|
60691
|
+
var xText=rtBG.Left+2;
|
|
60692
|
+
var yText=rtBG.Top+this.LabelConfig.YTextOffset;
|
|
60693
|
+
for(var i=0;i<labelInfo.AryText.length;++i)
|
|
60694
|
+
{
|
|
60695
|
+
var item=labelInfo.AryText[i];
|
|
60696
|
+
|
|
60697
|
+
if (item.Name)
|
|
60698
|
+
{
|
|
60699
|
+
this.Canvas.fillStyle=item.NameColor;
|
|
60700
|
+
this.Canvas.fillText(item.Name,xText,yText);
|
|
60701
|
+
}
|
|
60702
|
+
|
|
60703
|
+
if (item.Text)
|
|
60704
|
+
{
|
|
60705
|
+
this.Canvas.fillStyle=item.TextColor;
|
|
60706
|
+
this.Canvas.fillText(item.Text,xText+item.NameWidth ,yText);
|
|
60707
|
+
}
|
|
60708
|
+
|
|
60709
|
+
yText+=lineHeight;
|
|
60710
|
+
}
|
|
60711
|
+
}
|
|
60712
|
+
}
|
|
60713
|
+
|
|
60445
60714
|
//画图工具-波浪尺
|
|
60446
60715
|
function ChartDrawWaveRuler()
|
|
60447
60716
|
{
|