hqchart 1.1.14628 → 1.1.14632

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.
@@ -36693,28 +36693,87 @@ function ChartKLineTable()
36693
36693
  this.ClassName='ChartKlineTable'; //类名
36694
36694
  this.Data;
36695
36695
  this.RowName;
36696
- this.IsShowRowName=false;
36696
+ this.RowNamePosition=1; //0=不显示 1=左边内部 2=左边外部 3=右边外部
36697
36697
  this.BGColor; //背景色
36698
+ this.BorderColor; //分割线颜色
36698
36699
 
36699
36700
  this.RowCount=5; //行数
36700
36701
  this.RowHeight=10; //行高
36702
+ this.RowHeightType=1; //0=均分 1=固定高度
36701
36703
  this.TextFontConfig=CloneData(g_JSChartResource.ChartKLineTable.TextFont);
36702
36704
  this.ItemMergin=CloneData(g_JSChartResource.ChartKLineTable.ItemMergin);
36703
36705
 
36704
36706
  this.TextFont;
36705
36707
  this.TextColor='rgb(0,0,0)';
36706
- this.NameColor="rgb(0,0,0)";
36707
36708
 
36708
- this.Draw=function()
36709
+ this.AryTableData=[];
36710
+ this.MapCache=null; //key=date/date-time value={ Date:, Time:, Data:[ ] }
36711
+ this.GetKValue=ChartData.GetKValue;
36712
+
36713
+ this.BuildCacheData=function()
36709
36714
  {
36710
- if (!this.IsShow || this.ChartFrame.IsMinSize) return;
36711
- if (this.NotSupportMessage)
36715
+ var mapData=new Map();
36716
+ this.MapCache=mapData;
36717
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryTableData)) return;
36718
+
36719
+ for(var i=0;i<this.AryTableData.length;++i)
36712
36720
  {
36713
- this.DrawNotSupportmessage();
36714
- return;
36721
+ var item=this.AryTableData[i];
36722
+ var key=this.BuildKey(item);
36723
+ mapData.set(key,item);
36715
36724
  }
36725
+ }
36716
36726
 
