hqchart 1.1.14660 → 1.1.14663

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.14660",
3
+ "version": "1.1.14663",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -3026,6 +3026,89 @@ function ChartTReport()
3026
3026
  return null;
3027
3027
  }
3028
3028
 
3029
+ //获取一行位置 option={ Symbol:, RowIndex:}
3030
+ this.GetRowRect=function(option)
3031
+ {
3032
+ if (!this.Data) return null;
3033
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return null;
3034
+
3035
+ var symbol=null;
3036
+ var rowIndex=null;
3037
+ if (option)
3038
+ {
3039
+ if (option.Symbol) symbol=option.Symbol;
3040
+ if (IFrameSplitOperator.IsNumber(option.RowIndex)) rowIndex=option.RowIndex;
3041
+ }
3042
+ var top=this.RectClient.Top+this.HeaderHeight;
3043
+ var left=this.RectClient.Left;
3044
+ var right=this.RectClient.Right;
3045
+
3046
+ var textTop=top+this.FixedRowHeight*this.FixedRowCount;
3047
+ for(var i=this.Data.YOffset, j=0; i<this.Data.Data.length && j<this.RowCount ;++i, ++j, textTop+=this.RowHeight)
3048
+ {
3049
+ var exePrice=this.Data.Data[i];
3050
+ var rtRow={ Left:left, Top:textTop, Right:right, Bottom: textTop+this.RowHeight };
3051
+ rtRow.Height=rtRow.Bottom-rtRow.Top;
3052
+ rtRow.Width=rtRow.Right-rtRow.Left;
3053
+
3054
+ var data={ RectRow:rtRow, DataIndex:i, Index:j, ExePrice:exePrice };
3055
+ var item=this.GetExePriceDataCallback(exePrice);
3056
+ if (!item) continue;
3057
+
3058
+ var bLeftFind=false, bRightFind=false;
3059
+ if (symbol)
3060
+ {
3061
+ if (item.LeftData && item.LeftData.Symbol && item.LeftData.Symbol==symbol) bLeftFind=true;
3062
+ if (item.RightData && item.RightData.Symbol && item.RightData.Symbol==symbol) bRightFind=true;
3063
+ }
3064
+ else if (IFrameSplitOperator.IsNumber(rowIndex))
3065
+ {
3066
+ if (rowIndex==i)
3067
+ {
3068
+ bLeftFind=true;
3069
+ bRightFind=true;
3070
+ }
3071
+ }
3072
+
3073
+ if (bLeftFind || bRightFind)
3074
+ {
3075
+ data.Item=item;
3076
+ data.AryLeftRect=[];
3077
+ data.AryRightRect=[];
3078
+ data.ElementRect=this.UIElement.getBoundingClientRect();
3079
+ data.PixelRatio=GetDevicePixelRatio();
3080
+
3081
+ var rtCenterItem=this.GetCenterItemRect();
3082
+ var rtCenter={Left:rtCenterItem.Left, Right:rtCenterItem.Right, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom };
3083
+
3084
+ var xLeft=rtCenterItem.Left; //左边
3085
+ var xRight=rtCenterItem.Right; //右边
3086
+
3087
+ var reportleft=this.RectClient.Left;
3088
+ var reportRight=this.RectClient.Right;
3089
+ for(var k=this.Data.XOffset;k<this.Column.length;++k)
3090
+ {
3091
+ var colItem=this.Column[k];
3092
+ var itemWidth=colItem.Width+this.ItemExtraWidth;
3093
+ xLeft-=itemWidth;
3094
+ if (xLeft<reportleft) break;
3095
+
3096
+ var rtItem={ Left:xLeft, Right:xLeft+itemWidth, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom, Width:itemWidth };
3097
+ data.AryLeftRect.push({ Rect:rtItem, ColumnIndex:k, Column:colItem })
3098
+
3099
+ rtItem={ Left:xRight, Right:xRight+itemWidth, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom, Width:itemWidth };
3100
+ data.AryRightRect.push({ Rect:rtItem, ColumnIndex:k, Column:colItem });
3101
+
3102
+ xRight+=itemWidth;
3103
+ }
3104
+
3105
+ return data;
3106
+ }
3107
+ }
3108
+
3109
+ return null;
3110
+ }
3111
+
3029
3112
  this.PtInBody=function(x,y)
3030
3113
  {
3031
3114
  if (!this.Data) return null;
@@ -588,6 +588,7 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
588
588
  }
589
589
 
