hqchart 1.1.15258 → 1.1.15273

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.
@@ -3349,6 +3349,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3349
3349
  this.IsPress=false; //是否长按
3350
3350
  this.IsPressKeyboard=false; //是否键盘按键
3351
3351
  this.PressKeyboardConfig={ PauseUpdate:false, }; //按键以后 是否涨停数据更新
3352
+ this.DrawStatusData={ LatestTime:{ Draw:null, DrawDynamicInfo:null } };
3352
3353
 
3353
3354
  this.NetworkFilter; //网络请求回调 function(data, callback);
3354
3355
  this.LastMouseStatus={ MouseOnToolbar:null }; // MouseOnToolbar={ Rect:{}, Title: }
@@ -3554,6 +3555,24 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3554
3555
  return unit;
3555
3556
  }
3556
3557
 
3558
+ this.ClearDrawStatusData=function()
3559
+ {
3560
+ this.DrawStatusData.LatestTime.Draw=null;
3561
+ this.DrawStatusData.LatestTime.DrawDynamicInfo=null;
3562
+ }
3563
+
3564
+ this.UpdateDrawStatusData=function(funName)
3565
+ {
3566
+ if (funName=="Draw")
3567
+ {
3568
+ this.DrawStatusData.LatestTime.Draw=new Date();
3569
+ }
3570
+ else if (funName=="DrawDynamicInfo")
3571
+ {
3572
+ this.DrawStatusData.LatestTime.DrawDynamicInfo=new Date();
3573
+ }
3574
+ }
3575
+
3557
3576
  this.ClearStockCache=function()
3558
3577
  {
3559
3578
  this.StockCache.Data=null;
@@ -6866,6 +6885,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
6866
6885
  ++this.TouchDrawCount;
6867
6886
 
6868
6887
  this.UpdateCorssCursorStatus();
6888
+ this.UpdateDrawStatusData("Draw");
6869
6889
  }
6870
6890
 
6871
6891
  this.DrawExtendChartPaint=function(level, option)
@@ -7094,7 +7114,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
7094
7114
  IsOnTouch:this.IsOnTouch,
7095
7115
  CorssCursorTouchEnd:this.CorssCursorTouchEnd,
7096
7116
  IsTitleShowLatestData:this.IsTitleShowLatestData,
7097
- IsMinuteChart:(this.ClassName=="MinuteChartContainer" || this.ClassName=="MinuteChartHScreenContainer") ? true:false
7117
+ IsMinuteChart:(this.ClassName=="MinuteChartContainer" || this.ClassName=="MinuteChartHScreenContainer") ? true:false,
7118
+ DrawStatusData:this.DrawStatusData,
7098
7119
  };
7099
7120
 
7100
7121
  status.FrameID=this.Frame.PtInFrame(this.LastPoint.X, this.LastPoint.Y);
@@ -7389,6 +7410,8 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
7389
7410
  ++this.TouchDrawCount;
7390
7411
 
7391
7412
  this.UpdateCorssCursorStatus();
7413
+ this.UpdateDrawStatusData("DrawDynamicInfo");
7414
+
7392
7415
  }
7393
7416
 
7394
7417
  this.DrawAnimation=function() //绘制动画 如弹幕
@@ -39620,6 +39643,294 @@ function ChartSingleText()
39620
39643
  }
39621
39644
  }
39622
39645
 
