hqchart 1.1.14641 → 1.1.14648

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.
@@ -3147,7 +3147,10 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3147
3147
  },
3148
3148
 
3149
3149
  //锁十字光标
3150
- LockCorssCursor:{ X:{ Enable:false } }
3150
+ LockCorssCursor:{ X:{ Enable:false } },
3151
+
3152
+ //图形中的单元选中状态
3153
+ MapIndexChartCache:new Map(), //key 指标GUID
3151
3154
  };
3152
3155
 
3153
3156
  this.VerticalDrag; //通过X轴左右拖动数据(手势才有)
@@ -3824,6 +3827,56 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
3824
3827
  return false;
3825
3828
  }
3826
3829
 
3830
+ //点击图新内部元素
3831
+ this.TryClickChartCell=function(x, y, e)
3832
+ {
3833
+ var result=null;
3834
+ for(var i=0;i<this.ChartPaint.length;++i)
3835
+ {
3836
+ var item=this.ChartPaint[i];
3837
+ if (!item.ClickCell) continue;
3838
+ if (item.IsHideScriptIndex()) continue;
3839
+
3840
+ result=item.ClickCell(x,y,e);
3841
+ if (result) return result;
3842
+ }
3843
+
3844
+ for(var i=0;i<this.OverlayChartPaint.length;++i)
3845
+ {
3846
+ var item=this.OverlayChartPaint[i];
3847
+ if (!item.ClickCell) continue;
3848
+
3849
+ result=item.ClickCell(x,y,e);
3850
+ if (result) return result;
3851
+ }
3852
+
3853
+ for(var i=0,j=0,k=0;i<this.Frame.SubFrame.length;++i)
3854
+ {
3855
+ var item=this.Frame.SubFrame[i];
3856
+ if (!IFrameSplitOperator.IsNonEmptyArray(item.OverlayIndex)) continue;
3857
+
3858
+ for(j=0;j<item.OverlayIndex.length;++j)
3859
+ {
3860
+ var overlayItem=item.OverlayIndex[j];
3861
+ if (!IFrameSplitOperator.IsNonEmptyArray(overlayItem.ChartPaint)) continue;
3862
+
3863
+ for(var k=0;k<overlayItem.ChartPaint.length; ++k)
3864
+ {
3865
+ var chart=overlayItem.ChartPaint[k];
3866
+ if (!chart.IsShow) continue;
3867
+ if (chart.IsHideScriptIndex()) continue;
3868
+ if (chart.ClickCell)
3869
+ {
3870
+ result=chart.ClickCell(x,y,e);
3871
+ if (result) return result;
3872
+ }
3873
+ }
3874
+ }
3875
+ }
3876
+
3877
+ return null;
3878
+ }
3879
+
3827
3880
  this.TryMouseMove_CustomChartDrag=function(sendData)
3828
3881
  {
3829
3882
  var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_CUSTOM_DRAG_MOUSE_MOVE);
@@ -4135,23 +4188,41 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
4135
4188
  }, 250);
4136
4189
 
4137
4190
  var bSelectedChartChanged=false;
