hqchart 1.1.15058 → 1.1.15066

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.15058",
3
+ "version": "1.1.15066",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -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)
@@ -10305,6 +10308,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10305
10308
  if (!subFrame || !subFrame.Frame) return;
10306
10309
 
10307
10310
  var frame=subFrame.Frame;
10311
+ var pixelRatio=GetDevicePixelRatio();
10308
10312
 
10309
10313
  if (windowItem)
10310
10314
  {
@@ -10352,6 +10356,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10352
10356
  }
10353
10357
 
10354
10358
  if (IFrameSplitOperator.IsNumber(frameItem.Height) && frameItem.Height>=0) subFrame.Height = frameItem.Height;
10359
+ if (IFrameSplitOperator.IsNumber(frameItem.TopSpace)) frame.ChartBorder.TopSpace=frameItem.TopSpace*pixelRatio;
10360
+ if (IFrameSplitOperator.IsNumber(frameItem.BottomSpace)) frame.ChartBorder.BottomSpace=frameItem.BottomSpace*pixelRatio;
10355
10361
  }
10356
10362
 
10357
10363
  }
@@ -10361,6 +10367,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10361
10367
  if (!option) return;
10362
10368
 
10363
10369
  var frame=subFrame.Frame;
10370
+ var pixelRatio=GetDevicePixelRatio();
10364
10371
 
10365
10372
  if (option.Window)
10366
10373
  {
@@ -10400,6 +10407,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10400
10407
  if (IFrameSplitOperator.IsBool(option.IsShowYLine)) subFrame.Frame.IsShowYLine=option.IsShowYLine;
10401
10408
  if (IFrameSplitOperator.IsBool(option.IsShowIndexTitle)) subFrame.Frame.IsShowIndexTitle=option.IsShowIndexTitle;
10402
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;
10403
10412
 
10404
10413
 
10405
10414
  if (IFrameSplitOperator.IsBool(option.IsShowLeftText))
@@ -13569,6 +13578,8 @@ function AverageWidthFrame()
13569
13578
  this.BeforeDrawXYCallback; //坐标绘制前回调,绘制深度图
13570
13579
  this.GetEventCallback; //事件回调
13571
13580
 
13581
+ this.DivFrameToolbar;
13582
+
13572
13583
  //工具栏的按钮样式
13573
13584
  this.ToolbarButtonStyle=g_JSChartResource.ToolbarButtonStyle;
13574
13585
  this.CloseWindowButton=CloneData(g_JSChartResource.Buttons.CloseWindow);
@@ -13618,6 +13629,8 @@ function AverageWidthFrame()
13618
13629
  this.ButtonTooltip=CloneData(g_JSChartResource.Buttons.Tooltip);
13619
13630
  this.AddIndexWindowButton=CloneData(g_JSChartResource.Buttons.AddIndexWindow);
13620
13631
  }
13632
+
13633
+ if (this.DivFrameToolbar) this.DivFrameToolbar.ReloadResource(resource);
13621
13634
  }
13622
13635
 
13623
13636
  this.DrawFrame=function()
@@ -16187,7 +16200,6 @@ function AverageWidthFrame()
16187
16200
  }
16188
16201
  }
16189
16202
 
16190
-
16191
16203
  if (IFrameSplitOperator.IsNumber(width.Right)) width.Right+=rightExtendWidth;
16192
16204
  if (IFrameSplitOperator.IsNumber(width.Left)) width.Left+=this.YTextPadding[0]+leftExtendLineWidth;
16193
16205
  if (IFrameSplitOperator.IsNumber(width.Right)) width.Right+=this.YTextPadding[1]+rightExtendLineWidth;
@@ -16195,25 +16207,34 @@ function AverageWidthFrame()
16195
16207
  return { TextWidth:width };
16196
16208
  }
16197
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();
16222
+ }
16223
+ }
16224
+
16198
16225
  this.ClearToolbar=function()
