hqchart 1.1.13526 → 1.1.13537

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.
@@ -38,7 +38,7 @@ function JSReportChart(divElement)
38
38
  var element=document.createElement("canvas");
39
39
  element.className='jsreportlist-drawing-extra';
40
40
  element.id=Guid();
41
- if (name==JSChart.CorssCursorCanvasKey)
41
+ if (name==JSReportChart.CorssCursorCanvasKey)
42
42
  element.setAttribute("tabindex",5);
43
43
  else
44
44
  element.setAttribute("tabindex",1);
@@ -90,9 +90,18 @@ function JSReportChart(divElement)
90
90
  this.OnSize=function()
91
91
  {
92
92
  //画布大小通过div获取
93
- var height=parseInt(this.DivElement.style.height.replace("px",""));
93
+ var height=this.DivElement.offsetHeight;
94
+ var width=this.DivElement.offsetWidth;
95
+ if (this.DivElement.style.height && this.DivElement.style.width)
96
+ {
97
+ if (this.DivElement.style.height.includes("px"))
98
+ height=parseInt(this.DivElement.style.height.replace("px",""));
99
+ if (this.DivElement.style.width.includes("px"))
100
+ width=parseInt(this.DivElement.style.width.replace("px",""));
101
+ }
102
+
94
103
  this.CanvasElement.height=height;
95
- this.CanvasElement.width=parseInt(this.DivElement.style.width.replace("px",""));
104
+ this.CanvasElement.width=width;
96
105
  this.CanvasElement.style.width=this.CanvasElement.width+'px';
97
106
  this.CanvasElement.style.height=this.CanvasElement.height+'px';
98
107
 
@@ -132,7 +141,13 @@ function JSReportChart(divElement)
132
141
  this.JSChartContainer=chart;
133
142
  this.DivElement.JSChart=this; //div中保存一份
134
143
 
144
+ if (option.EnableResize==true) this.CreateResizeListener();
145
+
135
146
  if (option.EnablePopMenuV2===true) chart.InitalPopMenu();
147
+ if (option.EnableTooltip)
148
+ {
149
+ this.CreateExtraCanvasElement(JSReportChart.TooltipCursorCanvasKey, { ZIndex:99 });
150
+ }
136
151
 
137
152
  if (option.Symbol) chart.Symbol=option.Symbol;
138
153
  if (option.Name) chart.Name=option.Name;
@@ -154,6 +169,8 @@ function JSReportChart(divElement)
154
169
  this.CreateJSReportChartContainer=function(option)
155
170
  {
156
171
  var chart=new JSReportChartContainer(this.CanvasElement);
172
+ chart.GetExtraCanvas=(name)=>{ return this.GetExtraCanvas(name); }
173
+
157
174
  chart.Create(option);
158
175
 
159
176
  if (option.NetworkFilter) chart.NetworkFilter=option.NetworkFilter;
@@ -217,6 +234,19 @@ function JSReportChart(divElement)
217
234
  chart.Frame.ChartBorder.Bottom*=pixelTatio;
218
235
  }
219
236
 
237
+ this.CreateResizeListener=function()
238
+ {
239
+ this.ResizeListener = new ResizeObserver((entries)=>{ this.OnDivResize(entries); });
240
+ this.ResizeListener.observe(this.DivElement);
241
+ }
242
+
243
+ this.OnDivResize=function(entries)
244
+ {
245
+ JSConsole.Chart.Log("[JSReportChart::OnDivResize] entries=", entries);
246
+
247
+ this.OnSize();
248
+ }
249
+
220
250
  /////////////////////////////////////////////////////////////////////////////
221
251
  //对外接口
222
252
 
@@ -354,6 +384,9 @@ function JSReportChartContainer(uielement)
354
384
  this.SplashTitle={ StockList:"下载码表中.....", MemberList:"下载成分中....." } ;
355
385
 
356
386
  this.Canvas=uielement.getContext("2d"); //画布
387
+
388
+ this.TooltipCanvas;
389
+ this.ChartTooltip;
357
390
 
358
391
  this.Tooltip=document.createElement("div");
359
392
  this.Tooltip.className='jsreport-tooltip';
@@ -425,6 +458,8 @@ function JSReportChartContainer(uielement)
425
458
  this.JSPopMenu; //内置菜单
426
459
  this.IsShowRightMenu=true;
427
460
 
461
+ this.LastMouseStatus={ MoveStatus:null, TooltipStatus:null };
462
+
428
463
  this.ChartDestory=function() //销毁
429
464
  {
430
465
  this.IsDestroy=true;
@@ -575,6 +610,12 @@ function JSReportChartContainer(uielement)
575
610
 
576
611
  this.ChartPaint[0]=chart;
577
612
 
613
+ //提示信息
614
+ var chartTooltip=new ChartCellTooltip();
615
+ chartTooltip.Frame=this.Frame;
616
+ chartTooltip.ChartBorder=this.Frame.ChartBorder;
617
+ this.ChartTooltip=chartTooltip;
618
+
578
619
  //页脚
579
620
  if (option && option.PageInfo===true)
580
621
  {
@@ -686,6 +727,8 @@ function JSReportChartContainer(uielement)
686
727
  {
687
728
  this.DelayDraw(500);
688
729
  }
730
+
731
+ this.DrawTooltip(this.LastMouseStatus.TooltipStatus);
689
732
  }
690
733
 
691
734
  this.DelayDraw=function(frequency)
@@ -1452,6 +1495,7 @@ function JSReportChartContainer(uielement)
1452
1495
  console.log(`[OnWheel] wheelValue=${wheelValue}`);
1453
1496
  if (wheelValue<0) //下
1454
1497
  {
1498
+ this.LastMouseStatus.TooltipStatus=null;
1455
1499
  if (this.GotoNextItem(1))
1456
1500
  {
1457
1501
  this.Draw();
@@ -1460,6 +1504,7 @@ function JSReportChartContainer(uielement)
1460
1504
  }
1461
1505
  else if (wheelValue>0) //上
1462
1506
  {
1507
+ this.LastMouseStatus.TooltipStatus=null;
1463
1508
  if (this.GotoNextItem(-1))
1464
1509
  {
1465
1510
  this.Draw();
@@ -1471,6 +1516,7 @@ function JSReportChartContainer(uielement)
1471
1516
  {
1472
1517
  if (wheelValue<0) //下一页
1473
1518
  {
1519
+ this.LastMouseStatus.TooltipStatus=null;
1474
1520
  if (this.GotoNextPage(this.PageUpDownCycle))
1475
1521
  {
1476
1522
  this.Draw();
@@ -1479,6 +1525,7 @@ function JSReportChartContainer(uielement)
1479
1525
  }
1480
1526
  else if (wheelValue>0) //上一页
1481
1527
  {
1528
+ this.LastMouseStatus.TooltipStatus=null;
1482
1529
  if (this.GotoPreviousPage(this.PageUpDownCycle))
1483
1530
  {
1484
1531
  this.Draw();
@@ -1700,7 +1747,13 @@ function JSReportChartContainer(uielement)
1700
1747
  var pixelTatio = GetDevicePixelRatio();
1701
1748
  var x = (e.clientX-this.UIElement.getBoundingClientRect().left)*pixelTatio;
1702
1749
  var y = (e.clientY-this.UIElement.getBoundingClientRect().top)*pixelTatio;
1750
+
1751
+ this.LastMouseStatus.OnMouseMove=null;
1703
1752
 
1753
+ var bDrawTooltip=false;
1754
+ if (this.LastMouseStatus.TooltipStatus) bDrawTooltip=true;
1755
+ this.LastMouseStatus.TooltipStatus=null;
1756
+
1704
1757
  if (this.DragRow) return;
1705
1758
  if (this.DrawHeader) return;
1706
1759
  if (this.DragColumnWidth) return;
@@ -1720,10 +1773,11 @@ function JSReportChartContainer(uielement)
1720
1773
  }
1721
1774
  }
1722
1775
 
1776
+ this.LastMouseStatus.OnMouseMove={ X:x, Y:y };
1723
1777
  var mouseStatus={ Cursor:"default", Name:"Default"};; //鼠标状态
1724
1778
  var report=this.GetReportChart();
1725
- var cell=null;
1726
1779
  var bDraw=false;
1780
+
1727
1781
  if (report)
1728
1782
  {
1729
1783
  var dragHeaderWidth=report.PtInHeaderDragBorder(x,y);
@@ -1734,7 +1788,12 @@ function JSReportChartContainer(uielement)
1734
1788
  }
1735
1789
  else
1736
1790
  {
1737
- cell=report.PtInCell(x,y); //是否在单元格(EnableTooltip)
1791
+ var tooltipData=report.GetTooltipData(x,y); //单元格提示信息
1792
+ if (tooltipData)
1793
+ {
1794
+ this.LastMouseStatus.TooltipStatus={ X:x, Y:y, Data:tooltipData };
1795
+ bDrawTooltip=true;
1796
+ }
1738
1797
  }
1739
1798
 
1740
1799
  var scrollbar=report.VScrollbar;
@@ -1750,16 +1809,20 @@ function JSReportChartContainer(uielement)
1750
1809
  }
1751
1810
  }
1752
1811
 
1812
+
1813
+ /* 目前没有用到
1753
1814
  var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_REPORT_MOUSE_MOVE);
1754
1815
  if (event)
1755
1816
  {
1756
1817
  var sendData={X:x, Y:y, Cell:cell };
1757
1818
  event.Callback(event,sendData,this);
1758
1819
  }
1820
+ */
1759
1821
 
1760
1822
  if (mouseStatus) this.UIElement.style.cursor=mouseStatus.Cursor;
1761
1823
 
1762
1824
  if (bDraw) this.Draw();
1825
+ else if (bDrawTooltip) this.DrawTooltip(this.LastMouseStatus.TooltipStatus);
1763
1826
  }
1764
1827
 
1765
1828
  this.UIOnMounseOut=function(e)
@@ -2940,6 +3003,7 @@ function JSReportChartContainer(uielement)
2940
3003
  {
2941
3004
  this.ExecuteMenuCommand(tabData.Tab.CommandID, [tabData.Tab.ID]);
2942
3005
  this.SetSelectedTab(tabData.Index);
3006
+ redraw=true;
2943
3007
  }
2944
3008
  }
2945
3009
 
@@ -3038,6 +3102,7 @@ function JSReportChartContainer(uielement)
3038
3102
 
3039
3103
  case REPORT_COLUMN_ID.VOL_IN_ID:
3040
3104
  case REPORT_COLUMN_ID.VOL_OUT_ID:
3105
+ case REPORT_COLUMN_ID.DATE_ID:
3041
3106
 
3042
3107
  return this.LocalNumberSort(left, right, column, sortType);
3043
3108
  case REPORT_COLUMN_ID.CUSTOM_NUMBER_TEXT_ID: //自定义数值字段
@@ -3212,6 +3277,31 @@ function JSReportChartContainer(uielement)
3212
3277
  }
3213
3278
  }
3214
3279
 
3280
+ this.LoacCustomStringSort=function(left, right, column, sortType)
3281
+ {
3282
+ var leftValue="", rightValue="";
3283
+ if (sortType==2) rightValue=leftValue="啊啊啊啊啊";
3284
+
3285
+ var value=this.GetStockExtendData(left, column);
3286
+ if (IFrameSplitOperator.IsString(value)) leftValue=value;
3287
+
3288
+ var value=this.GetStockExtendData(right, column);
3289
+ if (IFrameSplitOperator.IsString(value)) rightValue=value;
3290
+
3291
+ if (sortType==1)
3292
+ {
3293
+ if (rightValue<leftValue) return -1;
3294
+ else if (rightValue<leftValue) return 1;
3295
+ else return 0;
3296
+ }
3297
+ else
3298
+ {
3299
+ if (leftValue<rightValue) return -1;
3300
+ else if (leftValue>rightValue) return 1;
3301
+ else return 0;
3302
+ }
3303
+ }
3304
+
3215
3305
  this.RequestStockSortData=function(column, filedid, sortType)
3216
3306
  {
3217
3307
  var chart=this.ChartPaint[0];
@@ -3328,6 +3418,28 @@ function JSReportChartContainer(uielement)
3328
3418
 
3329
3419
  return true;
3330
3420
  }
3421
+
3422
+ this.DrawTooltip=function(tooltipStatus)
3423
+ {
3424
+ if (!this.GetExtraCanvas) return;
3425
+ if (!this.TooltipCanvas)
3426
+ {
3427
+ var finder=this.GetExtraCanvas(JSReportChart.TooltipCursorCanvasKey);
3428
+ if (!finder) return;
3429
+ this.TooltipCanvas=finder.Canvas;
3430
+ }
3431
+
3432
+ if (!this.TooltipCanvas) return;
3433
+ this.ClearCanvas(this.TooltipCanvas);
3434
+ if (!this.ChartTooltip) return;
3435
+
3436
+ if (!tooltipStatus || !tooltipStatus.Data) return;
3437
+
3438
+ this.ChartTooltip.Canvas=this.TooltipCanvas;
3439
+ this.ChartTooltip.Point={ X:tooltipStatus.X, Y:tooltipStatus.Y };
3440
+ this.ChartTooltip.Data=tooltipStatus.Data.Data;
3441
+ this.ChartTooltip.Draw();
3442
+ }
3331
3443
  }