590
590
  if (IFrameSplitOperator.IsBool(item.EnablePrediction)) klineChart.PredictionConfig.Enable=item.EnablePrediction;
591
+ if (IFrameSplitOperator.IsBool(item.EnableDaySummary)) klineChart.DaySummary.Enable=item.EnableDaySummary;
591
592
  }
592
593
 
593
594
  if(option.KLineTitle)
@@ -2925,6 +2926,7 @@ var JSCHART_MENU_ID=
2925
2926
 
2926
2927
  CMD_FULLSCREEN_SUMMARY_ID:56, //当前屏区间统计
2927
2928
  CMD_CORSS_DBCLICK_ID:57, //双击显示隐藏十字光标
2929
+ CMD_ENABLE_KLINE_DAY_SUMMARY_ID:58, //K线底部显示走完剩余时间
2928
2930
 
2929
2931
 
2930
2932
 
@@ -10898,6 +10900,13 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10898
10900
  case JSCHART_MENU_ID.CMD_FULLSCREEN_SUMMARY_ID:
10899
10901
  this.FullScreenSummary();
10900
10902
  break;
10903
+ case JSCHART_MENU_ID.CMD_ENABLE_KLINE_DAY_SUMMARY_ID:
10904
+ if (IFrameSplitOperator.IsBool(srcParam))
10905
+ {
10906
+ this.ChartPaint[0].DaySummary.Enable=srcParam;
10907
+ this.Draw();
10908
+ }
10909
+ break;
10901
10910
  }
10902
10911
  }
10903
10912
 
@@ -11607,6 +11616,20 @@ function IsRectOverlap(rt, rt2)
11607
11616
  return false;
11608
11617
  }
11609
11618
 
11619
+ //获取文字高度和宽度
11620
+ function GetTextSize(canvas, text, option)
11621
+ {
11622
+ var data=canvas.measureText(text);
11623
+ var height=Math.abs(Math.abs(data.fontBoundingBoxAscent)+Math.abs(data.fontBoundingBoxDescent));
11624
+ var textBaseline=canvas.textBaseline;
11625
+
11626
+ if (textBaseline=="top") height=data.fontBoundingBoxDescent;
11627
+ else if (textBaseline=="bottom") height=data.fontBoundingBoxAscent;
11628
+
11629
+ var result={ Width:data.width, Height:height};
11630
+ return result;
11631
+ }
11632
+
11610
11633
  Number.prototype.toFixed2=Number.prototype.toFixed; //备份下老的
11611
11634
  Number.prototype.toFixed = function( precision )
11612
11635
  {
@@ -26565,6 +26588,31 @@ function ChartKLine()
26565
26588
  //面积图和收盘价线 断开点
26566
26589
  this.AryBreakPoint;
26567
26590
 
26591
+ //天数统计
26592
+ this.DaySummary={ MapDate:new Map(), Enable:false };
26593
+ this.DaySummaryConfig=
26594
+ {
26595
+ Font: g_JSChartResource.DaySummaryKLine.Font,
26596
+ TextColor: g_JSChartResource.DaySummaryKLine.TextColor
26597
+ }
26598
+
26599
+ this.AddToDaySummary=function(kItem)
26600
+ {
26601
+ if (!this.DaySummary.Enable) return false;
26602
+
26603
+ if (!kItem) return false;
26604
+ if (!IFrameSplitOperator.IsPlusNumber(kItem.Date)) return false;
26605
+
26606
+ if (this.DaySummary.MapDate.has(kItem.Date)) return false;
26607
+
26608
+ this.DaySummary.MapDate.set(kItem.Date, { Date:kItem.Date });
26609
+ }
26610
+
26611
+ this.ClearDaySummary=function()
26612
+ {
26613
+ this.DaySummary.MapDate.clear();
26614
+ }
26615
+
26568
26616
  this.BuildDateTimeKey=function(item)
26569
26617
  {
26570
26618
  if (!item) return null;
@@ -26622,6 +26670,13 @@ function ChartKLine()
26622
26670
  UnchangeColor:g_JSChartResource.PredictionKLine.Bar.UnchangeColor,
26623
26671
  DrawType:g_JSChartResource.PredictionKLine.Bar.DrawType
26624
26672
  };
26673
+
26674
+
26675
+ this.DaySummaryConfig=
26676
+ {
26677
+ Font: g_JSChartResource.DaySummaryKLine.Font,
26678
+ TextColor: g_JSChartResource.DaySummaryKLine.TextColor
26679
+ }
26625
26680
 
26626
26681
  }