36717
- if (!this.Data || !this.Data.Data) return;
36727
+ //绘制背景色
36728
+ this.DrawBG=function(rtBG)
36729
+ {
36730
+ if (!this.BGColor) return;
36731
+
36732
+ if (this.BGColor)
36733
+ {
36734
+ this.Canvas.fillStyle=this.BGColor;
36735
+ this.Canvas.fillRect(rtBG.Left+1, rtBG.Top, rtBG.Width-1, rtBG.Height);
36736
+ }
36737
+ }
36738
+
36739
+ this.DrawBorder=function(rtBG)
36740
+ {
36741
+ if (!this.BorderColor) return;
36742
+
36743
+ var yLine=rtBG.Top;
36744
+ for(var i=0;i<30;++i)
36745
+ {
36746
+ this.Canvas.beginPath();
36747
+ this.Canvas.moveTo(rtBG.Left,ToFixedPoint(yLine));
36748
+ this.Canvas.lineTo(rtBG.Right,ToFixedPoint(yLine));
36749
+ this.Canvas.stroke();
36750
+
36751
+ yLine+=this.RowHeight;
36752
+ if (yLine>=rtBG.Bottom) break;
36753
+ }
36754
+ }
36755
+
36756
+ //计算行高
36757
+ this.CalculateRowHeight=function(rtBG)
36758
+ {
36759
+ if (this.RowHeightType==1)
36760
+ {
36761
+ this.RowHeight=this.TextFontConfig.FontMaxSize+this.ItemMergin.Top+this.ItemMergin.Bottom;
36762
+ }
36763
+ else
36764
+ {
36765
+ this.RowHeight=rtBG.Height/this.RowCount;
36766
+ }
36767
+ }
36768
+
36769
+ this.Draw=function()
36770
+ {
36771
+ if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
36772
+ if (this.IsShowIndexTitleOnly()) return;
36773
+ if (this.IsHideScriptIndex()) return;
36774
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryTableData)) return;
36775
+ if (!this.MapCache || this.MapCache.size<=0) return;
36776
+ if(!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
36718
36777
 
36719
36778
  var isHScreen=(this.ChartFrame.IsHScreen===true);
36720
36779
  if (isHScreen) return;
@@ -36725,24 +36784,22 @@ function ChartKLineTable()
36725
36784
  var xPointCount=this.ChartFrame.XPointCount;
36726
36785
  var border=this.ChartFrame.GetBorder();
36727
36786
  var height=border.Bottom-border.TopTitle;
36728
- this.RowHeight=height/this.RowCount;
36729
36787
  var xOffset=border.LeftEx+g_JSChartResource.FrameLeftMargin;
36730
36788
  var chartright=border.RightEx;
36731
36789
  var top=border.TopTitle;
36732
36790
  var bottom=border.Bottom;
36733
36791
 
36734
- if (this.BGColor)
36735
- {
36736
- this.Canvas.fillStyle=this.BGColor;
36737
- var left=border.LeftEx;
36738
- var width=border.RightEx-border.LeftEx;
36739
- var height=bottom-top;
36740
- this.Canvas.fillRect(left, top, width, height);
36741
- }
36792
+ //绘制背景
36793
+ var rtBG={ Left:border.LeftEx, Top:top, Right:border.RightEx, Bottom:bottom };
36794
+ rtBG.Width=rtBG.Right-rtBG.Left;
36795
+ rtBG.Height=rtBG.Bottom-rtBG.Top;
36796
+ this.DrawBG(rtBG);
36742
36797
 
36798
+ this.CalculateRowHeight(rtBG);
36799
+
36743
36800
  var itemHeight=this.RowHeight;
36744
36801
  var itemWidth=dataWidth+distanceWidth;
36745
- if (itemHeight-this.ItemMergin.Top-this.ItemMergin.Bottom>0) itemHeight=itemHeight-this.ItemMergin.Left-this.ItemMergin.Right;
36802
+ if (itemHeight-this.ItemMergin.Top-this.ItemMergin.Bottom>0) itemHeight=itemHeight-this.ItemMergin.Top-this.ItemMergin.Bottom;
36746
36803
  if (itemWidth-this.ItemMergin.Left-this.ItemMergin.Right>0) itemWidth=itemWidth-this.ItemMergin.Left-this.ItemMergin.Right;
36747
36804
 
36748
36805
  var font=this.GetDynamicTextFont(itemHeight, itemWidth);
@@ -36751,8 +36808,8 @@ function ChartKLineTable()
36751
36808
 
36752
36809
  for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
36753
36810
  {
36754
- var item=this.Data.Data[i];
36755
- if (!item) continue;
36811
+ var kItem=this.Data.Data[i];
36812
+ if (!kItem) continue;
36756
36813
 
36757
36814
  var left=xOffset;
36758
36815
  var right=xOffset+dataWidth+distanceWidth;
@@ -36760,15 +36817,20 @@ function ChartKLineTable()
36760
36817
  var x=left+(right-left)/2;
36761
36818
  if (x>chartright) break;
36762
36819
 
36763
- if (j==0 && this.IsShowRowName)
36764
- {
36765
- this.DrawRowName(top, bottom, left, right);
36766
- }
36767
- else
36768
- {
36769
- this.DrawRow(item, top, bottom, left, right); //绘制一列
36770
- }
36820
+ var bDrawName=false;
36821
+ if (j==0 && this.RowNamePosition===1) bDrawName=true;
36822
+ if (bDrawName) this.DrawRowName(top, bottom, left, right);
36823
+
36824
+ var key=this.BuildKey(kItem);
36825
+ if (!this.MapCache.has(key)) continue;
36826
+ var mapItem=this.MapCache.get(key);
36827
+
36828
+ if (!bDrawName) this.DrawRow(mapItem, top, bottom, left, right); //绘制一列
36771
36829
  }
36830
+
36831
+ if (this.RowNamePosition==3) this.DrawRightRowName();
36832
+
36833
+ this.DrawBorder(rtBG);
36772
36834
  }
36773
36835
 
36774
36836
  this.DrawRowName=function(top, bottom, left, right)
@@ -36776,32 +36838,35 @@ function ChartKLineTable()
36776
36838
  if (!IFrameSplitOperator.IsNonEmptyArray(this.RowName)) return;
36777
36839
 
36778
36840
  var x=left,y=top, width=right-left;
36841
+ var yOffset=3;
36842
+ if (this.ItemMergin.YOffset) yOffset=this.ItemMergin.YOffset;
36779
36843
  for(var i=0;i<this.RowName.length;++i)