3332
3444
 
3333
3445
 
@@ -3496,6 +3608,8 @@ var MAP_COLUMN_FIELD=new Map([
3496
3608
  [REPORT_COLUMN_ID.VOL_OUT_ID,"VolOut"],
3497
3609
 
3498
3610
  [REPORT_COLUMN_ID.NAME_EX_ID, "NameEx"],
3611
+
3612
+ [REPORT_COLUMN_ID.DATE_ID, "Date"],
3499
3613
  ]);
3500
3614
 
3501
3615
  function ChartReport()
@@ -3628,7 +3742,11 @@ function ChartReport()
3628
3742
  this.BottomToolbarHeight=0; //底部工具条高度
3629
3743
  this.IsShowAllColumn=false; //是否已显示所有列
3630
3744
 
3631
- this.Column= //{ Type:列id, Title:标题, TextAlign:文字对齐方式, MaxText:文字最大宽度 , TextColor:文字颜色, Sort:0=不支持排序 1=本地排序 0=远程排序 }
3745
+ //{
3746
+ // Type:列id, Title:标题, TextAlign:文字对齐方式, MaxText:文字最大宽度 , TextColor:文字颜色, Sort:0=不支持排序 1=本地排序 0=远程排序,
3747
+ // Icon:{ Family:"iconfont", Size:12, Symbol:"", Margin: { Left:, Bottom }}
3748
+ //}
3749
+ this.Column=
3632
3750
  [
3633
3751
  { Type:REPORT_COLUMN_ID.INDEX_ID, Title:"序号", TextAlign:"center", Width:null, TextColor:g_JSChartResource.Report.FieldColor.Index, MaxText:"8888"},
3634
3752
  { Type:REPORT_COLUMN_ID.SYMBOL_ID, Title:"代码", TextAlign:"left", Width:null, TextColor:g_JSChartResource.Report.FieldColor.Symbol, MaxText:"888888"},
@@ -3638,6 +3756,9 @@ function ChartReport()
3638
3756
 
3639
3757
  this.RectClient={};
3640
3758
 
3759
+ //{ Rect:rtItem, Stock:stock, Index:index, Column:column, RowType:rowType, Type:drawInfo.Tooltip.Type, Data:{ AryText:[ {Text:xx} ]} };
3760
+ //Type:1=数据截断
3761
+ // { Text, Color, Title:, TitleColor, Space, Margin:{ Left, Top, Right, Bottom }}
3641
3762
  this.TooltipRect=[];
3642
3763
 
3643
3764
  this.ReloadResource=function(resource)
@@ -3736,11 +3857,11 @@ function ChartReport()
3736
3857
  if (item.FullColBGColor) colItem.FullColBGColor=item.FullColBGColor; //整列背景色
3737
3858
  if (item.HeaderBGColor) colItem.HeaderBGColor=item.HeaderBGColor; //表头背景色
3738
3859
  if (IFrameSplitOperator.IsNumber(item.Sort)) colItem.Sort=item.Sort;
3739
- if (IFrameSplitOperator.IsBool(item.EnableTooltip)) colItem.EnableTooltip=item.EnableTooltip;
3740
3860
  if (IFrameSplitOperator.IsNumber(item.FixedWidth)) colItem.FixedWidth=item.FixedWidth;
3741
3861
  if (IFrameSplitOperator.IsBool(item.EnableDragWidth)) colItem.EnableDragWidth=item.EnableDragWidth;
3742
3862
  if (IFrameSplitOperator.IsBool(item.IsDrawCallback)) colItem.IsDrawCallback=item.IsDrawCallback;
3743
3863
  else colItem.IsDrawCallback=false;
3864
+ if (item.Icon) colItem.Icon=item.Icon;
3744
3865
 
3745
3866
  if (item.Sort==1 || item.Sort==2) //1本地排序 2=远程排序
3746
3867
  {
@@ -4046,6 +4167,17 @@ function ChartReport()
4046
4167
 
4047
4168
  item.Width=itemWidth+4+this.ItemMergin.Left+this.ItemMergin.Right;
4048
4169
  }
4170
+
4171
+ if (item.Icon && item.Icon.Symbol)
4172
+ {
4173
+ item.Width+=item.Icon.Size;
4174
+ if (item.Icon.Margin)
4175
+ {
4176
+ var margin=item.Icon.Margin;
4177
+ if (IFrameSplitOperator.IsNumber(margin.Left)) item.Width+=margin.Left;
4178
+ if (IFrameSplitOperator.IsNumber(margin.Right)) item.Width+=margin.Right;
4179
+ }
4180
+ }
4049
4181
  }