26627
26682
 
@@ -27254,6 +27309,8 @@ function ChartKLine()
27254
27309
  this.ShowRange.End=i;
27255
27310
  if (!data || data.Open==null || data.High==null || data.Low==null || data.Close==null) continue;
27256
27311
 
27312
+ this.AddToDaySummary(data);
27313
+
27257
27314
  var left=xOffset;
27258
27315
  var right=xOffset+dataWidth;
27259
27316
  if (right>chartright) break;
@@ -29139,6 +29196,7 @@ function ChartKLine()
29139
29196
  if (this.IsShowIndexTitleOnly()) return;
29140
29197
  if (this.IsHideScriptIndex()) return;
29141
29198
 
29199
+ this.ClearDaySummary();
29142
29200
  this.IsShowOrderText=false;
29143
29201
  this.TooltipRect=[];
29144
29202
  this.InfoTooltipRect=[];
@@ -29277,6 +29335,8 @@ function ChartKLine()
29277
29335
  this.FFKChart.DrawMaxMinPrice();
29278
29336
  }
29279
29337
  }
29338
+
29339
+ this.DrawDaySummary();
29280
29340
  }
29281
29341
 
29282
29342
  this.OnFormatHighLowTitle=function(ptMax, ptMin)
@@ -29347,8 +29407,33 @@ function ChartKLine()
29347
29407
  else text=text+rightArrow;
29348
29408
  if (ptTop.Y>(top-2))
29349
29409
  {
29410
+ var textSize=GetTextSize(this.Canvas,text);
29411
+ var textWidth=textSize.Width;
29412
+ var textHeight=textSize.Height;
29413
+ if (this.ChartFrame.CoordinateType==1) //反转坐标
29414
+ {
29415
+ var rtText={ Width:textWidth, Height:textHeight, Top:ptTop.Y };
29416
+ rtText.Bottom=rtText.Top+rtText.Height;
29417
+ }
29418
+ else
29419
+ {
29420
+ var rtText={ Width:textWidth, Height:textHeight, Bottom:ptTop.Y };
29421
+ rtText.Top=rtText.Bottom-rtText.Height;
29422
+ }
29423
+
29424
+ if (ptTop.Align=="left")
29425
+ {
29426
+ rtText.Left=left;
29427
+ rtText.Right=rtText.Left+rtText.Width;
29428
+ }
29429
+ else
29430
+ {
29431
+ rtText.Right=left;
29432
+ rtText.Left=rtText.Right-rtText.Width;
29433
+ }
29434
+
29350
29435
  this.Canvas.fillText(text,left,ptTop.Y);
29351
- this.ChartFrame.ChartKLine.Max={X:left, Y:ptTop.Y, Text: { BaseLine:'bottom'}};
29436
+ this.ChartFrame.ChartKLine.Max={X:left, Y:ptTop.Y, Text: { BaseLine:'bottom'}, Rect:rtText };
29352
29437
  }
29353
29438
 
29354
29439
  var ptBottom=ptMin;
@@ -29377,8 +29462,33 @@ function ChartKLine()
29377
29462
  else text=text+rightArrow;
29378
29463
  if (ptBottom.Y<(bottom+1))
29379
29464
  {
29465
+ var textSize=GetTextSize(this.Canvas,text);
29466
+ var textWidth=textSize.Width;
29467
+ var textHeight=textSize.Height;
29468
+ if (this.ChartFrame.CoordinateType==1) //反转坐标
29469
+ {
29470
+ var rtText={ Width:textWidth, Height:textHeight, Bottom:ptBottom.Y };
29471
+ rtText.Top=rtText.Bottom-rtText.Height;
29472
+ }
29473
+ else
29474
+ {
29475
+ var rtText={ Width:textWidth, Height:textHeight, Top:ptBottom.Y };
29476
+ rtText.Bottom=rtText.Top+rtText.Height;
29477
+ }
29478
+
29479
+ if (ptBottom.Align=="left")
29480
+ {
29481
+ rtText.Left=left;
29482
+ rtText.Right=rtText.Left+rtText.Width;
29483
+ }
29484
+ else
29485
+ {
29486
+ rtText.Right=left;
29487
+ rtText.Left=rtText.Right-rtText.Width;
29488
+ }
29489
+
29380
29490
  this.Canvas.fillText(text,left,ptBottom.Y);
29381
- this.ChartFrame.ChartKLine.Min={X:left, Y:ptBottom.Y, Text:{ BaseLine:'top'}};
29491
+ this.ChartFrame.ChartKLine.Min={X:left, Y:ptBottom.Y, Text:{ BaseLine:'top'}, Rect:rtText };
29382
29492
  }