16199
16226
  {
16200
- if (!this.ToolbarID) return;
16227
+ if (!this.DivFrameToolbar) return;
16201
16228
 
16202
- var divToolbar=document.getElementById(this.ToolbarID);
16203
- if (!divToolbar) return;
16204
- this.ChartBorder.UIElement.parentNode.removeChild(divToolbar);
16205
- this.ToolbarRect=null;
16229
+ this.DivFrameToolbar.Destroy();
16230
+ this.DivFrameToolbar=null;
16206
16231
  }
16207
16232
 
16208
16233
  this.HideToolbar=function()
16209
16234
  {
16210
- if (!this.ToolbarID) return;
16235
+ if (!this.DivFrameToolbar) return;
16211
16236
 
16212
- this.ToolbarRect=null;
16213
- var divToolbar=document.getElementById(this.ToolbarID);
16214
- if (!divToolbar) return;
16215
-
16216
- if (divToolbar.style.display!='none') divToolbar.style.display='none';
16237
+ this.DivFrameToolbar.Hide();
16217
16238
  }
16218
16239
 
16219
16240
  this.GetMainOverlayFrame=function()
@@ -16251,7 +16272,6 @@ function MinuteFrame()
16251
16272
  this.MultiDayBorderPen=g_JSChartResource.MultiDayBorderPen;
16252
16273
  this.CustomHorizontalInfo=[];
16253
16274
  this.RightFrame=null; //右侧多重坐标
16254
- this.ToolbarID=Guid(); //工具条Div id
16255
16275
  this.ReDrawToolbar=false;
16256
16276
  this.DayCount=1; //显示天数
16257
16277
 
@@ -16264,7 +16284,6 @@ function MinuteFrame()
16264
16284
  this.OverlayIndex=g_JSChartResource.MinuteToolbar.OverlayIndex; //是否显示叠加指标
16265
16285
  this.AddIndexWindow=g_JSChartResource.MinuteToolbar.AddIndexWindow; //是否显示'增加指标窗口'菜单
16266
16286
 
16267
- this.ToolbarRect=null; //保存工具条的位置
16268
16287
  this.IsShowPositionTitle=false; //是否显示持仓标题
16269
16288
 
16270
16289
  this.LastCalculateStatus={ Width:0, XPointCount:0 }; //最后一次计算宽度的状态
@@ -16396,112 +16415,8 @@ function MinuteFrame()
16396
16415
  if (this.ToolbarButtonStyle==1) return;
16397
16416
  if (g_JSChartResource.IsDOMFrameToolbar===true) return;
16398
16417
 