36780
36844
  {
36781
36845
  var item=this.RowName[i];
36782
36846
 
36783
36847
  var rtBG={Left:x, Top:y, Right:right, Height:this.RowHeight, Width:width };
36784
36848
  rtBG.Bottom=rtBG.Top+this.RowHeight;
36849
+ var yText=rtBG.Bottom-yOffset;
36785
36850
 
36786
36851
  if (item.Name && rtBG.Width>10)
36787
36852
  {
36788
36853
  this.Canvas.fillStyle=item.Color?item.Color:this.TextColor;
36789
- this.Canvas.textBaseline='middle';
36854
+ this.Canvas.textBaseline='bottom';
36790
36855
 
36791
36856
  if (item.TextAlign=='right')
36792
36857
  {
36793
36858
  this.Canvas.textAlign='right';
36794
- this.Canvas.fillText(item.Name,rtBG.Right-2,rtBG.Top+this.RowHeight/2, width-4);
36859
+ this.Canvas.fillText(item.Name,rtBG.Right-2,yText, width-4);
36795
36860
  }
36796
36861
  else if (item.TextAlign=='center')
36797
36862
  {
36798
36863
  this.Canvas.textAlign='center';
36799
- this.Canvas.fillText(item.Name,rtBG.Left+rtBG.Width/2,rtBG.Top+this.RowHeight/2, width-4);
36864
+ this.Canvas.fillText(item.Name,rtBG.Left+rtBG.Width/2,yText, width-4);
36800
36865
  }
36801
36866
  else
36802
36867
  {
36803
36868
  this.Canvas.textAlign='left';
36804
- this.Canvas.fillText(item.Name,rtBG.Left+2,rtBG.Top+this.RowHeight/2, width-4);
36869
+ this.Canvas.fillText(item.Name,rtBG.Left+2,yText, width-4);
36805
36870
  }
36806
36871
  }
36807
36872
 
@@ -36809,40 +36874,133 @@ function ChartKLineTable()
36809
36874
  }
36810
36875
  }
36811
36876
 
36877
+ //绘制右侧行名
36878
+ this.DrawRightRowName=function()
36879
+ {
36880
+ var border=this.ChartFrame.GetBorder();
36881
+
36882
+ if (this.BGColor)
36883
+ {
36884
+ var rtRightBG={Left:border.RightEx, Top:border.TopTitle, Right:border.ChartWidth, Bottom:border.Bottom };
36885
+ rtRightBG.Width=rtRightBG.Right-rtRightBG.Left;
36886
+ rtRightBG.Height=rtRightBG.Bottom-rtRightBG.Top;
36887
+ this.Canvas.fillStyle=this.BGColor;
36888
+ this.Canvas.fillRect(rtRightBG.Left+1, rtRightBG.Top, rtRightBG.Width-1, rtRightBG.Height);
36889
+ }
36890
+
36891
+ var x=border.RightEx, y=border.TopTitle;
36892
+ var yOffset=3;
36893
+ if (this.ItemMergin.YOffset) yOffset=this.ItemMergin.YOffset;
36894
+ for(var i=0;i<this.RowName.length;++i)
36895
+ {
36896
+ var item=this.RowName[i];
36897
+
36898
+ var rtBG={Left:x, Top:y, Right:border.ChartWidth, Height:this.RowHeight };
36899
+ rtBG.Bottom=rtBG.Top+this.RowHeight;
36900
+ rtBG.Width=rtBG.Right-rtBG.Left;
36901
+ var yText=rtBG.Bottom-yOffset;
36902
+
36903
+ if (rtBG.Bottom>border.Bottom) break;
36904
+
36905
+ if (item.Name && rtBG.Width>10)
36906
+ {
36907
+ this.Canvas.fillStyle=item.Color?item.Color:this.TextColor;
36908
+ this.Canvas.textBaseline='bottom';
36909
+ this.Canvas.textAlign='left';
36910
+ this.Canvas.fillText(item.Name,rtBG.Left+2,yText);
36911
+ }
36912
+
36913
+ y+=this.RowHeight;
36914
+ }
36915
+ }
36916
+
36917
+
36812
36918
  this.DrawRow=function(data, top, bottom, left, right)
