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.
@@ -3952,6 +3952,7 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
3952
3952
  this.DivElement=divElement;
3953
3953
  this.DivToolElement=null; //工具条
3954
3954
  this.JSChartContainer; //画图控件
3955
+ this.ResizeListener;
3955
3956
 
3956
3957
  //h5 canvas
3957
3958
  this.CanvasElement=document.createElement("canvas");
@@ -5629,6 +5630,8 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
5629
5630
  this.JSChartContainer=chart;
5630
5631
  chart.DivElement=this.DivElement;
5631
5632
 
5633
+ if (option.EnableResize==true) this.CreateResizeListener();
5634
+
5632
5635
  if (option.DefaultCursor) chart.DefaultCursor=option.DefaultCursor;
5633
5636
  if (option.OnCreatedCallback) option.OnCreatedCallback(chart);
5634
5637
 
@@ -5671,6 +5674,19 @@ function JSChart(divElement, bOffscreen, bCacheCanvas)
5671
5674
  }
5672
5675
  }
5673
5676
 
5677
+ this.CreateResizeListener=function()
5678
+ {
5679
+ this.ResizeListener = new ResizeObserver((entries)=>{ this.OnDivResize(entries); });
5680
+ this.ResizeListener.observe(this.DivElement);
5681
+ }
5682
+
5683
+ this.OnDivResize=function(entries)
5684
+ {
5685
+ JSConsole.Chart.Log("[JSChart::OnDivResize] entries=", entries);
5686
+
5687
+ this.OnSize( {Type:1} );
5688
+ }
5689
+
5674
5690
  //创建工具条
5675
5691
  this.CreateToolbar=function(option)