16399
- if (typeof($)=="undefined") return;
16400
-
16401
- if (this.Identify<2) return;
16402
- if (!this.ChartBorder.UIElement) return;
16403
-
16404
- var divToolbar=document.getElementById(this.ToolbarID);
16405
- if (divToolbar && this.SizeChange==false && this.ReDrawToolbar==false) return;
16406
-
16407
- if (!divToolbar)
16408
- {
16409
- divToolbar=document.createElement("div");
16410
- divToolbar.className='klineframe-toolbar';
16411
- divToolbar.id=this.ToolbarID;
16412
- divToolbar.oncontextmenu = function() { return false;}; //屏蔽右键系统菜单
16413
- //为divToolbar添加属性identify
16414
- divToolbar.setAttribute("identify",this.Identify.toString());
16415
- this.ChartBorder.UIElement.parentNode.appendChild(divToolbar);
16416
- }
16417
-
16418
- if (!this.ModifyIndex && !this.ChangeIndex && !this.OverlayIndex && !this.CloseIndex)
16419
- {
16420
- if (divToolbar.style.display!='none')
16421
- divToolbar.style.display='none';
16422
- return;
16423
- }
16424
-
16425
- //使用外城div尺寸 画图尺寸是被放大的
16426
- var pixelTatio = GetDevicePixelRatio();
16427
- var chartWidth=parseInt(this.ChartBorder.UIElement.parentElement.style.width.replace("px",""));
16428
- var chartHeight=parseInt(this.ChartBorder.UIElement.parentElement.style.height.replace("px",""));
16429
- //JSConsole.Chart.Log('[KLineFrame::DrawToolbar] ',chartWidth,chartHeight,pixelTatio);
16430
-
16431
- var toolbarWidth=100;
16432
- var toolbarHeight=this.ChartBorder.GetTitleHeight();
16433
- var left=chartWidth-(this.ChartBorder.Right/pixelTatio)-toolbarWidth;
16434
- var top=this.ChartBorder.GetTop()/pixelTatio;
16435
-
16436
- if (this.ToolbarRect)
16437
- {
16438
- //尺寸变动移动才重新设置DOM
16439
- if (this.ToolbarRect.Left==left && this.ToolbarRect.Top==top &&
16440
- this.ToolbarRect.Width==toolbarWidth && this.ToolbarRect.Height==toolbarHeight/pixelTatio)
16441
- {
16442
- return;
16443
- }
16444
- }
16445
-
16446
- this.ToolbarRect={ Left:left, Top:top, Width:toolbarWidth, Height:toolbarHeight/pixelTatio };
16447
-
16448
- const modifyButton=`<span class='index_param icon iconfont icon-index_param' id='modifyindex' style='cursor:pointer;margin-left:2px;margin-right:2px;' title='调整指标参数'></span>`;
16449
- const changeButton=`<span class='index_change icon iconfont icon-change_index' id='changeindex' style='cursor:pointer;margin-left:2px;margin-right:2px;' title='切换指标'></span>`;
16450
- const closeButton=`<span class='index_close icon iconfont icon-close' id='closeindex' style='cursor:pointer;margin-left:2px;margin-right:2px;' title='关闭指标窗口'></span>`;
16451
-
16452
- var spanIcon=modifyButton+changeButton;
16453
- if (this.CloseIndex)
16454
- {
16455
- spanIcon+=closeButton;
16456
- }
16457
-
16458
- //var scrollPos=GetScrollPosition();
16459
- //left = left+scrollPos.Left;
16460
- //top = top+scrollPos.Top;
16461
- divToolbar.style.left = left + "px";
16462
- divToolbar.style.top = top + "px";
16463
- divToolbar.style.width=toolbarWidth+"px"; //宽度先不调整吧
16464
- divToolbar.style.height=(toolbarHeight/pixelTatio)+'px'; //只调整高度
16465
- divToolbar.innerHTML=spanIcon;
16466
-
16467
- var chart=this.ChartBorder.UIElement.JSChartContainer;
16468
- var identify=this.Identify;
16469
- if (!this.ModifyIndex) //隐藏'改参数'
16470
- $("#"+divToolbar.id+" .index_param").hide();
16471
- else if (typeof(this.ModifyIndexEvent)=='function') //绑定点击事件
16472
- $("#"+divToolbar.id+" .index_param").click(
16473
- {
16474
- Chart:this.ChartBorder.UIElement.JSChartContainer,
16475
- Identify:this.Identify
16476
- },this.ModifyIndexEvent);
16477
-
16478
- if (!this.ChangeIndex) //隐藏'换指标'
16479
- {
16480
- $("#"+divToolbar.id+" .index_change").hide();
16481
- }
16482
- else if (typeof(this.ChangeIndexEvent)=='function')
16483
- {
16484
- $("#"+divToolbar.id+" .index_change").click(
16485
- {
16486
- Chart:this.ChartBorder.UIElement.JSChartContainer,
16487
- Identify:this.Identify,
16488
- IsOverlay:false
16489
- },this.ChangeIndexEvent);
16490
- }
16491
-
16492
- $("#"+divToolbar.id+" .index_close").click(
16493
- {
16494
- Chart:this.ChartBorder.UIElement.JSChartContainer,
16495
- Identify:this.Identify
16496
- },
16497
- function(event)
16498
- {
16499
- var hqChart=event.data.Chart;
16500
- var id=event.data.Identify;
16501
- hqChart.RemoveIndexWindow(id);
16502
- });
16503
-
16504
- divToolbar.style.display = "block";
16418
+ if (!this.DivFrameToolbar) return;
16419
+ this.DivFrameToolbar.Show(this.Identify);
16505
16420
  }
