hqchart 1.1.15011 → 1.1.15018

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.15011",
3
+ "version": "1.1.15018",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -1137,8 +1137,6 @@ function JSFloatTooltip()
1137
1137
  Left:"UMyChart_Tooltip_Float_Text2_Span", //左对齐
1138
1138
  MarginLeft:'UMyChart_Tooltip_Float_Text3_Span',
1139
1139
  Right:"UMyChart_Tooltip_Float_Text_Span",
1140
-
1141
-
1142
1140
  }
1143
1141
 
1144
1142
  this.TitleAlign=
@@ -2353,4 +2351,162 @@ function JSFloatTooltip()
2353
2351
 
2354
2352
  this.UpdateStyle();
2355
2353
  }
2354
+ }
2355
+
2356
+ function JSSmallFloatTooltip()
2357
+ {
2358
+ this.DivDialog=null;
2359
+ this.DivContent=null;
2360
+ this.HQChart=null;
2361
+
2362
+ this.Destroy=function()
2363
+ {
2364
+ if (this.DivDialog)
2365
+ {
2366
+ document.body.removeChild(this.DivDialog);
2367
+ this.DivDialog=null;
2368
+ this.DivContent=null;
2369
+ }
2370
+
2371
+ this.HQChart=null;
2372
+ }
2373
+
2374
+ this.Hide=function()
2375
+ {
2376
+ if (!this.DivDialog) return;
2377
+ if (this.DivDialog.style.visibility!='hidden') this.DivDialog.style.visibility='hidden';
2378
+ }
2379
+
2380
+ this.Create=function()
2381
+ {
2382
+ var divDom=document.createElement("div");
2383
+ divDom.className='UMyChart_Small_Tooltip_Div';
2384
+
2385
+ var divContent=document.createElement("div");
2386
+ divContent.className='UMyChart_Small_Tooltip_Content_Div';
2387
+ divDom.appendChild(divContent);
2388
+
2389
+ document.body.appendChild(divDom);
2390
+
2391
+ this.DivContent=divContent;
2392
+ this.DivDialog=divDom;
2393
+ }
2394
+
2395
+ this.IsShow=function()
2396
+ {
2397
+ if (!this.DivDialog) return false;
2398
+
2399
+ return this.DivDialog.style.visibility==='visible';
2400
+ }
2401
+
2402
+ this.ShowTooltip=function(data)
2403
+ {
2404
+ if (!data.Point) return;
2405
+
2406
+ var x=data.Point.X;
2407
+ var y=data.Point.Y;
2408
+ this.Show(x, y, { YMove:data.Point.YMove });
2409
+ }
2410
+
2411
+ this.Show=function(x, y, option)
2412
+ {
2413
+ if (!this.DivDialog) return;
2414
+ if (!this.HQChart) return;
2415
+
2416
+ var rtClient=this.HQChart.UIElement.getBoundingClientRect();
2417
+ var yMove=0;
2418
+ if (option && IFrameSplitOperator.IsNumber(option.YMove)) yMove=option.YMove;
2419
+
2420
+ var left=x+rtClient.left,top=y+rtClient.top+yMove;
2421
+ var right=left+this.DivDialog.offsetWidth;
2422
+ var bottom=top+this.DivDialog.offsetHeight;
2423
+
2424
+ if ((right+5)>=window.innerWidth) left=left-this.DivDialog.offsetWidth;
2425
+ if ((bottom+5)>=window.innerHeight)
2426
+ {
2427
+ top=(y+rtClient.top)-this.DivDialog.offsetHeight;
2428
+ }
2429
+
2430
+ this.DivDialog.style.top = top + "px";
2431
+ this.DivDialog.style.left = left + "px";
2432
+
2433
+ if (this.DivDialog.style.visibility!='visible')
2434
+ this.DivDialog.style.visibility='visible';
2435
+ }
2436
+
2437
+ this.Update=function(data)
2438
+ {
2439
+ var text=data.Data.Data.Text;
2440
+ if (!this.DivContent) return false;
2441
+
2442
+ this.DivContent.innerText=text;
2443
+
2444
+ this.ShowTooltip(data);
2445
+ }
2446
+ }
2447
+
2448
+ function JSSmallFloatTooltipGroup()
2449
+ {
2450
+ this.AryTooltip=[];
2451
+ this.HQChart=null;
2452
+ this.MaxCount=5;
2453
+
2454
+ this.Inital=function(hqchart, option)
2455
+ {
2456
+ this.HQChart=hqchart;
2457
+ }
2458
+
2459
+ this.Create=function()
2460
+ {
2461
+ for(var i=0;i<this.MaxCount;++i)
2462
+ {
2463
+ var item=new JSSmallFloatTooltip();
2464
+ item.HQChart=this.HQChart;
2465
+ item.Create();
2466
+ this.AryTooltip.push(item);
2467
+ }
2468
+ }
2469
+
2470
+ this.Destroy=function()
2471
+ {
2472
+ for(var i=0;i<this.AryTooltip.length;++i)
2473
+ {
2474
+ var item=this.AryTooltip[i];
2475
+ item.Destroy();
2476
+ }
2477
+
2478
+ this.AryTooltip=[];
2479
+ }
2480
+
2481
+ this.Update=function(data)
2482
+ {
2483
+ var tooltipData=data.Tooltip;
2484
+ var pixelTatio = GetDevicePixelRatio();
2485
+ if (pixelTatio===0) pixelTatio=1;
2486
+ for(var i=0; i<tooltipData.AryData.length && i<this.AryTooltip.length; ++i)
2487
+ {
2488
+ var item=tooltipData.AryData[i];
2489
+ var tooltipItem=this.AryTooltip[i];
2490
+
2491
+ //去掉分辨率倍数
2492
+ var x=tooltipData.X/pixelTatio;
2493
+ var y=item.Y/pixelTatio;
2494
+ tooltipItem.Update({ Data:item, Point:{ X:x, Y:y} });
2495
+ }
2496
+
2497
+ for(var i=tooltipData.AryData.length; i<this.AryTooltip.length; ++i)
2498
+ {
2499
+ var item=this.AryTooltip[i];
2500
+ item.Hide();
2501
+ }
2502
+ }
2503
+
2504
+ this.Hide=function()
2505
+ {
2506
+ for(var i=0;i<this.AryTooltip.length;++i)
2507
+ {
2508
+ var item=this.AryTooltip[i];
2509
+ item.Hide();
2510
+ }
2511
+ }
2356
2512
  }