5676
5692
  {
@@ -41906,6 +41922,7 @@ function ChartMultiText()
41906
41922
  {
41907
41923
  var border=this.ChartBorder.GetHScreenBorder();
41908
41924
  var chartright=border.BottomEx;
41925
+ var chartleft=border.TopEx;
41909
41926
  var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
41910
41927
  var left=this.ChartBorder.GetTop();
41911
41928
  var right=this.ChartBorder.GetBottom();
@@ -41917,6 +41934,7 @@ function ChartMultiText()
41917
41934
  var border=this.ChartBorder.GetBorder();
41918
41935
  var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
41919
41936
  var chartright=border.RightEx;
41937
+ var chartleft=border.LeftEx;
41920
41938
  var left=this.ChartBorder.GetLeft();
41921
41939
  var right=this.ChartBorder.GetRight();
41922
41940
  var top=border.TopEx;
@@ -41952,16 +41970,17 @@ function ChartMultiText()
41952
41970
 
41953
41971
  var textWidth=this.Canvas.measureText(item.Text).width;
41954
41972
  this.Canvas.textAlign='center';
41955
- if (x+textWidth/2>=right)
41973
+ if (x+textWidth/2>=chartright)
41956
41974
  {
41957
41975
  this.Canvas.textAlign='right';
41958
- x=right;
41976
+ x=chartright;
41959
41977
  }
41960
- else if (x-textWidth/2<left)
41978
+ else if (x-textWidth/2<chartleft)
41961
41979
  {
41962
41980
  this.Canvas.textAlign = 'left';
41963
- x=left;
41981
+ x=chartleft;
41964
41982
  }
41983
+
41965
41984
  if (item.Baseline==1) this.Canvas.textBaseline='top';
41966
41985
  else if (item.Baseline==2) this.Canvas.textBaseline='bottom';
41967
41986
  else this.Canvas.textBaseline = 'middle';
@@ -125146,18 +125165,76 @@ function JSReportChart(divElement)
125146
125165
  this.DivElement=divElement;
125147
125166
  this.JSChartContainer; //表格控件
125148
125167
 
125149
- //h5 canvas
125150
- this.CanvasElement=document.createElement("canvas");
125151
- this.CanvasElement.className='jsreportlist-drawing';
125152
- this.CanvasElement.id=Guid();
125153
- this.CanvasElement.setAttribute("tabindex",0);
125154
- if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
125155
- if(divElement.hasChildNodes())
125156
- {
125157
- JSConsole.Chart.Log("[JSReportChart::JSReportChart] divElement hasChildNodes", divElement.childNodes);
125158
- }
125159
- divElement.appendChild(this.CanvasElement);
125168
+ //h5 canvas
125169
+ this.CanvasElement=document.createElement("canvas");
125170
+ this.CanvasElement.className='jsreportlist-drawing';
125171
+ this.CanvasElement.id=Guid();
125172
+ this.CanvasElement.setAttribute("tabindex",0);
125173
+ if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
125174
+ if(divElement.hasChildNodes())
125175
+ {
125176
+ JSConsole.Chart.Log("[JSReportChart::JSReportChart] divElement hasChildNodes", divElement.childNodes);
125177
+ }
125178
+ divElement.appendChild(this.CanvasElement);
125179
+
125180
+ //额外的画布
125181
+ this.MapExtraCanvasElement=new Map(); //key=画布名字, value={ Element:, Canvas:}
125182
+
125183
+ this.CreateExtraCanvasElement=function(name, option)
125184
+ {
125185
+ if (this.MapExtraCanvasElement.has(name)) return this.MapExtraCanvasElement.get(name);
125160
125186
 
125187
+ var element=document.createElement("canvas");
125188
+ element.className='jsreportlist-drawing-extra';
125189
+ element.id=Guid();
125190
+ if (name==JSChart.CorssCursorCanvasKey)
125191
+ element.setAttribute("tabindex",5);
125192
+ else
125193
+ element.setAttribute("tabindex",1);
125194
+
125195
+ if (element.style)
125196
+ {
125197
+ element.style.outline='none';
125198
+ element.style.position="absolute";
125199
+ element.style.left='0px';
125200
+ element.style.top='0px';
125201
+ element.style["pointer-events"]="none";
125202
+ }
125203
+
125204
+ if (option)
125205
+ {
125206
+ if (IFrameSplitOperator.IsNumber(option.TabIndex)) element.setAttribute("tabindex",option.TabIndex);
125207
+ if (IFrameSplitOperator.IsNumber(option.ZIndex)) element.style["z-index"]=option.ZIndex;
125208
+ }
125209
+
125210
+ if (this.CanvasElement)
125211
+ {
125212
+ element.height=this.CanvasElement.height;
125213
+ element.width=this.CanvasElement.width;
125214
+ if (element.style)
125215
+ {
125216
+ element.style.width=this.CanvasElement.style.width;
125217
+ element.style.height=this.CanvasElement.style.height
125218
+ }
125219
+ }
125220
+
125221
+ divElement.appendChild(element);
125222
+
125223
+ var item={ Element:element, Canvas:null };
125224
+ this.MapExtraCanvasElement.set(name, item);
125225
+ }
125226
+
125227
+ this.GetExtraCanvas=function(name)
125228
+ {
125229
+ if (!this.MapExtraCanvasElement.has(name)) return null;
125230
+
125231
+ var item=this.MapExtraCanvasElement.get(name);
125232
+ if (!item.Element) return null;
125233
+
125234
+ if (!item.Canvas) item.Canvas=item.Element.getContext("2d");
125235
+
125236
+ return item;
125237
+ }
125161
125238
 
125162
125239
  this.OnSize=function()
125163
125240
  {
@@ -125172,6 +125249,19 @@ function JSReportChart(divElement)
125172
125249
  this.CanvasElement.height*=pixelTatio;
125173
125250
  this.CanvasElement.width*=pixelTatio;
125174
125251
 
125252
+ //扩展画布
125253
+ for(var mapItem of this.MapExtraCanvasElement)
125254
+ {
125255
+ var item=mapItem[1];
125256
+ var element=item.Element;
125257
+ if (!element) continue;
125258
+
125259
+ element.height=this.CanvasElement.height;
125260
+ element.width=this.CanvasElement.width;
125261
+ element.style.width=this.CanvasElement.style.width;
125262
+ element.style.height=this.CanvasElement.style.height;
125263
+ }
125264
+
125175
125265
  JSConsole.Chart.Log(`[JSReportChart::OnSize] devicePixelRatio=${window.devicePixelRatio}, height=${this.CanvasElement.height}, width=${this.CanvasElement.width}`);
125176
125266
 
125177
125267
  if (this.JSChartContainer && this.JSChartContainer.OnSize)
@@ -125222,6 +125312,9 @@ function JSReportChart(divElement)
125222
125312
  if (IFrameSplitOperator.IsBool(option.EnableDragRow)) chart.EnableDragRow=option.EnableDragRow;
125223
125313
  if (IFrameSplitOperator.IsNumber(option.DragRowType)) chart.DragRowType=option.DragRowType;
125224
125314
  if (IFrameSplitOperator.IsBool(option.EnableDragHeader)) chart.EnableDragHeader=option.EnableDragHeader;
125315
+ if (IFrameSplitOperator.IsNumber(option.WheelPageType)) chart.WheelPageType=option.WheelPageType;
125316
+ if (IFrameSplitOperator.IsBool(option.PageUpDownCycle)) chart.PageUpDownCycle=option.PageUpDownCycle;
125317
+
125225
125318
  if (option.VScrollbar) chart.SetVScrollbar(option.VScrollbar);
125226
125319
  if (option.SortInfo)
125227
125320
  {
@@ -125330,6 +125423,8 @@ function JSReportChart(divElement)
125330
125423
  }
125331
125424
  }
125332
125425
 
125426
+ JSReportChart.TooltipCursorCanvasKey="hq_report_tooltip"; //提示信息
125427
+
125333
125428
 
125334
125429
  JSReportChart.Init=function(divElement)
125335
125430
  {
@@ -125467,6 +125562,7 @@ function JSReportChartContainer(uielement)
125467
125562
 
125468
125563
  this.PageUpDownCycle=true; //翻页循环
125469
125564
  this.DragPageCycle=true; //手机翻页循环
125565
+ this.WheelPageType=0; //鼠标滚轴翻页模式 0=一页一页翻 1=一条一条翻
125470
125566
 
125471
125567
  //拖拽滚动条
125472
125568
  this.DragXScroll=null; //{Start:{x,y}, End:{x, y}}
@@ -125547,6 +125643,15 @@ function JSReportChartContainer(uielement)
125547
125643
  }
125548
125644
 
125549
125645
 
125646
+ //清空画布
125647
+ this.ClearCanvas=function(canvas)
125648
+ {
125649
+ if (!canvas) return;
125650
+ if (!this.UIElement) return;
125651
+
125652
+ canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);
125653
+ }
125654
+
125550
125655
  //清空固定行数据
125551
125656
  this.ClearFixedRowData=function()
125552
125657
  {
@@ -126491,20 +126596,43 @@ function JSReportChartContainer(uielement)
126491
126596
  if (!IFrameSplitOperator.IsObjectExist(e.wheelDelta))
126492
126597
  wheelValue=e.deltaY* -0.01;
126493
126598
 
126494
- if (wheelValue<0) //下一页
126599
+ if (this.WheelPageType==1)
126495
126600
  {
126496
- if (this.GotoNextPage(this.PageUpDownCycle))
126601
+ console.log(`[OnWheel] wheelValue=${wheelValue}`);
126602
+ if (wheelValue<0) //下
126497
126603
  {
126498
- this.Draw();
126499
- this.DelayUpdateStockData();
126604
+ if (this.GotoNextItem(1))
126605
+ {
126606
+ this.Draw();
126607
+ this.DelayUpdateStockData();
126608
+ }
126609
+ }
126610
+ else if (wheelValue>0) //上
126611
+ {
126612
+ if (this.GotoNextItem(-1))
126613
+ {
126614
+ this.Draw();
126615
+ this.DelayUpdateStockData();
126616
+ }
126500
126617
  }
126501
126618
  }
126502
- else if (wheelValue>0) //上一页
126619
+ else
126503
126620
  {
126504
- if (this.GotoPreviousPage(this.PageUpDownCycle))
126621
+ if (wheelValue<0) //下一页
126505
126622
  {
126506
- this.Draw();
126507
- this.DelayUpdateStockData();
126623
+ if (this.GotoNextPage(this.PageUpDownCycle))
126624
+ {
126625
+ this.Draw();
126626
+ this.DelayUpdateStockData();
126627
+ }
126628
+ }
126629
+ else if (wheelValue>0) //上一页
126630
+ {
126631
+ if (this.GotoPreviousPage(this.PageUpDownCycle))
126632
+ {
126633
+ this.Draw();
126634
+ this.DelayUpdateStockData();
126635
+ }
126508
126636
  }
126509
126637
  }
126510
126638
 
@@ -127380,6 +127508,43 @@ function JSReportChartContainer(uielement)
127380
127508
  return chart;
127381
127509
  }
127382
127510
 
127511
+ this.GotoNextItem=function(step)
127512
+ {
127513
+ if (step==0) return false;
127514
+ if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return false;
127515
+ var chart=this.ChartPaint[0];
127516
+ if (!chart) return false;
127517
+ var pageSize=chart.GetPageSize();
127518
+ if (pageSize>this.Data.Data.length) return false;
127519
+
127520
+ var moveCount=0;
127521
+ if (step>0)
127522
+ {
127523
+ for(var i=0;i<step;++i)
127524
+ {
127525
+ if (this.Data.YOffset+pageSize>=this.Data.Data.length)
127526
+ break;
127527
+
127528
+ ++this.Data.YOffset;
127529
+ ++moveCount;
127530
+ }
127531
+ }
127532
+ else if (step<0)
127533
+ {
127534
+ step=Math.abs(step);
127535
+ for(var i=0;i<step;++i)
127536
+ {
127537
+ if (this.Data.YOffset<=0)
127538
+ break;
127539
+
127540
+ --this.Data.YOffset;
127541
+ ++moveCount;
127542
+ }
127543
+ }
127544
+
127545
+ return moveCount>0
127546
+ }
127547
+
127383
127548
  this.GotoNextPage=function(bCycle) //bCycle 是否循环
127384
127549
  {
127385
127550
  if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return false;
@@ -128735,8 +128900,10 @@ function ChartReport()
128735
128900
  if (item.Type==REPORT_COLUMN_ID.CUSTOM_STRING_TEXT_ID)
128736
128901
  {
128737
128902
  if (!IFrameSplitOperator.IsNumber(item.DataIndex) && !IFrameSplitOperator.IsNumber(item.BlockIndex)) continue;
128903
+ colItem.FormatType=0; //0=默认格式 1=长度不够使用...
128738
128904
  if (IFrameSplitOperator.IsNumber(item.DataIndex)) colItem.DataIndex=item.DataIndex; //数据在扩展数据索引列
128739
128905
  if (IFrameSplitOperator.IsNumber(item.BlockIndex)) colItem.BlockIndex=item.BlockIndex;
128906
+ if (IFrameSplitOperator.IsNumber(item.FormatType)) colItem.FormatType=item.FormatType; //输出样式
128740
128907
  }
128741
128908
  else if (item.Type==REPORT_COLUMN_ID.CUSTOM_NUMBER_TEXT_ID)
128742
128909
  {
@@ -129692,10 +129859,69 @@ function ChartReport()
129692
129859
  }
129693
129860
 
129694
129861
  this.DrawItemBG(drawInfo);
129695
- this.DrawItemText(drawInfo.Text, drawInfo.TextColor, drawInfo.TextAlign, x, top, textWidth, drawInfo.BGColor);
129862
+
129863
+ if (column.Type==REPORT_COLUMN_ID.CUSTOM_STRING_TEXT_ID)
129864
+ this.DrawCustomText(drawInfo,column, x, top, textWidth);
129865
+ else
129866
+ this.DrawItemText(drawInfo.Text, drawInfo.TextColor, drawInfo.TextAlign, x, top, textWidth, drawInfo.BGColor);
129696
129867
  }
129697
129868
  }
