hqchart 1.1.14628 → 1.1.14630

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.
@@ -36737,28 +36737,87 @@ function ChartKLineTable()
36737
36737
  this.ClassName='ChartKlineTable'; //类名
36738
36738
  this.Data;
36739
36739
  this.RowName;
36740
- this.IsShowRowName=false;
36740
+ this.RowNamePosition=1; //0=不显示 1=左边内部 2=左边外部 3=右边外部
36741
36741
  this.BGColor; //背景色
36742
+ this.BorderColor; //分割线颜色
36742
36743
 
36743
36744
  this.RowCount=5; //行数
36744
36745
  this.RowHeight=10; //行高
36746
+ this.RowHeightType=1; //0=均分 1=固定高度
36745
36747
  this.TextFontConfig=CloneData(g_JSChartResource.ChartKLineTable.TextFont);
36746
36748
  this.ItemMergin=CloneData(g_JSChartResource.ChartKLineTable.ItemMergin);
36747
36749
 
36748
36750
  this.TextFont;
36749
36751
  this.TextColor='rgb(0,0,0)';
36750
- this.NameColor="rgb(0,0,0)";
36751
36752
 
36752
- this.Draw=function()
36753
+ this.AryTableData=[];
36754
+ this.MapCache=null; //key=date/date-time value={ Date:, Time:, Data:[ ] }
36755
+ this.GetKValue=ChartData.GetKValue;
36756
+
36757
+ this.BuildCacheData=function()
36753
36758
  {
36754
- if (!this.IsShow || this.ChartFrame.IsMinSize) return;
36755
- if (this.NotSupportMessage)
36759
+ var mapData=new Map();
36760
+ this.MapCache=mapData;
36761
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryTableData)) return;
36762
+
36763
+ for(var i=0;i<this.AryTableData.length;++i)
36756
36764
  {
36757
- this.DrawNotSupportmessage();
36758
- return;
36765
+ var item=this.AryTableData[i];
36766
+ var key=this.BuildKey(item);
36767
+ mapData.set(key,item);
36759
36768
  }
36769
+ }
36760
36770
 
