hqchart 1.1.15060 → 1.1.15070

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.
@@ -3374,6 +3374,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3374
3374
  this.DialogSearchIndex; //指标搜索
3375
3375
  this.DialogModifyIndexParam; //指标参数修改
3376
3376
  this.SmallFloatTooltipGroup; //小浮框tooltip信息集合
3377
+ this.JSToolbarTooltip; //指标标题工具栏tooltip信息
3377
3378
 
3378
3379
 
3379
3380
  this.RestoreFocusTimer=null; //恢复焦点定时器
@@ -9836,6 +9837,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
9836
9837
  if (overlayItem.Frame && overlayItem.Frame.ReloadResource) overlayItem.Frame.ReloadResource(resource);
9837
9838
  }
9838
9839
  }
9840
+
9841
+ if (this.JSToolbarTooltip) this.JSToolbarTooltip.ReloadResource(resource); //工具栏提示框
9839
9842
  }
9840
9843
 
9841
9844
  this.ReloadChartPaint=function(resource)
@@ -10364,6 +10367,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10364
10367
  if (!option) return;
10365
10368
 
10366
10369
  var frame=subFrame.Frame;
10370
+ var pixelRatio=GetDevicePixelRatio();
10367
10371
 
10368
10372
  if (option.Window)
10369
10373
  {
@@ -10403,6 +10407,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10403
10407
  if (IFrameSplitOperator.IsBool(option.IsShowYLine)) subFrame.Frame.IsShowYLine=option.IsShowYLine;
10404
10408
  if (IFrameSplitOperator.IsBool(option.IsShowIndexTitle)) subFrame.Frame.IsShowIndexTitle=option.IsShowIndexTitle;
10405
10409
  if (IFrameSplitOperator.IsNumber(option.Height)) subFrame.Height=option.Height; //高度
10410
+ if (IFrameSplitOperator.IsNumber(option.TopSpace)) frame.ChartBorder.TopSpace=option.TopSpace*pixelRatio;
10411
+ if (IFrameSplitOperator.IsNumber(option.BottomSpace)) frame.ChartBorder.BottomSpace=option.BottomSpace*pixelRatio;
10406
10412
 
10407
10413
 
10408
10414
  if (IFrameSplitOperator.IsBool(option.IsShowLeftText))
@@ -13572,6 +13578,8 @@ function AverageWidthFrame()
13572
13578
  this.BeforeDrawXYCallback; //坐标绘制前回调,绘制深度图
13573
13579
  this.GetEventCallback; //事件回调
13574
13580
 
13581
+ this.DivFrameToolbar;
13582
+
13575
13583
  //工具栏的按钮样式
13576
13584
  this.ToolbarButtonStyle=g_JSChartResource.ToolbarButtonStyle;
13577
13585
  this.CloseWindowButton=CloneData(g_JSChartResource.Buttons.CloseWindow);
@@ -13621,6 +13629,8 @@ function AverageWidthFrame()
13621
13629
  this.ButtonTooltip=CloneData(g_JSChartResource.Buttons.Tooltip);
13622
13630
  this.AddIndexWindowButton=CloneData(g_JSChartResource.Buttons.AddIndexWindow);
13623
13631
  }
13632
+
13633
+ if (this.DivFrameToolbar) this.DivFrameToolbar.ReloadResource(resource);
13624
13634
  }
13625
13635
 
13626
13636
  this.DrawFrame=function()
@@ -16190,7 +16200,6 @@ function AverageWidthFrame()
16190
16200
  }
16191
16201
  }
16192
16202
 
16193
-
16194
16203
  if (IFrameSplitOperator.IsNumber(width.Right)) width.Right+=rightExtendWidth;
16195
16204
  if (IFrameSplitOperator.IsNumber(width.Left)) width.Left+=this.YTextPadding[0]+leftExtendLineWidth;
16196
16205
  if (IFrameSplitOperator.IsNumber(width.Right)) width.Right+=this.YTextPadding[1]+rightExtendLineWidth;
@@ -16198,25 +16207,34 @@ function AverageWidthFrame()
16198
16207
  return { TextWidth:width };
16199
16208
  }
16200
16209
 
16210
+ this.CreateDivFrameToolbar=function(hqchart, frameID, divHQChart)
16211
+ {
16212
+ if (this.ToolbarButtonStyle==1) return;
16213
+ if (this.DivFrameToolbar) return;
16214
+
16215
+ if (this.ClassName=="MinuteFrame" || this.ClassName=="KLineFrame")
16216
+ {
16217
+ this.DivFrameToolbar=new JSDivFrameToolbar();
16218
+ this.DivFrameToolbar.HQChart=hqchart;
16219
+ this.DivFrameToolbar.DivHQChart=divHQChart;
16220
+ this.DivFrameToolbar.FrameID=frameID;
16221
+ this.DivFrameToolbar.Create(this);
16222
+ }
16223
+ }
16224
+
16201
16225
  this.ClearToolbar=function()