4138
- if (this.SelectedChart.EnableSelected)
4191
+ var clickCellData=this.TryClickChartCell(x,y,e); //点击图形子元素
4192
+
4193
+ if (clickCellData)
4194
+ {
4195
+ if (clickCellData.Redraw===true) bRedraw=true;
4196
+ }
4197
+ else
4139
4198
  {
4140
- var selectChart=this.PtInChart(x,y);
4141
- if (selectChart)
4199
+ if (this.SelectedChart.EnableSelected) //整体图形选中
4142
4200
  {
4143
- if (this.SelectedChart.Selected.Identify!=selectChart.Identify)
4201
+ var selectChart=this.PtInChart(x,y);
4202
+ if (selectChart)
4144
4203
  {
4145
- this.SelectedChart.Selected.Identify=selectChart.Identify;
4146
- this.SelectedChart.Selected.Chart=selectChart.Chart;
4147
- bSelectedChartChanged=true;
4148
- }
4204
+ if (this.SelectedChart.Selected.Identify!=selectChart.Identify)
4205
+ {
4206
+ this.SelectedChart.Selected.Identify=selectChart.Identify;
4207
+ this.SelectedChart.Selected.Chart=selectChart.Chart;
4208
+ bSelectedChartChanged=true;
4209
+ }
4149
4210
 
4150
- if (this.EnableIndexChartDrag)
4211
+ if (this.EnableIndexChartDrag)
4212
+ {
4213
+ this.IndexChartDrag={ SelectedChart:selectChart, LastMove:{X:x, Y:y}, Click:{X:x, Y:y } };
4214
+ this.IndexChartDrag.Info=this.GetSelectedChartInfo(selectChart);
4215
+ if (this.IndexChartDrag.Info) this.IndexChartDrag.Info.FrameID=this.Frame.PtInFrame(x,y);
4216
+ }
4217
+ }
4218
+ else
4151
4219
  {
4152
- this.IndexChartDrag={ SelectedChart:selectChart, LastMove:{X:x, Y:y}, Click:{X:x, Y:y } };
4153
- this.IndexChartDrag.Info=this.GetSelectedChartInfo(selectChart);
4154
- if (this.IndexChartDrag.Info) this.IndexChartDrag.Info.FrameID=this.Frame.PtInFrame(x,y);
4220
+ if (this.SelectedChart.Selected.Identify)
4221
+ {
4222
+ this.SelectedChart.Selected.Identify=null;
4223
+ this.SelectedChart.Selected.Chart=null;
4224
+ bSelectedChartChanged=true;
4225
+ }
4155
4226
  }
4156
4227
  }
4157
4228
  else
@@ -4159,19 +4230,10 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
4159
4230
  if (this.SelectedChart.Selected.Identify)
4160
4231
  {
4161
4232
  this.SelectedChart.Selected.Identify=null;
4162
- this.SelectedChart.Selected.Chart=null;
4163
4233
  bSelectedChartChanged=true;
4164
4234
  }
4165
4235
  }
4166
4236
  }
4167
- else
4168
- {
4169
- if (this.SelectedChart.Selected.Identify)
4170
- {
4171
- this.SelectedChart.Selected.Identify=null;
4172
- bSelectedChartChanged=true;
4173
- }
4174
- }
4175
4237
 
4176
4238
  if ((drawPictureActive.Select.Guid!=null && this.SelectChartDrawPicture==null) || bSelectedChartChanged)
4177
4239
  {
@@ -10017,6 +10079,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
10017
10079
  frame.Canvas=this.Canvas;
10018
10080
  frame.MainFrame=subFrame.Frame;
10019
10081
  frame.ChartBorder=subFrame.Frame.ChartBorder;
10082
+ frame.GlobalOption=this.GlobalOption;
10020
10083
  if (findOverlayItem) frame.IsShow=findOverlayItem.Frame.IsShow;
10021
10084
  //if (obj.IsShareY===true) frame.IsShareY=true;
10022
10085
  frame.YSplitOperator=new FrameSplitY();
@@ -25485,6 +25548,59 @@ function IChartPainting()
25485
25548
  else return item.Date;
25486
25549
  }
25487
25550
 
25551
+ //保存图形状态
25552
+ this.SaveCacheData=function(name, value)
25553
+ {
25554
+ if (!this.ChartFrame || !this.ChartFrame.GlobalOption) return false;
25555
+ var mapIndexCache=this.ChartFrame.GlobalOption.MapIndexChartCache;
25556
+ if (!mapIndexCache) return false;
25557
+
25558
+ if (!this.Script || !this.Script.Guid) return false;
25559
+ if (!this.Name) return false;
25560
+
25561
+ var id=this.Script.Guid; //指标ID;
25562
+ if (!mapIndexCache.has(id))
25563
+ {
25564
+ mapIndexCache.set(id, { MapData:new Map() });
25565
+ }
25566
+
25567
+ var mapItem=mapIndexCache.get(id);
25568
+ var key=`${this.Name}-${name}`;
25569
+ mapItem.MapData.set(key, value);
25570
+
25571
+ return true;
25572
+ }
25573
+
25574
+ //获取缓存数据 返回数据 out:{ Data, Key, IndexGuid }
25575
+ this.GetCacheData=function(name, out)
25576
+ {
25577
+ if (!this.ChartFrame || !this.ChartFrame.GlobalOption) return false;
25578
+ var mapIndexCache=this.ChartFrame.GlobalOption.MapIndexChartCache;
25579
+ if (!mapIndexCache) return false;
25580
+
25581
+ if (!this.Script || !this.Script.Guid) return false;
25582
+ if (!this.Name) return false;
25583
+
25584
+ var id=this.Script.Guid; //指标ID;
25585
+ if (!mapIndexCache.has(id)) return false;
25586
+
25587
+ var mapItem=mapIndexCache.get(id);
25588
+ var key=`${this.Name}-${name}`;
25589
+
25590
+ if (!mapItem.MapData.has(key)) return false;
25591
+
25592
+ var value=mapItem.MapData.get(key);
25593
+ if (out)
25594
+ {
25595
+ out.Data=value;
25596
+ out.Key=key;
25597
+ out.IndexGuid=id;
25598
+ }
25599
+
25600
+ return true;
25601
+ }
25602
+
25603
+
25488
25604
  //数据导出 数据格式 [{ Title:数据名称, Data:[] }]
