hqchart 1.1.15060 → 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.15060",
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)
@@ -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();
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";
@@ -77477,6 +77396,12 @@ function JSChartResource()
77477
77396
  Mergin:{ Left:4, Right:4, Top:2, Bottom:3 },
77478
77397
  }
77479
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
+ }
77480
77405
 
77481
77406
  //画图工具
77482
77407
  this.DrawPicture=
@@ -79455,6 +79380,29 @@ function JSChartResource()
79455
79380
  if (style.KLineCountDownPaint) this.SetKLineCountDownPaint(style.KLineCountDownPaint);
79456
79381
 
79457
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
+ }
79458
79406
  }
79459
79407
 
79460
79408
  this.SetSmallFloatTooltipV2=function(style)
@@ -82791,6 +82739,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
82791
82739
  frame.RightSpaceCount=this.RightSpaceCount; //右边
82792
82740
  frame.GetEventCallback=(id)=> { return this.GetEventCallback(id); };
82793
82741
  frame.GlobalOption=this.GlobalOption;
82742
+ frame.CreateDivFrameToolbar(this, i, this.UIElement.parentNode);
82794
82743
 
82795
82744
  frame.HorizontalMax=20;
82796
82745
  frame.HorizontalMin=10;
@@ -82891,6 +82840,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
82891
82840
  frame.YSplitOperator.HQChart=this;
82892
82841
  frame.XSplitOperator.Symbol=this.Symbol;
82893
82842
  frame.XSplitOperator.Period=this.Period;
82843
+ frame.CreateDivFrameToolbar(this, id, this.UIElement.parentNode);
82894
82844
 
82895
82845
  //K线数据绑定
82896
82846
  var xPointCouont=this.Frame.SubFrame[0].Frame.XPointCount;
@@ -85481,7 +85431,6 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
85481
85431
  if (bChanged)
85482
85432
  {
85483
85433
  frame.SizeChange=true;
85484
- frame.ToolbarRect=null; //清空工具栏缓存
85485
85434
  frame.DrawToolbar();
85486
85435
  }
85487
85436
  }
@@ -92452,7 +92401,7 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
92452
92401
 
92453
92402
  if (i>=2)
92454
92403
  {
92455
-
92404
+ frame.CreateDivFrameToolbar(this, i, this.UIElement.parentNode);
92456
92405
  }
92457
92406
 
92458
92407
  var DEFAULT_HORIZONTAL=[9,8,7,6,5,4,3,2,1];
@@ -92559,6 +92508,7 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
92559
92508
  frame.XSplitOperator.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
92560
92509
  frame.YSplitOperator.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
92561
92510
  frame.XSplitOperator.Symbol=this.Symbol;
92511
+ frame.CreateDivFrameToolbar(this, id, this.UIElement.parentNode);
92562
92512
 
92563
92513
  if (this.DayCount>1)
92564
92514
  {
@@ -105305,6 +105255,304 @@ Path2DHelper.PtInRect=function(x, y, rect)
105305
105255
  }
105306
105256
 
105307
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
+
105308
105556
 
105309
105557
 
105310
105558