hqchart 1.1.13516 → 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);
125204
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;
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)
@@ -125266,6 +125356,9 @@ function JSReportChart(divElement)
125266
125356
  if (IFrameSplitOperator.IsBool(option.EnableDragRow)) chart.EnableDragRow=option.EnableDragRow;
125267
125357
  if (IFrameSplitOperator.IsNumber(option.DragRowType)) chart.DragRowType=option.DragRowType;
125268
125358
  if (IFrameSplitOperator.IsBool(option.EnableDragHeader)) chart.EnableDragHeader=option.EnableDragHeader;
125359
+ if (IFrameSplitOperator.IsNumber(option.WheelPageType)) chart.WheelPageType=option.WheelPageType;
125360
+ if (IFrameSplitOperator.IsBool(option.PageUpDownCycle)) chart.PageUpDownCycle=option.PageUpDownCycle;
125361
+
125269
125362
  if (option.VScrollbar) chart.SetVScrollbar(option.VScrollbar);
125270
125363
  if (option.SortInfo)
125271
125364
  {
@@ -125374,6 +125467,8 @@ function JSReportChart(divElement)
125374
125467
  }
125375
125468
  }
125376
125469
 
125470
+ JSReportChart.TooltipCursorCanvasKey="hq_report_tooltip"; //提示信息
125471
+
125377
125472
 
125378
125473
  JSReportChart.Init=function(divElement)
125379
125474
  {
@@ -125511,6 +125606,7 @@ function JSReportChartContainer(uielement)
125511
125606
 
125512
125607
  this.PageUpDownCycle=true; //翻页循环
125513
125608
  this.DragPageCycle=true; //手机翻页循环
125609
+ this.WheelPageType=0; //鼠标滚轴翻页模式 0=一页一页翻 1=一条一条翻
125514
125610
 
125515
125611
  //拖拽滚动条
125516
125612
  this.DragXScroll=null; //{Start:{x,y}, End:{x, y}}
@@ -125591,6 +125687,15 @@ function JSReportChartContainer(uielement)
125591
125687
  }
125592
125688
 
125593
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
+
125594
125699
  //清空固定行数据
125595
125700
  this.ClearFixedRowData=function()
125596
125701
  {
@@ -126535,20 +126640,43 @@ function JSReportChartContainer(uielement)
126535
126640
  if (!IFrameSplitOperator.IsObjectExist(e.wheelDelta))
126536
126641
  wheelValue=e.deltaY* -0.01;
126537
126642
 
126538
- if (wheelValue<0) //下一页
126643
+ if (this.WheelPageType==1)
126539
126644
  {
126540
- if (this.GotoNextPage(this.PageUpDownCycle))
126645
+ console.log(`[OnWheel] wheelValue=${wheelValue}`);
126646
+ if (wheelValue<0) //下
126541
126647
  {
126542
- this.Draw();
126543
- this.DelayUpdateStockData();
126648
+ if (this.GotoNextItem(1))
126649
+ {
126650
+ this.Draw();
126651
+ this.DelayUpdateStockData();
126652
+ }
126653
+ }
126654
+ else if (wheelValue>0) //上
126655
+ {
126656
+ if (this.GotoNextItem(-1))
126657
+ {
126658
+ this.Draw();
126659
+ this.DelayUpdateStockData();
126660
+ }
126544
126661
  }
126545
126662
  }
126546
- else if (wheelValue>0) //上一页
126663
+ else
126547
126664
  {
126548
- if (this.GotoPreviousPage(this.PageUpDownCycle))
126665
+ if (wheelValue<0) //下一页
126549
126666
  {
126550
- this.Draw();
126551
- this.DelayUpdateStockData();
126667
+ if (this.GotoNextPage(this.PageUpDownCycle))
126668
+ {
126669
+ this.Draw();
126670
+ this.DelayUpdateStockData();
126671
+ }
126672
+ }
126673
+ else if (wheelValue>0) //上一页
126674
+ {
126675
+ if (this.GotoPreviousPage(this.PageUpDownCycle))
126676
+ {
126677
+ this.Draw();
126678
+ this.DelayUpdateStockData();
126679
+ }
126552
126680
  }
126553
126681
  }
126554
126682
 
@@ -127424,6 +127552,43 @@ function JSReportChartContainer(uielement)
127424
127552
  return chart;
127425
127553
  }