4050
4182
 
4051
4183
  this.Canvas.font=this.HeaderFont;
@@ -4105,16 +4237,36 @@ function ChartReport()
4105
4237
  this.DrawItemBG({ Rect:rtBG, BGColor:item.HeaderBGColor });
4106
4238
  }
4107
4239
 
4240
+ var iconWidth=0;
4241
+ if (item.Icon && item.Icon.Symbol) //图标
4242
+ {
4243
+ var iconWidth=item.Icon.Size;
4244
+ if (item.Icon.Margin)
4245
+ {
4246
+ var margin=item.Icon.Margin;
4247
+ if (IFrameSplitOperator.IsNumber(margin.Left)) iconWidth+=margin.Left;
4248
+ if (IFrameSplitOperator.IsNumber(margin.Right)) iconWidth+=margin.Right;
4249
+ }
4250
+ }
4251
+ textWidth-=iconWidth;
4252
+
4108
4253
  if (item.HeaderColor) this.Canvas.fillStyle=item.HeaderColor;
4109
4254
  else this.Canvas.fillStyle=this.HeaderColor;
4110
4255
 
4256
+ var textSize={ }
4111
4257
  if (this.SortInfo && this.SortInfo.Field==i && this.SortInfo.Sort>0)
4112
4258
  {
4113
- this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort);
4259
+ this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort, textSize);
4114
4260
  }