129698
129869
 
129870
+ this.DrawCustomText=function(drawInfo, column, left, top, cellWidth)
129871
+ {
129872
+ if (!drawInfo.Text) return;
129873
+
129874
+ var text=drawInfo.Text;
129875
+ var x=left;
129876
+ if (drawInfo.TextAlign=='center')
129877
+ {
129878
+ x=left+cellWidth/2;
129879
+ this.Canvas.textAlign="center";
129880
+ }
129881
+ else if (drawInfo.TextAlign=='right')
129882
+ {
129883
+ x=left+cellWidth-2;
129884
+ this.Canvas.textAlign="right";
129885
+ }
129886
+ else
129887
+ {
129888
+ x+=2;
129889
+ this.Canvas.textAlign="left";
129890
+ }
129891
+
129892
+ var textWidth=this.Canvas.measureText(text).width+1;
129893
+ var bClip=false;
129894
+ if (textWidth>=cellWidth) //长度超过单元格 裁剪
129895
+ {
129896
+ if (column.FormatType==2)
129897
+ {
129898
+ var count=text.length+5;
129899
+ text="";
129900
+ for(var i=0;i<count;++i)
129901
+ text+="#";
129902
+ }
129903
+ else if (column.FormatType==1)
129904
+ {
129905
+ text=this.TextEllipsis(text, cellWidth, column.MaxText);
129906
+ }
129907
+
129908
+ this.Canvas.save();
129909
+ bClip=true;
129910
+
129911
+ var rtCell={ Left:left, Top:top+this.ItemMergin.Top, Width:cellWidth, Height:this.RowHeight };
129912
+ this.Canvas.beginPath();
129913
+ this.Canvas.rect(rtCell.Left, rtCell.Top, rtCell.Width, rtCell.Height);
129914
+ //this.Canvas.stroke(); //调试用
129915
+ this.Canvas.clip();
129916
+ }
129917
+
129918
+ this.Canvas.textBaseline="middle";
129919
+ this.Canvas.fillStyle=drawInfo.TextColor;
129920
+ this.Canvas.fillText(text,x,top+this.ItemMergin.Top+this.RowHeight/2);
129921
+
129922
+ if (bClip) this.Canvas.restore();
129923
+ }
129924
+
129699
129925
  this.DrawSymbolName=function(data, column, left, top, rowType)
