hqchart 1.1.15480 → 1.1.15503

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.
@@ -5851,6 +5851,8 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
5851
5851
  {
5852
5852
  var item=option.Frame[i];
5853
5853
  if (!chart.Frame.SubFrame[i]) continue;
5854
+ chart.SetSubFrameAttribute(chart.Frame.SubFrame[i], null, item);
5855
+ /*
5854
5856
  if (item.SplitCount) chart.Frame.SubFrame[i].Frame.YSplitOperator.SplitCount=item.SplitCount;
5855
5857
  if (item.StringFormat) chart.Frame.SubFrame[i].Frame.YSplitOperator.StringFormat=item.StringFormat;
5856
5858
  if (IFrameSplitOperator.IsNumber(item.FloatPrecision)) chart.Frame.SubFrame[i].Frame.YSplitOperator.FloatPrecision=item.FloatPrecision;
@@ -5860,6 +5862,7 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
5860
5862
 
5861
5863
  if (item.IsShowLeftText==false) chart.Frame.SubFrame[i].Frame.YSplitOperator.IsShowLeftText=item.IsShowLeftText; //显示左边刻度
5862
5864
  if (item.IsShowRightText==false) chart.Frame.SubFrame[i].Frame.YSplitOperator.IsShowRightText=item.IsShowRightText; //显示右边刻度
5865
+ */
5863
5866
  }
5864
5867
  }
5865
5868
 
@@ -5874,9 +5877,13 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
5874
5877
 
5875
5878
  if(option.KLineTitle) //股票名称 日期 周期
5876
5879
  {
5877
- if(option.KLineTitle.IsShowName==false) chart.TitlePaint[0].IsShowName=false;
5878
- if(option.KLineTitle.IsShowSettingInfo==false) chart.TitlePaint[0].IsShowSettingInfo=false;
5879
- if(option.KLineTitle.IsShow == false) chart.TitlePaint[0].IsShow = false;
5880
+ var item=option.KLineTitle;
5881
+ var chartTitle=chart.TitlePaint[0];
5882
+ if (IFrameSplitOperator.IsBool(item.IsShowName)) chartTitle.IsShowName=item.IsShowName;
5883
+ if (IFrameSplitOperator.IsBool(item.IsShowSettingInfo)) chartTitle.IsShowSettingInfo=item.IsShowSettingInfo;
5884
+ if (IFrameSplitOperator.IsBool(item.IsShow)) chartTitle.IsShow=item.IsShow;
5885
+ if (IFrameSplitOperator.IsBool(item.IsShowDateTime)) chartTitle.IsShowDateTime=item.IsShowDateTime;
5886
+ if (IFrameSplitOperator.IsBool(item.IsTitleShowLatestData)) chart.IsTitleShowLatestData=item.IsTitleShowLatestData;
5880
5887
  }
5881
5888
 
5882
5889
  if (IFrameSplitOperator.IsNonEmptyArray(option.Overlay)) //叠加股票
@@ -43622,6 +43629,125 @@ function ChartText()
43622
43629
  }
43623
43630
  }
43624
43631
 
