hqchart 1.1.13520 → 1.1.13526

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.
@@ -3996,6 +3996,7 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
3996
3996
  this.DivElement=divElement;
3997
3997
  this.DivToolElement=null; //工具条
3998
3998
  this.JSChartContainer; //画图控件
3999
+ this.ResizeListener;
3999
4000
 
4000
4001
  //h5 canvas
4001
4002
  this.CanvasElement=document.createElement("canvas");
@@ -5673,6 +5674,8 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
5673
5674
  this.JSChartContainer=chart;
5674
5675
  chart.DivElement=this.DivElement;
5675
5676
 
5677
+ if (option.EnableResize==true) this.CreateResizeListener();
5678
+
5676
5679
  if (option.DefaultCursor) chart.DefaultCursor=option.DefaultCursor;
5677
5680
  if (option.OnCreatedCallback) option.OnCreatedCallback(chart);
5678
5681
 
@@ -5715,6 +5718,19 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
5715
5718
  }
5716
5719
  }
5717
5720
 
5721
+ this.CreateResizeListener=function()
5722
+ {
5723
+ this.ResizeListener = new ResizeObserver((entries)=>{ this.OnDivResize(entries); });
5724
+ this.ResizeListener.observe(this.DivElement);
5725
+ }
5726
+
5727
+ this.OnDivResize=function(entries)
5728
+ {
5729
+ JSConsole.Chart.Log("[JSChart::OnDivResize] entries=", entries);
5730
+
5731
+ this.OnSize( {Type:1} );
5732
+ }
5733
+
5718
5734
  //创建工具条
5719
5735
  this.CreateToolbar=function(option)