36761
- if (!this.Data || !this.Data.Data) return;
36771
+ //绘制背景色
36772
+ this.DrawBG=function(rtBG)
36773
+ {
36774
+ if (!this.BGColor) return;
36775
+
36776
+ if (this.BGColor)
36777
+ {
36778
+ this.Canvas.fillStyle=this.BGColor;
36779
+ this.Canvas.fillRect(rtBG.Left+1, rtBG.Top, rtBG.Width-1, rtBG.Height);
36780
+ }
36781
+ }
36782
+
36783
+ this.DrawBorder=function(rtBG)
36784
+ {
36785
+ if (!this.BorderColor) return;
36786
+
36787
+ var yLine=rtBG.Top;
36788
+ for(var i=0;i<30;++i)
36789
+ {
36790
+ this.Canvas.beginPath();
36791
+ this.Canvas.moveTo(rtBG.Left,ToFixedPoint(yLine));
36792
+ this.Canvas.lineTo(rtBG.Right,ToFixedPoint(yLine));
36793
+ this.Canvas.stroke();
36794
+
36795
+ yLine+=this.RowHeight;
36796
+ if (yLine>=rtBG.Bottom) break;
36797
+ }
36798
+ }
36799
+
36800
+ //计算行高
36801
+ this.CalculateRowHeight=function(rtBG)
36802
+ {
36803
+ if (this.RowHeightType==1)
36804
+ {
36805
+ this.RowHeight=this.TextFontConfig.FontMaxSize+this.ItemMergin.Top+this.ItemMergin.Bottom;
36806
+ }
36807
+ else
36808
+ {
36809
+ this.RowHeight=rtBG.Height/this.RowCount;
36810
+ }
36811
+ }
36812
+
36813
+ this.Draw=function()
36814
+ {
36815
+ if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
36816
+ if (this.IsShowIndexTitleOnly()) return;
36817
+ if (this.IsHideScriptIndex()) return;
36818
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryTableData)) return;
36819
+ if (!this.MapCache || this.MapCache.size<=0) return;
36820
+ if(!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
36762
36821
 
36763
36822
  var isHScreen=(this.ChartFrame.IsHScreen===true);
36764
36823
  if (isHScreen) return;
@@ -36769,24 +36828,22 @@ function ChartKLineTable()
36769
36828
  var xPointCount=this.ChartFrame.XPointCount;
36770
36829
  var border=this.ChartFrame.GetBorder();
36771
36830
  var height=border.Bottom-border.TopTitle;
36772
- this.RowHeight=height/this.RowCount;
36773
36831
  var xOffset=border.LeftEx+g_JSChartResource.FrameLeftMargin;
36774
36832
  var chartright=border.RightEx;
36775
36833
  var top=border.TopTitle;
36776
36834
  var bottom=border.Bottom;
36777
36835
 
36778
- if (this.BGColor)
36779
- {
36780
- this.Canvas.fillStyle=this.BGColor;
36781
- var left=border.LeftEx;
36782
- var width=border.RightEx-border.LeftEx;
36783
- var height=bottom-top;
36784
- this.Canvas.fillRect(left, top, width, height);
36785
- }
36836
+ //绘制背景
36837
+ var rtBG={ Left:border.LeftEx, Top:top, Right:border.RightEx, Bottom:bottom };
36838
+ rtBG.Width=rtBG.Right-rtBG.Left;
36839
+ rtBG.Height=rtBG.Bottom-rtBG.Top;
36840
+ this.DrawBG(rtBG);
36786
36841
 
36842
+ this.CalculateRowHeight(rtBG);
36843
+
36787
36844
  var itemHeight=this.RowHeight;
36788
36845
  var itemWidth=dataWidth+distanceWidth;
36789
- if (itemHeight-this.ItemMergin.Top-this.ItemMergin.Bottom>0) itemHeight=itemHeight-this.ItemMergin.Left-this.ItemMergin.Right;
36846
+ if (itemHeight-this.ItemMergin.Top-this.ItemMergin.Bottom>0) itemHeight=itemHeight-this.ItemMergin.Top-this.ItemMergin.Bottom;
36790
36847
  if (itemWidth-this.ItemMergin.Left-this.ItemMergin.Right>0) itemWidth=itemWidth-this.ItemMergin.Left-this.ItemMergin.Right;
36791
36848
 
36792
36849
  var font=this.GetDynamicTextFont(itemHeight, itemWidth);
@@ -36795,8 +36852,8 @@ function ChartKLineTable()
36795
36852
 
36796
36853
  for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
36797
36854
  {
36798
- var item=this.Data.Data[i];
36799
- if (!item) continue;
36855
+ var kItem=this.Data.Data[i];
36856
+ if (!kItem) continue;
36800
36857
 
36801
36858
  var left=xOffset;
36802
36859
  var right=xOffset+dataWidth+distanceWidth;
@@ -36804,15 +36861,20 @@ function ChartKLineTable()
36804
36861
  var x=left+(right-left)/2;
36805
36862
  if (x>chartright) break;
36806
36863
 
36807
- if (j==0 && this.IsShowRowName)
36808
- {
36809
- this.DrawRowName(top, bottom, left, right);
36810
- }
36811
- else
36812
- {
36813
- this.DrawRow(item, top, bottom, left, right); //绘制一列
36814
- }
36864
+ var bDrawName=false;
36865
+ if (j==0 && this.RowNamePosition===1) bDrawName=true;
36866
+ if (bDrawName) this.DrawRowName(top, bottom, left, right);
36867
+
36868
+ var key=this.BuildKey(kItem);
36869
+ if (!this.MapCache.has(key)) continue;
36870
+ var mapItem=this.MapCache.get(key);
36871
+
36872
+ if (!bDrawName) this.DrawRow(mapItem, top, bottom, left, right); //绘制一列
36815
36873
  }
36874
+
36875
+ if (this.RowNamePosition==3) this.DrawRightRowName();
36876
+
36877
+ this.DrawBorder(rtBG);
36816
36878
  }
36817
36879
 
36818
36880
  this.DrawRowName=function(top, bottom, left, right)
@@ -36820,32 +36882,35 @@ function ChartKLineTable()
36820
36882
  if (!IFrameSplitOperator.IsNonEmptyArray(this.RowName)) return;
36821
36883
 
36822
36884
  var x=left,y=top, width=right-left;
36885
+ var yOffset=3;
36886
+ if (this.ItemMergin.YOffset) yOffset=this.ItemMergin.YOffset;
36823
36887
  for(var i=0;i<this.RowName.length;++i)