16202
16226
  {
16203
- if (!this.ToolbarID) return;
16227
+ if (!this.DivFrameToolbar) return;
16204
16228
 
16205
- var divToolbar=document.getElementById(this.ToolbarID);
16206
- if (!divToolbar) return;
16207
- this.ChartBorder.UIElement.parentNode.removeChild(divToolbar);
16208
- this.ToolbarRect=null;
16229
+ this.DivFrameToolbar.Destroy();
16230
+ this.DivFrameToolbar=null;
16209
16231
  }
16210
16232
 
16211
16233
  this.HideToolbar=function()
16212
16234
  {
16213
- if (!this.ToolbarID) return;
16235
+ if (!this.DivFrameToolbar) return;
16214
16236
 
16215
- this.ToolbarRect=null;
16216
- var divToolbar=document.getElementById(this.ToolbarID);
16217
- if (!divToolbar) return;
16218
-
16219
- if (divToolbar.style.display!='none') divToolbar.style.display='none';
16237
+ this.DivFrameToolbar.Hide();
16220
16238
  }
16221
16239
 
16222
16240
  this.GetMainOverlayFrame=function()
@@ -16254,7 +16272,6 @@ function MinuteFrame()
16254
16272
  this.MultiDayBorderPen=g_JSChartResource.MultiDayBorderPen;
16255
16273
  this.CustomHorizontalInfo=[];
16256
16274
  this.RightFrame=null; //右侧多重坐标
16257
- this.ToolbarID=Guid(); //工具条Div id
16258
16275
  this.ReDrawToolbar=false;
16259
16276
  this.DayCount=1; //显示天数
16260
16277
 
@@ -16267,7 +16284,6 @@ function MinuteFrame()
16267
16284
  this.OverlayIndex=g_JSChartResource.MinuteToolbar.OverlayIndex; //是否显示叠加指标
16268
16285
  this.AddIndexWindow=g_JSChartResource.MinuteToolbar.AddIndexWindow; //是否显示'增加指标窗口'菜单
16269
16286
 
16270
- this.ToolbarRect=null; //保存工具条的位置
16271
16287
  this.IsShowPositionTitle=false; //是否显示持仓标题
16272
16288
 
16273
16289
  this.LastCalculateStatus={ Width:0, XPointCount:0 }; //最后一次计算宽度的状态
@@ -16399,112 +16415,8 @@ function MinuteFrame()
16399
16415
  if (this.ToolbarButtonStyle==1) return;
16400
16416
  if (g_JSChartResource.IsDOMFrameToolbar===true) return;
16401
16417
 