39646
+ function ChartDrawText_Fix()
39647
+ {
39648
+ this.newMethod=IChartPainting; //派生
39649
+ this.newMethod();
39650
+ delete this.newMethod;
39651
+
39652
+ this.ClassName='ChartDrawText_Fix'; //类名
39653
+
39654
+ this.Color="rgb(255,193,37)"; //字颜色
39655
+ this.TextFont=g_JSChartResource.DRAWTEXT_FIX.Font;
39656
+ this.PtPercentage=null; //{ X:, Y: } 百分比坐标
39657
+ this.TextBaseline="top";
39658
+ this.TextAlign='center';
39659
+ this.ShowOffset={ X:0, Y:0 }; //显示偏移
39660
+ this.MapCache;
39661
+ this.HQChart;
39662
+ this.AryText;
39663
+
39664
+ this.BuildCacheData=function(kData, data)
39665
+ {
39666
+ var mapData=new Map();
39667
+ this.MapCache=mapData;
39668
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return;
39669
+ if (!data || !IFrameSplitOperator.IsNonEmptyArray(data.Value) || !IFrameSplitOperator.IsNonEmptyArray(data.Text)) return;
39670
+
39671
+ for(var i=0;i<kData.Data.length;++i)
39672
+ {
39673
+ var value=data.Value[i];
39674
+ if (value!==1) continue;
39675
+
39676
+ var text=data.Text[i];
39677
+ if (!text) continue;
39678
+
39679
+ var kItem=kData.Data[i];
39680
+ var item={ Value:value, Text:text, Date:kItem.Date, Time:kItem.Time };
39681
+ var key=this.BuildKey(item);
39682
+
39683
+ /* //测试
39684
+ item.Text=
39685
+ [
39686
+ { Name:`日期`, Text:`${item.Date}`, Margin:{ Bottom:10 }},
39687
+ { Name:`日期2`, Text:`${item.Date}-2`},
39688
+ ]
39689
+ */
39690
+
39691
+ mapData.set(key,item);
39692
+ }
39693
+ }
39694
+
39695
+ this.ReloadResource=function(resource)
39696
+ {
39697
+ this.TextFont=g_JSChartResource.DRAWTEXT_FIX.Font;
39698
+ }
39699
+
39700
+ this.Draw=function()
39701
+ {
39702
+ this.AryText=null;
39703
+ if (!this.IsShow || this.ChartFrame.IsMinSize) return;
39704
+ if (this.IsShowIndexTitleOnly()) return;
39705
+ if (this.IsHideScriptIndex()) return;
39706
+ if (!this.MapCache || this.MapCache.size<=0) return;
39707
+ if (!this.PtPercentage || !IFrameSplitOperator.IsNumber(this.PtPercentage.X) || !IFrameSplitOperator.IsNumber(this.PtPercentage.Y)) return;
39708
+ if (!this.IsDrawText()) return;
39709
+
39710
+ var bHScreen=(this.ChartFrame.IsHScreen===true)
39711
+ this.Canvas.save();
39712
+ this.ClipClient(bHScreen);
39713
+
39714
+ this.DrawText();
39715
+
39716
+ this.Canvas.restore();
39717
+ this.AryText=null;
39718
+ }
39719
+
39720
+ //当前屏是否要绘制文字
39721
+ this.IsDrawText=function()
39722
+ {
39723
+ if (!this.HQChart) return false;
39724
+ var kData=this.HQChart.GetKData();
39725
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return false;
39726
+
39727
+ var bHScreen=(this.ChartFrame.IsHScreen===true)
39728
+ var dataWidth=this.ChartFrame.DataWidth;
39729
+ var distanceWidth=this.ChartFrame.DistanceWidth;
39730
+ var xPointCount=this.ChartFrame.XPointCount;
39731
+ var xOffset=this.ChartBorder.GetLeft()+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
39732
+ var chartright=this.ChartBorder.GetRight();
39733
+ var top=this.ChartBorder.GetTopEx();
39734
+ var bottom=this.ChartBorder.GetBottomEx();
39735
+
39736
+ if (bHScreen)
39737
+ {
39738
+ chartright=this.ChartBorder.GetBottom();
39739
+ top=this.ChartBorder.GetRightEx();
39740
+ bottom=this.ChartBorder.GetLeftEx();
39741
+ xOffset=this.ChartBorder.GetTop()+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
39742
+ }
39743
+
39744
+ for(var i=kData.DataOffset,j=0;i<kData.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
39745
+ {
39746
+ var kItem=kData.Data[i];
39747
+ if (kItem==null) continue;
39748
+
39749
+ var key=this.BuildKey(kItem);
39750
+ if (!this.MapCache.has(key)) continue;
39751
+
39752
+ var item=this.MapCache.get(key);
39753
+ if (Array.isArray(item.Text)) this.AryText=item.Text;
39754
+ else this.AryText=[{ Name:item.Text }];
39755
+ return true;
39756
+ }
39757
+
39758
+ return false;
39759
+ }
39760
+
39761
+ this.DrawText=function()
39762
+ {
39763
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
39764
+ if (bHScreen)
39765
+ {
39766
+ var x=this.ChartBorder.GetRightEx()-this.ChartBorder.GetWidthEx()*this.PtPercentage.Y;
39767
+ var y=this.ChartBorder.GetTop()+this.ChartBorder.GetHeight()*this.PtPercentage.X;
39768
+ }
39769
+ else
39770
+ {
39771
+ var x=this.ChartBorder.GetLeft()+this.ChartBorder.GetWidth()*this.PtPercentage.X;
39772
+ var y=this.ChartBorder.GetTopEx()+this.ChartBorder.GetHeightEx()*this.PtPercentage.Y;
39773
+ }
39774
+
39775
+ var drawInfo=this.CalculateComplexTextSize(this.AryText, { Font:this.TextFont, Color:this.Color });
39776
+ if (!drawInfo) return;
39777
+
39778
+ drawInfo.IsHScreen=bHScreen;
39779
+
39780
+ if (bHScreen)
39781
+ {
39782
+ if (this.TextBaseline=="middle") x=x-drawInfo.Height/2; //上下居中
39783
+ else if (this.TextBaseline=="bottom") x=x-drawInfo.Height; //底部
39784
+
39785
+ if (this.TextAlign=="center") y=y-drawInfo.Width/2; //左右居中
39786
+ else if (this.TextAlign=='right') y=y-drawInfo.Width; //右对齐
39787
+
39788
+ this.DrawComplexText(x,y, drawInfo);
39789
+ }
39790
+ else
39791
+ {
39792
+ if (this.TextBaseline=="middle") y=y-drawInfo.Height/2; //上下居中
39793
+ else if (this.TextBaseline=="bottom") y=y-drawInfo.Height; //底部
39794
+
39795
+ if (this.TextAlign=="center") x=x-drawInfo.Width/2; //左右居中
39796
+ else if (this.TextAlign=='right') x=x-drawInfo.Width; //右对齐
39797
+
39798
+ this.DrawComplexText(x,y, drawInfo);
39799
+ }
39800
+ }
39801
+
39802
+ this.DrawComplexText=function(x, y, drawInfo)
39803
+ {
39804
+ var left=x;
39805
+ var lineTop=y;
39806
+ if (drawInfo.IsHScreen)
39807
+ {
39808
+ left=0;
39809
+ lineTop=0;
39810
+ this.Canvas.save();
39811
+ this.Canvas.translate(x, y);
39812
+ this.Canvas.rotate(90 * Math.PI / 180);
39813
+ }
39814
+
39815
+ this.Canvas.textBaseline="bottom";
39816
+ this.Canvas.textAlign="left";
39817
+ for(var i=0;i<drawInfo.AryData.length;++i)
39818
+ {
39819
+ var item=drawInfo.AryData[i];
39820
+ var margin=item.Margin;
39821
+ var xText=left+margin.Left;
39822
+ var yText=lineTop+item.Height-margin.Bottom;
39823
+
39824
+ if (item.Name)
39825
+ {
39826
+ this.Canvas.font=item.Font;
39827
+ this.Canvas.fillStyle=item.NameColor;
39828
+ this.Canvas.fillText(item.Name,xText,yText);
39829
+ xText+=item.NameWidth+item.Space;
39830
+ }
39831
+
39832
+ if (item.Text)
39833
+ {
39834
+ this.Canvas.font=item.Font;
39835
+ this.Canvas.fillStyle=item.TextColor;
39836
+ this.Canvas.fillText(item.Text,xText,yText);
39837
+ xText+=item.TextWidth;
39838
+ }
39839
+
39840
+ lineTop+=item.Height;
39841
+ }
39842
+
39843
+ if (drawInfo.IsHScreen) this.Canvas.restore();
39844
+ }
39845
+
39846
+ //计算复杂文本长度高度 defaultOption:{ Font:, }
39847
+ this.CalculateComplexTextSize=function(aryText, defaultOption)
39848
+ {
39849
+ if (!defaultOption) return null;
39850
+ if (!aryText || !IFrameSplitOperator.IsNonEmptyArray(aryText)) return null;
39851
+
39852
+ this.Canvas.font=defaultOption.Font;
39853
+ var lineHeight=this.Canvas.measureText("擎").width;
39854
+ var maxNameWidth=0, maxTextWidth=0;
39855
+ var result={ AryData:[], Width:0, Height:0 }
39856
+ for(var i=0;i<aryText.length;++i)
39857
+ {
39858
+ var item=aryText[i];
39859
+ var newItem={ NameWidth:0, TextWidth:0, Margin:{ Left:0, Top:0, Right:0, Bottom:0 }, Font:defaultOption.Font, Space:0, YOffset:0, Width:0, Height:0 };
39860
+ if (item.Name)
39861
+ {
39862
+ newItem.NameWidth=this.Canvas.measureText(item.Name).width;
39863
+ newItem.Name=item.Name;
39864
+ if (maxNameWidth<item.NameWidth) maxNameWidth=newItem.NameWidth;
39865
+ if (IFrameSplitOperator.IsNumber(item.Space)) newItem.Space=item.Space;
39866
+ if (item.NameColor) newItem.NameColor=item.NameColor;
39867
+ else newItem.NameColor=defaultOption.Color;
39868
+ }
39869
+
39870
+ if (item.Text)
39871
+ {
39872
+ newItem.TextWidth=this.Canvas.measureText(item.Text).width;
39873
+ newItem.Text=item.Text;
39874
+ if (maxTextWidth<item.TextWidth) maxTextWidth=newItem.TextWidth;
39875
+ if (item.TextColor) newItem.TextColor=item.TextColor;
39876
+ else newItem.TextColor=defaultOption.Color;
39877
+ }
39878
+
39879
+
39880
+ CopyMarginConfig(newItem.Margin, item.Margin);
39881
+
39882
+ if (IFrameSplitOperator.IsNumber(item.YOffset)) newItem.YOffset=item.YOffset;
39883
+
39884
+ newItem.Width=newItem.NameWidth+newItem.TextWidth;
39885
+ newItem.Width+=newItem.Margin.Left+newItem.Margin.Right+newItem.Space;
39886
+ newItem.Height=(lineHeight+newItem.Margin.Top+newItem.Margin.Bottom);
39887
+
39888
+ result.AryData.push(newItem);
39889
+ result.Height+=newItem.Height;
39890
+ if (result.Width<newItem.Width) result.Width=newItem.Width;
39891
+ }
39892
+
39893
+ return result;
39894
+ }
39895
+
39896
+ }
39897
+
39898
+ function ChartDrawNumber_Fix()
39899
+ {
39900
+ this.newMethod=ChartDrawText_Fix; //派生
39901
+ this.newMethod();
39902
+ delete this.newMethod;
39903
+
39904
+ this.ClassName='ChartDrawNumber_Fix'; //类名
39905
+ this.TextFont=g_JSChartResource.DRAWNUMBER_FIX.Font;
39906
+
39907
+ this.BuildCacheData=function(kData, data)
39908
+ {
39909
+ var mapData=new Map();
39910
+ this.MapCache=mapData;
39911
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return;
39912
+ if (!data || !IFrameSplitOperator.IsNonEmptyArray(data.Value) || !IFrameSplitOperator.IsNonEmptyArray(data.Text)) return;
39913
+
39914
+ for(var i=0;i<kData.Data.length;++i)
39915
+ {
39916
+ var value=data.Value[i];
39917
+ var text=data.Text[i];
39918
+ if (!text) continue;
39919
+
39920
+ var kItem=kData.Data[i];
39921
+ var item={ Value:value, Text:text, Date:kItem.Date, Time:kItem.Time };
39922
+ var key=this.BuildKey(item);
39923
+
39924
+ mapData.set(key,item);
39925
+ }
39926
+ }
39927
+
39928
+ this.ReloadResource=function(resource)
39929
+ {
39930
+ this.TextFont=g_JSChartResource.DRAWNUMBER_FIX.Font;
39931
+ }
39932
+ }
39933
+
39623
39934
 
39624
39935
  function ChartTradeIcon()
39625
39936
  {
@@ -39786,6 +40097,12 @@ function ChartDrawText()
39786
40097
  }
39787
40098
  }