36824
36888
  {
36825
36889
  var item=this.RowName[i];
36826
36890
 
36827
36891
  var rtBG={Left:x, Top:y, Right:right, Height:this.RowHeight, Width:width };
36828
36892
  rtBG.Bottom=rtBG.Top+this.RowHeight;
36893
+ var yText=rtBG.Bottom-yOffset;
36829
36894
 
36830
36895
  if (item.Name && rtBG.Width>10)
36831
36896
  {
36832
36897
  this.Canvas.fillStyle=item.Color?item.Color:this.TextColor;
36833
- this.Canvas.textBaseline='middle';
36898
+ this.Canvas.textBaseline='bottom';
36834
36899
 
36835
36900
  if (item.TextAlign=='right')
36836
36901
  {
36837
36902
  this.Canvas.textAlign='right';
36838
- this.Canvas.fillText(item.Name,rtBG.Right-2,rtBG.Top+this.RowHeight/2, width-4);
36903
+ this.Canvas.fillText(item.Name,rtBG.Right-2,yText, width-4);
36839
36904
  }
36840
36905
  else if (item.TextAlign=='center')
36841
36906
  {
36842
36907
  this.Canvas.textAlign='center';
36843
- this.Canvas.fillText(item.Name,rtBG.Left+rtBG.Width/2,rtBG.Top+this.RowHeight/2, width-4);
36908
+ this.Canvas.fillText(item.Name,rtBG.Left+rtBG.Width/2,yText, width-4);
36844
36909
  }
36845
36910
  else
36846
36911
  {
36847
36912
  this.Canvas.textAlign='left';
36848
- this.Canvas.fillText(item.Name,rtBG.Left+2,rtBG.Top+this.RowHeight/2, width-4);
36913
+ this.Canvas.fillText(item.Name,rtBG.Left+2,yText, width-4);
36849
36914
  }
36850
36915
  }
36851
36916
 
@@ -36853,40 +36918,129 @@ function ChartKLineTable()
36853
36918
  }
36854
36919
  }
36855
36920
 
36921
+ //绘制右侧行名
36922
+ this.DrawRightRowName=function()
36923
+ {
36924
+ var border=this.ChartFrame.GetBorder();
36925
+
36926
+ if (this.BGColor)
36927
+ {
36928
+ var rtRightBG={Left:border.RightEx, Top:border.TopTitle, Right:border.ChartWidth, Bottom:border.Bottom };
36929
+ rtRightBG.Width=rtRightBG.Right-rtRightBG.Left;
36930
+ rtRightBG.Height=rtRightBG.Bottom-rtRightBG.Top;
36931
+ this.Canvas.fillStyle=this.BGColor;
36932
+ this.Canvas.fillRect(rtRightBG.Left+1, rtRightBG.Top, rtRightBG.Width-1, rtRightBG.Height);
36933
+ }
36934
+
36935
+ var x=border.RightEx, y=border.TopTitle;
36936
+ var yOffset=3;
36937
+ if (this.ItemMergin.YOffset) yOffset=this.ItemMergin.YOffset;
36938
+ for(var i=0;i<this.RowName.length;++i)
36939
+ {
36940
+ var item=this.RowName[i];
36941
+
36942
+ var rtBG={Left:x, Top:y, Right:border.ChartWidth, Height:this.RowHeight };
36943
+ rtBG.Bottom=rtBG.Top+this.RowHeight;
36944
+ rtBG.Width=rtBG.Right-rtBG.Left;
36945
+ var yText=rtBG.Bottom-yOffset;
36946
+
36947
+ if (item.Name && rtBG.Width>10)
36948
+ {
36949
+ this.Canvas.fillStyle=item.Color?item.Color:this.TextColor;
36950
+ this.Canvas.textBaseline='bottom';
36951
+ this.Canvas.textAlign='left';
36952
+ this.Canvas.fillText(item.Name,rtBG.Left+2,yText);
36953
+ }
36954
+
36955
+ y+=this.RowHeight;
36956
+ }
36957
+ }
36958
+
36959
+
36856
36960
  this.DrawRow=function(data, top, bottom, left, right)