5720
5736
  {
@@ -41950,6 +41966,7 @@ function ChartMultiText()
41950
41966
  {
41951
41967
  var border=this.ChartBorder.GetHScreenBorder();
41952
41968
  var chartright=border.BottomEx;
41969
+ var chartleft=border.TopEx;
41953
41970
  var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
41954
41971
  var left=this.ChartBorder.GetTop();
41955
41972
  var right=this.ChartBorder.GetBottom();
@@ -41961,6 +41978,7 @@ function ChartMultiText()
41961
41978
  var border=this.ChartBorder.GetBorder();
41962
41979
  var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
41963
41980
  var chartright=border.RightEx;
41981
+ var chartleft=border.LeftEx;
41964
41982
  var left=this.ChartBorder.GetLeft();
41965
41983
  var right=this.ChartBorder.GetRight();
41966
41984
  var top=border.TopEx;
@@ -41996,16 +42014,17 @@ function ChartMultiText()
41996
42014
 
41997
42015
  var textWidth=this.Canvas.measureText(item.Text).width;
41998
42016
  this.Canvas.textAlign='center';
41999
- if (x+textWidth/2>=right)
42017
+ if (x+textWidth/2>=chartright)
42000
42018
  {
42001
42019
  this.Canvas.textAlign='right';
42002
- x=right;
42020
+ x=chartright;
42003
42021
  }
42004
- else if (x-textWidth/2<left)
42022
+ else if (x-textWidth/2<chartleft)
42005
42023
  {
42006
42024
  this.Canvas.textAlign = 'left';
42007
- x=left;
42025
+ x=chartleft;
42008
42026
  }
42027
+
42009
42028
  if (item.Baseline==1) this.Canvas.textBaseline='top';
42010
42029
  else if (item.Baseline==2) this.Canvas.textBaseline='bottom';
42011
42030
  else this.Canvas.textBaseline = 'middle';
@@ -125190,18 +125209,76 @@ function JSReportChart(divElement)
125190
125209
  this.DivElement=divElement;
125191
125210
  this.JSChartContainer; //表格控件
125192
125211
 
125193
- //h5 canvas
125194
- this.CanvasElement=document.createElement("canvas");
125195
- this.CanvasElement.className='jsreportlist-drawing';
125196
- this.CanvasElement.id=Guid();
125197
- this.CanvasElement.setAttribute("tabindex",0);
125198
- if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
125199
- if(divElement.hasChildNodes())
125200
- {
125201
- JSConsole.Chart.Log("[JSReportChart::JSReportChart] divElement hasChildNodes", divElement.childNodes);
125202
- }
125203
- divElement.appendChild(this.CanvasElement);
125212
+ //h5 canvas
125213
+ this.CanvasElement=document.createElement("canvas");
125214
+ this.CanvasElement.className='jsreportlist-drawing';
125215
+ this.CanvasElement.id=Guid();
125216
+ this.CanvasElement.setAttribute("tabindex",0);
125217
+ if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
125218
+ if(divElement.hasChildNodes())
125219
+ {
125220
+ JSConsole.Chart.Log("[JSReportChart::JSReportChart] divElement hasChildNodes", divElement.childNodes);
125221
+ }
125222
+ divElement.appendChild(this.CanvasElement);
125223
+
125224
+ //额外的画布
125225
+ this.MapExtraCanvasElement=new Map(); //key=画布名字, value={ Element:, Canvas:}
125226
+
125227
+ this.CreateExtraCanvasElement=function(name, option)
125228
+ {
125229
+ if (this.MapExtraCanvasElement.has(name)) return this.MapExtraCanvasElement.get(name);
125230
+
125231
+ var element=document.createElement("canvas");
125232
+ element.className='jsreportlist-drawing-extra';
125233
+ element.id=Guid();
125234
+ if (name==JSChart.CorssCursorCanvasKey)
125235
+ element.setAttribute("tabindex",5);
125236
+ else
125237
+ element.setAttribute("tabindex",1);
125238
+
125239
+ if (element.style)
125240
+ {
125241
+ element.style.outline='none';
125242
+ element.style.position="absolute";
125243
+ element.style.left='0px';
125244
+ element.style.top='0px';
125245
+ element.style["pointer-events"]="none";
125246
+ }
125247
+
125248
+ if (option)
125249
+ {
125250
+ if (IFrameSplitOperator.IsNumber(option.TabIndex)) element.setAttribute("tabindex",option.TabIndex);
125251
+ if (IFrameSplitOperator.IsNumber(option.ZIndex)) element.style["z-index"]=option.ZIndex;
125252
+ }
125253
+
125254
+ if (this.CanvasElement)
125255
+ {
125256
+ element.height=this.CanvasElement.height;
125257
+ element.width=this.CanvasElement.width;
125258
+ if (element.style)
125259
+ {
125260
+ element.style.width=this.CanvasElement.style.width;
125261
+ element.style.height=this.CanvasElement.style.height
125262
+ }
125263
+ }
125264
+
125265
+ divElement.appendChild(element);
125266
+
125267
+ var item={ Element:element, Canvas:null };
125268
+ this.MapExtraCanvasElement.set(name, item);
125269
+ }
125270
+
125271
+ this.GetExtraCanvas=function(name)
125272
+ {
125273
+ if (!this.MapExtraCanvasElement.has(name)) return null;
125204
125274
 
125275
+ var item=this.MapExtraCanvasElement.get(name);
125276
+ if (!item.Element) return null;
125277
+
125278
+ if (!item.Canvas) item.Canvas=item.Element.getContext("2d");
125279
+
125280
+ return item;
125281
+ }
125205
125282
 
125206
125283
  this.OnSize=function()
125207
125284
  {
@@ -125216,6 +125293,19 @@ function JSReportChart(divElement)
125216
125293
  this.CanvasElement.height*=pixelTatio;
125217
125294
  this.CanvasElement.width*=pixelTatio;
125218
125295
 
125296
+ //扩展画布
125297
+ for(var mapItem of this.MapExtraCanvasElement)
125298
+ {
125299
+ var item=mapItem[1];
125300
+ var element=item.Element;
125301
+ if (!element) continue;
125302
+
125303
+ element.height=this.CanvasElement.height;
125304
+ element.width=this.CanvasElement.width;
125305
+ element.style.width=this.CanvasElement.style.width;
125306
+ element.style.height=this.CanvasElement.style.height;
125307
+ }
125308
+
125219
125309
  JSConsole.Chart.Log(`[JSReportChart::OnSize] devicePixelRatio=${window.devicePixelRatio}, height=${this.CanvasElement.height}, width=${this.CanvasElement.width}`);
125220
125310
 
125221
125311
  if (this.JSChartContainer && this.JSChartContainer.OnSize)
@@ -125377,6 +125467,8 @@ function JSReportChart(divElement)
125377
125467
  }
125378
125468
  }
125379
125469
 
125470
+ JSReportChart.TooltipCursorCanvasKey="hq_report_tooltip"; //提示信息
125471
+
125380
125472
 
125381
125473
  JSReportChart.Init=function(divElement)
125382
125474
  {
@@ -125595,6 +125687,15 @@ function JSReportChartContainer(uielement)
125595
125687
  }
125596
125688
 
125597
125689
 
125690
+ //清空画布
125691
+ this.ClearCanvas=function(canvas)
125692
+ {
125693
+ if (!canvas) return;
125694
+ if (!this.UIElement) return;
125695
+
125696
+ canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);
125697
+ }
125698
+
125598
125699
  //清空固定行数据