4115
4261
  else
4116
4262
  {
4117
- this.DrawText(item.Title,item.TextAlign,x,y,textWidth);
4263
+ this.DrawText(item.Title,item.TextAlign,x,y,textWidth,textSize);
4264
+ }
4265
+
4266
+ if (iconWidth>0)
4267
+ {
4268
+ this.DrawHeaderIcon(item.Icon, textSize.Right, y, i, item);
4269
+ this.Canvas.font=this.HeaderFont;
4118
4270
  }
4119
4271
 
4120
4272
  this.Canvas.fillStyle=this.HeaderColor;
@@ -4137,44 +4289,91 @@ function ChartReport()
4137
4289
  this.DrawItemBG({ Rect:rtBG, BGColor:item.HeaderBGColor });
4138
4290
  }
4139
4291
 
4292
+ var iconWidth=0;
4293
+ if (item.Icon && item.Icon.Symbol) //图标
4294
+ {
4295
+ var iconWidth=item.Icon.Size;
4296
+ if (item.Icon.Margin)
4297
+ {
4298
+ var margin=item.Icon.Margin;
4299
+ if (IFrameSplitOperator.IsNumber(margin.Left)) iconWidth+=margin.Left;
4300
+ if (IFrameSplitOperator.IsNumber(margin.Right)) iconWidth+=margin.Right;
4301
+ }
4302
+ }
4303
+
4304
+ textWidth-=iconWidth;
4305
+
4140
4306
  if (item.HeaderColor) this.Canvas.fillStyle=item.HeaderColor;