29383
29493
  }
29384
29494
 
@@ -31465,7 +31575,99 @@ function ChartKLine()
31465
31575
  }
31466
31576
  }
31467
31577
  }
31468
-
31578
+
31579
+ this.GetDaySummaryText=function()
31580
+ {
31581
+ var count=this.DaySummary.MapDate.size;
31582
+ if (count<=0) return null;
31583
+ if (!this.HQChart) return null;
31584
+
31585
+ var text;
31586
+ if (ChartData.IsMinutePeriod(this.Data.Period,true))
31587
+ {
31588
+ text=`${count}${g_JSChartLocalization.GetText('天',this.HQChart.LanguageID)}`;
31589
+ return text;
31590
+ }
31591
+
31592
+ if (ChartData.IsDayPeriod(this.Data.Period,true))
31593
+ {
31594
+ switch(this.Data.Period)
31595
+ {
31596
+ case 0:
31597
+ text=`${count}${g_JSChartLocalization.GetText('天',this.HQChart.LanguageID)}`;
31598
+ break;
31599
+ case 1:
31600
+ text=`${count}${g_JSChartLocalization.GetText('周',this.HQChart.LanguageID)}`;
31601
+ break;
31602
+ case 2:
31603
+ text=`${count}${g_JSChartLocalization.GetText('月',this.HQChart.LanguageID)}`;
31604
+ break;
31605
+ case 4:
31606
+ text=`${count}${g_JSChartLocalization.GetText('年',this.HQChart.LanguageID)}`;
31607
+ break;
31608
+ default:
31609
+ return null;
31610
+ }
31611
+
31612
+ return text;
31613
+ }
31614
+
31615
+ return null;
31616
+ }
31617
+
31618
+ this.DrawDaySummary=function()
31619
+ {
31620
+ if (!this.DaySummary.Enable) return;
31621
+ if (this.ChartFrame.IsHScreen===true) return;
31622
+
31623
+ var text=this.GetDaySummaryText();
31624
+ if (!text) return;
31625
+
31626
+ this.Canvas.font=this.DaySummaryConfig.Font;
31627
+
31628
+ this.Canvas.textAlign = 'left';
31629
+ this.Canvas.textBaseline = 'bottom';
31630
+
31631
+ var border=this.ChartBorder.GetBorder();
31632
+ var xText=border.Left+1;
31633
+ var yText=border.Bottom;
31634
+
31635
+ var textSize=GetTextSize(this.Canvas,text);
31636
+ var textWidth=textSize.Width;
31637
+ var textHeight=textSize.Height;
31638
+
31639
+ var rtText={ Left:xText, Bottom:yText, Width:textWidth, Height:textHeight };
31640
+ rtText.Right=rtText.Left+rtText.Width;
31641
+ rtText.Top=rtText.Bottom-rtText.Height;
31642
+
31643
+ if (this.ChartFrame.ChartKLine.Max && this.ChartFrame.ChartKLine.Max.Rect)
31644
+ {
31645
+ var rtMax=this.ChartFrame.ChartKLine.Max.Rect;
31646
+ if (IsRectOverlap(rtText,rtMax))
31647
+ {
31648
+ rtText.Left=rtMax.Right+2;
31649
+ rtText.Right=rtText.Left+rtText.Width;
31650
+ }
31651
+ }
31652
+
31653
+ if (this.ChartFrame.ChartKLine.Min && this.ChartFrame.ChartKLine.Min.Rect)
31654
+ {
31655
+ var rtMin=this.ChartFrame.ChartKLine.Min.Rect;
31656
+ if (IsRectOverlap(rtText,rtMin))
31657
+ {
31658
+ rtText.Left=rtMin.Right+2;
31659
+ rtText.Right=rtText.Left+rtText.Width;
31660
+ }
31661
+ }
31662
+
31663
+ //this.Canvas.fillStyle="rgb(100,0,100)";
31664
+ //this.Canvas.fillRect(rtText.Left,rtText.Top,rtText.Width,rtText.Height);
31665
+
31666
+ this.Canvas.fillStyle=this.DaySummaryConfig.TextColor;
31667
+ this.Canvas.fillText(text,rtText.Left,rtText.Bottom);
31668
+
31669
+ this.ClearDaySummary();
31670
+ }
31469
31671
  }