@@ -9309,6 +9309,55 @@ function JSDraw(errorHandler,symbolData)
9309
9309
  this.ErrorHandler=errorHandler;
9310
9310
  this.SymbolData=symbolData;
9311
9311
 
9312
+ //绘制随光标移动的浮动文字。
9313
+ //用法: DRAWFLAGTEXT(COND,PRICE,TEXT),光标处当COND条件满足时,在PRICE位置用半透明窗口显示文字TEXT,随光标移动而移动。将\\n插入TEXT内容中可实现文字换行。
9314
+ //例如:DRAWFLAGTEXT(CLOSE/OPEN>1.08,LOW,'大阳线')表示当光标移动到涨幅大于8%的地方,在最低价位置显示'大阳线'字样的浮动窗口。
9315
+ this.DRAWFLAGTEXT=function(condition,price,text)
9316
+ {
9317
+ var drawData=[];
9318
+ var result={ DrawData:drawData, DrawType:'DRAWFLAGTEXT' };
9319
+ if (!text) return result;
9320
+
9321
+ if (Array.isArray(condition))
9322
+ {
9323
+ if (condition.length<=0) return result;
9324
+
9325
+ var bSinglePrice=IFrameSplitOperator.IsNumber(price);
9326
+ for(var i=0; i<condition.length; ++i)
9327
+ {
9328
+ drawData[i]=null;
9329
+
9330
+ if (isNaN(condition[i]) || !condition[i]) continue;
9331
+
9332
+ if (bSinglePrice)
9333
+ {
9334
+ drawData[i]={ YValue:price, Text:text };
9335
+ }
9336
+ else
9337
+ {
9338
+ if (IFrameSplitOperator.IsNumber(price[i])) drawData[i]={ YValue:price[i], Text:text };
9339
+ }
9340
+ }
9341
+ }
9342
+ else if (IFrameSplitOperator.IsPlusNumber(condition))
9343
+ {
9344
+ var bSinglePrice=IFrameSplitOperator.IsNumber(price);
9345
+ for(var i=0;i<this.SymbolData.Data.Data.length;++i)
9346
+ {
9347
+ if (bSinglePrice)
9348
+ {
9349
+ drawData[i]={ YValue:price, Text:text };
9350
+ }
9351
+ else
9352
+ {
9353
+ if (IFrameSplitOperator.IsNumber(price[i])) drawData[i]={ YValue:price[i], Text:text };
9354
+ }
9355
+ }
9356
+ }
9357
+
9358
+ return result;
9359
+ }
9360
+
9312
9361
  this.DRAWTEXT=function(condition,price,text)
9313
9362
  {
9314
9363
  let drawData=[];
@@ -11689,6 +11738,7 @@ JSDraw.prototype.IsDrawFunction=function(name)
11689
11738
  "VERTLINE","HORLINE","TIPICON",
11690
11739
  "BUY","SELL","SELLSHORT","BUYSHORT",
11691
11740
  "DRAWLASTBARICON","DRAWLASTBARNUMBER", "DRAWLASTBARTEXT","DRAWTABLE","DRAWPIE","DRAWRADAR","DRAWDOUGHNUT",
11741
+ "DRAWFLAGTEXT"
11692
11742
  ]);