16402
- if (typeof($)=="undefined") return;
16403
-
16404
- if (this.Identify<2) return;
16405
- if (!this.ChartBorder.UIElement) return;
16406
-
16407
- var divToolbar=document.getElementById(this.ToolbarID);
16408
- if (divToolbar && this.SizeChange==false && this.ReDrawToolbar==false) return;
16409
-
16410
- if (!divToolbar)
16411
- {
16412
- divToolbar=document.createElement("div");
16413
- divToolbar.className='klineframe-toolbar';
16414
- divToolbar.id=this.ToolbarID;
16415
- divToolbar.oncontextmenu = function() { return false;}; //屏蔽右键系统菜单
16416
- //为divToolbar添加属性identify
16417
- divToolbar.setAttribute("identify",this.Identify.toString());
16418
- this.ChartBorder.UIElement.parentNode.appendChild(divToolbar);
16419
- }
16420
-
16421
- if (!this.ModifyIndex && !this.ChangeIndex && !this.OverlayIndex && !this.CloseIndex)
16422
- {
16423
- if (divToolbar.style.display!='none')
16424
- divToolbar.style.display='none';
16425
- return;
16426
- }
16427
-
16428
- //使用外城div尺寸 画图尺寸是被放大的
16429
- var pixelTatio = GetDevicePixelRatio();
16430
- var chartWidth=parseInt(this.ChartBorder.UIElement.parentElement.style.width.replace("px",""));
16431
- var chartHeight=parseInt(this.ChartBorder.UIElement.parentElement.style.height.replace("px",""));
16432
- //JSConsole.Chart.Log('[KLineFrame::DrawToolbar] ',chartWidth,chartHeight,pixelTatio);
16433
-
16434
- var toolbarWidth=100;
16435
- var toolbarHeight=this.ChartBorder.GetTitleHeight();
16436
- var left=chartWidth-(this.ChartBorder.Right/pixelTatio)-toolbarWidth;
16437
- var top=this.ChartBorder.GetTop()/pixelTatio;
16438
-
16439
- if (this.ToolbarRect)
16440
- {
16441
- //尺寸变动移动才重新设置DOM
16442
- if (this.ToolbarRect.Left==left && this.ToolbarRect.Top==top &&
16443
- this.ToolbarRect.Width==toolbarWidth && this.ToolbarRect.Height==toolbarHeight/pixelTatio)
16444
- {
16445
- return;
16446
- }
16447
- }
16448
-
16449
- this.ToolbarRect={ Left:left, Top:top, Width:toolbarWidth, Height:toolbarHeight/pixelTatio };
16450
-
16451
- const modifyButton=`<span class='index_param icon iconfont icon-index_param' id='modifyindex' style='cursor:pointer;margin-left:2px;margin-right:2px;' title='调整指标参数'></span>`;
16452
- const changeButton=`<span class='index_change icon iconfont icon-change_index' id='changeindex' style='cursor:pointer;margin-left:2px;margin-right:2px;' title='切换指标'></span>`;
16453
- const closeButton=`<span class='index_close icon iconfont icon-close' id='closeindex' style='cursor:pointer;margin-left:2px;margin-right:2px;' title='关闭指标窗口'></span>`;
16454
-
16455
- var spanIcon=modifyButton+changeButton;
16456
- if (this.CloseIndex)
16457
- {
16458
- spanIcon+=closeButton;
16459
- }
16460
-
16461
- //var scrollPos=GetScrollPosition();
16462
- //left = left+scrollPos.Left;
16463
- //top = top+scrollPos.Top;
16464
- divToolbar.style.left = left + "px";
16465
- divToolbar.style.top = top + "px";
16466
- divToolbar.style.width=toolbarWidth+"px"; //宽度先不调整吧
16467
- divToolbar.style.height=(toolbarHeight/pixelTatio)+'px'; //只调整高度
16468
- divToolbar.innerHTML=spanIcon;
16469
-
16470
- var chart=this.ChartBorder.UIElement.JSChartContainer;
16471
- var identify=this.Identify;
16472
- if (!this.ModifyIndex) //隐藏'改参数'
16473
- $("#"+divToolbar.id+" .index_param").hide();
16474
- else if (typeof(this.ModifyIndexEvent)=='function') //绑定点击事件
16475
- $("#"+divToolbar.id+" .index_param").click(
16476
- {
16477
- Chart:this.ChartBorder.UIElement.JSChartContainer,
16478
- Identify:this.Identify
16479
- },this.ModifyIndexEvent);
16480
-
16481
- if (!this.ChangeIndex) //隐藏'换指标'
16482
- {
16483
- $("#"+divToolbar.id+" .index_change").hide();
16484
- }
16485
- else if (typeof(this.ChangeIndexEvent)=='function')
16486
- {
16487
- $("#"+divToolbar.id+" .index_change").click(
16488
- {
16489
- Chart:this.ChartBorder.UIElement.JSChartContainer,
16490
- Identify:this.Identify,
16491
- IsOverlay:false
16492
- },this.ChangeIndexEvent);
16493
- }
16494
-
16495
- $("#"+divToolbar.id+" .index_close").click(
16496
- {
16497
- Chart:this.ChartBorder.UIElement.JSChartContainer,
16498
- Identify:this.Identify
16499
- },
16500
- function(event)
16501
- {
16502
- var hqChart=event.data.Chart;
16503
- var id=event.data.Identify;
16504
- hqChart.RemoveIndexWindow(id);
16505
- });
16506
-
16507
- divToolbar.style.display = "block";
16418
+ if (!this.DivFrameToolbar) return;
16419
+ this.DivFrameToolbar.Show(this.Identify);
16508
16420
  }
16509
16421
 
16510
16422
  //手绘,不用DOM,使用DOM太麻烦了
@@ -18686,7 +18598,6 @@ function KLineFrame()
18686
18598
  delete this.newMethod;
18687
18599
 
18688
18600
  this.ClassName='KLineFrame';
18689
- this.ToolbarID=Guid(); //工具条Div id
18690
18601
 
18691
18602
  this.ModifyIndex=g_JSChartResource.KLineToolbar.ModifyIndex; //是否显示'改参数'菜单
18692
18603
  this.ChangeIndex=g_JSChartResource.KLineToolbar.ChangeIndex; //是否显示'换指标'菜单
@@ -18699,7 +18610,6 @@ function KLineFrame()
18699
18610
 
18700
18611
  this.SelBorderColor=g_JSChartResource.SelFrameBorderColor;
18701
18612
 
18702
- this.ToolbarRect=null; //保存工具条的位置
18703
18613
  this.ReDrawToolbar=false;
18704
18614
 
18705
18615
  this.LastCalculateStatus={ Width:0, XPointCount:0 }; //最后一次计算宽度的状态
@@ -18723,6 +18633,11 @@ function KLineFrame()
18723
18633
  {
18724
18634
  if (this.ToolbarButtonStyle==1) return;
18725
18635
  if (g_JSChartResource.IsDOMFrameToolbar===true) return;
18636
+ if (!this.DivFrameToolbar) return;
18637
+
18638
+ this.DivFrameToolbar.Show(this.Identify);
18639
+
18640
+ return;
18726
18641
 
18727
18642
  if (typeof($)=="undefined") return;
18728
18643
 
@@ -53144,6 +53059,10 @@ function KLineCountDownPaint()
53144
53059
  this.CanvasEx.fillStyle=out.BGColor;
53145
53060
  this.CanvasEx.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
53146
53061
  }
53062
+ else
53063
+ {
53064
+ return;
53065
+ }
53147
53066
 
53148
53067
  this.Canvas.textAlign = "left";
53149
53068
  this.Canvas.textBaseline = "bottom";