39788
40099
 
40100
+ this.GetMaxMin=function()
40101
+ {
40102
+ var range={ Min:null, Max:null };
40103
+ return range;
40104
+ }
40105
+
39789
40106
  this.Draw=function()
39790
40107
  {
39791
40108
  if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
@@ -85625,7 +85942,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
85625
85942
  this.ClearCustomKLine();
85626
85943
  this.ClearKLineCaluate();
85627
85944
  this.UnlockCorssCursor();
85628
-
85945
+ this.ClearDrawStatusData();
85629
85946
 
85630
85947
  var kLineDrawType=this.GetKLineDrawType();
85631
85948
  if (kLineDrawType==10 || kLineDrawType==11 || kLineDrawType==12 || kLineDrawType==16) isDataTypeChange=true;
@@ -87030,7 +87347,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
87030
87347
  this.UnlockCorssCursor();
87031
87348
  this.Frame.ClearYCoordinateMaxMin();
87032
87349
  this.ClosePopMinuteChart();
87033
-
87350
+ this.ClearDrawStatusData();
87034
87351
 
87035
87352
  this.Symbol=symbol;
87036
87353
  if (!symbol)
@@ -93644,6 +93961,7 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
93644
93961
  this.ClearStockCache();
93645
93962
  this.UnlockCorssCursor();
93646
93963
  this.Frame.ClearYCoordinateMaxMin();
93964
+ this.ClearDrawStatusData();
93647
93965
 
93648
93966
 
93649
93967
  if (option)
@@ -93812,6 +94130,7 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
93812
94130
  this.ClearStockCache();
93813
94131
  this.UnlockCorssCursor();
93814
94132
  this.Frame.ClearYCoordinateMaxMin();
94133
+ this.ClearDrawStatusData();
93815
94134
 
93816
94135
  if (option && option.PageInfo)
93817
94136
  {
@@ -122,6 +122,7 @@ HQData.NetworkFilter=function(data, callback)
122
122
  break;
123
123
 
124
124
  case "JSSymbolData::GetFinance": //财务数据
125
+ //HQChart使用教程30-K线图如何对接第3方数据23- FINANCE函数数据
125
126
  HQData.Finance_RequestData(data,callback);
126
127
  break;
127
128
 
@@ -145,6 +146,7 @@ HQData.NetworkFilter=function(data, callback)
145
146
  HQData.BKJYOne_RequestData(data,callback);
146
147
  break;
147
148
  case "JSSymbolData::GetFinValue":
149
+ //HQChart使用教程30-K线图如何对接第3方数据22- FINVALUE函数数据
148
150
  HQData.FinValue_RequestData(data,callback);
149
151
  break;
150
152
  case "JSSymbolData::GetFinOne":
@@ -152,9 +154,15 @@ HQData.NetworkFilter=function(data, callback)
152
154
  break;
153
155
 
154
156
  case "JSSymbolData::GetIndexData":
157
+ //HQChart使用教程30-K线图如何对接第3方数据28-大盘数据[INDEXA,INDEXC......]
155
158
  HQData.INDEX_RequestData(data,callback);
156
159
  break;
157
160
 
161
+ case 'JSSymbolData::GetSymbolData':
162
+ //HQChart使用教程30-K线图如何对接第3方数据38-通达信指标K线数据
163
+ HQData.RequestSymbolData(data,callback); //计算指标需要的K线数据
164
+ break;
165
+
158
166
  //////////////////////////////////////////////////////
159
167
  //报价列表数据
160
168
  case "JSReportChartContainer::RequestStockListData":
@@ -1802,6 +1810,20 @@ HQData.INDEX_RequestData=function(data,callback)
1802
1810
  callback(hqchartData);
1803
1811
  }
1804
1812
 
1813
+ HQData.RequestSymbolData=function(data,callback)
1814
+ {
1815
+ data.PreventDefault=true;
1816
+ var symbol=data.Request.Data.symbol;
1817
+ var period=data.Request.Data.period;
1818
+ //if (this.Chart.JSChartContainer.Symbol==symbol)
1819
+ {
1820
+ if (ChartData.IsDayPeriod(period, true))
1821
+ HQData.RequestHistoryData(data, callback);
1822
+ else if (ChartData.IsMinutePeriod(peirod, true))
1823
+ HQData.RequestHistoryMinuteData(data, callback);
1824
+ }
1825
+ }
1826
+
1805
1827
  //////////////////////////////////////////////////////////////////////////////////////
1806
1828
  // 报价列表
1807
1829
  //