125599
125700
  this.ClearFixedRowData=function()
125600
125701
  {
@@ -128843,8 +128944,10 @@ function ChartReport()
128843
128944
  if (item.Type==REPORT_COLUMN_ID.CUSTOM_STRING_TEXT_ID)
128844
128945
  {
128845
128946
  if (!IFrameSplitOperator.IsNumber(item.DataIndex) && !IFrameSplitOperator.IsNumber(item.BlockIndex)) continue;
128947
+ colItem.FormatType=0; //0=默认格式 1=长度不够使用...
128846
128948
  if (IFrameSplitOperator.IsNumber(item.DataIndex)) colItem.DataIndex=item.DataIndex; //数据在扩展数据索引列
128847
128949
  if (IFrameSplitOperator.IsNumber(item.BlockIndex)) colItem.BlockIndex=item.BlockIndex;
128950
+ if (IFrameSplitOperator.IsNumber(item.FormatType)) colItem.FormatType=item.FormatType; //输出样式
128848
128951
  }
128849
128952
  else if (item.Type==REPORT_COLUMN_ID.CUSTOM_NUMBER_TEXT_ID)
128850
128953
  {
@@ -129800,8 +129903,67 @@ function ChartReport()
129800
129903
  }
129801
129904
 
129802
129905
  this.DrawItemBG(drawInfo);
129803
- this.DrawItemText(drawInfo.Text, drawInfo.TextColor, drawInfo.TextAlign, x, top, textWidth, drawInfo.BGColor);
129906
+
129907
+ if (column.Type==REPORT_COLUMN_ID.CUSTOM_STRING_TEXT_ID)
129908
+ this.DrawCustomText(drawInfo,column, x, top, textWidth);
129909
+ else
129910
+ this.DrawItemText(drawInfo.Text, drawInfo.TextColor, drawInfo.TextAlign, x, top, textWidth, drawInfo.BGColor);
129911
+ }
129912
+ }
129913
+
129914
+ this.DrawCustomText=function(drawInfo, column, left, top, cellWidth)
129915
+ {
129916
+ if (!drawInfo.Text) return;
129917
+
129918
+ var text=drawInfo.Text;
129919
+ var x=left;
129920
+ if (drawInfo.TextAlign=='center')
129921
+ {
129922
+ x=left+cellWidth/2;
129923
+ this.Canvas.textAlign="center";
129924
+ }
129925
+ else if (drawInfo.TextAlign=='right')
129926
+ {
129927
+ x=left+cellWidth-2;
129928
+ this.Canvas.textAlign="right";
129929
+ }
129930
+ else
129931
+ {
129932
+ x+=2;
129933
+ this.Canvas.textAlign="left";
129934
+ }
129935
+
129936
+ var textWidth=this.Canvas.measureText(text).width+1;
129937
+ var bClip=false;
129938
+ if (textWidth>=cellWidth) //长度超过单元格 裁剪
129939
+ {
129940
+ if (column.FormatType==2)
129941
+ {
129942
+ var count=text.length+5;
129943
+ text="";
129944
+ for(var i=0;i<count;++i)
129945
+ text+="#";
129946
+ }
129947
+ else if (column.FormatType==1)
129948
+ {
129949
+ text=this.TextEllipsis(text, cellWidth, column.MaxText);
129950
+ }
129951
+
129952
+ this.Canvas.save();
129953
+ bClip=true;
129954
+
129955
+ var rtCell={ Left:left, Top:top+this.ItemMergin.Top, Width:cellWidth, Height:this.RowHeight };
129956
+ this.Canvas.beginPath();
129957
+ this.Canvas.rect(rtCell.Left, rtCell.Top, rtCell.Width, rtCell.Height);
129958
+ //this.Canvas.stroke(); //调试用
129959
+ this.Canvas.clip();
129804
129960
  }
129961
+
129962
+ this.Canvas.textBaseline="middle";
129963
+ this.Canvas.fillStyle=drawInfo.TextColor;
129964
+ this.Canvas.fillText(text,x,top+this.ItemMergin.Top+this.RowHeight/2);
129965
+
129966
+ if (bClip) this.Canvas.restore();
129805
129967
  }
129806
129968
 
129807
129969
  this.DrawSymbolName=function(data, column, left, top, rowType)
@@ -138654,7 +138816,7 @@ function HQChartScriptWorker()
138654
138816
 
138655
138817
 
138656
138818
 
138657
- var HQCHART_VERSION="1.1.13519";
138819
+ var HQCHART_VERSION="1.1.13525";
138658
138820
 
138659
138821
  function PrintHQChartVersion()
138660
138822
  {