129700
129926
  {
129701
129927
  var stock=data.Stock;
@@ -131492,6 +131718,11 @@ function ChartVScrollbar()
131492
131718
  var rtBar = {Right:right-this.Mergin.Right, Top:y, Width:buttonSize, Height: this.ScrollBarHeight };
131493
131719
  rtBar.Left=rtBar.Right-buttonSize;
131494
131720
  rtBar.Bottom=rtBar.Top+rtBar.Height;
131721
+ if (rtBar.Bottom>rtBottom.Top-2)
131722
+ {
131723
+ rtBar.Bottom=rtBottom.Top-2;
131724
+ rtBar.Top=rtBar.Bottom-rtBar.Height;
131725
+ }
131495
131726
 
131496
131727
  this.RectScroll.Top=rtTop;
131497
131728
  this.RectScroll.Bottom=rtBottom;
@@ -134644,7 +134875,7 @@ function ScrollBarBGChart()
134644
134875
 
134645
134876
 
134646
134877
 
134647
- var HQCHART_VERSION="1.1.13515";
134878
+ var HQCHART_VERSION="1.1.13525";
134648
134879
 
134649
134880
  function PrintHQChartVersion()
134650
134881
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var HQCHART_VERSION="1.1.13515";
8
+ var HQCHART_VERSION="1.1.13525";
9
9
 
10
10
  function PrintHQChartVersion()
11
11
  {