16506
16421
 
16507
16422
  //手绘,不用DOM,使用DOM太麻烦了
@@ -18683,7 +18598,6 @@ function KLineFrame()
18683
18598
  delete this.newMethod;
18684
18599
 
18685
18600
  this.ClassName='KLineFrame';
18686
- this.ToolbarID=Guid(); //工具条Div id
18687
18601
 
18688
18602
  this.ModifyIndex=g_JSChartResource.KLineToolbar.ModifyIndex; //是否显示'改参数'菜单
18689
18603
  this.ChangeIndex=g_JSChartResource.KLineToolbar.ChangeIndex; //是否显示'换指标'菜单
@@ -18696,7 +18610,6 @@ function KLineFrame()
18696
18610
 
18697
18611
  this.SelBorderColor=g_JSChartResource.SelFrameBorderColor;
18698
18612
 
18699
- this.ToolbarRect=null; //保存工具条的位置
18700
18613
  this.ReDrawToolbar=false;
18701
18614
 
18702
18615
  this.LastCalculateStatus={ Width:0, XPointCount:0 }; //最后一次计算宽度的状态
@@ -18720,6 +18633,11 @@ function KLineFrame()
18720
18633
  {
18721
18634
  if (this.ToolbarButtonStyle==1) return;
18722
18635
  if (g_JSChartResource.IsDOMFrameToolbar===true) return;
18636
+ if (!this.DivFrameToolbar) return;
18637
+
18638
+ this.DivFrameToolbar.Show(this.Identify);
18639
+
18640
+ return;
18723
18641
 
18724
18642
  if (typeof($)=="undefined") return;
18725
18643
 
@@ -53141,6 +53059,10 @@ function KLineCountDownPaint()
53141
53059
  this.CanvasEx.fillStyle=out.BGColor;
53142
53060
  this.CanvasEx.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
53143
53061
  }
53062
+ else
53063
+ {
53064
+ return;
53065
+ }
53144
53066
 
53145
53067
  this.Canvas.textAlign = "left";
53146
53068
  this.Canvas.textBaseline = "bottom";
@@ -77474,6 +77396,12 @@ function JSChartResource()
77474
77396
  Mergin:{ Left:4, Right:4, Top:2, Bottom:3 },
77475
77397
  }
77476
77398
  }
77399
+
77400
+ this.DivFrameToolbar=
77401
+ {
77402
+ Icon:{ Color:"rgb(0,0,0)", HoverColor:"rgb(30,144,255)" },
77403
+ Tooltip:{ BGColor:"rgb(255,255,255)", TextColor:"rgb(71,71,71)", BorderColor:"rgb(0,0,0)" },
77404
+ }
77477
77405
 
77478
77406
  //画图工具
77479
77407
  this.DrawPicture=
@@ -79452,6 +79380,29 @@ function JSChartResource()
79452
79380
  if (style.KLineCountDownPaint) this.SetKLineCountDownPaint(style.KLineCountDownPaint);
79453
79381
 
79454
79382
  if (style.SmallFloatTooltipV2) this.SetSmallFloatTooltipV2(style.SmallFloatTooltipV2);
79383
+
79384
+ if (style.DivFrameToolbar) this.SetDivFrameToolbar(style.DivFrameToolbar);
79385
+ }
79386
+
79387
+ this.SetDivFrameToolbar=function(style)
79388
+ {
79389
+ var dest=this.DivFrameToolbar;
79390
+ if (style.Icon)
79391
+ {
79392
+ var item=style.Icon;
79393
+ var subDest=dest.Icon;
79394
+ if (item.Color) subDest.Color=item.Color;
79395
+ if (item.HoverColor) subDest.HoverColor=item.HoverColor;
79396
+ }
79397
+
79398
+ if (style.Tooltip)
79399
+ {
79400
+ var item=style.Tooltip;
79401
+ var subDest=dest.Tooltip;
79402
+ if (item.TextColor) subDest.TextColor=item.TextColor;
79403
+ if (item.BorderColor) subDest.BorderColor=item.BorderColor;
79404
+ if (item.BGColor) subDest.BGColor=item.BGColor;
79405
+ }
79455
79406
  }