@@ -66737,7 +66656,7 @@ function ChartDrawPictureHorizontalLine()
66737
66656
  {
66738
66657
  Left:{ IsShow:true, Margin:{ Left:5, Top:4, Bottom:2, Right:5 } },
66739
66658
  Right:{ IsShow:true, Margin:{ Left:5, Top:4, Bottom:2, Right:5 } },
66740
- Font:`${12*GetDevicePixelRatio()}px 微软雅黑`, TextColor:"rgb(255,255,255)"
66659
+ Font:`${12*GetDevicePixelRatio()}px 微软雅黑`, TextColor:"rgb(255,255,255)", BGColor:null
66741
66660
  };
66742
66661
 
66743
66662
  this.InsideLabelConfig=
@@ -66746,7 +66665,8 @@ function ChartDrawPictureHorizontalLine()
66746
66665
  Font:`${14*GetDevicePixelRatio()}px 微软雅黑`,
66747
66666
  Margin:{ Left:5, Top:4, Bottom:2, Right:5 },
66748
66667
  TextColor:"rgb(255,255,255)",
66749
- BGAlpha:0.8, //背景色透明度
66668
+ BGAlpha:0.8, //背景色透明度,
66669
+ IsShow:true
66750
66670
  }
66751
66671
 
66752
66672
  this.LabelTitle;
@@ -66775,7 +66695,8 @@ function ChartDrawPictureHorizontalLine()
66775
66695
  }
66776
66696
 
66777
66697
  if (item.Font) this.LabelConfig.Font=item.Font;
66778
- if (item.TextColor) this.LabelConfig.FoTextColornt=item.TextColor;
66698
+ if (item.TextColor) this.LabelConfig.TextColor=item.TextColor;
66699
+ if (item.BGColor) this.LabelConfig.BGColor=item.BGColor;
66779
66700
  }
66780
66701
 
66781
66702
  if (option.InsideLabel)
@@ -66785,6 +66706,7 @@ function ChartDrawPictureHorizontalLine()
66785
66706
  if (item.TextColor) this.InsideLabelConfig.TextColor=item.TextColor;
66786
66707
  if (IFrameSplitOperator.IsNumber(item.Position)) this.InsideLabelConfig.Position=item.Position;
66787
66708
  if (IFrameSplitOperator.IsNumber(item.BGAlpha)) this.InsideLabelConfig.BGAlpha=item.BGAlpha;
66709
+ if (IFrameSplitOperator.IsBool(item.IsShow)) this.InsideLabelConfig.IsShow=item.IsShow;
66788
66710
  }
66789
66711
  }
66790
66712
  }
@@ -66796,6 +66718,8 @@ function ChartDrawPictureHorizontalLine()
66796
66718
  {
66797
66719
  storageData=this.Super_ExportStorageData();
66798
66720
  if (this.LabelTitle) storageData.LabelTitle=this.LabelTitle;
66721
+ if (this.LabelConfig) storageData.Label=this.LabelConfig;
66722
+ if (this.InsideLabelConfig) storageData.InsideLabel=this.InsideLabelConfig;
66799
66723
  }
66800
66724
 
66801
66725
  return storageData;
@@ -66902,7 +66826,8 @@ function ChartDrawPictureHorizontalLine()
66902
66826
  rtBG.Bottom=rtBG.Top+rtBG.Height;
66903
66827
  rtBG.Left=rtBG.Right-rtBG.Width;
66904
66828
 
66905
- this.Canvas.fillStyle=this.LineColor;
66829
+ if (config.BGColor) this.Canvas.fillStyle=config.BGColor;
66830
+ else this.Canvas.fillStyle=this.LineColor;
66906
66831
  this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
66907
66832
 
66908
66833
  this.Canvas.textAlign="left";
@@ -66920,7 +66845,9 @@ function ChartDrawPictureHorizontalLine()
66920
66845
  rtBG.Top=y-textHeight/2-margin.Top;
66921
66846
  rtBG.Bottom=rtBG.Top+rtBG.Height;
66922
66847
  rtBG.Right=rtBG.Left+rtBG.Width;
66923
- this.Canvas.fillStyle=this.LineColor;
66848
+
66849
+ if (config.BGColor) this.Canvas.fillStyle=config.BGColor;
66850
+ else this.Canvas.fillStyle=this.LineColor;
66924
66851
  this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
66925
66852
 
66926
66853
  this.Canvas.textAlign="left";
@@ -66938,6 +66865,7 @@ function ChartDrawPictureHorizontalLine()
66938
66865
 
66939
66866
  var isHScreen=this.Frame.IsHScreen;
66940
66867
  var config=this.InsideLabelConfig;
66868
+ if (!config.IsShow) return;
66941
66869
  if (config.Position!=0 && config.Position!=1) return;
66942
66870
  var margin=config.Margin;
66943
66871
 
@@ -77477,6 +77405,12 @@ function JSChartResource()
77477
77405
  Mergin:{ Left:4, Right:4, Top:2, Bottom:3 },
77478
77406
  }
77479
77407
  }