4141
4307
  else this.Canvas.fillStyle=this.HeaderColor;
4142
4308
 
4309
+ var textSize={ }
4143
4310
  if (this.SortInfo && this.SortInfo.Field==i && this.SortInfo.Sort>0)
4144
4311
  {
4145
- this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort);
4312
+ this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort,textSize);
4146
4313
  }
4147
4314
  else
4148
4315
  {
4149
- this.DrawText(item.Title,item.TextAlign,x,y,textWidth);
4316
+ this.DrawText(item.Title,item.TextAlign,x,y,textWidth,textSize);
4317
+ }
4318
+
4319
+ if (iconWidth>0)
4320
+ {
4321
+ this.DrawHeaderIcon(item.Icon, textSize.Right, y, i, item);
4322
+ this.Canvas.font=this.HeaderFont;
4150
4323
  }
4151
4324
 
4152
4325
  textLeft+=item.Width;
4153
4326
  }
4154
4327
  }
4155
4328
 
4156
- this.DrawText=function(text, textAlign, x, y, textWidth)
4329
+ this.DrawText=function(text, textAlign, x, y, cellWidth, textSize)
4157
4330
  {
4331
+ var textWidth=this.Canvas.measureText(text).width;
4158
4332
  if (textAlign=='center')
4159
4333
  {
4160
- x=x+textWidth/2;
4161
- this.Canvas.textAlign="center";
4334
+ x=x+(cellWidth-textWidth)/2;
4162
4335
  }
4163
4336
  else if (textAlign=='right')
4164
4337
  {
4165
- x=x+textWidth;
4166
- this.Canvas.textAlign="right";
4167
- }
4168
- else
4169
- {
4170
- this.Canvas.textAlign="left";
4338
+ x=x+cellWidth-textWidth;
4171
4339
  }
4172
4340
 
4341
+ this.Canvas.textAlign="left";
4173
4342
  this.Canvas.textBaseline="middle";
4174
4343
  this.Canvas.fillText(text,x,y);
4344
+
4345
+ if (textSize)
4346
+ {
4347
+ textSize.Right=x+textWidth;
4348
+ textSize.Width=textWidth;
4349
+ }
4350
+ }
4351
+
4352
+ this.DrawHeaderIcon=function(icon, x, y, index, column)
4353
+ {
4354
+ var iconFont=`${icon.Size}px ${icon.Family}`;
4355
+ this.Canvas.font=iconFont;
4356
+ this.Canvas.textAlign="left";
4357
+ if (icon.Color) this.Canvas.fillStyle=icon.Color;
4358
+
4359
+ var xIcon=x;
4360
+ var yIcon=y;
4361
+ if (icon.Margin && IFrameSplitOperator.IsNumber(icon.Margin.Left)) xIcon+=icon.Margin.Left;
4362
+ if (icon.Margin && IFrameSplitOperator.IsNumber(icon.Margin.Bottom)) yIcon-=icon.Margin.Bottom;
4363
+ this.Canvas.fillText(icon.Symbol, xIcon, yIcon);
4364
+
4365
+ if (icon.Tooltip)
4366
+ {
4367
+ var rtIcon={ Left:xIcon, Top:yIcon-icon.Size/2, Width:icon.Size, Height:icon.Size };
4368
+ rtIcon.Right=rtIcon.Left+rtIcon.Width;
4369
+ rtIcon.Bottom=rtIcon.Top+rtIcon.Height;
4370
+
4371
+ var tooltipData={ Rect:rtIcon, Type:2, Column:column, Index:index, Data:icon.Tooltip.Data };
4372
+ this.TooltipRect.push(tooltipData);
4373
+ }
4175
4374
  }