43632
+ function ChartDrawIconV2()
43633
+ {
43634
+ this.newMethod=IChartPainting; //派生
43635
+ this.newMethod();
43636
+ delete this.newMethod;
43637
+
43638
+ this.ClassName="ChartDrawIconV2";
43639
+ this.bHScreen=false; //是否横屏
43640
+ this.Icon=null;
43641
+ this.TextAlign='left';
43642
+ this.Direction=0; //0=middle 1=bottom 2=top
43643
+ this.ShowOffset={ X:0, Y:0 }; //显示偏移
43644
+ this.Size=null;
43645
+
43646
+ this.Draw=function()
43647
+ {
43648
+ if (!this.IsShow || this.ChartFrame.IsMinSize) return;
43649
+ if (this.IsShowIndexTitleOnly()) return;
43650
+ if (this.IsHideScriptIndex()) return;
43651
+
43652
+ if (!this.Data || !this.Data.Data) return;
43653
+ if (!this.Icon) return;
43654
+
43655
+ this.bHScreen=(this.ChartFrame.IsHScreen===true);
43656
+ var xPointCount=this.ChartFrame.XPointCount;
43657
+ var bMinute=this.IsMinuteFrame();
43658
+ var dataWidth=this.ChartFrame.DataWidth;
43659
+ var distanceWidth=this.ChartFrame.DistanceWidth;
43660
+ var xOffset=this.ChartBorder.GetLeft()+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
43661
+ var chartright=this.ChartBorder.GetRight();
43662
+ var top=this.ChartBorder.GetTopEx();
43663
+ var bottom=this.ChartBorder.GetBottomEx();
43664
+
43665
+ if (this.bHScreen)
43666
+ {
43667
+ chartright=this.ChartBorder.GetBottom();
43668
+ top=this.ChartBorder.GetRightEx();
43669
+ bottom=this.ChartBorder.GetLeftEx();
43670
+ xOffset=this.ChartBorder.GetTop()+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
43671
+ }
43672
+
43673
+ var pixelTatio = GetDevicePixelRatio();
43674
+ var iconWidth=this.Icon.Width*pixelTatio;
43675
+ var iconHeight=this.Icon.Height*pixelTatio;
43676
+ if (IFrameSplitOperator.IsNumber(this.Size)) iconWidth=iconHeight=this.Size*pixelTatio;
43677
+
43678
+
43679
+
43680
+ this.Canvas.save();
43681
+ this.ClipClient(this.ChartFrame.IsHScreen);
43682
+
43683
+ for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
43684
+ {
43685
+ var value=this.Data.Data[i];
43686
+ if (value==null) continue;
43687
+
43688
+ if (bMinute)
43689
+ {
43690
+ var x=this.ChartFrame.GetXFromIndex(j);
43691
+ }
43692
+ else
43693
+ {
43694
+ var left=xOffset;
43695
+ var right=xOffset+dataWidth;
43696
+ if (right>chartright) break;
43697
+ var x=left+(right-left)/2;
43698
+ }
43699
+
43700
+ var y=this.ChartFrame.GetYFromData(value,false);
43701
+
43702
+ if (x>chartright) break;
43703
+
43704
+ if (this.TextAlign=="right") x-=iconWidth;
43705
+ else if (this.TextAlign=="center") x-=iconWidth/2;
43706
+
43707
+ if (this.Direction===0) y-=iconHeight/2;
43708
+ else if (this.Direction===1) y-=iconHeight;
43709
+
43710
+
43711
+ y+=this.ShowOffset.Y;
43712
+ x+=this.ShowOffset.X;
43713
+
43714
+ var drawInfo={ X:x, Y:y, Image:this.Icon.Image, Width:iconWidth, Height:iconHeight };
43715
+
43716
+ this.DrawIcon(drawInfo);
43717
+ }
43718
+
43719
+
43720
+
43721
+ this.Canvas.restore();
43722
+
43723
+ }
43724
+
43725
+ this.DrawIcon=function(drawInfo)
43726
+ {
43727
+ if (!drawInfo || !drawInfo.Image) return;
43728
+
43729
+ if (this.bHScreen)
43730
+ {
43731
+ /*
43732
+ var xCenter=drawInfo.X+drawInfo.Width/2;
43733
+ var yCenter=drawInfo.Y+drawInfo.Height/2;
43734
+ this.Canvas.save();
43735
+ this.Canvas.translate(yCenter,xCenter);
43736
+ this.Canvas.rotate(90 * Math.PI / 180);
43737
+ this.Canvas.drawImage(drawInfo.Image, 0, 0, drawInfo.Width, drawInfo.Height);
43738
+ this.Canvas.restore();
43739
+ */
43740
+
43741
+ this.Canvas.drawImage(drawInfo.Image, drawInfo.Y, drawInfo.X, drawInfo.Width, drawInfo.Height);
43742
+ }
43743
+ else
43744
+ {
43745
+ this.Canvas.drawImage(drawInfo.Image, drawInfo.X, drawInfo.Y, drawInfo.Width, drawInfo.Height);
43746
+ }
43747
+ }
43748
+ }
43749
+
43750
+
43625
43751
  /*
43626
43752
  文字输出 支持横屏
43627
43753
  数组(Data)不为null的数据中输出 this.Text文本
@@ -107146,6 +107272,26 @@ var MARKET_SUFFIX_NAME=
107146
107272
  return false;
107147
107273
  },
107148
107274
 
107275
+ IsCFFEXOption:function(upperSymbol) //中金所股票期权
107276
+ {
107277
+ if (!upperSymbol) return false;
107278
+ if (!this.IsCFFEX(upperSymbol)) return false;
107279
+ var shortSymbol=JSChart.GetShortSymbol(upperSymbol);
107280
+ //MO2602-C-6300.cffex
107281
+ var aryValue=shortSymbol.split("-");
107282
+ if (!aryValue || aryValue.length!=3) return false;
107283
+
107284
+ var strValue=aryValue[0];
107285
+ const regex = /([a-zA-Z]+)(\d+)/;
107286
+ const match = strValue.match(regex);
107287
+ if (!match || !match[1] || !match[2]) return false;
107288
+
107289
+ var prefix=match[1];
107290
+ if (["IM","IO","MO","HO"].includes(prefix)) return true;
107291
+
107292
+ return true;
107293
+ },
107294
+
107149
107295
  IsDCE: function (upperSymbol)
107150
107296
  {
107151
107297
  if (!upperSymbol) return false;
@@ -107402,6 +107548,43 @@ var MARKET_SUFFIX_NAME=
107402
107548
  return false;
107403
107549
  },
107404
107550
 
107551
+ IsSHSZETF:function(symbol) //是否是沪深ETF
107552
+ {
107553
+ if (!symbol) return false;
107554
+ var upperSymbol=symbol.toUpperCase();
107555
+ if (this.IsSHETF(upperSymbol)) return true;
107556
+ else if (this.IsSZETF(upperSymbol)) return true;
107557
+
107558
+
107559
+ return false;
107560
+ },
107561
+
107562
+ IsSHETF:function(upperSymbol)
107563
+ {
107564
+ if (upperSymbol && this.IsSH(upperSymbol))
107565
+ {
107566
+ //上证ETF:通常以51开头
107567
+ if (upperSymbol.charAt(0)=='5' && upperSymbol.charAt(1)=='1')
107568
+ return true;
107569
+ if (upperSymbol.charAt(0)=='5' && upperSymbol.charAt(1)=='8')
107570
+ return true;
107571
+ }
107572
+
107573
+ return false;
107574
+ },
107575
+
107576
+ IsSZETF:function(upperSymbol)
107577
+ {
107578
+ if (upperSymbol && this.IsSZ(upperSymbol))
107579
+ {
107580
+ //深交所上市的ETF代码以15开头
107581
+ if (upperSymbol.charAt(0)=='1' && upperSymbol.charAt(1)=='5')
107582
+ return true;
107583
+ }
107584
+
107585
+ return false;
107586
+ },
107587
+
107405
107588
  GetMarketStatus:function(symbol) //获取市场状态 0=闭市 1=盘前 2=盘中 3=盘后
107406
107589
  {
107407
107590
  if (!symbol) return 0;
@@ -107752,6 +107935,23 @@ var MARKET_SUFFIX_NAME=
107752
107935
  if (pos<=0) return symbol;
107753
107936
 
107754
107937
  return symbol.slice(0,pos);
107938
+ },
107939
+
107940
+ SplitSymbol:function(symbol, format) //分析代码 返回对象
107941
+ {
107942
+ if (!format || !symbol) return null;
107943
+ var shortSymbol=this.GetShortSymbol(symbol);
107944
+ if (format=="A+D+")
107945
+ {
107946
+ var regex=/([a-zA-Z]+)(\d+)/;
107947
+ var match=shortSymbol.match(regex);
107948
+ if (!match || !match[1] || !match[2]) return null;
107949
+
107950
+ return { AryString:[match[1], match[2]], ShortSymbol:shortSymbol, Symbol:symbol, Market:symbol.slice(shortSymbol.length) };
107951
+ }
107952
+
107953
+
107954
+ return null;
107755
107955
  }
107756
107956
 
107757
107957
  }
@@ -111652,6 +111852,7 @@ var g_JSComplierResource=
111652
111852
  Data:new Map() //自定义图标 key=id
111653
111853
  //value={ID:, Text:, Color, Family: } //svg
111654
111854
  //value={ ID:1, Symbol:'↑', Color:'rgb(238,44,44)' } //文字
111855
+ //value={ ID:, Image:, Width, Height }
111655
111856
  },
111656
111857
 
111657
111858
  CustomFunction: //定制函数
@@ -111699,20 +111900,24 @@ var g_JSComplierResource=
111699
111900
  GetDrawIcon:function(id)
111700
111901
  {
111701
111902
  var icon;
111702
- if (g_JSComplierResource.CustomDrawIcon.Data.has(id))
111903
+ if (this.CustomDrawIcon.Data.has(id))
111703
111904
  {
111704
111905
  const iconfont=g_JSComplierResource.CustomDrawIcon.Data.get(id);
111705
- if (iconfont.Symbol) //文字
111906
+
111907
+ if (iconfont.Image) //图片
111908
+ icon={ ID:id, Image:iconfont.Image, Width:iconfont.Width, Height:iconfont.Height };
111909
+ else if (iconfont.Symbol) //文字
111706
111910
  icon={ Symbol:iconfont.Symbol, Color:iconfont.Color, IconFont:false, ID:id };
111707
111911
  else //SVG图标
111708
111912
  icon={ Symbol:iconfont.Text, Color:iconfont.Color, Family:iconfont.Family, IconFont:true, ID:id };
111913
+
111709
111914
  return icon;
111710
111915
  }
111711
111916
 
111712
- if (g_JSComplierResource.DrawIcon.Data.has(id))
111917
+ if (this.DrawIcon.Data.has(id))
111713
111918
  {
111714
- const iconfont=g_JSComplierResource.DrawIcon.Data.get(id);
111715
- icon={ Symbol:iconfont.Text, Color:iconfont.Color, Family:g_JSComplierResource.DrawIcon.Family, IconFont:true, ID:id };
111919
+ const iconfont=this.DrawIcon.Data.get(id);
111920
+ icon={ Symbol:iconfont.Text, Color:iconfont.Color, Family:this.DrawIcon.Family, IconFont:true, ID:id };
111716
111921
  return icon;
111717
111922
  }
111718
111923
 
@@ -111754,6 +111959,11 @@ var g_JSComplierResource=
111754
111959
  {
111755
111960
  if (g_JSComplierResource.CustomDataFunction.Data.has(name)) return true;
111756
111961
  return false;
111962
+ },
111963
+
111964
+ AddDrawIcon:function(id, icon)
111965
+ {
111966
+ this.CustomDrawIcon.Data.set(id, icon);
111757
111967
  }
111758
111968
  }
111759
111969
 
@@ -132213,7 +132423,10 @@ JSComplier.SetDomain = function (domain, cacheDomain) //修改API地址
132213
132423
 
132214
132424
  JSComplier.AddIcon=function(obj) //添加一个obj={ID:, Text:, Color, Family: }
132215
132425
  {
132216
- g_JSComplierResource.CustomDrawIcon.Data.set(obj.ID, obj);
132426
+
132427
+ if (!obj || !obj.ID) return;
132428
+
132429
+ g_JSComplierResource.AddDrawIcon(obj.ID, obj);
132217
132430
  }
132218
132431
 
132219
132432
  JSComplier.AddFunction=function(obj) //添加函数 { Name:函数名, Description:描述信息, IsDownload:是否需要下载数据, Invoke:函数执行(可选) }
@@ -134004,7 +134217,21 @@ function ScriptIndex(name,script,args,option)
134004
134217
  //创建图标
134005
134218
  this.CreateIcon=function(hqChart,windowIndex,varItem,id)
134006
134219
  {
134007
- let chartText=new ChartSingleText();
134220
+ var chartText=null;
134221
+
134222
+ if (varItem.Draw && varItem.Draw.Icon && varItem.Draw.Icon.Image)
134223
+ {
134224
+ chartText=new ChartDrawIconV2();
134225
+ chartText.Icon=varItem.Draw.Icon;
134226
+ if (varItem.DrawFontSize>0) chartText.Size=varItem.DrawFontSize;
134227
+ }
134228
+ else
134229
+ {
134230
+ chartText=new ChartSingleText();
134231
+ if (varItem.DrawFontSize>0) chartText.FixedFontSize=varItem.DrawFontSize;
134232
+ }
134233
+
134234
+
134008
134235
  chartText.Canvas=hqChart.Canvas;
134009
134236
  chartText.TextAlign='center';
134010
134237
 
@@ -134035,6 +134262,10 @@ function ScriptIndex(name,script,args,option)
134035
134262
  {
134036
134263
  chartText.IconFont={ Family:icon.Family, Text:icon.Symbol, Color:icon.Color };
134037
134264
  if (varItem.Color) chartText.IconFont.Color=this.GetColor(varItem.Color);
134265
+ }
134266
+ else if (icon.Image)
134267
+ {
134268
+
134038
134269
  }
134039
134270
  else
134040
134271
  {
@@ -134044,7 +134275,7 @@ function ScriptIndex(name,script,args,option)
134044
134275
  else chartText.Color='rgb(0,0,0)';
134045
134276
  }
134046
134277
 
134047
- if (varItem.DrawFontSize>0) chartText.FixedFontSize=varItem.DrawFontSize;
134278
+
134048
134279
  if (IFrameSplitOperator.IsNumber(varItem.XOffset)) chartText.ShowOffset.X=varItem.XOffset;
134049
134280
  if (IFrameSplitOperator.IsNumber(varItem.YOffset)) chartText.ShowOffset.Y=varItem.YOffset;
134050
134281
 
@@ -136102,7 +136333,19 @@ function OverlayScriptIndex(name,script,args,option)
136102
136333
  {
136103
136334
  var overlayIndex=this.OverlayIndex;
136104
136335
  var frame=overlayIndex.Frame;
136105
- let chart=new ChartSingleText();
136336
+ var chart=null;
136337
+
136338
+ if (varItem.Draw && varItem.Draw.Icon && varItem.Draw.Icon.Image)
136339
+ {
136340
+ chart=new ChartDrawIconV2();
136341
+ chart.Icon=varItem.Draw.Icon;
136342
+ if (varItem.DrawFontSize>0) chart.Size=varItem.DrawFontSize;
136343
+ }
136344
+ else
136345
+ {
136346
+ chart=new ChartSingleText();
136347
+ }
136348
+
136106
136349
  chart.Canvas=hqChart.Canvas;
136107
136350
  chart.TextAlign='center';
136108
136351
 
@@ -136133,6 +136376,10 @@ function OverlayScriptIndex(name,script,args,option)
136133
136376
  if (icon.IconFont==true)
136134
136377
  {
136135
136378
  chart.IconFont={ Family:icon.Family, Text:icon.Symbol, Color:icon.Color };
136379
+ }
136380
+ else if (icon.Image)
136381
+ {
136382
+
136136
136383
  }
136137
136384
  else
136138
136385
  {
@@ -153956,6 +154203,7 @@ function JSTReportChartContainer(uielement)
153956
154203
  {
153957
154204
  Name:'JSTReportChartContainer::RequestStockListData', //类名::
153958
154205
  Explain:'T型报价列表数据',
154206
+ Request:{ Data: { symbol:this.Symbol } },
153959
154207
  Self:this,
153960
154208
  PreventDefault:false
153961
154209
  };
@@ -165684,7 +165932,7 @@ function JSFloatTooltip()
165684
165932
  Color:this.ValueColor
165685
165933
  };
165686
165934
 
165687
- if (!IFrameSplitOperator.IsNumber(price) || !IFrameSplitOperator.IsNumber(yClose)) return item;
165935
+ if (!IFrameSplitOperator.IsNumber(price) || !IFrameSplitOperator.IsNumber(yClose) || yClose===0) return item;
165688
165936
 
165689
165937
  var diffValue=price-yClose;
165690
165938
  var value=(price-yClose)/yClose;
@@ -165725,7 +165973,7 @@ function JSFloatTooltip()
165725
165973
  };
165726
165974
 
165727
165975
 
165728
- if (!IFrameSplitOperator.IsNumber(high) || !IFrameSplitOperator.IsNumber(low) || !IFrameSplitOperator.IsNumber(yClose)) return item;
165976
+ if (!IFrameSplitOperator.IsNumber(high) || !IFrameSplitOperator.IsNumber(low) || !IFrameSplitOperator.IsNumber(yClose) || yClose===0) return item;
165729
165977
 
165730
165978
  var diffValue=high-low;
165731
165979
  var value=(diffValue)/yClose;
@@ -171502,7 +171750,7 @@ function ChartStockData()
171502
171750
 
171503
171751
 
171504
171752
 
171505
- var HQCHART_VERSION="1.1.15479";
171753
+ var HQCHART_VERSION="1.1.15502";
171506
171754
 
171507
171755
  function PrintHQChartVersion()
171508
171756
  {