127426
127554
 
127555
+ this.GotoNextItem=function(step)
127556
+ {
127557
+ if (step==0) return false;
127558
+ if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return false;
127559
+ var chart=this.ChartPaint[0];
127560
+ if (!chart) return false;
127561
+ var pageSize=chart.GetPageSize();
127562
+ if (pageSize>this.Data.Data.length) return false;
127563
+
127564
+ var moveCount=0;
127565
+ if (step>0)
127566
+ {
127567
+ for(var i=0;i<step;++i)
127568
+ {
127569
+ if (this.Data.YOffset+pageSize>=this.Data.Data.length)
127570
+ break;
127571
+
127572
+ ++this.Data.YOffset;
127573
+ ++moveCount;
127574
+ }
127575
+ }
127576
+ else if (step<0)
127577
+ {
127578
+ step=Math.abs(step);
127579
+ for(var i=0;i<step;++i)
127580
+ {
127581
+ if (this.Data.YOffset<=0)
127582
+ break;
127583
+
127584
+ --this.Data.YOffset;
127585
+ ++moveCount;
127586
+ }
127587
+ }
127588
+
127589
+ return moveCount>0
127590
+ }
127591
+
127427
127592
  this.GotoNextPage=function(bCycle) //bCycle 是否循环
127428
127593
  {
127429
127594
  if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return false;
@@ -128779,8 +128944,10 @@ function ChartReport()
128779
128944
  if (item.Type==REPORT_COLUMN_ID.CUSTOM_STRING_TEXT_ID)
128780
128945
  {
128781
128946
  if (!IFrameSplitOperator.IsNumber(item.DataIndex) && !IFrameSplitOperator.IsNumber(item.BlockIndex)) continue;
128947
+ colItem.FormatType=0; //0=默认格式 1=长度不够使用...
128782
128948
  if (IFrameSplitOperator.IsNumber(item.DataIndex)) colItem.DataIndex=item.DataIndex; //数据在扩展数据索引列
128783
128949
  if (IFrameSplitOperator.IsNumber(item.BlockIndex)) colItem.BlockIndex=item.BlockIndex;
128950
+ if (IFrameSplitOperator.IsNumber(item.FormatType)) colItem.FormatType=item.FormatType; //输出样式
128784
128951
  }
128785
128952
  else if (item.Type==REPORT_COLUMN_ID.CUSTOM_NUMBER_TEXT_ID)
128786
128953
  {
@@ -129736,10 +129903,69 @@ function ChartReport()
129736
129903
  }
129737
129904
 
129738
129905
  this.DrawItemBG(drawInfo);
129739
- 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);
129740
129911
  }
129741
129912
  }
129742
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();
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();
129967
+ }
129968
+
129743
129969
  this.DrawSymbolName=function(data, column, left, top, rowType)
129744
129970
  {
129745
129971
  var stock=data.Stock;
@@ -131536,6 +131762,11 @@ function ChartVScrollbar()
131536
131762
  var rtBar = {Right:right-this.Mergin.Right, Top:y, Width:buttonSize, Height: this.ScrollBarHeight };
131537
131763
  rtBar.Left=rtBar.Right-buttonSize;
131538
131764
  rtBar.Bottom=rtBar.Top+rtBar.Height;
131765
+ if (rtBar.Bottom>rtBottom.Top-2)
131766
+ {
131767
+ rtBar.Bottom=rtBottom.Top-2;
131768
+ rtBar.Top=rtBar.Bottom-rtBar.Height;
131769
+ }
131539
131770
 
131540
131771
  this.RectScroll.Top=rtTop;
131541
131772
  this.RectScroll.Bottom=rtBottom;
@@ -138585,7 +138816,7 @@ function HQChartScriptWorker()
138585
138816
 
138586
138817
 
138587
138818
 
138588
- var HQCHART_VERSION="1.1.13515";
138819
+ var HQCHART_VERSION="1.1.13525";
138589
138820
 
138590
138821
  function PrintHQChartVersion()
138591
138822
  {