79456
79407
 
79457
79408
  this.SetSmallFloatTooltipV2=function(style)
@@ -82788,6 +82739,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
82788
82739
  frame.RightSpaceCount=this.RightSpaceCount; //右边
82789
82740
  frame.GetEventCallback=(id)=> { return this.GetEventCallback(id); };
82790
82741
  frame.GlobalOption=this.GlobalOption;
82742
+ frame.CreateDivFrameToolbar(this, i, this.UIElement.parentNode);
82791
82743
 
82792
82744
  frame.HorizontalMax=20;
82793
82745
  frame.HorizontalMin=10;
@@ -82888,6 +82840,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
82888
82840
  frame.YSplitOperator.HQChart=this;
82889
82841
  frame.XSplitOperator.Symbol=this.Symbol;
82890
82842
  frame.XSplitOperator.Period=this.Period;
82843
+ frame.CreateDivFrameToolbar(this, id, this.UIElement.parentNode);
82891
82844
 
82892
82845
  //K线数据绑定
82893
82846
  var xPointCouont=this.Frame.SubFrame[0].Frame.XPointCount;
@@ -85478,7 +85431,6 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
85478
85431
  if (bChanged)
85479
85432
  {
85480
85433
  frame.SizeChange=true;
85481
- frame.ToolbarRect=null; //清空工具栏缓存
85482
85434
  frame.DrawToolbar();
85483
85435
  }
85484
85436
  }
@@ -92449,7 +92401,7 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
92449
92401
 
92450
92402
  if (i>=2)
92451
92403
  {
92452
-
92404
+ frame.CreateDivFrameToolbar(this, i, this.UIElement.parentNode);
92453
92405
  }
92454
92406
 
92455
92407
  var DEFAULT_HORIZONTAL=[9,8,7,6,5,4,3,2,1];
@@ -92556,6 +92508,7 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
92556
92508
  frame.XSplitOperator.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
92557
92509
  frame.YSplitOperator.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
92558
92510
  frame.XSplitOperator.Symbol=this.Symbol;
92511
+ frame.CreateDivFrameToolbar(this, id, this.UIElement.parentNode);
92559
92512
 
92560
92513
  if (this.DayCount>1)
92561
92514
  {
@@ -105302,6 +105255,304 @@ Path2DHelper.PtInRect=function(x, y, rect)
105302
105255
  }
105303
105256
 
105304
105257
 