77408
+
77409
+ this.DivFrameToolbar=
77410
+ {
77411
+ Icon:{ Color:"rgb(0,0,0)", HoverColor:"rgb(30,144,255)" },
77412
+ Tooltip:{ BGColor:"rgb(255,255,255)", TextColor:"rgb(71,71,71)", BorderColor:"rgb(0,0,0)" },
77413
+ }
77480
77414
 
77481
77415
  //画图工具
77482
77416
  this.DrawPicture=
@@ -79455,6 +79389,29 @@ function JSChartResource()
79455
79389
  if (style.KLineCountDownPaint) this.SetKLineCountDownPaint(style.KLineCountDownPaint);
79456
79390
 
79457
79391
  if (style.SmallFloatTooltipV2) this.SetSmallFloatTooltipV2(style.SmallFloatTooltipV2);
79392
+
79393
+ if (style.DivFrameToolbar) this.SetDivFrameToolbar(style.DivFrameToolbar);
79394
+ }
79395
+
79396
+ this.SetDivFrameToolbar=function(style)
79397
+ {
79398
+ var dest=this.DivFrameToolbar;
79399
+ if (style.Icon)
79400
+ {
79401
+ var item=style.Icon;
79402
+ var subDest=dest.Icon;
79403
+ if (item.Color) subDest.Color=item.Color;
79404
+ if (item.HoverColor) subDest.HoverColor=item.HoverColor;
79405
+ }
79406
+
79407
+ if (style.Tooltip)
79408
+ {
79409
+ var item=style.Tooltip;
79410
+ var subDest=dest.Tooltip;
79411
+ if (item.TextColor) subDest.TextColor=item.TextColor;
79412
+ if (item.BorderColor) subDest.BorderColor=item.BorderColor;
79413
+ if (item.BGColor) subDest.BGColor=item.BGColor;
79414
+ }
79458
79415
  }
79459
79416
 
79460
79417
  this.SetSmallFloatTooltipV2=function(style)
@@ -82791,6 +82748,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
82791
82748
  frame.RightSpaceCount=this.RightSpaceCount; //右边
82792
82749
  frame.GetEventCallback=(id)=> { return this.GetEventCallback(id); };
82793
82750
  frame.GlobalOption=this.GlobalOption;
82751
+ frame.CreateDivFrameToolbar(this, i, this.UIElement.parentNode);
82794
82752
 
82795
82753
  frame.HorizontalMax=20;
82796
82754
  frame.HorizontalMin=10;
@@ -82891,6 +82849,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
82891
82849
  frame.YSplitOperator.HQChart=this;
82892
82850
  frame.XSplitOperator.Symbol=this.Symbol;
82893
82851
  frame.XSplitOperator.Period=this.Period;
82852
+ frame.CreateDivFrameToolbar(this, id, this.UIElement.parentNode);
82894
82853
 
82895
82854
  //K线数据绑定
82896
82855
  var xPointCouont=this.Frame.SubFrame[0].Frame.XPointCount;
@@ -85481,7 +85440,6 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
85481
85440
  if (bChanged)
85482
85441
  {
85483
85442
  frame.SizeChange=true;
85484
- frame.ToolbarRect=null; //清空工具栏缓存
85485
85443
  frame.DrawToolbar();
85486
85444
  }
85487
85445
  }
@@ -92452,7 +92410,7 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
92452
92410
 
92453
92411
  if (i>=2)
92454
92412
  {
92455
-
92413
+ frame.CreateDivFrameToolbar(this, i, this.UIElement.parentNode);
92456
92414
  }
92457
92415
 
92458
92416
  var DEFAULT_HORIZONTAL=[9,8,7,6,5,4,3,2,1];
@@ -92559,6 +92517,7 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
92559
92517
  frame.XSplitOperator.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
92560
92518
  frame.YSplitOperator.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
92561
92519
  frame.XSplitOperator.Symbol=this.Symbol;
92520
+ frame.CreateDivFrameToolbar(this, id, this.UIElement.parentNode);
92562
92521
 
92563
92522
  if (this.DayCount>1)
92564
92523
  {
@@ -105305,6 +105264,375 @@ Path2DHelper.PtInRect=function(x, y, rect)
105305
105264
  }
105306
105265
 
105307
105266
 