11693
11743
  if (setFunctionName.has(name)) return true;
11694
11744
 
@@ -18254,6 +18304,10 @@ function JSExecute(ast,option)
18254
18304
  node.Draw=this.Draw.DRAWTEXT_FIX(args[0],args[1],args[2],args[3],args[4]);
18255
18305
  node.Out=[];
18256
18306
  break;
18307
+ case "DRAWFLAGTEXT":
18308
+ node.Draw=this.Draw.DRAWFLAGTEXT(args[0],args[1],args[2]);
18309
+ node.Out=[];
18310
+ break;
18257
18311
  case 'SUPERDRAWTEXT':
18258
18312
  node.Draw=this.Draw.SUPERDRAWTEXT(args[0],args[1],args[2],args[3],args[4]);
18259
18313
  node.Out=[];
@@ -21079,6 +21133,22 @@ function ScriptIndex(name,script,args,option)
21079
21133
  hqChart.ChartPaint.push(chartText);
21080
21134
  }
21081
21135
 
21136
+ this.CreateDrawFlagText=function(hqChart,windowIndex,varItem,id)
21137
+ {
21138
+ var chart=new ChartDrawFlagText();
21139
+ chart.Canvas=hqChart.Canvas;
21140
+ chart.Name=varItem.Name;
21141
+ chart.ChartBorder=hqChart.Frame.SubFrame[windowIndex].Frame.ChartBorder;
21142
+ chart.ChartFrame=hqChart.Frame.SubFrame[windowIndex].Frame;
21143
+ if (chart.ReloadResource) chart.ReloadResource();
21144
+
21145
+ chart.Data=hqChart.GetKData();
21146
+ if (varItem.Draw.DrawData) chart.AryData=varItem.Draw.DrawData;
21147
+ chart.BuildCacheData();
21148
+
21149
+ hqChart.ChartPaint.push(chart);
21150
+ }
21151
+
21082
21152
  //COLORSTICK
21083
21153
  this.CreateMACD=function(hqChart,windowIndex,varItem,id)
21084
21154
  {
@@ -22545,6 +22615,9 @@ function ScriptIndex(name,script,args,option)
22545
22615
  case 'DRAWTEXT':
22546
22616
  this.CreateDrawTextV2(hqChart,windowIndex,item,i);
22547
22617
  break;
22618
+ case "DRAWFLAGTEXT":
22619
+ this.CreateDrawFlagText(hqChart,windowIndex,item,i);
22620
+ break;
22548
22621
  case 'SUPERDRAWTEXT':
22549
22622
  this.CreateText(hqChart,windowIndex,item,i);
22550
22623
  break;
@@ -22966,6 +23039,8 @@ function OverlayScriptIndex(name,script,args,option)
22966
23039
  case 'DRAWTEXT':
22967
23040
  this.CreateDrawTextV2(hqChart,windowIndex,item,i);
22968
23041
  break;
23042
+ case "DRAWFLAGTEXT":
23043
+ this.CreateDrawFlagText(hqChart,windowIndex,item,i);
22969
23044
  case 'SUPERDRAWTEXT':
22970
23045
  this.CreateText(hqChart,windowIndex,item,i);
22971
23046
  break;
@@ -23330,6 +23405,25 @@ function OverlayScriptIndex(name,script,args,option)
23330
23405
  frame.ChartPaint.push(chartText);
23331
23406
  }
23332
23407
 
23408
+ this.CreateDrawFlagText=function(hqChart,windowIndex,varItem,id)
23409
+ {
23410
+ var overlayIndex=this.OverlayIndex;
23411
+ var frame=overlayIndex.Frame;
23412
+ var chart=new ChartDrawFlagText();
23413
+ chart.Canvas=hqChart.Canvas;
23414
+ chart.Name=varItem.Name;
23415
+ chart.ChartBorder=frame.Frame.ChartBorder;
23416
+ chart.ChartFrame=frame.Frame;
23417
+ chart.Identify=overlayIndex.Identify;
23418
+ if (chart.ReloadResource) chart.ReloadResource();
23419
+
23420
+ chart.Data=hqChart.GetKData();
23421
+ if (varItem.Draw.DrawData) chart.AryData=varItem.Draw.DrawData;
23422
+ chart.BuildCacheData();
23423
+
23424
+ frame.ChartPaint.push(chart);
23425
+ }
23426
+
23333
23427
  //创建文本
23334
23428
  this.CreateText=function(hqChart,windowIndex,varItem,id, drawName)
23335
23429
  {