105258
+ ////////////////////////////////////////////////////////////////////////////////////
105259
+ // 指标窗口顶部工具条
105260
+ //
105261
+ //
105262
+ ///////////////////////////////////////////////////////////////////////////////////
105263
+
105264
+
105265
+ function JSDivFrameToolbar()
105266
+ {
105267
+ this.DivToolbar=null;
105268
+ this.DivHQChart=null;
105269
+ this.HQChart=null;
105270
+ this.FrameID=-1; //指标窗口ID
105271
+ this.ID=Guid();
105272
+ this.Left=-1;
105273
+ this.Top=-1;
105274
+
105275
+ this.IconConfig=
105276
+ {
105277
+ Color:g_JSChartResource.DivFrameToolbar.Icon.Color,
105278
+ HoverColor:g_JSChartResource.DivFrameToolbar.Icon.HoverColor
105279
+ }
105280
+
105281
+ this.AryButton=
105282
+ [
105283
+ {
105284
+ ID:JSCHART_BUTTON_ID.MODIFY_INDEX_PARAM, ClassName:"UMyChart_FrameToolbar_Span_Button icon iconfont icon-index_param", Tooltip:{ Text:"修改参数"},
105285
+ Span:null, Div:null, TooltipSpan:null
105286
+ },
105287
+ {
105288
+ ID:JSCHART_BUTTON_ID.CHANGE_INDEX, ClassName:"UMyChart_FrameToolbar_Span_Button icon iconfont icon-change_index", Tooltip:{ Text:"切换指标"},
105289
+ Span:null,Div:null, TooltipSpan:null
105290
+ },
105291
+ {
105292
+ ID:JSCHART_BUTTON_ID.OVERLAY_INDEX, ClassName:"UMyChart_FrameToolbar_Span_Button icon iconfont icon-overlay_index", Tooltip:{ Text:"叠加指标"},
105293
+ Span:null,Div:null, TooltipSpan:null
105294
+ },
105295
+ {
105296
+ ID:JSCHART_BUTTON_ID.CLOSE_INDEX_WINDOW, ClassName:"UMyChart_FrameToolbar_Span_Button icon iconfont icon-close", Tooltip:{ Text:"关闭窗口"},
105297
+ Span:null,Div:null, TooltipSpan:null
105298
+ },
105299
+ ];
105300
+
105301
+ this.SetToolbar=function(aryButton)
105302
+ {
105303
+ //清空原来的按钮
105304
+ for(var i=0; i<this.AryButton.length; i++)
105305
+ {
105306
+ var item=this.AryButton[i];
105307
+ if (item.Div && this.DivToolbar) this.DivToolbar.removeChild(item.Div);
105308
+ item.Div=null;
105309
+ item.Span=null;
105310
+ item.TooltipSpan=null;
105311
+ }
105312
+ this.AryButton=[];
105313
+
105314
+ //重新创建
105315
+ for(var i=0;i<aryButton.length; i++)
105316
+ {
105317
+ var item=aryButton[i];
105318
+ if (!item.ID || !item.ClassName) continue;
105319
+ var newItem={ ID:item.ID, ClassName:item.ClassName, Span:null,Div:null, TooltipSpan:null };
105320
+ if (item.Tooltip && item.Tooltip.Text) newItem.Tooltip={ Text:item.Tooltip.Text };
105321
+
105322
+ this.AryButton.push(newItem);
105323
+
105324
+ if (this.DivToolbar) this.CreateButton(newItem, this.DivToolbar);
105325
+ }
105326
+
105327
+ this.UpdateStyle();
105328
+ }
105329
+
105330
+ this.Destroy=function()
105331
+ {
105332
+ if (this.DivToolbar)
105333
+ {
105334
+ if (this.DivHQChart.removeChild) this.DivHQChart.removeChild(this.DivToolbar);
105335
+ this.DivToolbar=null;
105336
+ }
105337
+
105338
+ this.HQChart=null;
105339
+ this.DivHQChart=null;
105340
+ this.FrameID=-1;
105341
+ }
105342
+
105343
+ this.Create=function()
105344
+ {
105345
+ var divToolbar=document.createElement("div");
105346
+ divToolbar.className='UMyChart_FrameToolbar_Div';
105347
+ divToolbar.id=this.ID;
105348
+ divToolbar.oncontextmenu = function() { return false; }; //屏蔽右键系统菜单
105349
+
105350
+ for(var i=0;i<this.AryButton.length; i++)
105351
+ {
105352
+ var item=this.AryButton[i];
105353
+ if (this.FrameID==0 && item.ID==JSCHART_BUTTON_ID.CLOSE_INDEX_WINDOW) continue; //第一个指标窗口不显示关闭按钮
105354
+ this.CreateButton(item, divToolbar);
105355
+ }
105356
+
105357
+ this.DivHQChart.appendChild(divToolbar);
105358
+
105359
+ this.DivToolbar=divToolbar;
105360
+
105361
+ this.UpdateStyle();
105362
+
105363
+ if (!this.HQChart.JSToolbarTooltip)
105364
+ {
105365
+ this.HQChart.JSToolbarTooltip=new JSToolbarTooltip();
105366
+ this.HQChart.JSToolbarTooltip.DivHQChart=this.DivHQChart;
105367
+ this.HQChart.JSToolbarTooltip.Create();
105368
+ }
105369
+ }
105370
+
105371
+ this.UpdateStyle=function()
105372
+ {
105373
+ if (!this.DivToolbar) return;
105374
+
105375
+ for(var i=0;i<this.AryButton.length; i++)
105376
+ {
105377
+ var item=this.AryButton[i]
105378
+ if (!item.Span) continue;
105379
+ item.Span.style["color"]=this.IconConfig.Color;
105380
+ }
105381
+ }
105382
+
105383
+ this.ReloadResource=function(option)
105384
+ {
105385
+ this.IconConfig.Color=g_JSChartResource.DivFrameToolbar.Icon.Color,
105386
+ this.IconConfig.HoverColor=g_JSChartResource.DivFrameToolbar.Icon.HoverColor;
105387
+
105388
+ this.UpdateStyle();
105389
+ }
105390
+
105391
+ this.CreateButton=function(item, divDom)
105392
+ {
105393
+ var btnDiv=document.createElement("div");
105394
+ btnDiv.className="UMyChart_FrameToolbar_Div_Button";
105395
+ btnDiv.onmouseover=(e)=> { this.OnHoverButton(e, item); }
105396
+ btnDiv.onmouseout=(e)=>{ this.OnLeaveButton(e, item); }
105397
+ item.Div=btnDiv;
105398
+
105399
+ var spanDom=document.createElement("span");
105400
+ spanDom.className=item.ClassName;
105401
+ spanDom.onmousedown=(e)=>{ this.OnClickButton(e, item); };
105402
+ item.Span=spanDom;
105403
+ btnDiv.appendChild(spanDom);
105404
+
105405
+ divDom.appendChild(btnDiv);
105406
+ }
105407
+
105408
+ this.OnClickButton=function(e, item)
105409
+ {
105410
+ if (!this.FrameID<0) return;
105411
+ if (!this.HQChart) return;
105412
+
105413
+ var frame=this.HQChart.Frame.SubFrame[this.FrameID].Frame;
105414
+
105415
+ var button={ ID:item.ID, Frame:frame };
105416
+ this.HQChart.ClickFrameButton(button, e);
105417
+ }
105418
+
105419
+ this.OnHoverButton=function(e, item)
105420
+ {
105421
+ if (!item.Span) return;
105422
+
105423
+ item.Span.style["color"]=this.IconConfig.HoverColor;
105424
+
105425
+ this.ShowTooltip(e, item);
105426
+ }
105427
+
105428
+ this.OnLeaveButton=function(e, item)
105429
+ {
105430
+ if (!item.Span) return;
105431
+ item.Span.style["color"]=this.IconConfig.Color;
105432
+
105433
+ this.HideTooltip();
105434
+ }
105435
+
105436
+ this.Show=function(frameID)
105437
+ {
105438
+ this.FrameID=frameID;
105439
+ if (!this.FrameID<0) return;
105440
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.HQChart.Frame.SubFrame)) return;
105441
+ if (!this.HQChart.Frame.SubFrame[this.FrameID]) return;
105442
+
105443
+ var pixelTatio = GetDevicePixelRatio();
105444
+ var frame=this.HQChart.Frame.SubFrame[this.FrameID].Frame;
105445
+ var border=frame.GetBorder();
105446
+
105447
+ var top=border.Top/pixelTatio;
105448
+ var right=border.RightEx/pixelTatio;
105449
+ var left=right-this.DivToolbar.offsetWidth-2;
105450
+
105451
+ if (this.Top!=top || this.Left!=left)
105452
+ {
105453
+ this.DivToolbar.style.top = top + "px";
105454
+ this.DivToolbar.style.left = left + "px";
105455
+ this.DivToolbar.style.height=frame.ChartBorder.TitleHeight/pixelTatio + "px";
105456
+ this.Top=top;
105457
+ this.Left=left;
105458
+ }
105459
+
105460
+ if (this.DivToolbar.style.visibility!='visible') this.DivToolbar.style.visibility='visible';
105461
+ }
105462
+
105463
+ this.Hide=function()
105464
+ {
105465
+ if (this.DivToolbar) this.DivToolbar.style.visibility="hidden";
105466
+ }
105467
+
105468
+ this.HideTooltip=function()
105469
+ {
105470
+ if (this.HQChart.JSToolbarTooltip) this.HQChart.JSToolbarTooltip.Hide();
105471
+ }
105472
+
105473
+ this.ShowTooltip=function(e, item)
105474
+ {
105475
+ if (!this.HQChart.JSToolbarTooltip) return;
105476
+ if (!item.Div) return;
105477
+
105478
+ var rtButton=item.Div.getBoundingClientRect();
105479
+ var rtHQChart=this.DivHQChart.getBoundingClientRect();
105480
+ var left=rtButton.left-rtHQChart.left;
105481
+ var top=rtButton.bottom-rtHQChart.top+2;
105482
+ this.HQChart.JSToolbarTooltip.Show(top, left, { Text:item.Tooltip.Text });
105483
+ }
105484
+ }
105485
+
105486
+
105487
+ function JSToolbarTooltip()
105488
+ {
105489
+ this.DivTooltip=null;
105490
+ this.DivHQChart=null;
105491
+ this.Text=null;
105492
+ this.Left=-1;
105493
+ this.Top=-1;
105494
+
105495
+ this.BGColor=g_JSChartResource.DivFrameToolbar.Tooltip.BGColor;
105496
+ this.TextColor=g_JSChartResource.DivFrameToolbar.Tooltip.TextColor;
105497
+ this.BorderColor=g_JSChartResource.DivFrameToolbar.Tooltip.BorderColor;
105498
+
105499
+ this.Create=function()
105500
+ {
105501
+ var divDom=document.createElement("div");
105502
+ divDom.className='UMyChart_Toolbar_Tooltip_Div';
105503
+ this.DivHQChart.appendChild(divDom);
105504
+
105505
+ this.DivTooltip=divDom;
105506
+
105507
+ this.UpdateStyle();
105508
+ }
105509
+
105510
+ this.ReloadResource=function(option)
105511
+ {
105512
+ this.BGColor=g_JSChartResource.DivFrameToolbar.Tooltip.BGColor;
105513
+ this.TextColor=g_JSChartResource.DivFrameToolbar.Tooltip.TextColor;
105514
+ this.BorderColor=g_JSChartResource.DivFrameToolbar.Tooltip.BorderColor;
105515
+
105516
+ this.UpdateStyle();
105517
+ }
105518
+
105519
+ this.UpdateStyle=function()
105520
+ {
105521
+ if (!this.DivTooltip) return;
105522
+
105523
+ this.DivTooltip.style["background-color"]=this.BGColor;
105524
+ this.DivTooltip.style["color"]=this.TextColor;
105525
+ this.DivTooltip.style["border"]="1px solid " + this.BorderColor;
105526
+ }
105527
+
105528
+ this.Show=function(top, left, tooltipData)
105529
+ {
105530
+ if (!this.DivTooltip) return;
105531
+
105532
+ if (this.Text!=tooltipData.Text) this.DivTooltip.innerHTML=tooltipData.Text;
105533
+ var right=left+this.DivTooltip.offsetWidth;
105534
+ if ((right+5)>=window.innerWidth) left=left-this.DivTooltip.offsetWidth;
105535
+
105536
+ if (this.Top!=top || this.Left!=left)
105537
+ {
105538
+ this.DivTooltip.style.top = top + "px";
105539
+ this.DivTooltip.style.left = left + "px";
105540
+ this.Top=top;
105541
+ this.Left=left;
105542
+ }
105543
+
105544
+ if (this.DivTooltip.style.visibility!='visible') this.DivTooltip.style.visibility='visible';
105545
+ }
105546
+
105547
+ this.Hide=function()
105548
+ {
105549
+ if (!this.DivTooltip) return;
105550
+
105551
+ if (this.DivTooltip.style["visibility"]!='hidden') this.DivTooltip.style["visibility"]="hidden";
105552
+ }
105553
+ }
105554
+
105555
+
105305
105556
 
105306
105557
 
105307
105558