4176
4375
 
4177
- this.DrawSortHeader=function(text, textAlign, x, y, width, sortType)
4376
+ this.DrawSortHeader=function(text, textAlign, x, y, width, sortType,textSize)
4178
4377
  {
4179
4378
  var sortText=sortType==1?"↓":"↑";
4180
4379
  var sortTextWidth=this.Canvas.measureText(sortText).width;
@@ -4190,15 +4389,17 @@ function ChartReport()
4190
4389
  {
4191
4390
  x=(x+width)-sortTextWidth-textWidth;
4192
4391
  }
4193
- else
4194
- {
4195
-
4196
- }
4197
4392
 
4198
4393
  this.Canvas.fillText(text,x,y);
4199
4394
  this.Canvas.fillStyle=this.SortColor;
4200
4395
  this.Canvas.fillText(sortText,x+textWidth,y);
4201
4396
  this.Canvas.fillStyle=this.HeaderColor;
4397
+
4398
+ if (textSize)
4399
+ {
4400
+ textSize.Right=x+textWidth+sortTextWidth;
4401
+ textSize.Width=textWidth+sortTextWidth;
4402
+ }
4202
4403
  }
4203
4404
 
4204
4405
 
@@ -4452,7 +4653,7 @@ function ChartReport()
4452
4653
  var x=left+this.ItemMergin.Left;
4453
4654
  var textWidth=column.Width-this.ItemMergin.Left-this.ItemMergin.Right;
4454
4655
  var stock=data.Stock;
4455
- var drawInfo={ Text:null, TextColor:column.TextColor , TextAlign:column.TextAlign };
4656
+ var drawInfo={ Text:null, TextColor:column.TextColor , TextAlign:column.TextAlign, Tooltip:null };
4456
4657
  var rtItem={ Left:left, Top:top, Width:column.Width, Height:this.RowHeight };
4457
4658
  rtItem.Right=rtItem.Left+rtItem.Width;
4458
4659
  rtItem.Bottom=rtItem.Top+rtItem.Height;
@@ -4463,12 +4664,6 @@ function ChartReport()
4463
4664
  this.DrawItemBG({ Rect:rtItem, BGColor:column.FullColBGColor });
4464
4665
  }
4465
4666
 
4466
- //tooltip提示
4467
- if (column.EnableTooltip===true)
4468
- {
4469
- this.TooltipRect.push({ Rect:rtItem, Stock:stock, Index:index, Column:column, RowType:rowType })
4470
- }
4471
-
4472
4667
  if (column.Type==REPORT_COLUMN_ID.INDEX_ID)
4473
4668
  {
4474
4669
  if (rowType==1) return; //固定行序号空
@@ -4716,6 +4911,14 @@ function ChartReport()
4716
4911
  else
4717
4912
  this.DrawItemText(drawInfo.Text, drawInfo.TextColor, drawInfo.TextAlign, x, top, textWidth, drawInfo.BGColor);
4718
4913
  }
4914
+
4915
+ //tooltip提示
4916
+ if (drawInfo.Tooltip)
4917
+ {
4918
+ //Type:1=数据截断
4919
+ var tooltipData={ Rect:rtItem, Stock:stock, Index:index, Column:column, RowType:rowType, Type:drawInfo.Tooltip.Type, Data:drawInfo.Tooltip.Data };
4920
+ this.TooltipRect.push(tooltipData);
4921
+ }
4719
4922
  }
4720
4923
 
4721
4924
  this.DrawCustomText=function(drawInfo, column, left, top, cellWidth)
@@ -4764,6 +4967,13 @@ function ChartReport()
4764
4967
  this.Canvas.rect(rtCell.Left, rtCell.Top, rtCell.Width, rtCell.Height);
4765
4968
  //this.Canvas.stroke(); //调试用
4766
4969
  this.Canvas.clip();