36857
36961
  {
36962
+ if (!IFrameSplitOperator.IsNonEmptyArray(data.Data)) return;
36963
+
36858
36964
  var x=left,y=top, width=right-left;
36859
- for(var i=0;i<data.length;++i)
36965
+ var yOffset=3;
36966
+ if (this.ItemMergin.YOffset) yOffset=this.ItemMergin.YOffset;
36967
+ for(var i=0;i<data.Data.length;++i)
36860
36968
  {
36861
- var item=data[i];
36969
+ var item=data.Data[i];
36862
36970
  var rtBG={Left:x, Top:y, Right:right, Height:this.RowHeight, Width:width };
36863
36971
  rtBG.Bottom=rtBG.Top+this.RowHeight;
36864
36972
 
36865
- if (item.BGColor)
36973
+ if (IFrameSplitOperator.IsNonEmptyArray(item.AryText)) //左右显示
36866
36974
  {
36867
- this.Canvas.fillStyle=item.BGColor;
36868
- this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
36869
- }
36975
+ var subCellWidth=rtBG.Width/item.AryText.length;
36976
+ var xCell=rtBG.Left;
36977
+ for(var j=0;j<item.AryText.length;++j)
36978
+ {
36979
+ var subItem=item.AryText[j];
36980
+ var rtSubBG={ Left:xCell, Top:rtBG.Top, Bottom:rtBG.Bottom, Width:subCellWidth, Height:rtBG.Height };
36981
+ rtSubBG.Right=rtSubBG.Left+rtSubBG.Width;
36870
36982
 
36871
- if (item.Color && rtBG.Width>10)
36872
- {
36873
- this.Canvas.fillStyle=item.Color;
36874
- this.Canvas.textBaseline='middle';
36983
+ if (subItem && subItem.BGColor)
36984
+ {
36985
+ this.Canvas.fillStyle=subItem.BGColor;
36986
+ this.Canvas.fillRect(rtSubBG.Left, rtSubBG.Top, rtSubBG.Width, rtSubBG.Height);
36987
+ }
36875
36988
 
36876
- if (item.TextAlign=='right')
36877
- {
36878
- this.Canvas.textAlign='right';
36879
- this.Canvas.fillText(item.Text,rtBG.Right-2,rtBG.Top+this.RowHeight/2, width-4);
36989
+ if (subItem && subItem.Color && subCellWidth>10)
36990
+ {
36991
+ this.Canvas.fillStyle=subItem.Color;
36992
+ this.Canvas.textBaseline='bottom';
36993
+ var yText=rtSubBG.Bottom-yOffset;
36994
+
36995
+ if (subItem.TextAlign=='right')
36996
+ {
36997
+ this.Canvas.textAlign='right';
36998
+ this.Canvas.fillText(subItem.Text,rtSubBG.Right-2,yText, width-4);
36999
+ }
37000
+ else if (subItem.TextAlign=='center')
37001
+ {
37002
+ this.Canvas.textAlign='center';
37003
+ this.Canvas.fillText(subItem.Text,rtSubBG.Left+rtSubBG.Width/2,yText, width-4);
37004
+ }
37005
+ else
37006
+ {
37007
+ this.Canvas.textAlign='left';
37008
+ this.Canvas.fillText(subItem.Text,rtSubBG.Left+2,yText, width-4);
37009
+ }
37010
+ }
37011
+
37012
+ xCell+=subCellWidth;
36880
37013
  }
36881
- else if (item.TextAlign=='center')
37014
+ }
37015
+ else
37016
+ {
37017
+ if (item && item.BGColor)
36882
37018
  {
36883
- this.Canvas.textAlign='center';
36884
- this.Canvas.fillText(item.Text,rtBG.Left+rtBG.Width/2,rtBG.Top+this.RowHeight/2, width-4);
37019
+ this.Canvas.fillStyle=item.BGColor;
37020
+ this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
36885
37021
  }
36886
- else
37022
+
37023
+ if (item && item.Color && rtBG.Width>10)
36887
37024
  {
36888
- this.Canvas.textAlign='left';
36889
- this.Canvas.fillText(item.Text,rtBG.Left+2,rtBG.Top+this.RowHeight/2, width-4);
37025
+ this.Canvas.fillStyle=item.Color;
37026
+ this.Canvas.textBaseline='bottom';
37027
+ var yText=rtBG.Bottom-yOffset;
37028
+
37029
+ if (item.TextAlign=='right')
37030
+ {
37031
+ this.Canvas.textAlign='right';
37032
+ this.Canvas.fillText(item.Text,rtBG.Right-2,yText, width-4);
37033
+ }
37034
+ else if (item.TextAlign=='center')
37035
+ {
37036
+ this.Canvas.textAlign='center';
37037
+ this.Canvas.fillText(item.Text,rtBG.Left+rtBG.Width/2,yText, width-4);
37038
+ }
37039
+ else
37040
+ {
37041
+ this.Canvas.textAlign='left';
37042
+ this.Canvas.fillText(item.Text,rtBG.Left+2,yText, width-4);
37043
+ }
36890
37044
  }
36891
37045
  }
36892
37046
 
@@ -126567,16 +126721,41 @@ function ScriptIndex(name,script,args,option)
126567
126721
  chart.HQChart=hqChart;
126568
126722
  chart.Identify=this.Guid;
126569
126723
 
126570
- chart.Data.Data=varItem.Draw.DrawData;
126724
+ chart.Data=hqChart.GetKData(); //绑定K线
126725
+ chart.AryTableData=varItem.Draw.DrawData;
126571
126726
  if (IFrameSplitOperator.IsNumber(varItem.Draw.RowCount)) chart.RowCount=varItem.Draw.RowCount;
126572
- if (IFrameSplitOperator.IsBool(varItem.Draw.IsShowRowName)) chart.IsShowRowName=varItem.Draw.IsShowRowName;
126573
126727
  if (IFrameSplitOperator.IsNonEmptyArray(varItem.Draw.RowName)) chart.RowName=varItem.Draw.RowName;
126574
- if (varItem.Draw.BGColor) chart.BGColor=varItem.Draw.BGColor;
126575
126728
 
126729
+ var config=varItem.Draw.Config;
126730
+ if (config)
126731
+ {
126732
+ if (config.BGColor) chart.BGColor=config.BGColor;
126733
+ if (config.TextColor) chart.TextColor=config.TextColor;
126734
+ if (config.BorderColor) chart.BorderColor=config.BorderColor;
126735
+ if (IFrameSplitOperator.IsNumber(config.RowNamePosition)) chart.RowNamePosition=config.RowNamePosition;
126736
+
126737
+ if (config.ItemMergin)
126738
+ {
126739
+ var subItem=config.ItemMergin;
126740
+ if (IFrameSplitOperator.IsNumber(subItem.Left)) chart.ItemMergin.Left=subItem.Left;
126741
+ if (IFrameSplitOperator.IsNumber(subItem.Top)) chart.ItemMergin.Top=subItem.Top;
126742
+ if (IFrameSplitOperator.IsNumber(subItem.Bottom)) chart.ItemMergin.Bottom=subItem.Bottom;
126743
+ if (IFrameSplitOperator.IsNumber(subItem.Right)) chart.ItemMergin.Right=subItem.Right;
126744
+ if (IFrameSplitOperator.IsNumber(subItem.YOffset)) chart.ItemMergin.YOffset=subItem.YOffset;
126745
+ }
126746
+
126747
+ if (config.TextFont)
126748
+ {
126749
+ var subItem=config.TextFont;
126750
+ if (IFrameSplitOperator.IsNumber(subItem.FontMaxSize)) chart.TextFontConfig.FontMaxSize=subItem.FontMaxSize;
126751
+ if (subItem.Family) chart.TextFontConfig.Family=subItem.Family;
126752
+ }
126753
+ }
126754
+
126755
+ chart.BuildCacheData();
126576
126756
  hqChart.ChartPaint.push(chart);
126577
126757
 
126578
126758
  var titleIndex=windowIndex+1;
126579
-
126580
126759
  var titleData=new DynamicTitleData(chart.Data,chart.BarName,chart.BarColor);
126581
126760
  titleData.DataType="ChartKLineTable";
126582
126761
  hqChart.TitlePaint[titleIndex].Data[i]=titleData;
@@ -129568,13 +129747,11 @@ function APIScriptIndex(name,script,args,option, isOverlay)
129568
129747
  drawItem.Name=draw.Name;
129569
129748
  drawItem.Type=draw.Type;
129570
129749
  drawItem.DrawType=draw.DrawType;
129571
- drawItem.DrawData=this.FittingArray(draw.DrawData,date,time,hqChart,1);
129750
+ drawItem.DrawData=draw.DrawData;
129572
129751
  drawItem.RowCount=draw.RowCount;
129573
129752
  drawItem.RowName=draw.RowName;
129574
- drawItem.IsShowRowName=draw.IsShowRowName;
129575
- drawItem.BGColor=draw.BGColor;
129753
+ drawItem.Config=draw.Config;
129576
129754
  outVarItem.Draw=drawItem;
129577
-
129578
129755
  result.push(outVarItem);
129579
129756
  }
129580
129757
  else if (draw.DrawType=='MULTI_TEXT')
@@ -157162,7 +157339,7 @@ function HQChartScriptWorker()
157162
157339
 
157163
157340
 
157164
157341
 
157165
- var HQCHART_VERSION="1.1.14627";
157342
+ var HQCHART_VERSION="1.1.14629";
157166
157343
 
157167
157344
  function PrintHQChartVersion()
157168
157345
  {