105267
+ ////////////////////////////////////////////////////////////////////////////////////
105268
+ // 指标窗口顶部工具条
105269
+ //
105270
+ //
105271
+ ///////////////////////////////////////////////////////////////////////////////////
105272
+
105273
+
105274
+ function JSDivFrameToolbar()
105275
+ {
105276
+ this.DivToolbar=null;
105277
+ this.DivHQChart=null;
105278
+ this.HQChart=null;
105279
+ this.FrameID=-1; //指标窗口ID
105280
+ this.ID=Guid();
105281
+ this.Left=-1;
105282
+ this.Top=-1;
105283
+
105284
+ this.IconConfig=
105285
+ {
105286
+ Color:g_JSChartResource.DivFrameToolbar.Icon.Color,
105287
+ HoverColor:g_JSChartResource.DivFrameToolbar.Icon.HoverColor
105288
+ }
105289
+
105290
+ this.AryButton=[]; //按钮数组
105291
+
105292
+ //创建按钮
105293
+ this.CreateArrayButton=function(aryButton)
105294
+ {
105295
+ for(var i=0;i<aryButton.length; i++)
105296
+ {
105297
+ var item=aryButton[i];
105298
+ if (!item.ID || !item.ClassName) continue;
105299
+ var newItem={ ID:item.ID, ClassName:item.ClassName, Span:null,Div:null, TooltipSpan:null };
105300
+ if (item.Tooltip && item.Tooltip.Text) newItem.Tooltip={ Text:item.Tooltip.Text };
105301
+
105302
+ this.AryButton.push(newItem);
105303
+
105304
+ if (this.DivToolbar) this.CreateButton(newItem, this.DivToolbar);
105305
+ }
105306
+ }
105307
+
105308
+ //清空原来的按钮
105309
+ this.ClearAllButtons=function()
105310
+ {
105311
+ //清空原来的按钮
105312
+ for(var i=0; i<this.AryButton.length; i++)
105313
+ {
105314
+ var item=this.AryButton[i];
105315
+ if (item.Div && this.DivToolbar) this.DivToolbar.removeChild(item.Div);
105316
+ item.Div=null;
105317
+ item.Span=null;
105318
+ item.TooltipSpan=null;
105319
+ }
105320
+
105321
+ this.AryButton=[];
105322
+ }
105323
+
105324
+ this.GetShowButtons=function(subFrame)
105325
+ {
105326
+ var frame=subFrame;
105327
+ if (!frame && this.FrameID>=0 && this.FrameID<this.HQChart.Frame.SubFrame.length)
105328
+ frame=this.HQChart.Frame.SubFrame[this.FrameID].Frame;
105329
+
105330
+ var aryDefaultButton=JSDivFrameToolbar.GetDfaultButtons();
105331
+ var aryButton=[];
105332
+ for(var i=0;i<aryDefaultButton.length; i++)
105333
+ {
105334
+ var item=aryDefaultButton[i];
105335
+ if (this.FrameID==0 && item.ID==JSCHART_BUTTON_ID.CLOSE_INDEX_WINDOW) continue; //第一个指标窗口不显示关闭按钮
105336
+
105337
+ if (item.ID==JSCHART_BUTTON_ID.MODIFY_INDEX_PARAM && frame && frame.ModifyIndex===false) continue;
105338
+ if (item.ID==JSCHART_BUTTON_ID.CHANGE_INDEX && frame && frame.ChangeIndex===false) continue;
105339
+ if (item.ID==JSCHART_BUTTON_ID.OVERLAY_INDEX && frame && frame.OverlayIndex===false) continue;
105340
+ if (item.ID==JSCHART_BUTTON_ID.CLOSE_INDEX_WINDOW && frame && frame.CloseIndex===false) continue;
105341
+
105342
+ aryButton.push(item);
105343
+ }
105344
+
105345
+ return aryButton;
105346
+ }
105347
+
105348
+ this.SetToolbar=function(aryButton)
105349
+ {
105350
+ this.ClearAllButtons(); //清空原来的按钮
105351
+
105352
+ this.CreateArrayButton(aryButton); //重新创建
105353
+
105354
+ this.UpdateStyle();
105355
+ }
105356
+
105357
+ this.UpdateButton=function()
105358
+ {
105359
+ if (!this.DivToolbar) return;
105360
+
105361
+ var aryButton=this.GetShowButtons();
105362
+ var bChange=false;
105363
+ if (aryButton.length!=this.AryButton.length)
105364
+ {
105365
+ bChange=true;
105366
+ }
105367
+ else
105368
+ {
105369
+ for(var i=0;i<this.AryButton.length;++i)
105370
+ {
105371
+ var leftItem=this.AryButton[i];
105372
+ var rightItem=aryButton[i];
105373
+
105374
+ if (leftItem.ID!=rightItem.ID || leftItem.ClassName!=rightItem.ClassName)
105375
+ {
105376
+ bChange=true;
105377
+ break;
105378
+ }
105379
+ }
105380
+ }
105381
+
105382
+ if (!bChange) return;
105383
+
105384
+ this.SetToolbar(aryButton); //重新设置按钮
105385
+ }
105386
+
105387
+
105388
+
105389
+ this.Destroy=function()
105390
+ {
105391
+ if (this.DivToolbar)
105392
+ {
105393
+ if (this.DivHQChart.removeChild) this.DivHQChart.removeChild(this.DivToolbar);
105394
+ this.DivToolbar=null;
105395
+ }
105396
+
105397
+ this.HQChart=null;
105398
+ this.DivHQChart=null;
105399
+ this.FrameID=-1;
105400
+ }
105401
+
105402
+ this.Create=function(frame)
105403
+ {
105404
+ var divToolbar=document.createElement("div");
105405
+ divToolbar.className='UMyChart_FrameToolbar_Div';
105406
+ divToolbar.id=this.ID;
105407
+ divToolbar.oncontextmenu = function() { return false; }; //屏蔽右键系统菜单
105408
+ this.DivToolbar=divToolbar;
105409
+
105410
+ var aryButtons=this.GetShowButtons(frame);
105411
+ this.CreateArrayButton(aryButtons)
105412
+
105413
+ this.DivHQChart.appendChild(divToolbar);
105414
+
105415
+ this.UpdateStyle();
105416
+
105417
+ if (!this.HQChart.JSToolbarTooltip)
105418
+ {
105419
+ this.HQChart.JSToolbarTooltip=new JSToolbarTooltip();
105420
+ this.HQChart.JSToolbarTooltip.DivHQChart=this.DivHQChart;
105421
+ this.HQChart.JSToolbarTooltip.Create();
105422
+ }
105423
+ }
105424
+
105425
+ this.UpdateStyle=function()
105426
+ {
105427
+ if (!this.DivToolbar) return;
105428
+
105429
+ for(var i=0;i<this.AryButton.length; i++)
105430
+ {
105431
+ var item=this.AryButton[i]
105432
+ if (!item.Span) continue;
105433
+ item.Span.style["color"]=this.IconConfig.Color;
105434
+ }
105435
+ }
105436
+
105437
+ this.ReloadResource=function(option)
105438
+ {
105439
+ this.IconConfig.Color=g_JSChartResource.DivFrameToolbar.Icon.Color,
105440
+ this.IconConfig.HoverColor=g_JSChartResource.DivFrameToolbar.Icon.HoverColor;
105441
+
105442
+ this.UpdateStyle();
105443
+ }
105444
+
105445
+ this.CreateButton=function(item, divDom)
105446
+ {
105447
+ var btnDiv=document.createElement("div");
105448
+ btnDiv.className="UMyChart_FrameToolbar_Div_Button";
105449
+ btnDiv.onmouseover=(e)=> { this.OnHoverButton(e, item); }
105450
+ btnDiv.onmouseout=(e)=>{ this.OnLeaveButton(e, item); }
105451
+ item.Div=btnDiv;
105452
+
105453
+ var spanDom=document.createElement("span");
105454
+ spanDom.className=item.ClassName;
105455
+ spanDom.onmousedown=(e)=>{ this.OnClickButton(e, item); };
105456
+ item.Span=spanDom;
105457
+ btnDiv.appendChild(spanDom);
105458
+
105459
+ divDom.appendChild(btnDiv);
105460
+ }
105461
+
105462
+ this.OnClickButton=function(e, item)
105463
+ {
105464
+ if (!this.FrameID<0) return;
105465
+ if (!this.HQChart) return;
105466
+
105467
+ var frame=this.HQChart.Frame.SubFrame[this.FrameID].Frame;
105468
+
105469
+ var button={ ID:item.ID, Frame:frame };
105470
+ this.HQChart.ClickFrameButton(button, e);
105471
+ }
105472
+
105473
+ this.OnHoverButton=function(e, item)
105474
+ {
105475
+ if (!item.Span) return;
105476
+
105477
+ item.Span.style["color"]=this.IconConfig.HoverColor;
105478
+
105479
+ this.ShowTooltip(e, item);
105480
+ }
105481
+
105482
+ this.OnLeaveButton=function(e, item)
105483
+ {
105484
+ if (!item.Span) return;
105485
+ item.Span.style["color"]=this.IconConfig.Color;
105486
+
105487
+ this.HideTooltip();
105488
+ }
105489
+
105490
+ this.Show=function(frameID)
105491
+ {
105492
+ this.FrameID=frameID;
105493
+ if (!this.FrameID<0) return;
105494
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.HQChart.Frame.SubFrame)) return;
105495
+ if (!this.HQChart.Frame.SubFrame[this.FrameID]) return;
105496
+
105497
+ var pixelTatio = GetDevicePixelRatio();
105498
+ var frame=this.HQChart.Frame.SubFrame[this.FrameID].Frame;
105499
+ var border=frame.GetBorder();
105500
+
105501
+ var top=border.Top/pixelTatio;
105502
+ var right=border.RightEx/pixelTatio;
105503
+ var left=right-this.DivToolbar.offsetWidth-2;
105504
+
105505
+ if (this.Top!=top || this.Left!=left)
105506
+ {
105507
+ this.DivToolbar.style.top = top + "px";
105508
+ this.DivToolbar.style.left = left + "px";
105509
+ this.DivToolbar.style.height=frame.ChartBorder.TitleHeight/pixelTatio + "px";
105510
+ this.Top=top;
105511
+ this.Left=left;
105512
+ }
105513
+
105514
+ if (this.DivToolbar.style.visibility!='visible') this.DivToolbar.style.visibility='visible';
105515
+ }
105516
+
105517
+ this.Hide=function()
105518
+ {
105519
+ if (this.DivToolbar) this.DivToolbar.style.visibility="hidden";
105520
+ }
105521
+
105522
+ this.HideTooltip=function()
105523
+ {
105524
+ if (this.HQChart.JSToolbarTooltip) this.HQChart.JSToolbarTooltip.Hide();
105525
+ }
105526
+
105527
+ this.ShowTooltip=function(e, item)
105528
+ {
105529
+ if (!this.HQChart.JSToolbarTooltip) return;
105530
+ if (!item.Div) return;
105531
+
105532
+ var rtButton=item.Div.getBoundingClientRect();
105533
+ var rtHQChart=this.DivHQChart.getBoundingClientRect();
105534
+ var left=rtButton.left-rtHQChart.left;
105535
+ var top=rtButton.bottom-rtHQChart.top+2;
105536
+ this.HQChart.JSToolbarTooltip.Show(top, left, { Text:item.Tooltip.Text });
105537
+ }
105538
+ }
105539
+
105540
+ JSDivFrameToolbar.GetDfaultButtons=function()
105541
+ {
105542
+ var aryButton=
105543
+ [
105544
+
105545
+ {
105546
+ ID:JSCHART_BUTTON_ID.MODIFY_INDEX_PARAM, ClassName:"UMyChart_FrameToolbar_Span_Button icon iconfont icon-index_param", Tooltip:{ Text:"修改参数"},
105547
+ Span:null, Div:null, TooltipSpan:null
105548
+ },
105549
+ {
105550
+ ID:JSCHART_BUTTON_ID.CHANGE_INDEX, ClassName:"UMyChart_FrameToolbar_Span_Button icon iconfont icon-change_index", Tooltip:{ Text:"切换指标"},
105551
+ Span:null,Div:null, TooltipSpan:null
105552
+ },
105553
+ {
105554
+ ID:JSCHART_BUTTON_ID.OVERLAY_INDEX, ClassName:"UMyChart_FrameToolbar_Span_Button icon iconfont icon-overlay_index", Tooltip:{ Text:"叠加指标"},
105555
+ Span:null,Div:null, TooltipSpan:null
105556
+ },
105557
+ {
105558
+ ID:JSCHART_BUTTON_ID.CLOSE_INDEX_WINDOW, ClassName:"UMyChart_FrameToolbar_Span_Button icon iconfont icon-close", Tooltip:{ Text:"关闭窗口"},
105559
+ Span:null,Div:null, TooltipSpan:null
105560
+ },
105561
+ ];
105562
+
105563
+ return aryButton
105564
+ }
105565
+
105566
+
105567
+ function JSToolbarTooltip()
105568
+ {
105569
+ this.DivTooltip=null;
105570
+ this.DivHQChart=null;
105571
+ this.Text=null;
105572
+ this.Left=-1;
105573
+ this.Top=-1;
105574
+
105575
+ this.BGColor=g_JSChartResource.DivFrameToolbar.Tooltip.BGColor;
105576
+ this.TextColor=g_JSChartResource.DivFrameToolbar.Tooltip.TextColor;
105577
+ this.BorderColor=g_JSChartResource.DivFrameToolbar.Tooltip.BorderColor;
105578
+
105579
+ this.Create=function()
105580
+ {
105581
+ var divDom=document.createElement("div");
105582
+ divDom.className='UMyChart_Toolbar_Tooltip_Div';
105583
+ this.DivHQChart.appendChild(divDom);
105584
+
105585
+ this.DivTooltip=divDom;
105586
+
105587
+ this.UpdateStyle();
105588
+ }
105589
+
105590
+ this.ReloadResource=function(option)
105591
+ {
105592
+ this.BGColor=g_JSChartResource.DivFrameToolbar.Tooltip.BGColor;
105593
+ this.TextColor=g_JSChartResource.DivFrameToolbar.Tooltip.TextColor;
105594
+ this.BorderColor=g_JSChartResource.DivFrameToolbar.Tooltip.BorderColor;
105595
+
105596
+ this.UpdateStyle();
105597
+ }
105598
+
105599
+ this.UpdateStyle=function()
105600
+ {
105601
+ if (!this.DivTooltip) return;
105602
+
105603
+ this.DivTooltip.style["background-color"]=this.BGColor;
105604
+ this.DivTooltip.style["color"]=this.TextColor;
105605
+ this.DivTooltip.style["border"]="1px solid " + this.BorderColor;
105606
+ }
105607
+
105608
+ this.Show=function(top, left, tooltipData)
105609
+ {
105610
+ if (!this.DivTooltip) return;
105611
+
105612
+ if (this.Text!=tooltipData.Text) this.DivTooltip.innerHTML=tooltipData.Text;
105613
+ var right=left+this.DivTooltip.offsetWidth;
105614
+ if ((right+5)>=window.innerWidth) left=left-this.DivTooltip.offsetWidth;
105615
+
105616
+ if (this.Top!=top || this.Left!=left)
105617
+ {
105618
+ this.DivTooltip.style.top = top + "px";
105619
+ this.DivTooltip.style.left = left + "px";
105620
+ this.Top=top;
105621
+ this.Left=left;
105622
+ }
105623
+
105624
+ if (this.DivTooltip.style.visibility!='visible') this.DivTooltip.style.visibility='visible';
105625
+ }
105626
+
105627
+ this.Hide=function()
105628
+ {
105629
+ if (!this.DivTooltip) return;
105630
+
105631
+ if (this.DivTooltip.style["visibility"]!='hidden') this.DivTooltip.style["visibility"]="hidden";
105632
+ }
105633
+ }
105634
+
105635
+
105308
105636
 
105309
105637
 
105310
105638