4970
+
4971
+ //数据截断提示信息
4972
+ drawInfo.Tooltip=
4973
+ {
4974
+ Type:1,
4975
+ Data:{ AryText:[ {Text:drawInfo.Text} ] }
4976
+ }
4767
4977
  }
4768
4978
 
4769
4979
  this.Canvas.textBaseline="middle";
@@ -6041,8 +6251,7 @@ function ChartReport()
6041
6251
 
6042
6252
  }
6043
6253
 
6044
- //坐标所在单元格
6045
- this.PtInCell=function(x,y)
6254
+ this.GetTooltipData=function(x,y)
6046
6255
  {
6047
6256
  if (!IFrameSplitOperator.IsNonEmptyArray(this.TooltipRect)) return null;
6048
6257
 
@@ -6054,9 +6263,11 @@ function ChartReport()
6054
6263
 
6055
6264
  if (x>=rt.Left && x<=rt.Right && y>=rt.Top && y<=rt.Bottom)
6056
6265
  {
6057
- return { Rect:item.Rect, Stock:item.Stock, Column:item.Column, Index:item.Index };
6266
+ return { Rect:item.Rect, Stock:item.Stock, Column:item.Column, Index:item.Index, Type:item.Type, Data:item.Data };
6058
6267
  }
6059
6268
  }
6269
+
6270
+ return null;
6060
6271
  }
6061
6272
 
6062
6273
  this.PtInHeaderDragBorder=function(x, y)
@@ -6648,3 +6859,166 @@ function ChartVScrollbar()
6648
6859
  return pos;
6649
6860
  }
6650
6861
  }