31470
31672
 
31471
31673
  function ChartColorKline()
@@ -73549,6 +73751,12 @@ function JSChartResource()
73549
73751
  Text:{ Color:"rgb(105,105,105)", Font:`${12*GetDevicePixelRatio()}px 微软雅黑`}
73550
73752
  };
73551
73753
 
73754
+ this.DaySummaryKLine=
73755
+ {
73756
+ Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
73757
+ TextColor:"rgb(105,105,105)"
73758
+ }
73759
+
73552
73760
  //订单流配置
73553
73761
  this.OrderFlow=
73554
73762
  {
@@ -75000,6 +75208,14 @@ function JSChartResource()
75000
75208
  }
75001
75209
  }
75002
75210
 
75211
+ if (style.DaySummaryKLine)
75212
+ {
75213
+ var item=style.DaySummaryKLine;
75214
+ var dest=this.DaySummaryKLine;
75215
+ if (item.Font) dest.Font=item.Font;
75216
+ if (item.TextColor) dest.TextColor=item.TextColor;
75217
+ }
75218
+
75003
75219
  if (style.Index)
75004
75220
  {
75005
75221
  if (style.Index.LineColor) this.Index.LineColor = style.Index.LineColor;
@@ -76547,7 +76763,14 @@ function JSChartLocalization()
76547
76763
 
76548
76764
  //日盘|夜盘
76549
76765
  ["日盘",{CN:'日盘', EN:'Day', TC:'日盤'}],
76550
- ["夜盘",{CN:'夜盘', EN:'Night', TC:'夜盤'} ]
76766
+ ["夜盘",{CN:'夜盘', EN:'Night', TC:'夜盤'} ],
76767
+
76768
+
76769
+ ["天", {CN:'天', EN:'Day', TC:'天'} ],
76770
+ ["周", {CN:'周', EN:'Week', TC:'周'} ],
76771
+ ["月", {CN:'月', EN:'Month', TC:'月'} ],
76772
+ ["年", {CN:'年', EN:'Year', TC:'年'} ],
76773
+
76551
76774
  ]);
76552
76775
 
76553
76776
  this.GetText=function(key,language)
@@ -78732,6 +78955,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
78732
78955
  kline.Name="Main-KLine";
78733
78956
  kline.DrawType=this.KLineDrawType;
78734
78957
  kline.Identify="Main-KLine";
78958
+ kline.HQChart=this;
78735
78959
  kline.GetEventCallback=(id)=>{ return this.GetEventCallback(id); };
78736
78960
 
78737
78961
  this.ChartPaint[0]=kline;
@@ -83291,6 +83515,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
83291
83515
  var klineType=klineChart.DrawType;
83292
83516
  var bThinAKBar=klineChart.IsThinAKBar;
83293
83517
  var priceGap=klineChart.PriceGap; //缺口配置信息
83518
+ var bDaySummary=klineChart.DaySummary.Enable;
83294
83519
  var infoPosition=klineChart.InfoPosition;
83295
83520
  var coordinateType=null, yCoordinateType=null; //坐标类型
83296
83521
  var mainFrame=null;
@@ -83538,6 +83763,8 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
83538
83763
 
83539
83764
  { Name:"双击弹分时图", Data:{ ID:JSCHART_MENU_ID.CMD_ENABLE_POP_MINUTE_CHART_ID, Args:[!bPopMinuteChart]}, Checked:bPopMinuteChart},
83540
83765
 
83766
+ { Name:"显示走完剩余时间", Data:{ ID:JSCHART_MENU_ID.CMD_ENABLE_KLINE_DAY_SUMMARY_ID, Args:[!bDaySummary]}, Checked:bDaySummary},
83767
+
83541
83768
  { Name:JSPopMenu.SEPARATOR_LINE_NAME },
83542
83769
  {
83543
83770
  Name:"鼠标形状",
@@ -296,6 +296,13 @@ function GetBlackStyle()
296
296
  Text:{ Color:"rgb(219,220,220)", Font:`${12*GetDevicePixelRatio()}px 微软雅黑` }
297
297
  },
298
298
 
299
+ DaySummaryKLine:
300
+ {
301
+ //Font:`${12*GetDevicePixelRatio()}px 微软雅黑`,
302
+ TextColor:"rgb(255,165,0)"
303
+ },
304
+
305
+
299
306
  //指标锁
300
307
  IndexLock:
301
308
  {