25489
25605
  //this.ExportData=function(aryKData) { }
25490
25606
 
@@ -26198,6 +26314,12 @@ function IChartPainting()
26198
26314
  }
26199
26315
  }
26200
26316
 
26317
+ //缓存键值
26318
+ IChartPainting.CACHE_KEY=
26319
+ {
26320
+ SELECTED:"_Selected_Key_", //图形元素选中(单选)
26321
+ }
26322
+
26201
26323
 
26202
26324
  //缩放因子
26203
26325
  /*
@@ -32603,7 +32725,7 @@ function ChartKLineTable()
32603
32725
  this.newMethod();
32604
32726
  delete this.newMethod;
32605
32727
 
32606
- this.ClassName='ChartKlineTable'; //类名
32728
+ this.ClassName='ChartKLineTable'; //类名
32607
32729
  this.Data;
32608
32730
  this.RowName;
32609
32731
  this.RowNamePosition=1; //0=不显示 1=左边内部 2=左边外部 3=右边外部
@@ -44000,8 +44122,11 @@ function ChartDrawSVG()
44000
44122
  this.BuildKeyCallback=null;
44001
44123
  this.MapCache=null; //key=date/date-time value={ Data:[] }
44002
44124
 
44003
- this.AryDrawDetail=[]; //需要绘制的文字信息
44004
- this.EnalbeDetailNoOverlap=false; //详情重叠不显示
44125
+ this.AryDrawDetail=[]; //需要绘制的文字信息
44126
+ this.EnalbeDetailNoOverlap=false; //详情重叠不显示
44127
+ this.EnableClick=false; //是否支持点击
44128
+ this.PixelRatio=GetDevicePixelRatio();
44129
+ this.SelectedItemCache=null;
44005
44130
 
44006
44131
  this.BuildKey=function(item)
44007
44132
  {
@@ -44039,6 +44164,7 @@ function ChartDrawSVG()
44039
44164
  this.AryDrawRect=[];
44040
44165
  this.AryDrawDetail=[];
44041
44166
  this.AutoYOffset=0;
44167
+ this.SelectedItemCache=null;
44042
44168
 
44043
44169
  if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
44044
44170
  if (this.IsShowIndexTitleOnly()) return;
@@ -44049,13 +44175,17 @@ function ChartDrawSVG()
44049
44175
 
44050
44176
  if (this.EnalbeDetailNoOverlap) this.DrawOnVerlapDetail();
44051
44177
 
44178
+ this.DrawSelectedItem();
44179
+
44052
44180
  this.AryDrawDetail=[];
44181
+ this.SelectedItemCache=null;
44053
44182
  }
44054
44183
 
44055
44184
  this.DrawDetail=function(rtSVG, data, svgItem)
44056
44185
  {
44057
44186
  if (!IFrameSplitOperator.IsNonEmptyArray(data.Content)) return;
44058
44187
 
44188
+ var bSelected=this.IsSelectedItem(svgItem); //是否是选中点
44059
44189
  var lefMargin=2;
44060
44190
  var rightMargin=2;
44061
44191
  var itemSpace=2;
@@ -44116,13 +44246,15 @@ function ChartDrawSVG()
44116
44246
  }
44117
44247
  }
44118
44248
 
44249
+ if (bSelected) this.SelectedItemCache.Detail={ AryText:aryText, Rect:rtBorder, Data:svgItem };
44250
+
44119
44251
  if (this.EnalbeDetailNoOverlap) //启动重叠不会 先不画只计算位置, 后面统一画
44120
44252
  {
44121
44253
  this.AryDrawDetail.push({ Rect:rtBorder, AryText:aryText, Data:svgItem });
44122
44254
  return;
44123
44255
  }
44124
44256
 
44125
- this.DrawDetailText(data,aryText,rtBorder);
44257
+ if (!bSelected) this.DrawDetailText(data,aryText,rtBorder);
44126
44258
 
44127
44259
  this.AryDrawRect.push( {Left:rtBorder.Left, Top:rtBorder.Top, Right:rtBorder.Right, Bottom:rtBorder.Bottom, Type:"Detail", Data:svgItem } );
44128
44260
  }
@@ -44131,6 +44263,11 @@ function ChartDrawSVG()
44131
44263
  {
44132
44264
  if (!data) return;
44133
44265
 
44266
+ if (data.Font) this.Canvas.font=data.Font;
44267
+ else this.Canvas.font=this.TextFont;
44268
+ this.Canvas.textBaseline='bottom';
44269
+ this.Canvas.textAlign='left';
44270
+
44134
44271
  if (data.BGColor)
44135
44272
  {
44136
44273
  this.Canvas.fillStyle=data.BGColor;
@@ -44164,7 +44301,9 @@ function ChartDrawSVG()
44164
44301
 
44165
44302
  if (this.IsRectOverlap(rtBorder)) continue;
44166
44303
 
44167
- this.DrawDetailText(drawItem.Data.Detail, drawItem.AryText, rtBorder);
44304
+ var bSelected=this.IsSelectedItem(drawItem.Data); //是否是选中点
44305
+
44306
+ if (!bSelected) this.DrawDetailText(drawItem.Data.Detail, drawItem.AryText, rtBorder);
44168
44307
 
44169
44308
  this.AryDrawRect.push( {Left:rtBorder.Left, Top:rtBorder.Top, Right:rtBorder.Right, Bottom:rtBorder.Bottom, Type:"Detail", Data:drawItem.Data } );
44170
44309
  }
@@ -44329,6 +44468,12 @@ function ChartDrawSVG()
44329
44468
  }
44330
44469
  }
44331
44470
 
44471
+ this.IsSelectedItem=function(item)
44472
+ {
44473
+ if (!this.SelectedItemCache) return false;
44474
+ return this.SelectedItemCache.ID==item.ID;
44475
+ }
44476
+
44332
44477
  this.DrawSVGV2=function()
44333
44478
  {
44334
44479
  if (!this.IsShow || this.ChartFrame.IsMinSize) return;
@@ -44344,7 +44489,7 @@ function ChartDrawSVG()
44344
44489
  var distanceWidth=this.ChartFrame.DistanceWidth;
44345
44490
  var isMinute=this.IsMinuteFrame();
44346
44491
  var border=this.GetBorder();
44347
- var pixelRatio = GetDevicePixelRatio();
44492
+ this.PixelRatio=GetDevicePixelRatio();
44348
44493
 
44349
44494
  if (this.IsHScreen)
44350
44495
  {
@@ -44359,7 +44504,11 @@ function ChartDrawSVG()
44359
44504
  var bottom=border.BottomEx;
44360
44505
  }
44361
44506
 
44362
- var x,y,price;
44507
+ var selectedData={ };
44508
+ if (this.GetCacheData(IChartPainting.CACHE_KEY.SELECTED, selectedData)) //选中图标
44509
+ this.SelectedItemCache={ ID:selectedData.Data.ID };
44510
+
44511
+ var x;
44363
44512
  var setKey=new Set(); //已经画过的Key就不再用了
44364
44513
  for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
44365
44514
  {
@@ -44386,147 +44535,200 @@ function ChartDrawSVG()
44386
44535
  {
44387
44536
  var item=mapItem.Data[k];
44388
44537
 
44389
- if (item.Value=="Top") y=top;
44390
- else if (item.Value=="Bottom") y=bottom;
44391
- else
44538
+ if (this.IsSelectedItem(item))
44392
44539
  {
44393
- if (IFrameSplitOperator.IsString(item.Value)) price=this.GetKValue(kItem,item.Value);
44394
- else price=item.Value;
44395
-
44396
- y=this.ChartFrame.GetYFromData(price, false);
44540
+ this.SelectedItemCache.Item=item;
44541
+ this.SelectedItemCache.KItem=kItem;
44542
+ this.SelectedItemCache.Index=i;
44543
+ this.SelectedItemCache.X=x;
44544
+ this.SelectedItemCache.Top=top;
44545
+ this.SelectedItemCache.Bottom=bottom;
44397
44546
  }
44398
- if (IFrameSplitOperator.IsNumber(item.YOffset)) y+=item.YOffset; //Y轴偏移
44399
44547
 
44400
- var svgItem=item.SVG;
44401
- if (IFrameSplitOperator.IsNumber(svgItem.YOffset)) y+=svgItem.YOffset;
44548
+ this.DrawSVGItem(item, kItem, i, x, top, bottom);
44549
+ }
44402
44550
 
44403
- if (this.AutoPosition)
44404
- {
44405
- var pt={ X:x, Y:y };
44406
- this.CalculateShowPosition(item, pt); //重新计算位置
44407
- x=pt.X;
44408
- y=pt.Y;
44409
- }
44551
+ setKey.add(key);
44552
+ }
44553
+ }
44410
44554
 
44411
- var fontSVG=`${svgItem.Size}px ${this.Family}`;
44412
- this.Canvas.font=fontSVG;
44413
- var halfSize=svgItem.Size/2;
44414
- var textBaseline='bottom';
44415
- var rtSVG={ Left:x-halfSize, Right:x+halfSize, Top:y-svgItem.Size, Bottom:y, Height:svgItem.Size, Width:svgItem.Size };
44416
- if (svgItem.VAlign===0)
44417
- {
44418
- textBaseline="top";
44419
- rtSVG.Top=y;
44420
- rtSVG.Bottom=rtSVG.Top+svgItem.Size;
44421
- }
44422
- else if (svgItem.VAlign===1)
44423
- {
44424
- textBaseline='middle';
44425
- rtSVG.Top=y-svgItem.Size/2;
44426
- rtSVG.Bottom=rtSVG.Top+svgItem.Size;
44427
- }
44428
44555
 
44429
- if (rtSVG.Top<0)
44430
- {
44431
- rtSVG.Top=0;
44432
- rtSVG.Bottom=svgItem.Size;
44433
- y=rtSVG.Bottom;
44434
- }
44556
+ this.GetYFromData=function(value, kItem, top, bottom)
44557
+ {
44558
+ if (value=="Top") return top;
44559
+ if (value=="Bottom") return bottom;
44560
+
44561
+ var price;
44562
+ if (IFrameSplitOperator.IsString(value)) price=this.GetKValue(kItem,value);
44563
+ else price=value;
44435
44564
 
44436
- this.Canvas.textBaseline=textBaseline;
44437
- this.Canvas.textAlign='center';
44438
- this.Canvas.fillStyle = svgItem.Color;
44439
- this.Canvas.fillText(svgItem.Symbol, x, y);
44565
+ var y=this.ChartFrame.GetYFromData(price, false);
44440
44566
 
44441
- this.AryDrawRect.push( {Left:rtSVG.Left, Top:rtSVG.Top, Right:rtSVG.Right, Bottom:rtSVG.Bottom, Type:"SVG", Data:item } );
44567
+ return y;
44568
+ }
44442
44569
 
44443
- if (this.EnableTooltip) this.TooltipRect.push({ Rect:rtSVG, Index:i, Item:item });
44570
+ this.DrawSVGItem=function(item, kItem, index, x, top, bottom)
44571
+ {
44572
+ var y=this.GetYFromData(item.Value, kItem, top, bottom);
44573
+ if (IFrameSplitOperator.IsNumber(item.YOffset)) y+=item.YOffset; //Y轴偏移
44444
44574
 
44445
- //文字
44446
- if (item.Text && item.Text.Content && this.TextFont)
44447
- {
44448
- var textItem=item.Text;
44449
- this.Canvas.font=this.TextFont;
44450
- this.Canvas.fillStyle=textItem.Color;
44451
- var yText=y;
44452
- if (IFrameSplitOperator.IsNumber(textItem.YOffset)) yText+=textItem.YOffset;
44453
- this.Canvas.fillText(textItem.Content, x, yText);
44454
- }
44575
+ var svgItem=item.SVG;
44576
+ if (IFrameSplitOperator.IsNumber(svgItem.YOffset)) y+=svgItem.YOffset;
44455
44577
 
44456
- if (item.Detail)
44457
- {
44458
- this.DrawDetail(rtSVG,item.Detail, item);
44459
- }
44460
-
44461
- //连线
44462
- if (item.Line)
44463
- {
44464
- var lineItem=item.Line;
44465
- var price=null, yPrice=null;
44466
- if (lineItem.Value=="Bottom")
44467
- {
44468
- yPrice=bottom;
44469
- }
44470
- else if (lineItem.Value=="Top")
44471
- {
44472
- yPrice=top;
44473
- }
44474
- else
44475
- {
44476
- if (IFrameSplitOperator.IsString(lineItem.Value)) price=this.GetKValue(kItem,lineItem.Value);
44477
- else if (IFrameSplitOperator.IsNumber(lineItem.Value)) price=lineItem.Value;
44578
+ if (this.AutoPosition)
44579
+ {
44580
+ var pt={ X:x, Y:y };
44581
+ this.CalculateShowPosition(item, pt); //重新计算位置
44582
+ x=pt.X;
44583
+ y=pt.Y;
44584
+ }
44478
44585
 
44479
- if (!IFrameSplitOperator.IsNumber(price)) continue;
44480
- yPrice=this.ChartFrame.GetYFromData(price);
44481
- }
44482
-
44483
- if (yPrice>=rtSVG.Top && yPrice<=rtSVG.Bottom) continue;
44586
+ var bSelected=this.IsSelectedItem(item); //是否是选中点
44484
44587
 
44485
- var yText;
44486
- if (yPrice<rtSVG.Top)
44487
- {
44488
- yText=rtSVG.Top;
44489
- if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
44490
- {
44491
- //yPrice+=lineItem.Blank;
44492
- yText-=lineItem.SVGBlank;
44493
- }
44494
- }
44495
- else
44496
- {
44497
- yText=rtSVG.Bottom;
44498
- if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
44499
- {
44500
- //yPrice-=lineItem.Blank;
44501
- yText+=lineItem.SVGBlank;
44502
- }
44503
- }
44588
+ var fontSVG=`${svgItem.Size}px ${this.Family}`;
44589
+ this.Canvas.font=fontSVG;
44590
+ var halfSize=svgItem.Size/2;
44591
+ var textBaseline='bottom';
44592
+ var rtSVG={ Left:x-halfSize, Right:x+halfSize, Top:y-svgItem.Size, Bottom:y, Height:svgItem.Size, Width:svgItem.Size };
44593
+ if (svgItem.VAlign===0)
44594
+ {
44595
+ textBaseline="top";
44596
+ rtSVG.Top=y;
44597
+ rtSVG.Bottom=rtSVG.Top+svgItem.Size;
44598
+ }
44599
+ else if (svgItem.VAlign===1)
44600
+ {
44601
+ textBaseline='middle';
44602
+ rtSVG.Top=y-svgItem.Size/2;
44603
+ rtSVG.Bottom=rtSVG.Top+svgItem.Size;
44604
+ }
44504
44605
 
44505
- if (lineItem.Dash) this.Canvas.setLineDash(lineItem.Dash); //虚线
44506
- var lineWidth=1*pixelRatio;
44507
- if (lineItem.Width>0) lineWidth=lineItem.Width*pixelRatio;
44508
- this.Canvas.lineWidth=lineWidth; //线宽
44509
- this.Canvas.strokeStyle = lineItem.Color;
44510
- this.Canvas.beginPath();
44606
+ if (rtSVG.Top<0)
44607
+ {
44608
+ rtSVG.Top=0;
44609
+ rtSVG.Bottom=svgItem.Size;
44610
+ y=rtSVG.Bottom;
44611
+ }
44511
44612
 
44512
- if (this.IsHScreen)
44513
- {
44514
- this.Canvas.moveTo(yText, ToFixedPoint(x));
44515
- this.Canvas.lineTo(yPrice,ToFixedPoint(x));
44516
- }
44517
- else
44518
- {
44519
- this.Canvas.moveTo(ToFixedPoint2(lineWidth,x),yText);
44520
- this.Canvas.lineTo(ToFixedPoint2(lineWidth,x),yPrice);
44521
- }
44522
-
44523
- this.Canvas.stroke();
44524
- this.Canvas.setLineDash([]);
44525
- }
44613
+ if (!bSelected)
44614
+ {
44615
+ this.Canvas.textBaseline=textBaseline;
44616
+ this.Canvas.textAlign='center';
44617
+ this.Canvas.fillStyle = svgItem.Color;
44618
+ this.Canvas.fillText(svgItem.Symbol, x, y);
44619
+ }
44620
+ else
44621
+ {
44622
+ this.SelectedItemCache.RectSVG=rtSVG; //保存图标的位置
44623
+ this.SelectedItemCache.SVGConfig={ Font:fontSVG, TextBaseline:textBaseline, X:x, Y:y };
44624
+ }
44625
+
44626
+ this.AryDrawRect.push( {Left:rtSVG.Left, Top:rtSVG.Top, Right:rtSVG.Right, Bottom:rtSVG.Bottom, Type:"SVG", Data:item } );
44627
+
44628
+ if (this.EnableTooltip) this.TooltipRect.push({ Rect:rtSVG, Index:index, Item:item });
44629
+
44630
+ //图标内的文字
44631
+ if (!bSelected && item.Text && item.Text.Content && this.TextFont)
44632
+ {
44633
+ var textItem=item.Text;
44634
+ this.Canvas.font=this.TextFont;
44635
+ this.Canvas.fillStyle=textItem.Color;
44636
+ var yText=y;
44637
+ if (IFrameSplitOperator.IsNumber(textItem.YOffset)) yText+=textItem.YOffset;
44638
+ this.Canvas.fillText(textItem.Content, x, yText);
44639
+ }
44640
+
44641
+ //图标左右两边文字
44642
+ if (item.Detail) this.DrawDetail(rtSVG, item.Detail, item);
44643
+
44644
+ //连线
44645
+ if (!bSelected && item.Line) this.DrawVerticalLine(item,kItem,x, rtSVG, top, bottom);
44646
+ }
44647
+
44648
+ //绘制垂直连线
44649
+ this.DrawVerticalLine=function(item, kItem, x, rtSVG, top, bottom)
44650
+ {
44651
+ if (!item.Line) return;
44652
+
44653
+ var lineItem=item.Line;
44654
+ var yPrice=this.GetYFromData(lineItem.Value, kItem, top, bottom)
44655
+ if (yPrice>=rtSVG.Top && yPrice<=rtSVG.Bottom) return;
44656
+
44657
+ var yText;
44658
+ if (yPrice<rtSVG.Top)
44659
+ {
44660
+ yText=rtSVG.Top;
44661
+ if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
44662
+ {
44663
+ //yPrice+=lineItem.Blank;
44664
+ yText-=lineItem.SVGBlank;
44665
+ }
44666
+ }
44667
+ else
44668
+ {
44669
+ yText=rtSVG.Bottom;
44670
+ if (IFrameSplitOperator.IsNumber(lineItem.SVGBlank))
44671
+ {
44672
+ //yPrice-=lineItem.Blank;
44673
+ yText+=lineItem.SVGBlank;
44526
44674
  }
44675
+ }
44527
44676
 
44528
- setKey.add(key);
44677
+ if (lineItem.Dash) this.Canvas.setLineDash(lineItem.Dash); //虚线
44678
+ var lineWidth=1*this.PixelRatio;
44679
+ if (lineItem.Width>0) lineWidth=lineItem.Width*this.PixelRatio;
44680
+ this.Canvas.lineWidth=lineWidth; //线宽
44681
+ this.Canvas.strokeStyle = lineItem.Color;
44682
+ this.Canvas.beginPath();
44683
+
44684
+ if (this.IsHScreen)
44685
+ {
44686
+ this.Canvas.moveTo(yText, ToFixedPoint(x));
44687
+ this.Canvas.lineTo(yPrice,ToFixedPoint(x));
44688
+ }
44689
+ else
44690
+ {
44691
+ this.Canvas.moveTo(ToFixedPoint2(lineWidth,x),yText);
44692
+ this.Canvas.lineTo(ToFixedPoint2(lineWidth,x),yPrice);
44693
+ }
44694
+
44695
+ this.Canvas.stroke();
44696
+ this.Canvas.setLineDash([]);
44697
+ }
44698
+
44699
+ this.DrawSelectedItem=function()
44700
+ {
44701
+ if (!this.SelectedItemCache || !this.SelectedItemCache.Item) return;
44702
+
44703
+ var selecteItem=this.SelectedItemCache;
44704
+ var item=selecteItem.Item;
44705
+ var kItem=selecteItem.KItem;
44706
+ var top=selecteItem.Top;
44707
+ var bottom=selecteItem.Bottom;
44708
+ var rtSVG=selecteItem.RectSVG;
44709
+ var svgItem=item.SVG;
44710
+ var config=selecteItem.SVGConfig;
44711
+
44712
+ var x=config.X, y=config.Y;
44713
+ this.Canvas.font=config.Font;
44714
+ this.Canvas.textBaseline=config.TextBaseline;
44715
+ this.Canvas.textAlign='center';
44716
+ this.Canvas.fillStyle = svgItem.Color;
44717
+ this.Canvas.fillText(svgItem.Symbol, config.X, config.Y);
44718
+
44719
+ if (item.Text && item.Text.Content && this.TextFont)
44720
+ {
44721
+ var textItem=item.Text;
44722
+ this.Canvas.font=this.TextFont;
44723
+ this.Canvas.fillStyle=textItem.Color;
44724
+ var yText=y;
44725
+ if (IFrameSplitOperator.IsNumber(textItem.YOffset)) yText+=textItem.YOffset;
44726
+ this.Canvas.fillText(textItem.Content, x, yText);
44529
44727
  }
44728
+
44729
+ if (item.Line) this.DrawVerticalLine(item, kItem, x, rtSVG, top, bottom);
44730
+
44731
+ if (selecteItem.Detail) this.DrawDetailText(selecteItem.Item.Detail, selecteItem.Detail.AryText, selecteItem.Detail.Rect);
44530
44732
  }
44531
44733
 
44532
44734
  this.GetMaxMin=function()
@@ -44565,8 +44767,9 @@ function ChartDrawSVG()
44565
44767
  this.GetTooltipData=function(x,y,tooltip)
44566
44768
  {
44567
44769
  if (!this.IsShow) return false;
44770
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.TooltipRect)) return;
44568
44771
 
44569
- for(var i=0;i<this.TooltipRect.length;++i)
44772
+ for(var i=this.TooltipRect.length-1; i>=0; --i)
44570
44773
  {
44571
44774
  var item=this.TooltipRect[i];
44572
44775
  if (!item.Rect) continue;
@@ -44586,6 +44789,38 @@ function ChartDrawSVG()
44586
44789
 
44587
44790
  return false;
44588
44791
  }
44792
+
44793
+ this.ClickCell=function(x,y,e)
44794
+ {
44795
+ if (!this.IsShow) return null;
44796
+ if (!this.EnableClick) return null;
44797
+
44798
+ for(var i=this.TooltipRect.length-1; i>=0; --i)
44799
+ {
44800
+ var item=this.TooltipRect[i];
44801
+ if (!item.Rect) continue;
44802
+
44803
+ var rect=item.Rect;
44804
+ if (x>=rect.Left && x<=rect.Right && y>=rect.Top && y<=rect.Bottom)
44805
+ {
44806
+ var svgItem=item.Item;
44807
+ var id=svgItem.ID;
44808
+ var result={ Data:svgItem, Redraw:false, ChartPaint:this };
44809
+ var oldSelectedID=null;
44810
+ var out={ };
44811
+ if (this.GetCacheData(IChartPainting.CACHE_KEY.SELECTED, out)) oldSelectedID=out.Data.ID;
44812
+ if (id!=oldSelectedID)
44813
+ {
44814
+ this.SaveCacheData(IChartPainting.CACHE_KEY.SELECTED, { ID:id } );
44815
+ result.Redraw=true;
44816
+ }
44817
+
44818
+ return result;
44819
+ }
44820
+ }
44821
+
44822
+ return null;
44823
+ }
44589
44824
  }
44590
44825
 
44591
44826
  // OX图 支持横屏
@@ -81255,6 +81490,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
81255
81490
  frame.Canvas=this.Canvas;
81256
81491
  frame.MainFrame=subFrame.Frame;
81257
81492
  frame.ChartBorder=subFrame.Frame.ChartBorder;
81493
+ frame.GlobalOption=this.GlobalOption;
81258
81494
  frame.GetEventCallback=(id)=> { return this.GetEventCallback(id); };
81259
81495
  if (obj.ShowRightText===true) frame.IsShow=true;
81260
81496
  else if (obj.ShowRightText===false) frame.IsShow=false;