6862
+
6863
+
6864
+ function ChartCellTooltip()
6865
+ {
6866
+ this.Canvas; //画布
6867
+ this.ChartBorder; //边框信息
6868
+ this.ChartFrame; //框架画法
6869
+ this.Name; //名称
6870
+ this.ClassName='ChartCellTooltip'; //类名
6871
+
6872
+ this.BGColor="rgba(255,255,225, 0.9)";
6873
+ this.BorderColor="rgb(0,0,0)";
6874
+ this.Margin={ Left:5, Right:5, Top:4, Bottom:5 };
6875
+ this.Font=`${13*GetDevicePixelRatio()}px 微软雅黑`;
6876
+ this.TextColor="rgb(0,0,0)";
6877
+ this.YOffset=20;
6878
+ this.XOffset=5;
6879
+
6880
+ this.Point; //{ X, Y}
6881
+ this.Data; //{ AryText:[ { Text, Color, Title:, TitleColor, Space, Margin:{ Left, Top, Right, Bottom }} ]}
6882
+
6883
+
6884
+ this.Draw=function()
6885
+ {
6886
+ if (!this.Canvas) return;
6887
+ if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.AryText)) return;
6888
+ if (!this.Point) return;
6889
+
6890
+ var size={ Width:0, Height:0, Text:[] };
6891
+ this.CalculateTextSize(this.Data.AryText, size);
6892
+ if (!IFrameSplitOperator.IsNonEmptyArray(size.Text)) return;
6893
+
6894
+ this.DrawTooltip(this.Data.AryText, size);
6895
+ }
6896
+
6897
+ this.CalculateTextSize=function(aryText, size)
6898
+ {
6899
+ var width=0, height=0;
6900
+ for(var i=0;i<aryText.length;++i)
6901
+ {
6902
+ var item=aryText[i];
6903
+ var titleHeight=0, titleWidth=0;
6904
+ if (!item.Title && !item.Text) continue;
6905
+
6906
+ if (item.Title)
6907
+ {
6908
+ if (item.TitleFont) this.Canvas.font=item.TitleFont;
6909
+ else this.Canvas.font=this.Font;
6910
+
6911
+ titleWidth=this.Canvas.measureText(item.Title).width;
6912
+ titleHeight=this.Canvas.measureText("擎").width;
6913
+ }
6914
+
6915
+ var textWidth=0, textHeight=0;
6916
+ if (item.Text)
6917
+ {
6918
+ if (item.Font) this.Canvas.font=item.Font;
6919
+ else this.Canvas.font=this.Font;
6920
+
6921
+ textWidth=this.Canvas.measureText(item.Text).width;
6922
+ textHeight=this.Canvas.measureText("擎").width;
6923
+ }
6924
+
6925
+ var itemWidth=titleWidth+textWidth;
6926
+ var itemHeight=Math.max(textHeight,titleHeight);
6927
+
6928
+ if (IFrameSplitOperator.IsNumber(item.Space)) itemWidth+=item.Space;
6929
+
6930
+ if (item.Margin)
6931
+ {
6932
+ var margin=item.Margin;
6933
+ if (IFrameSplitOperator.IsNumber(margin.Left)) itemWidth+=margin.Left;
6934
+ if (IFrameSplitOperator.IsNumber(margin.Right)) itemWidth+=margin.Right;
6935
+ if (IFrameSplitOperator.IsNumber(margin.Top)) itemHeight+=margin.Top;
6936
+ if (IFrameSplitOperator.IsNumber(margin.Bottom)) itemHeight+=margin.Bottom;
6937
+ }
6938
+
6939
+ if (width<itemWidth) width=itemWidth;
6940
+ height+=itemHeight;
6941
+
6942
+ size.Text[i]={ Width: itemWidth, Height:itemHeight, TitleWidth:titleWidth, TextWidth:textWidth };
6943
+ }
6944
+
6945
+ if (this.Margin)
6946
+ {
6947
+ var margin=this.Margin;
6948
+ if (IFrameSplitOperator.IsNumber(margin.Left)) width+=margin.Left;
6949
+ if (IFrameSplitOperator.IsNumber(margin.Right)) width+=margin.Right;
6950
+ if (IFrameSplitOperator.IsNumber(margin.Top)) height+=margin.Top;
6951
+ if (IFrameSplitOperator.IsNumber(margin.Bottom)) height+=margin.Bottom;
6952
+ }
6953
+
6954
+ size.Width=width;
6955
+ size.Height=height;
6956
+ }
6957
+
6958
+ this.DrawTooltip=function(aryText, size)
6959
+ {
6960
+ var rtBG={ Left:this.Point.X+this.XOffset, Top:this.Point.Y+this.YOffset, Width:size.Width, Height:size.Height };
6961
+ rtBG.Right=rtBG.Left+rtBG.Width;
6962
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
6963
+
6964
+ var border=this.ChartBorder.GetBorder();
6965
+ if (rtBG.Bottom>border.ChartHeight)
6966
+ {
6967
+ rtBG.Bottom=this.Point.Y;
6968
+ rtBG.Top=rtBG.Bottom-rtBG.Height;
6969
+ }
6970
+
6971
+ if (rtBG.Right>border.ChartWidth)
6972
+ {
6973
+ rtBG.Right=this.Point.X;
6974
+ rtBG.Left=rtBG.Right-rtBG.Width;
6975
+ }
6976
+
6977
+ if (this.BGColor)
6978
+ {
6979
+ this.Canvas.fillStyle=this.BGColor;
6980
+ this.Canvas.fillRect(ToFixedPoint(rtBG.Left),ToFixedPoint(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));
6981
+ }
6982
+
6983
+ if (this.BorderColor)
6984
+ {
6985
+ this.Canvas.strokeStyle=this.BorderColor;
6986
+ this.Canvas.strokeRect(ToFixedPoint(rtBG.Left),ToFixedPoint(rtBG.Top),ToFixedRect(rtBG.Width),ToFixedRect(rtBG.Height));
6987
+ }
6988
+
6989
+ var left=rtBG.Left;
6990
+ var top=rtBG.Top;
6991
+ if (this.Margin && IFrameSplitOperator.IsNumber(this.Margin.Left)) left+=this.Margin.Left;
6992
+ if (this.Margin && IFrameSplitOperator.IsNumber(this.Margin.Top)) top+=this.Margin.Top;
6993
+
6994
+ var xText, yText=top;
6995
+ for(var i=0;i<aryText.length;++i)
6996
+ {
6997
+ var item=aryText[i];
6998
+ if (!item.Title && !item.Text) continue;
6999
+ var itemSize=size.Text[i];
7000
+
7001
+ xText=left;
7002
+ yText+=itemSize.Height;
7003
+
7004
+ if (item.Margin && IFrameSplitOperator.IsNumber(item.Margin.Left)) xText+=item.Margin.Left;
7005
+ if (item.Margin && IFrameSplitOperator.IsNumber(item.Margin.Bottom)) yText-=item.Margin.Bottom;
7006
+ if (item.Title)
7007
+ {
7008
+ if (item.TitleColor) this.Canvas.fillStyle=item.TitleColor;
7009
+ else this.Canvas.fillStyle=this.TextColor;
7010
+ this.Canvas.fillText(item.Title,xText,yText,itemSize.TitleWidth);
7011
+ xText+=itemSize.TitleWidth;
7012
+ if (IFrameSplitOperator.IsNumber(item.Space)) xText+=item.Space;
7013
+ }
7014
+
7015
+ if (item.Text)
7016
+ {
7017
+ if (item.Color) this.Canvas.fillStyle=item.Color;
7018
+ else this.Canvas.fillStyle=this.TextColor;
7019
+ this.Canvas.fillText(item.Text,xText,yText,itemSize.TextWidth);
7020
+ }
7021
+
7022
+ }
7023
+ }
7024
+ }