36813
36919
  {
36920
+ if (!IFrameSplitOperator.IsNonEmptyArray(data.Data)) return;
36921
+
36814
36922
  var x=left,y=top, width=right-left;
36815
- for(var i=0;i<data.length;++i)
36923
+ var yOffset=3;
36924
+ if (this.ItemMergin.YOffset) yOffset=this.ItemMergin.YOffset;
36925
+ for(var i=0;i<data.Data.length;++i)
36816
36926
  {
36817
- var item=data[i];
36927
+ var item=data.Data[i];
36818
36928
  var rtBG={Left:x, Top:y, Right:right, Height:this.RowHeight, Width:width };
36819
36929
  rtBG.Bottom=rtBG.Top+this.RowHeight;
36820
36930
 
36821
- if (item.BGColor)
36822
- {
36823
- this.Canvas.fillStyle=item.BGColor;
36824
- this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
36825
- }
36931
+ if (rtBG.Bottom>bottom) break;
36826
36932
 
36827
- if (item.Color && rtBG.Width>10)
36933
+ if (IFrameSplitOperator.IsNonEmptyArray(item.AryText)) //左右显示
36828
36934
  {
36829
- this.Canvas.fillStyle=item.Color;
36830
- this.Canvas.textBaseline='middle';
36831
-
36832
- if (item.TextAlign=='right')
36935
+ var subCellWidth=rtBG.Width/item.AryText.length;
36936
+ var xCell=rtBG.Left;
36937
+ for(var j=0;j<item.AryText.length;++j)
36833
36938
  {
36834
- this.Canvas.textAlign='right';
36835
- this.Canvas.fillText(item.Text,rtBG.Right-2,rtBG.Top+this.RowHeight/2, width-4);
36939
+ var subItem=item.AryText[j];
36940
+ var rtSubBG={ Left:xCell, Top:rtBG.Top, Bottom:rtBG.Bottom, Width:subCellWidth, Height:rtBG.Height };
36941
+ rtSubBG.Right=rtSubBG.Left+rtSubBG.Width;
36942
+
36943
+ if (subItem && subItem.BGColor)
36944
+ {
36945
+ this.Canvas.fillStyle=subItem.BGColor;
36946
+ this.Canvas.fillRect(rtSubBG.Left, rtSubBG.Top, rtSubBG.Width, rtSubBG.Height);
36947
+ }
36948
+
36949
+ if (subItem && subItem.Color && subCellWidth>10)
36950
+ {
36951
+ this.Canvas.fillStyle=subItem.Color;
36952
+ this.Canvas.textBaseline='bottom';
36953
+ var yText=rtSubBG.Bottom-yOffset;
36954
+
36955
+ if (subItem.TextAlign=='right')
36956
+ {
36957
+ this.Canvas.textAlign='right';
36958
+ this.Canvas.fillText(subItem.Text,rtSubBG.Right-2,yText, width-4);
36959
+ }
36960
+ else if (subItem.TextAlign=='center')
36961
+ {
36962
+ this.Canvas.textAlign='center';
36963
+ this.Canvas.fillText(subItem.Text,rtSubBG.Left+rtSubBG.Width/2,yText, width-4);
36964
+ }
36965
+ else
36966
+ {
36967
+ this.Canvas.textAlign='left';
36968
+ this.Canvas.fillText(subItem.Text,rtSubBG.Left+2,yText, width-4);
36969
+ }
36970
+ }
36971
+
36972
+ xCell+=subCellWidth;
36836
36973
  }
36837
- else if (item.TextAlign=='center')
36974
+ }
36975
+ else
36976
+ {
36977
+ if (item && item.BGColor)
36838
36978
  {
36839
- this.Canvas.textAlign='center';
36840
- this.Canvas.fillText(item.Text,rtBG.Left+rtBG.Width/2,rtBG.Top+this.RowHeight/2, width-4);
36979
+ this.Canvas.fillStyle=item.BGColor;
36980
+ this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
36841
36981
  }
36842
- else
36982
+
36983
+ if (item && item.Color && rtBG.Width>10)
36843
36984
  {
36844
- this.Canvas.textAlign='left';
36845
- this.Canvas.fillText(item.Text,rtBG.Left+2,rtBG.Top+this.RowHeight/2, width-4);
36985
+ this.Canvas.fillStyle=item.Color;
36986
+ this.Canvas.textBaseline='bottom';
36987
+ var yText=rtBG.Bottom-yOffset;
36988
+
36989
+ if (item.TextAlign=='right')
36990
+ {
36991
+ this.Canvas.textAlign='right';
36992
+ this.Canvas.fillText(item.Text,rtBG.Right-2,yText, width-4);
36993
+ }
36994
+ else if (item.TextAlign=='center')
36995
+ {
36996
+ this.Canvas.textAlign='center';
36997
+ this.Canvas.fillText(item.Text,rtBG.Left+rtBG.Width/2,yText, width-4);
36998
+ }
36999
+ else
37000
+ {
37001
+ this.Canvas.textAlign='left';
37002
+ this.Canvas.fillText(item.Text,rtBG.Left+2,yText, width-4);
37003
+ }
36846
37004
  }
36847
37005
  }
36848
37006
 
@@ -126523,16 +126681,41 @@ function ScriptIndex(name,script,args,option)
126523
126681
  chart.HQChart=hqChart;
126524
126682
  chart.Identify=this.Guid;
126525
126683
 
126526
- chart.Data.Data=varItem.Draw.DrawData;
126684
+ chart.Data=hqChart.GetKData(); //绑定K线
126685
+ chart.AryTableData=varItem.Draw.DrawData;
126527
126686
  if (IFrameSplitOperator.IsNumber(varItem.Draw.RowCount)) chart.RowCount=varItem.Draw.RowCount;
126528
- if (IFrameSplitOperator.IsBool(varItem.Draw.IsShowRowName)) chart.IsShowRowName=varItem.Draw.IsShowRowName;
126529
126687
  if (IFrameSplitOperator.IsNonEmptyArray(varItem.Draw.RowName)) chart.RowName=varItem.Draw.RowName;
126530
- if (varItem.Draw.BGColor) chart.BGColor=varItem.Draw.BGColor;
126531
126688
 
126689
+ var config=varItem.Draw.Config;
126690
+ if (config)
126691
+ {
126692
+ if (config.BGColor) chart.BGColor=config.BGColor;
126693
+ if (config.TextColor) chart.TextColor=config.TextColor;
126694
+ if (config.BorderColor) chart.BorderColor=config.BorderColor;
126695
+ if (IFrameSplitOperator.IsNumber(config.RowNamePosition)) chart.RowNamePosition=config.RowNamePosition;
126696
+
126697
+ if (config.ItemMergin)
126698
+ {
126699
+ var subItem=config.ItemMergin;
126700
+ if (IFrameSplitOperator.IsNumber(subItem.Left)) chart.ItemMergin.Left=subItem.Left;
126701
+ if (IFrameSplitOperator.IsNumber(subItem.Top)) chart.ItemMergin.Top=subItem.Top;
126702
+ if (IFrameSplitOperator.IsNumber(subItem.Bottom)) chart.ItemMergin.Bottom=subItem.Bottom;
126703
+ if (IFrameSplitOperator.IsNumber(subItem.Right)) chart.ItemMergin.Right=subItem.Right;
126704
+ if (IFrameSplitOperator.IsNumber(subItem.YOffset)) chart.ItemMergin.YOffset=subItem.YOffset;
126705
+ }
126706
+
126707
+ if (config.TextFont)
126708
+ {
126709
+ var subItem=config.TextFont;
126710
+ if (IFrameSplitOperator.IsNumber(subItem.FontMaxSize)) chart.TextFontConfig.FontMaxSize=subItem.FontMaxSize;
126711
+ if (subItem.Family) chart.TextFontConfig.Family=subItem.Family;
126712
+ }
126713
+ }
126714
+
126715
+ chart.BuildCacheData();
126532
126716
  hqChart.ChartPaint.push(chart);
126533
126717
 
126534
126718
  var titleIndex=windowIndex+1;
126535
-
126536
126719
  var titleData=new DynamicTitleData(chart.Data,chart.BarName,chart.BarColor);
126537
126720
  titleData.DataType="ChartKLineTable";
126538
126721
  hqChart.TitlePaint[titleIndex].Data[i]=titleData;
@@ -129524,13 +129707,11 @@ function APIScriptIndex(name,script,args,option, isOverlay)
129524
129707
  drawItem.Name=draw.Name;
129525
129708
  drawItem.Type=draw.Type;
129526
129709
  drawItem.DrawType=draw.DrawType;
129527
- drawItem.DrawData=this.FittingArray(draw.DrawData,date,time,hqChart,1);
129710
+ drawItem.DrawData=draw.DrawData;
129528
129711
  drawItem.RowCount=draw.RowCount;
129529
129712
  drawItem.RowName=draw.RowName;
129530
- drawItem.IsShowRowName=draw.IsShowRowName;
129531
- drawItem.BGColor=draw.BGColor;
129713
+ drawItem.Config=draw.Config;
129532
129714
  outVarItem.Draw=drawItem;
129533
-
129534
129715
  result.push(outVarItem);
129535
129716
  }
129536
129717
  else if (draw.DrawType=='MULTI_TEXT')
@@ -146450,7 +146631,7 @@ function ScrollBarBGChart()
146450
146631
 
146451
146632
 
146452
146633
 
146453
- var HQCHART_VERSION="1.1.14627";
146634
+ var HQCHART_VERSION="1.1.14631";
146454
146635
 
146455
146636
  function PrintHQChartVersion()
146456
146637
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var HQCHART_VERSION="1.1.14627";
8
+ var HQCHART_VERSION="1.1.14631";
9
9
 
10
10
  function PrintHQChartVersion()
11
11
  {