hqchart 1.1.15449 → 1.1.15455

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.
@@ -60966,6 +60966,8 @@ function FrameSplitKLinePriceY()
60966
60966
  isLast=pageInfo.IsLast;
60967
60967
  }
60968
60968
  }
60969
+
60970
+ if (!latestItem || !IFrameSplitOperator.IsNumber(latestItem.Close)) return null;
60969
60971
 
60970
60972
  var info=new CoordinateInfo();
60971
60973
  info.Type=0;
@@ -84068,7 +84070,7 @@ function JSChartResource()
84068
84070
  TitleColor:"rgb(90,90,90)",
84069
84071
  VolColor:"rgb(90,90,90)",
84070
84072
  Margin:{ Left:0, Top:0, Bottom:0, Right:0 },
84071
- CellMargin:{ Top:5, Bottom:5, Left:5, Right:5, YOffset:0 },
84073
+ CellMargin:{ Top:3*GetDevicePixelRatio(), Bottom:3*GetDevicePixelRatio(), Left:5*GetDevicePixelRatio(), Right:5*GetDevicePixelRatio(), YOffset:1*GetDevicePixelRatio() },
84072
84074
  BottomLine:{ Enable:true, Color:"rgb(192,192,192)"}, //底部分割线
84073
84075
  TopLine:{ Enable:false, Color:"rgb(192,192,192)"}, //底部分割线
84074
84076
 
@@ -84084,10 +84086,12 @@ function JSChartResource()
84084
84086
  Font:14*GetDevicePixelRatio() +'px 微软雅黑',
84085
84087
  TitleColor:"rgb(90,90,90)",
84086
84088
  TextColor:"rgb(90,90,90)",
84087
- Margin:{ Left:0, Top:0, Bottom:0, Right:0 },
84088
- CellMargin:{ Top:5, Bottom:5, Left:5, Right:5, YOffset:0 },
84089
+ Margin:{ Left:0, Top:2*GetDevicePixelRatio(), Bottom:0, Right:0 },
84090
+ CellMargin:{ Top:3*GetDevicePixelRatio(), Bottom:3*GetDevicePixelRatio(), Left:5, Right:5, YOffset:1*GetDevicePixelRatio() },
84089
84091
  },
84090
84092
 
84093
+ MouseOn:{ BGColor:"rgb(169,169,169)" },
84094
+
84091
84095
  UpTextColor:"rgb(238,21,21)", //上涨文字颜色
84092
84096
  DownTextColor:"rgb(25,158,0)", //下跌文字颜色
84093
84097
  UnchangeTextColor:"rgb(90,90,90)", //平盘文字颜色
@@ -85290,6 +85294,12 @@ function JSChartResource()
85290
85294
  }
85291
85295
  }
85292
85296
 
85297
+ if (style.MouseOn)
85298
+ {
85299
+ var item=style.MouseOn;
85300
+ if (item.BGColor) dest.MouseOn.BGColor=item.BGColor;
85301
+ }
85302
+
85293
85303
  if (style.UpTextColor) dest.UpTextColor=style.UpTextColor;
85294
85304
  if (style.DownTextColor) dest.DownTextColor=style.DownTextColor;
85295
85305
  if (style.UnchangeTextColor) dest.UnchangeTextColor=style.UnchangeTextColor;
@@ -140114,6 +140124,8 @@ function GetBlackStyle()
140114
140124
  //CellMargin:{ Top:5, Bottom:5, YOffset:0, Left:5, Right:5, YOffset:-5 },
140115
140125
  },
140116
140126
 
140127
+ MouseOn:{ BGColor:"rgb(54,54,54)" },
140128
+
140117
140129
  UpTextColor:"rgb(238,21,21)", //上涨文字颜色
140118
140130
  DownTextColor:"rgb(25,158,0)", //下跌文字颜色
140119
140131
  UnchangeTextColor:"rgb(90,90,90)", //平盘文字颜色
@@ -162314,484 +162326,510 @@ function JSTooltipMinuteChart()
162314
162326
  this.Minute.Date=date;
162315
162327
  this.Minute.PopData=data;
162316
162328
  this.Minute.JSChart.ChangeSymbol(symbol);
162317
- }
162318
- }
162319
-
162320
- if (IFrameSplitOperator.IsNumberV2(x,y))
162321
- {
162322
-
162323
- }
162324
- else if (data.Rect)
162325
- {
162326
- var rtCell=data.Rect;
162327
- var pixelRatio=GetDevicePixelRatio();
162328
- var rtItem={ Left:rtCell.Left/pixelRatio, Right:rtCell.Right/pixelRatio, Bottom:rtCell.Bottom/pixelRatio, Top:rtCell.Top/pixelRatio };
162329
- rtItem.Width=rtItem.Right-rtItem.Left;
162330
- rtItem.Height=rtItem.Bottom-rtItem.Top;
162331
-
162332
- //超出窗口调整位置
162333
- var height=this.DivDialog.offsetHeight;
162334
- var width=this.DivDialog.offsetWidth;
162335
- var x=rtItem.Right+data.Offset.Left;
162336
- var y=rtItem.Bottom+data.Offset.Top;
162337
-
162338
- var xRight=window.innerWidth-5;
162339
- var ybottom=window.innerHeight-5;
162340
- if (x+width>xRight) x=(rtItem.Left+data.Offset.Left)-width;
162341
- if (y+height>ybottom) y=(rtItem.Top+data.Offset.Top)-height;
162342
-
162343
- this.DivDialog.style.visibility='visible';
162344
- this.DivDialog.style.top = y + "px";
162345
- this.DivDialog.style.left = x + "px";
162346
- }
162347
- }
162348
-
162349
- this.Hide=function()
162350
- {
162351
- if (!this.DivDialog) return;
162352
- if (this.DivDialog.style.visibility!='hidden')
162353
- this.DivDialog.style.visibility='hidden';
162354
- }
162355
-
162356
-
162357
- this.ReloadResource=function(option)
162358
- {
162359
- this.BGColor=g_JSChartResource.PopMinuteChart.BGColor;
162360
- this.BorderColor=g_JSChartResource.PopMinuteChart.BorderColor;
162361
-
162362
- this.TitleFont=g_JSChartResource.PopMinuteChart.Title.Font; //指标标题字体
162363
- this.CorssCursorFont=g_JSChartResource.PopMinuteChart.CorssCursor.Font; //十字光标
162364
- this.FrameSplitTextFont=g_JSChartResource.PopMinuteChart.Frame.Font; //刻度文字
162365
-
162366
- if (!this.DivDialog) return;
162367
-
162368
- this.UpdateStyle();
162369
-
162370
- if (this.Minute.JSChart) this.Minute.JSChart.ReloadResource(option);
162371
- }
162372
-
162373
- this.LoadChartResource=function(chart)
162374
- {
162375
- if (IFrameSplitOperator.IsNonEmptyArray(chart.TitlePaint))
162376
- {
162377
- for(var i=0;i<chart.TitlePaint.length;++i)
162378
- {
162379
- var item=chart.TitlePaint[i];
162380
- if (!item) continue;
162381
-
162382
- item.Font=this.TitleFont;
162383
- }
162384
- }
162385
-
162386
- if (IFrameSplitOperator.IsNonEmptyArray(chart.WindowIndex))
162387
- {
162388
- for(var i=0;i<chart.WindowIndex.length;++i) //去掉指标里面的字体
162389
- {
162390
- var item=chart.WindowIndex[i];
162391
- if (!item) continue;
162392
- item.TitleFont=null;
162393
- }
162394
- }
162395
-
162396
- if (chart.ChartCorssCursor)
162397
- {
162398
- chart.ChartCorssCursor.Font=this.CorssCursorFont;
162399
- }
162400
- }
162401
-
162402
- this.OnSplitXCoordinate=function(event, data, obj)
162403
- {
162404
- var frame=data.Frame;
162405
- if (IFrameSplitOperator.IsNonEmptyArray(frame.VerticalInfo))
162406
- {
162407
- for(var i=0;i<frame.VerticalInfo.length;++i)
162408
- {
162409
- var item=frame.VerticalInfo[i];
162410
- if (!item) continue;
162411
- if (item.Font) item.Font=this.FrameSplitTextFont;
162412
- }
162413
- }
162414
- }
162415
-
162416
- this.OnSplitYCoordinate=function(event, data, obj)
162417
- {
162418
- var frame=data.Frame;
162419
- if (IFrameSplitOperator.IsNonEmptyArray(frame.HorizontalInfo))
162420
- {
162421
- for(var i=0;i<frame.HorizontalInfo.length;++i)
162422
- {
162423
- var item=frame.HorizontalInfo[i];
162424
- if (!item) continue;
162425
- if (item.Font) item.Font=this.FrameSplitTextFont;
162426
- }
162427
- }
162428
- }
162429
-
162430
- }
162431
-
162432
- JSTooltipMinuteChart.GetMinuteOption=function()
162433
- {
162434
- var option=
162435
- {
162436
- Type:'分钟走势图', //创建图形类型
162437
- Windows: //窗口指标
162438
- [
162439
- //{ Index:"VOL" },
162440
- //{ Index:"RSI" }
162441
- ],
162442
-
162443
- Symbol:null, // cf1909.czc
162444
- IsAutoUpdate:false, //是自动更新数据
162445
- AutoUpdateFrequency:10000, //数据更新频率
162446
- DayCount:1, //1 最新交易日数据 >1 多日走势图
162447
- IsShowRightMenu:false, //是否显示右键菜单
162448
-
162449
- EnableSelectRect:true,
162450
- EnableZoomIndexWindow:true,
162451
- EnableResize:true,
162452
-
162453
- //BeforeOpen:{IsShow:true, Width:120, IsShowMultiDay:true, MulitiDayWidth:100, },
162454
- //AfterClose:{IsShow:true, Width:100, IsShowMultiDay:true, MulitiDayWidth:50, ShareVol:2 }, //ShareVol:0=盘后成交量独立坐标, 1==盘后成交量主图共用 2==盘后成交量盘前共用
162455
-
162456
- CorssCursorInfo:{ Left:1, Right:1, Bottom:1 },
162457
-
162458
- MinuteLine:
162459
- {
162460
-
162461
- },
162462
-
162463
- MinuteTitle:
162464
- {
162465
- IsShowTime:true,
162466
- IsShowName:true,
162467
- IsShowDate:true,
162468
- IsShowVolTitle:true,
162469
- //IsAlwaysShowLastData:true,
162470
- IsTitleShowLatestData:true,
162471
-
162472
- ShowPostion:{ Type:1 , Margin:{ Left:5*GetDevicePixelRatio(), Right:5*GetDevicePixelRatio() } }
162473
- },
162474
-
162475
- MinuteVol:
162476
- {
162477
- BarColorType:1,
162478
- },
162479
-
162480
- //Language:'EN',
162481
-
162482
- Border: //边框
162483
- {
162484
- Left:20, //左边间距
162485
- Right:120, //右边间距
162486
- Top:20,
162487
- Bottom:20,
162488
-
162489
- AutoLeft:{ Blank:10, MinWidth:40 },
162490
- AutoRight:{ Blank:10, MinWidth:40 },
162491
- },
162492
-
162493
- Frame: //子框架设置
162494
- [
162495
- { SplitCount:5 },
162496
- { SplitCount:3 },
162497
- { SplitCount:3 },
162498
- ],
162499
- }
162500
-
162501
- return option;
162502
- }
162503
-
162504
-
162505
- ///////////////////////////////////////////////////////
162506
- // K线上标记选中
162507
-
162508
- function MarkPopMinutePaint()
162509
- {
162510
- this.newMethod=IExtendChartPainting; //派生
162511
- this.newMethod();
162512
- delete this.newMethod;
162513
-
162514
- this.ClassName="MarkPopMinutePaint";
162515
- this.MapDate; //标记日期
162516
- this.BGColor="rgba(100,100,100,0.2)";
162517
- this.LineWidth=g_JSChartResource.PopMinuteChart.Mark.LineWidth;
162518
- this.LineColor=g_JSChartResource.PopMinuteChart.Mark.LineColor;
162519
- this.SubFrame;
162520
- this.IsDynamic=true;
162521
- this.IsShow=true;
162522
-
162523
-
162524
- this.ReloadResource=function(resource)
162525
- {
162526
- this.LineWidth=g_JSChartResource.PopMinuteChart.Mark.LineWidth;
162527
- this.LineColor=g_JSChartResource.PopMinuteChart.Mark.LineColor;
162528
- }
162529
-
162530
- this.SetDate=function(aryDate)
162531
- {
162532
- this.MapDate=new Map();
162533
- if (IFrameSplitOperator.IsNonEmptyArray(aryDate))
162534
- {
162535
- for(var i=0;i<aryDate.length;++i)
162536
- {
162537
- var date=aryDate[i];
162538
- this.MapDate.set(date, { Date:date} );
162539
- }
162540
- }
162541
- }
162542
-
162543
- this.ClearData=function()
162544
- {
162545
- this.MapDate=null;
162546
- }
162547
-
162548
- this.Draw=function()
162549
- {
162550
- this.SubFrame=null;
162551
- if (!this.IsShow) return;
162552
- if (!this.HQChart) return;
162553
- if (!this.ChartFrame || !IFrameSplitOperator.IsNonEmptyArray(this.ChartFrame.SubFrame)) return;
162554
- if (!this.MapDate || this.MapDate.size<=0) return;
162555
-
162556
- var kData=this.HQChart.GetKData();
162557
- if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return;
162558
- this.SubFrame=this.ChartFrame.SubFrame[0].Frame;
162559
- if (!this.SubFrame) return;
162560
-
162561
- var dataWidth=this.SubFrame.DataWidth;
162562
- var distanceWidth=this.SubFrame.DistanceWidth;
162563
- var xPointCount=this.SubFrame.XPointCount;
162564
- var border=this.SubFrame.GetBorder();
162565
- var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
162566
- var chartright=border.RightEx;
162567
-
162568
- var startIndex=kData.DataOffset;
162569
- var aryBG=[];
162570
- for(var i=startIndex,j=0;i<kData.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
162571
- {
162572
- var kItem=kData.Data[i];
162573
- if (!kItem) continue;
162574
- if (!this.MapDate.has(kItem.Date)) continue
162575
-
162576
- var left=xOffset;
162577
- var right=xOffset+dataWidth;
162578
- var x=left+(right-left)/2;
162579
-
162580
- var bgItem={ Left:left, XCenter:x, Right:right, DataIndex:i, DataWidth:dataWidth };
162581
- aryBG.push(bgItem);
162582
- }
162583
-
162584
- if (IFrameSplitOperator.IsNonEmptyArray(aryBG))
162585
- {
162586
- this.Canvas.save();
162587
- this.DrawBG(aryBG);
162588
- this.Canvas.restore();
162589
- }
162590
-
162591
- this.SubFrame=null;
162592
- }
162593
-
162594
- this.DrawBG=function(aryBG)
162595
- {
162596
- var border=this.ChartFrame.ChartBorder.GetBorder();
162597
- var pixelRatio=GetDevicePixelRatio();
162598
- if (this.MapDate.size==1) //标记一天
162599
- {
162600
- var item=aryBG[0];
162601
- var lineWidth=this.LineWidth*pixelRatio;
162602
- if (item.DataWidth<=4) lineWidth=1*pixelRatio;
162603
-
162604
- this.Canvas.lineWidth=lineWidth;
162605
- this.Canvas.strokeStyle=this.LineColor;
162606
- var x=ToFixedPoint2(lineWidth,item.XCenter);
162607
- this.Canvas.beginPath();
162608
- this.Canvas.moveTo(x,border.TopEx);
162609
- this.Canvas.lineTo(x,border.BottomEx);
162610
- this.Canvas.stroke();
162611
- }
162612
- }
162613
- }
162614
-
162615
-
162616
- JSChart.RegisterExtendChartClass("MarkPopMinutePaint", { Create:function() { return new MarkPopMinutePaint}} );
162617
-
162618
-
162619
-
162620
-
162621
-
162622
-
162623
-
162624
-
162625
-
162626
- /*
162627
- Copyright (c) 2018 jones
162628
-
162629
- http://www.apache.org/licenses/LICENSE-2.0
162630
-
162631
- 开源项目 https://github.com/jones2000/HQChart
162632
-
162633
- jones_2000@163.com
162634
- */
162635
-
162636
-
162637
- ///////////////////////////////////////////////////////
162638
- // K线图提示信息
162639
- //
162640
- //////////////////////////////////////////////////////
162641
-
162642
- function JSTooltipKLineChart()
162643
- {
162644
- this.DivDialog=null;
162645
- this.HQChart=null;
162646
- this.ID=Guid();
162647
-
162648
- this.BGColor=g_JSChartResource.PopMinuteChart.BGColor;
162649
- this.BorderColor=g_JSChartResource.PopMinuteChart.BorderColor;
162650
- this.TitleFont=g_JSChartResource.PopMinuteChart.Title.Font; //指标标题字体
162651
- this.CorssCursorFont=g_JSChartResource.PopMinuteChart.CorssCursor.Font; //十字光标
162652
- this.FrameSplitTextFont=g_JSChartResource.PopMinuteChart.Frame.Font; //刻度文字
162653
-
162654
- this.OnCreatedCallback=null;
162655
-
162656
- this.KLine=
162657
- {
162658
- Option:JSTooltipKLineChart.GetKLineOption(),
162659
- JSChart:null,
162660
- Symbol:null,
162661
- }
162662
-
162663
- this.Inital=function(hqchart, option)
162664
- {
162665
- this.HQChart=hqchart;
162666
-
162667
- if (option)
162668
- {
162669
- if (IFrameSplitOperator.IsObject(option.Option))
162670
- {
162671
- var item=CloneData(option.Option); //复制一份出来
162672
- this.KLine.Option=Object.assign(this.KLine.Option,item);
162673
-
162674
- if (IFrameSplitOperator.IsNonEmptyArray(option.Option.EventCallback)) this.KLine.Option.EventCallback=option.Option.EventCallback;
162675
- }
162676
- if (option.OnCreatedCallback) this.OnCreatedCallback=option.OnCreatedCallback;
162677
- }
162678
- }
162679
-
162680
- this.Create=function()
162681
- {
162682
- var divDom=document.createElement('div');
162683
- divDom.className='UMyChart_Tooltip_KLine_Div';
162684
- divDom.id=this.ID;
162685
-
162686
- var divChart=document.createElement('div');
162687
- divChart.className='UMyChart_Tooltip_KLine_Chart_Div';
162688
- divDom.appendChild(divChart);
162689
-
162690
- this.DivDialog=divDom;
162691
-
162692
- var chart=JSChart.Init(divChart);
162693
- this.KLine.JSChart=chart;
162694
-
162695
- //语言跟主图保持一致
162696
- if (this.HQChart) this.KLine.Option.Language=g_JSChartLocalization.GetLanguageName(this.HQChart.LanguageID);
162697
- this.KLine.Option.OnCreatedCallback=(chart)=>{ this.OnCreateHQChart(chart); }
162698
- this.KLine.Option.NetworkFilter=(data, callback)=>{ this.NetworkFilter(data, callback); }
162699
-
162700
- var reloadResourceEvent=
162701
- {
162702
- event:JSCHART_EVENT_ID.ON_RELOAD_RESOURCE,
162703
- callback:(event, data, obj)=>{ this.LoadChartResource(obj); }
162704
- }
162705
-
162706
- var splitXEvent=
162707
- {
162708
- event:JSCHART_EVENT_ID.ON_SPLIT_XCOORDINATE,
162709
- callback:(event, data, obj)=>{ this.OnSplitXCoordinate(event, data, obj); }
162710
- };
162711
-
162712
- var splitYEvent=
162713
- {
162714
- event:JSCHART_EVENT_ID.ON_SPLIT_YCOORDINATE,
162715
- callback:(event, data, obj)=>{ this.OnSplitYCoordinate(event, data, obj); }
162716
- }
162717
-
162718
- if (Array.isArray(this.KLine.Option.EventCallback))
162719
- {
162720
- this.KLine.Option.EventCallback.unshift(reloadResourceEvent,splitYEvent,splitYEvent);
162721
- }
162722
- else
162723
- {
162724
- this.KLine.Option.EventCallback=[reloadResourceEvent,splitXEvent,splitYEvent];
162725
- }
162726
-
162727
-
162728
- chart.SetOption(this.KLine.Option); //设置K线配置
162729
-
162730
- document.body.appendChild(divDom);
162731
-
162732
- this.UpdateStyle();
162733
-
162734
- if (!this.KLine.Option.EnableResize)
162735
- {
162736
- if (this.KLine.JSChart) this.KLine.JSChart.OnSize({ Type:1 });
162737
- }
162738
- }
162739
-
162740
- this.UpdateStyle=function()
162741
- {
162742
- if (!this.DivDialog) return;
162743
-
162744
- if (this.BGColor) this.DivDialog.style['background-color']=this.BGColor;
162745
- if (this.BorderColor) this.DivDialog.style['border-color']=this.BorderColor;
162746
- }
162747
-
162748
- this.NetworkFilter=function(data, callback)
162749
- {
162750
- if (!this.HQChart || !this.HQChart.NetworkFilter) return;
162751
-
162752
- this.HQChart.NetworkFilter(data, callback);
162753
- }
162754
-
162755
- this.OnCreateHQChart=function(chart)
162756
- {
162757
- this.LoadChartResource(chart);
162758
-
162759
- if (this.OnCreatedCallback) this.OnCreatedCallback(chart);
162760
- }
162761
-
162762
- this.Destroy=function()
162763
- {
162764
- if (this.DivDialog)
162765
- {
162766
- if (document && document.body && document.body.removeChild)
162767
- document.body.removeChild(this.DivDialog);
162768
- }
162769
-
162770
- this.DivDialog=null;
162771
- this.TitleBox=null;
162772
- if (!this.KLine.JSChart) this.KLine.JSChart.ChartDestory();
162773
- this.KLine.JSChart=null;
162774
- }
162775
-
162776
- this.IsShow=function()
162777
- {
162778
- if (!this.DivDialog) return false;
162779
-
162780
- return this.DivDialog.style.visibility==='visible';
162781
- }
162782
-
162783
- this.Show=function(data, x, y)
162784
- {
162785
- if (!this.DivDialog) this.Create();
162786
- if (!data || !data.Symbol) return;
162787
-
162788
- var symbol=data.Symbol;
162789
- if (this.KLine.JSChart)
162790
- {
162791
- if (this.KLine.Symbol!=symbol)
162792
- {
162793
- this.KLine.Symbol=symbol;
162794
- this.KLine.JSChart.ChangeSymbol(symbol);
162329
+ }
162330
+ }
162331
+
162332
+ if (IFrameSplitOperator.IsNumberV2(x,y))
162333
+ {
162334
+
162335
+ }
162336
+ else if (data.Rect)
162337
+ {
162338
+ if (data.Position===1) //上左位置
162339
+ {
162340
+ var rtCell=data.Rect;
162341
+ var pixelRatio=GetDevicePixelRatio();
162342
+ var rtItem={ Left:rtCell.Left/pixelRatio, Right:rtCell.Right/pixelRatio, Bottom:rtCell.Bottom/pixelRatio, Top:rtCell.Top/pixelRatio };
162343
+ rtItem.Width=rtItem.Right-rtItem.Left;
162344
+ rtItem.Height=rtItem.Bottom-rtItem.Top;
162345
+
162346
+ //超出窗口调整位置
162347
+ var height=this.DivDialog.offsetHeight;
162348
+ var width=this.DivDialog.offsetWidth;
162349
+ var x=rtItem.Left+data.Offset.Left;
162350
+ var y=rtItem.Top+data.Offset.Top;
162351
+
162352
+ var xRight=window.innerWidth-5;
162353
+ var ybottom=window.innerHeight-5;
162354
+ if (x+width>xRight) x=(rtItem.Left+data.Offset.Left)-width;
162355
+ if (y+height>ybottom) y=(rtItem.Top+data.Offset.Top)-height;
162356
+
162357
+ this.DivDialog.style.visibility='visible';
162358
+ this.DivDialog.style.top = y + "px";
162359
+ this.DivDialog.style.left = x + "px";
162360
+ }
162361
+ else
162362
+ {
162363
+ var rtCell=data.Rect;
162364
+ var pixelRatio=GetDevicePixelRatio();
162365
+ var rtItem={ Left:rtCell.Left/pixelRatio, Right:rtCell.Right/pixelRatio, Bottom:rtCell.Bottom/pixelRatio, Top:rtCell.Top/pixelRatio };
162366
+ rtItem.Width=rtItem.Right-rtItem.Left;
162367
+ rtItem.Height=rtItem.Bottom-rtItem.Top;
162368
+
162369
+ //超出窗口调整位置
162370
+ var height=this.DivDialog.offsetHeight;
162371
+ var width=this.DivDialog.offsetWidth;
162372
+ var x=rtItem.Right+data.Offset.Left;
162373
+ var y=rtItem.Bottom+data.Offset.Top;
162374
+
162375
+ var xRight=window.innerWidth-5;
162376
+ var ybottom=window.innerHeight-5;
162377
+ if (x+width>xRight) x=(rtItem.Left+data.Offset.Left)-width;
162378
+ if (y+height>ybottom) y=(rtItem.Top+data.Offset.Top)-height;
162379
+
162380
+ this.DivDialog.style.visibility='visible';
162381
+ this.DivDialog.style.top = y + "px";
162382
+ this.DivDialog.style.left = x + "px";
162383
+ }
162384
+ }
162385
+ }
162386
+
162387
+ this.Hide=function()
162388
+ {
162389
+ if (!this.DivDialog) return;
162390
+ if (this.DivDialog.style.visibility!='hidden')
162391
+ this.DivDialog.style.visibility='hidden';
162392
+ }
162393
+
162394
+
162395
+ this.ReloadResource=function(option)
162396
+ {
162397
+ this.BGColor=g_JSChartResource.PopMinuteChart.BGColor;
162398
+ this.BorderColor=g_JSChartResource.PopMinuteChart.BorderColor;
162399
+
162400
+ this.TitleFont=g_JSChartResource.PopMinuteChart.Title.Font; //指标标题字体
162401
+ this.CorssCursorFont=g_JSChartResource.PopMinuteChart.CorssCursor.Font; //十字光标
162402
+ this.FrameSplitTextFont=g_JSChartResource.PopMinuteChart.Frame.Font; //刻度文字
162403
+
162404
+ if (!this.DivDialog) return;
162405
+
162406
+ this.UpdateStyle();
162407
+
162408
+ if (this.Minute.JSChart) this.Minute.JSChart.ReloadResource(option);
162409
+ }
162410
+
162411
+ this.LoadChartResource=function(chart)
162412
+ {
162413
+ if (IFrameSplitOperator.IsNonEmptyArray(chart.TitlePaint))
162414
+ {
162415
+ for(var i=0;i<chart.TitlePaint.length;++i)
162416
+ {
162417
+ var item=chart.TitlePaint[i];
162418
+ if (!item) continue;
162419
+
162420
+ item.Font=this.TitleFont;
162421
+ }
162422
+ }
162423
+
162424
+ if (IFrameSplitOperator.IsNonEmptyArray(chart.WindowIndex))
162425
+ {
162426
+ for(var i=0;i<chart.WindowIndex.length;++i) //去掉指标里面的字体
162427
+ {
162428
+ var item=chart.WindowIndex[i];
162429
+ if (!item) continue;
162430
+ item.TitleFont=null;
162431
+ }
162432
+ }
162433
+
162434
+ if (chart.ChartCorssCursor)
162435
+ {
162436
+ chart.ChartCorssCursor.Font=this.CorssCursorFont;
162437
+ }
162438
+ }
162439
+
162440
+ this.OnSplitXCoordinate=function(event, data, obj)
162441
+ {
162442
+ var frame=data.Frame;
162443
+ if (IFrameSplitOperator.IsNonEmptyArray(frame.VerticalInfo))
162444
+ {
162445
+ for(var i=0;i<frame.VerticalInfo.length;++i)
162446
+ {
162447
+ var item=frame.VerticalInfo[i];
162448
+ if (!item) continue;
162449
+ if (item.Font) item.Font=this.FrameSplitTextFont;
162450
+ }
162451
+ }
162452
+ }
162453
+
162454
+ this.OnSplitYCoordinate=function(event, data, obj)
162455
+ {
162456
+ var frame=data.Frame;
162457
+ if (IFrameSplitOperator.IsNonEmptyArray(frame.HorizontalInfo))
162458
+ {
162459
+ for(var i=0;i<frame.HorizontalInfo.length;++i)
162460
+ {
162461
+ var item=frame.HorizontalInfo[i];
162462
+ if (!item) continue;
162463
+ if (item.Font) item.Font=this.FrameSplitTextFont;
162464
+ }
162465
+ }
162466
+ }
162467
+
162468
+ }
162469
+
162470
+ JSTooltipMinuteChart.GetMinuteOption=function()
162471
+ {
162472
+ var option=
162473
+ {
162474
+ Type:'分钟走势图', //创建图形类型
162475
+ Windows: //窗口指标
162476
+ [
162477
+ //{ Index:"VOL" },
162478
+ //{ Index:"RSI" }
162479
+ ],
162480
+
162481
+ Symbol:null, // cf1909.czc
162482
+ IsAutoUpdate:false, //是自动更新数据
162483
+ AutoUpdateFrequency:10000, //数据更新频率
162484
+ DayCount:1, //1 最新交易日数据 >1 多日走势图
162485
+ IsShowRightMenu:false, //是否显示右键菜单
162486
+
162487
+ EnableSelectRect:true,
162488
+ EnableZoomIndexWindow:true,
162489
+ EnableResize:true,
162490
+
162491
+ //BeforeOpen:{IsShow:true, Width:120, IsShowMultiDay:true, MulitiDayWidth:100, },
162492
+ //AfterClose:{IsShow:true, Width:100, IsShowMultiDay:true, MulitiDayWidth:50, ShareVol:2 }, //ShareVol:0=盘后成交量独立坐标, 1==盘后成交量主图共用 2==盘后成交量盘前共用
162493
+
162494
+ CorssCursorInfo:{ Left:1, Right:1, Bottom:1 },
162495
+
162496
+ MinuteLine:
162497
+ {
162498
+
162499
+ },
162500
+
162501
+ MinuteTitle:
162502
+ {
162503
+ IsShowTime:true,
162504
+ IsShowName:true,
162505
+ IsShowDate:true,
162506
+ IsShowVolTitle:true,
162507
+ //IsAlwaysShowLastData:true,
162508
+ IsTitleShowLatestData:true,
162509
+
162510
+ ShowPostion:{ Type:1 , Margin:{ Left:5*GetDevicePixelRatio(), Right:5*GetDevicePixelRatio() } }
162511
+ },
162512
+
162513
+ MinuteVol:
162514
+ {
162515
+ BarColorType:1,
162516
+ },
162517
+
162518
+ //Language:'EN',
162519
+
162520
+ Border: //边框
162521
+ {
162522
+ Left:20, //左边间距
162523
+ Right:120, //右边间距
162524
+ Top:20,
162525
+ Bottom:20,
162526
+
162527
+ AutoLeft:{ Blank:10, MinWidth:40 },
162528
+ AutoRight:{ Blank:10, MinWidth:40 },
162529
+ },
162530
+
162531
+ Frame: //子框架设置
162532
+ [
162533
+ { SplitCount:5 },
162534
+ { SplitCount:3 },
162535
+ { SplitCount:3 },
162536
+ ],
162537
+ }
162538
+
162539
+ return option;
162540
+ }
162541
+
162542
+
162543
+ ///////////////////////////////////////////////////////
162544
+ // K线上标记选中
162545
+
162546
+ function MarkPopMinutePaint()
162547
+ {
162548
+ this.newMethod=IExtendChartPainting; //派生
162549
+ this.newMethod();
162550
+ delete this.newMethod;
162551
+
162552
+ this.ClassName="MarkPopMinutePaint";
162553
+ this.MapDate; //标记日期
162554
+ this.BGColor="rgba(100,100,100,0.2)";
162555
+ this.LineWidth=g_JSChartResource.PopMinuteChart.Mark.LineWidth;
162556
+ this.LineColor=g_JSChartResource.PopMinuteChart.Mark.LineColor;
162557
+ this.SubFrame;
162558
+ this.IsDynamic=true;
162559
+ this.IsShow=true;
162560
+
162561
+
162562
+ this.ReloadResource=function(resource)
162563
+ {
162564
+ this.LineWidth=g_JSChartResource.PopMinuteChart.Mark.LineWidth;
162565
+ this.LineColor=g_JSChartResource.PopMinuteChart.Mark.LineColor;
162566
+ }
162567
+
162568
+ this.SetDate=function(aryDate)
162569
+ {
162570
+ this.MapDate=new Map();
162571
+ if (IFrameSplitOperator.IsNonEmptyArray(aryDate))
162572
+ {
162573
+ for(var i=0;i<aryDate.length;++i)
162574
+ {
162575
+ var date=aryDate[i];
162576
+ this.MapDate.set(date, { Date:date} );
162577
+ }
162578
+ }
162579
+ }
162580
+
162581
+ this.ClearData=function()
162582
+ {
162583
+ this.MapDate=null;
162584
+ }
162585
+
162586
+ this.Draw=function()
162587
+ {
162588
+ this.SubFrame=null;
162589
+ if (!this.IsShow) return;
162590
+ if (!this.HQChart) return;
162591
+ if (!this.ChartFrame || !IFrameSplitOperator.IsNonEmptyArray(this.ChartFrame.SubFrame)) return;
162592
+ if (!this.MapDate || this.MapDate.size<=0) return;
162593
+
162594
+ var kData=this.HQChart.GetKData();
162595
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return;
162596
+ this.SubFrame=this.ChartFrame.SubFrame[0].Frame;
162597
+ if (!this.SubFrame) return;
162598
+
162599
+ var dataWidth=this.SubFrame.DataWidth;
162600
+ var distanceWidth=this.SubFrame.DistanceWidth;
162601
+ var xPointCount=this.SubFrame.XPointCount;
162602
+ var border=this.SubFrame.GetBorder();
162603
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
162604
+ var chartright=border.RightEx;
162605
+
162606
+ var startIndex=kData.DataOffset;
162607
+ var aryBG=[];
162608
+ for(var i=startIndex,j=0;i<kData.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
162609
+ {
162610
+ var kItem=kData.Data[i];
162611
+ if (!kItem) continue;
162612
+ if (!this.MapDate.has(kItem.Date)) continue
162613
+
162614
+ var left=xOffset;
162615
+ var right=xOffset+dataWidth;
162616
+ var x=left+(right-left)/2;
162617
+
162618
+ var bgItem={ Left:left, XCenter:x, Right:right, DataIndex:i, DataWidth:dataWidth };
162619
+ aryBG.push(bgItem);
162620
+ }
162621
+
162622
+ if (IFrameSplitOperator.IsNonEmptyArray(aryBG))
162623
+ {
162624
+ this.Canvas.save();
162625
+ this.DrawBG(aryBG);
162626
+ this.Canvas.restore();
162627
+ }
162628
+
162629
+ this.SubFrame=null;
162630
+ }
162631
+
162632
+ this.DrawBG=function(aryBG)
162633
+ {
162634
+ var border=this.ChartFrame.ChartBorder.GetBorder();
162635
+ var pixelRatio=GetDevicePixelRatio();
162636
+ if (this.MapDate.size==1) //标记一天
162637
+ {
162638
+ var item=aryBG[0];
162639
+ var lineWidth=this.LineWidth*pixelRatio;
162640
+ if (item.DataWidth<=4) lineWidth=1*pixelRatio;
162641
+
162642
+ this.Canvas.lineWidth=lineWidth;
162643
+ this.Canvas.strokeStyle=this.LineColor;
162644
+ var x=ToFixedPoint2(lineWidth,item.XCenter);
162645
+ this.Canvas.beginPath();
162646
+ this.Canvas.moveTo(x,border.TopEx);
162647
+ this.Canvas.lineTo(x,border.BottomEx);
162648
+ this.Canvas.stroke();
162649
+ }
162650
+ }
162651
+ }
162652
+
162653
+
162654
+ JSChart.RegisterExtendChartClass("MarkPopMinutePaint", { Create:function() { return new MarkPopMinutePaint}} );
162655
+
162656
+
162657
+
162658
+
162659
+
162660
+
162661
+
162662
+
162663
+
162664
+ /*
162665
+ Copyright (c) 2018 jones
162666
+
162667
+ http://www.apache.org/licenses/LICENSE-2.0
162668
+
162669
+ 开源项目 https://github.com/jones2000/HQChart
162670
+
162671
+ jones_2000@163.com
162672
+ */
162673
+
162674
+
162675
+ ///////////////////////////////////////////////////////
162676
+ // K线图提示信息
162677
+ //
162678
+ //////////////////////////////////////////////////////
162679
+
162680
+ function JSTooltipKLineChart()
162681
+ {
162682
+ this.DivDialog=null;
162683
+ this.HQChart=null;
162684
+ this.ID=Guid();
162685
+
162686
+ this.BGColor=g_JSChartResource.PopMinuteChart.BGColor;
162687
+ this.BorderColor=g_JSChartResource.PopMinuteChart.BorderColor;
162688
+ this.TitleFont=g_JSChartResource.PopMinuteChart.Title.Font; //指标标题字体
162689
+ this.CorssCursorFont=g_JSChartResource.PopMinuteChart.CorssCursor.Font; //十字光标
162690
+ this.FrameSplitTextFont=g_JSChartResource.PopMinuteChart.Frame.Font; //刻度文字
162691
+
162692
+ this.OnCreatedCallback=null;
162693
+
162694
+ this.KLine=
162695
+ {
162696
+ Option:JSTooltipKLineChart.GetKLineOption(),
162697
+ JSChart:null,
162698
+ Symbol:null,
162699
+ }
162700
+
162701
+ this.Inital=function(hqchart, option)
162702
+ {
162703
+ this.HQChart=hqchart;
162704
+
162705
+ if (option)
162706
+ {
162707
+ if (IFrameSplitOperator.IsObject(option.Option))
162708
+ {
162709
+ var item=CloneData(option.Option); //复制一份出来
162710
+ this.KLine.Option=Object.assign(this.KLine.Option,item);
162711
+
162712
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Option.EventCallback)) this.KLine.Option.EventCallback=option.Option.EventCallback;
162713
+ }
162714
+ if (option.OnCreatedCallback) this.OnCreatedCallback=option.OnCreatedCallback;
162715
+ }
162716
+ }
162717
+
162718
+ this.Create=function()
162719
+ {
162720
+ var divDom=document.createElement('div');
162721
+ divDom.className='UMyChart_Tooltip_KLine_Div';
162722
+ divDom.id=this.ID;
162723
+
162724
+ var divChart=document.createElement('div');
162725
+ divChart.className='UMyChart_Tooltip_KLine_Chart_Div';
162726
+ divDom.appendChild(divChart);
162727
+
162728
+ this.DivDialog=divDom;
162729
+
162730
+ var chart=JSChart.Init(divChart);
162731
+ this.KLine.JSChart=chart;
162732
+
162733
+ //语言跟主图保持一致
162734
+ if (this.HQChart) this.KLine.Option.Language=g_JSChartLocalization.GetLanguageName(this.HQChart.LanguageID);
162735
+ this.KLine.Option.OnCreatedCallback=(chart)=>{ this.OnCreateHQChart(chart); }
162736
+ this.KLine.Option.NetworkFilter=(data, callback)=>{ this.NetworkFilter(data, callback); }
162737
+
162738
+ var reloadResourceEvent=
162739
+ {
162740
+ event:JSCHART_EVENT_ID.ON_RELOAD_RESOURCE,
162741
+ callback:(event, data, obj)=>{ this.LoadChartResource(obj); }
162742
+ }
162743
+
162744
+ var splitXEvent=
162745
+ {
162746
+ event:JSCHART_EVENT_ID.ON_SPLIT_XCOORDINATE,
162747
+ callback:(event, data, obj)=>{ this.OnSplitXCoordinate(event, data, obj); }
162748
+ };
162749
+
162750
+ var splitYEvent=
162751
+ {
162752
+ event:JSCHART_EVENT_ID.ON_SPLIT_YCOORDINATE,
162753
+ callback:(event, data, obj)=>{ this.OnSplitYCoordinate(event, data, obj); }
162754
+ }
162755
+
162756
+ if (Array.isArray(this.KLine.Option.EventCallback))
162757
+ {
162758
+ this.KLine.Option.EventCallback.unshift(reloadResourceEvent,splitYEvent,splitYEvent);
162759
+ }
162760
+ else
162761
+ {
162762
+ this.KLine.Option.EventCallback=[reloadResourceEvent,splitXEvent,splitYEvent];
162763
+ }
162764
+
162765
+
162766
+ chart.SetOption(this.KLine.Option); //设置K线配置
162767
+
162768
+ document.body.appendChild(divDom);
162769
+
162770
+ this.UpdateStyle();
162771
+
162772
+ if (!this.KLine.Option.EnableResize)
162773
+ {
162774
+ if (this.KLine.JSChart) this.KLine.JSChart.OnSize({ Type:1 });
162775
+ }
162776
+ }
162777
+
162778
+ this.UpdateStyle=function()
162779
+ {
162780
+ if (!this.DivDialog) return;
162781
+
162782
+ if (this.BGColor) this.DivDialog.style['background-color']=this.BGColor;
162783
+ if (this.BorderColor) this.DivDialog.style['border-color']=this.BorderColor;
162784
+ }
162785
+
162786
+ this.NetworkFilter=function(data, callback)
162787
+ {
162788
+ if (!this.HQChart || !this.HQChart.NetworkFilter) return;
162789
+
162790
+ this.HQChart.NetworkFilter(data, callback);
162791
+ }
162792
+
162793
+ this.OnCreateHQChart=function(chart)
162794
+ {
162795
+ this.LoadChartResource(chart);
162796
+
162797
+ if (this.OnCreatedCallback) this.OnCreatedCallback(chart);
162798
+ }
162799
+
162800
+ this.Destroy=function()
162801
+ {
162802
+ if (this.DivDialog)
162803
+ {
162804
+ if (document && document.body && document.body.removeChild)
162805
+ document.body.removeChild(this.DivDialog);
162806
+ }
162807
+
162808
+ this.DivDialog=null;
162809
+ this.TitleBox=null;
162810
+ if (!this.KLine.JSChart) this.KLine.JSChart.ChartDestory();
162811
+ this.KLine.JSChart=null;
162812
+ }
162813
+
162814
+ this.IsShow=function()
162815
+ {
162816
+ if (!this.DivDialog) return false;
162817
+
162818
+ return this.DivDialog.style.visibility==='visible';
162819
+ }
162820
+
162821
+ this.Show=function(data, x, y)
162822
+ {
162823
+ if (!this.DivDialog) this.Create();
162824
+ if (!data || !data.Symbol) return;
162825
+
162826
+ var symbol=data.Symbol;
162827
+ if (this.KLine.JSChart)
162828
+ {
162829
+ if (this.KLine.Symbol!=symbol)
162830
+ {
162831
+ this.KLine.Symbol=symbol;
162832
+ this.KLine.JSChart.ChangeSymbol(symbol);
162795
162833
  }
162796
162834
  }
162797
162835
 
@@ -168592,6 +168630,2619 @@ function HQChartScriptWorker()
168592
168630
  }
168593
168631
  }
168594
168632
 
168633
+ /*
168634
+ Copyright (c) 2018 jones
168635
+
168636
+ http://www.apache.org/licenses/LICENSE-2.0
168637
+
168638
+ 开源项目 https://github.com/jones2000/HQChart
168639
+
168640
+ jones_2000@163.com
168641
+
168642
+ 底部状态栏 (H5版本)
168643
+ 不提供内置测试数据
168644
+ */
168645
+
168646
+ function JSStatusBarChart(divElement)
168647
+ {
168648
+ this.DivElement=divElement;
168649
+ this.JSChartContainer; //表格控件
168650
+ this.ResizeListener; //大小变动监听
168651
+
168652
+ //h5 canvas
168653
+ this.CanvasElement=document.createElement("canvas");
168654
+ this.CanvasElement.className='jsstatusbar-drawing';
168655
+ this.CanvasElement.id=Guid();
168656
+ this.CanvasElement.setAttribute("tabindex",0);
168657
+ if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
168658
+ if(divElement.hasChildNodes())
168659
+ {
168660
+ JSConsole.Chart.Log("[JSStatusBarChart::JSStatusBarChart] divElement hasChildNodes", divElement.childNodes);
168661
+ }
168662
+ divElement.appendChild(this.CanvasElement);
168663
+
168664
+
168665
+ this.OnSize=function()
168666
+ {
168667
+ //画布大小通过div获取 如果有style里的大小 使用style里的
168668
+ var height=this.DivElement.offsetHeight;
168669
+ var width=this.DivElement.offsetWidth;
168670
+ if (this.DivElement.style.height && this.DivElement.style.width)
168671
+ {
168672
+ if (this.DivElement.style.height.includes("px"))
168673
+ height=parseInt(this.DivElement.style.height.replace("px",""));
168674
+ if (this.DivElement.style.width.includes("px"))
168675
+ width=parseInt(this.DivElement.style.width.replace("px",""));
168676
+ }
168677
+
168678
+ this.CanvasElement.height=height;
168679
+ this.CanvasElement.width=width;
168680
+ this.CanvasElement.style.width=this.CanvasElement.width+'px';
168681
+ this.CanvasElement.style.height=this.CanvasElement.height+'px';
168682
+
168683
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
168684
+ this.CanvasElement.height*=pixelTatio;
168685
+ this.CanvasElement.width*=pixelTatio;
168686
+
168687
+ JSConsole.Chart.Log(`[JSStatusBarChart::OnSize] devicePixelRatio=${window.devicePixelRatio}, height=${this.CanvasElement.height}, width=${this.CanvasElement.width}`);
168688
+
168689
+ if (this.JSChartContainer && this.JSChartContainer.OnSize)
168690
+ {
168691
+ this.JSChartContainer.OnSize();
168692
+ }
168693
+ }
168694
+
168695
+ this.SetOption=function(option)
168696
+ {
168697
+ var chart=this.CreateJSStatusBarChartContainer(option);
168698
+
168699
+ if (!chart) return false;
168700
+
168701
+ if (option.OnCreatedCallback) option.OnCreatedCallback(chart);
168702
+
168703
+ this.JSChartContainer=chart;
168704
+ this.DivElement.JSChart=this; //div中保存一份
168705
+
168706
+ if (option.EnableResize==true) this.CreateResizeListener();
168707
+
168708
+ if (option.MinuteChartTooltip && option.MinuteChartTooltip.Enable) chart.InitalMinuteChartTooltip(option.MinuteChartTooltip);
168709
+
168710
+ chart.Draw();
168711
+ chart.RequestData();
168712
+ }
168713
+
168714
+ this.CreateResizeListener=function()
168715
+ {
168716
+ this.ResizeListener = new ResizeObserver((entries)=>{ this.OnDivResize(entries); });
168717
+ this.ResizeListener.observe(this.DivElement);
168718
+ }
168719
+
168720
+ this.OnDivResize=function(entries)
168721
+ {
168722
+ JSConsole.Chart.Log("[JSStatusBarChart::OnDivResize] entries=", entries);
168723
+
168724
+ this.OnSize();
168725
+ }
168726
+
168727
+ this.CreateJSStatusBarChartContainer=function(option)
168728
+ {
168729
+ var chart=new JSStatusBarChartContainer(this.CanvasElement);
168730
+ chart.Create(option);
168731
+
168732
+ this.SetChartBorder(chart, option);
168733
+
168734
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) chart.SetColumn(option.Column);
168735
+ if (option.RightToolbar) chart.SetRightToolbar(option.RightToolbar);
168736
+
168737
+ //是否自动更新
168738
+ if (option.NetworkFilter) chart.NetworkFilter=option.NetworkFilter;
168739
+
168740
+ if (option.IsAutoUpdate!=null) chart.IsAutoUpdate=option.IsAutoUpdate;
168741
+ if (option.AutoUpdateFrequency>0) chart.AutoUpdateFrequency=option.AutoUpdateFrequency;
168742
+
168743
+ //注册事件
168744
+ if (option.EventCallback)
168745
+ {
168746
+ for(var i=0;i<option.EventCallback.length;++i)
168747
+ {
168748
+ var item=option.EventCallback[i];
168749
+ chart.AddEventCallback(item);
168750
+ }
168751
+ }
168752
+
168753
+ return chart;
168754
+ }
168755
+
168756
+ this.SetChartBorder=function(chart, option)
168757
+ {
168758
+ if (!option.Border) return;
168759
+
168760
+ var item=option.Border;
168761
+ if (IFrameSplitOperator.IsNumber(option.Border.Left)) chart.Frame.ChartBorder.Left=option.Border.Left;
168762
+ if (IFrameSplitOperator.IsNumber(option.Border.Right)) chart.Frame.ChartBorder.Right=option.Border.Right;
168763
+ if (IFrameSplitOperator.IsNumber(option.Border.Top)) chart.Frame.ChartBorder.Top=option.Border.Top;
168764
+ if (IFrameSplitOperator.IsNumber(option.Border.Bottom)) chart.Frame.ChartBorder.Bottom=option.Border.Bottom;
168765
+
168766
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
168767
+ chart.Frame.ChartBorder.Left*=pixelTatio;
168768
+ chart.Frame.ChartBorder.Right*=pixelTatio;
168769
+ chart.Frame.ChartBorder.Top*=pixelTatio;
168770
+ chart.Frame.ChartBorder.Bottom*=pixelTatio;
168771
+ }
168772
+
168773
+ //事件回调
168774
+ this.AddEventCallback=function(obj)
168775
+ {
168776
+ if(this.JSChartContainer && typeof(this.JSChartContainer.AddEventCallback)=='function')
168777
+ {
168778
+ JSConsole.Chart.Log('[JSStatusBarChart:AddEventCallback] obj=', obj);
168779
+ this.JSChartContainer.AddEventCallback(obj);
168780
+ }
168781
+ }
168782
+
168783
+ //重新加载配置
168784
+ this.ReloadResource=function(option)
168785
+ {
168786
+ if(this.JSChartContainer && typeof(this.JSChartContainer.ReloadResource)=='function')
168787
+ {
168788
+ JSConsole.Chart.Log('[JSStatusBarChart:ReloadResource] ');
168789
+ this.JSChartContainer.ReloadResource(option);
168790
+ }
168791
+ }
168792
+
168793
+ this.ChartDestroy=function()
168794
+ {
168795
+ if (this.JSChartContainer && typeof (this.JSChartContainer.ChartDestroy) == 'function')
168796
+ {
168797
+ this.JSChartContainer.ChartDestroy();
168798
+ }
168799
+ }
168800
+
168801
+ this.Draw=function()
168802
+ {
168803
+ if(this.JSChartContainer && typeof(this.JSChartContainer.Draw)=='function')
168804
+ {
168805
+ JSConsole.Chart.Log('[JSStatusBarChart:Draw] ');
168806
+ this.JSChartContainer.Draw();
168807
+ }
168808
+ }
168809
+ }
168810
+
168811
+ JSStatusBarChart.Init=function(divElement)
168812
+ {
168813
+ var jsChartControl=new JSStatusBarChart(divElement);
168814
+ jsChartControl.OnSize();
168815
+
168816
+ return jsChartControl;
168817
+ }
168818
+
168819
+ //自定义风格
168820
+ JSStatusBarChart.SetStyle=function(option)
168821
+ {
168822
+ if (option) g_JSChartResource.SetStyle(option);
168823
+ }
168824
+
168825
+ //获取颜色配置 (JSStatusBarChart.Init()之前)
168826
+ JSStatusBarChart.GetResource=function()
168827
+ {
168828
+ return g_JSChartResource;
168829
+ }
168830
+
168831
+ JSStatusBarChart.GetfloatPrecision=function(symbol)
168832
+ {
168833
+ return GetfloatPrecision(symbol);
168834
+ }
168835
+
168836
+
168837
+ function JSStatusBarChartContainer(uielement)
168838
+ {
168839
+ this.ClassName='JSStatusBarChartContainer';
168840
+ this.Frame; //框架画法
168841
+ this.ChartPaint=[]; //图形画法
168842
+
168843
+ this.Canvas=uielement.getContext("2d"); //画布
168844
+
168845
+ this.NetworkFilter; //数据回调接口
168846
+ this.Data=
168847
+ {
168848
+ MapSymbol:new Map(), //key=symbol, { Value:, Text:, } 股票数据
168849
+ };
168850
+
168851
+ //事件回调
168852
+ this.mapEvent=new Map(); //通知外部调用 key:JSCHART_EVENT_ID value:{ Callback:回调,}
168853
+
168854
+ this.AutoUpdateTimer=null;
168855
+ this.AutoUpdateFrequency=15000; //15秒更新一次数据
168856
+
168857
+ this.ToolbarTimer=null;
168858
+
168859
+ this.TooltipMinuteChart; //分时图
168860
+
168861
+ this.UIElement=uielement;
168862
+
168863
+ this.IsDestroy=false; //是否已经销毁了
168864
+
168865
+ this.ChartDestroy=function() //销毁
168866
+ {
168867
+ this.IsDestroy=true;
168868
+ this.StopAutoUpdate();
168869
+
168870
+ if (this.ToolbarTimer)
168871
+ {
168872
+ clearInterval(this.ToolbarTimer);
168873
+ this.ToolbarTimer=null;
168874
+ }
168875
+
168876
+ this.DestroyMinuteChartTooltip();
168877
+ }
168878
+
168879
+ this.InitalMinuteChartTooltip=function(option)
168880
+ {
168881
+ if (this.TooltipMinuteChart) return;
168882
+
168883
+ this.TooltipMinuteChart=new JSTooltipMinuteChart();
168884
+ this.TooltipMinuteChart.Inital(this, option);
168885
+ this.TooltipMinuteChart.Create();
168886
+ }
168887
+
168888
+ this.DestroyMinuteChartTooltip=function()
168889
+ {
168890
+ if (!this.TooltipMinuteChart) return;
168891
+
168892
+ this.TooltipMinuteChart.Destroy();
168893
+ this.TooltipMinuteChart=null;
168894
+ }
168895
+
168896
+ //设置事件回调
168897
+ //{event:事件id, callback:回调函数}
168898
+ this.AddEventCallback=function(object)
168899
+ {
168900
+ if (!object || !object.event || !object.callback) return;
168901
+
168902
+ var data={Callback:object.callback, Source:object};
168903
+ this.mapEvent.set(object.event,data);
168904
+ }
168905
+
168906
+ this.RemoveEventCallback=function(eventid)
168907
+ {
168908
+ if (!this.mapEvent.has(eventid)) return;
168909
+
168910
+ this.mapEvent.delete(eventid);
168911
+ }
168912
+
168913
+ this.GetEventCallback=function(id) //获取事件回调
168914
+ {
168915
+ if (!this.mapEvent.has(id)) return null;
168916
+ var item=this.mapEvent.get(id);
168917
+ return item;
168918
+ }
168919
+
168920
+ this.ClearData=function()
168921
+ {
168922
+ this.Data.MapSymbol=new Map();
168923
+ }
168924
+
168925
+ this.RequestData=function(option)
168926
+ {
168927
+ this.CancelAutoUpdate();
168928
+ this.ClearData();
168929
+
168930
+ if (option)
168931
+ {
168932
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) this.SetColumn(option.Column);
168933
+ }
168934
+
168935
+ this.Draw();
168936
+ this.RequestStockData();
168937
+
168938
+ if (this.IsAutoUpdate)
168939
+ {
168940
+ var frequency=this.AutoUpdateFrequency;
168941
+ setInterval(()=>
168942
+ {
168943
+ var marketStatus=MARKET_SUFFIX_NAME.GetMarketStatus(this.Symbol);
168944
+ if (marketStatus==0 || marketStatus==3) //闭市,盘后
168945
+ return;
168946
+
168947
+ this.RequestStockData();
168948
+ }, frequency)
168949
+ }
168950
+ }
168951
+
168952
+ this.CancelAutoUpdate=function() //关闭停止更新
168953
+ {
168954
+ if (this.AutoUpdateTimer)
168955
+ {
168956
+ clearInterval(this.AutoUpdateTimer);
168957
+ this.AutoUpdateTimer = null;
168958
+ }
168959
+ }
168960
+
168961
+ this.StopAutoUpdate=function()
168962
+ {
168963
+ this.CancelAutoUpdate();
168964
+ if (!this.IsAutoUpdate) return;
168965
+ this.IsAutoUpdate=false;
168966
+ }
168967
+
168968
+ this.RequestStockData=function()
168969
+ {
168970
+ if (!this.NetworkFilter) return;
168971
+
168972
+ var chart=this.ChartPaint[0];
168973
+ if (!chart) return;
168974
+ if (!IFrameSplitOperator.IsNonEmptyArray(chart.Column)) return;
168975
+
168976
+ var arySymbol=[];
168977
+ for(var i=0;i<chart.Column.length;++i)
168978
+ {
168979
+ var item=chart.Column[i];
168980
+ var newItem={ Symbol:item.Symbol, Fields:[] };
168981
+ arySymbol.push(newItem);
168982
+ }
168983
+
168984
+ var obj=
168985
+ {
168986
+ Name:'JSStatusBarChartContainer::RequestStockData', //类名::函数名
168987
+ Explain:'工具栏股票数据',
168988
+ Request: { Data:{ stocks:arySymbol } },
168989
+ Self:this,
168990
+ PreventDefault:false
168991
+ };
168992
+
168993
+ this.NetworkFilter(obj, (data)=>
168994
+ {
168995
+ this.RecvStockData(data);
168996
+ });
168997
+
168998
+ if (obj.PreventDefault==true) return; //已被上层替换,不调用默认的网络请求
168999
+
169000
+ }
169001
+
169002
+ this.RecvStockData=function(recv)
169003
+ {
169004
+ if (!recv) return;
169005
+ if (!IFrameSplitOperator.IsNonEmptyArray(recv.data)) return;
169006
+
169007
+ for(var i=0;i<recv.data.length;++i)
169008
+ {
169009
+ var item=recv.data[i];
169010
+ if (!item.Symbol) continue;
169011
+
169012
+ var stockItem=null;
169013
+ if (this.Data.MapSymbol.has(item.Symbol))
169014
+ {
169015
+ stockItem=this.Data.MapSymbol.get(item.Symbol);
169016
+ }
169017
+ else
169018
+ {
169019
+ stockItem={ Symbol:item.Symbol, MapData:new Map() };
169020
+ stockItem.YClose=item.YClose;
169021
+ if (IFrameSplitOperator.IsNumber(item.FYClose)) stockItem.YClose=item.FYClose;
169022
+ this.Data.MapSymbol.set(item.Symbol,stockItem);
169023
+ }
169024
+
169025
+ for(var j=0;j<item.Data.length;++j)
169026
+ {
169027
+ var itemData=item.Data[j];
169028
+ stockItem.MapData.set(itemData.Key,itemData.Value);
169029
+ }
169030
+ }
169031
+
169032
+ if (!this.ToolbarTimer) this.Draw();
169033
+ }
169034
+
169035
+ //创建
169036
+ this.Create=function(option)
169037
+ {
169038
+ this.UIElement.JSChartContainer=this;
169039
+
169040
+ //创建框架
169041
+ this.Frame=new JSStatusBarFrame();
169042
+ this.Frame.ChartBorder=new ChartBorder();
169043
+ this.Frame.ChartBorder.UIElement=this.UIElement;
169044
+ this.Frame.ChartBorder.Top=30;
169045
+ this.Frame.ChartBorder.Left=5;
169046
+ this.Frame.ChartBorder.Bottom=20;
169047
+ this.Frame.Canvas=this.Canvas;
169048
+
169049
+ //创建表格
169050
+ var chart=new ChartStatusBarStockData();
169051
+ chart.Frame=this.Frame;
169052
+ chart.ChartBorder=this.Frame.ChartBorder;
169053
+ chart.Canvas=this.Canvas;
169054
+ chart.UIElement=this.UIElement;
169055
+ chart.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
169056
+ chart.Data=this.Data;
169057
+ chart.BorderData=this.BorderData;
169058
+ chart.GlobalOption=this.GlobalOption;
169059
+ chart.FixedRowData=this.FixedRowData;
169060
+ chart.SortInfo=this.SortInfo;
169061
+ this.ChartPaint[0]=chart;
169062
+
169063
+
169064
+ if (option)
169065
+ {
169066
+
169067
+ }
169068
+
169069
+ this.UIElement.onmousedown=(e)=> { this.UIOnMouseDown(e); }
169070
+ this.UIElement.onmousemove=(e)=>{ this.UIOnMouseMove(e); }
169071
+ this.UIElement.onmouseout=(e)=>{ this.UIOnMounseOut(e); }
169072
+ this.UIElement.oncontextmenu=(e)=> { this.UIOnContextMenu(e); }
169073
+
169074
+ /*
169075
+ this.UIElement.ondblclick=(e)=>{ this.UIOnDblClick(e); }
169076
+ this.UIElement.onmousedown=(e)=> { this.UIOnMouseDown(e); }
169077
+
169078
+
169079
+ this.UIElement.onmouseleave=(e)=>{ this.UIOnMouseleave(e); }
169080
+
169081
+ */
169082
+
169083
+ var frequency=500;
169084
+ this.ToolbarTimer=setInterval(()=>
169085
+ {
169086
+ this.Draw();
169087
+ }, frequency)
169088
+ }
169089
+
169090
+ this.UIOnMouseDown=function(e)
169091
+ {
169092
+ var pixelTatio = GetDevicePixelRatio();
169093
+ this.ClickDownPoint={ X:e.clientX, Y:e.clientY };
169094
+ var x = (e.clientX-this.UIElement.getBoundingClientRect().left)*pixelTatio;
169095
+ var y = (e.clientY-this.UIElement.getBoundingClientRect().top)*pixelTatio;
169096
+
169097
+ if (e && e.button==0) //左键点击
169098
+ {
169099
+ var ptClick={ X:this.ClickDownPoint.X, Y:this.ClickDownPoint.Y };
169100
+ this.TryClickPaintEvent(JSCHART_EVENT_ID.ON_CLICK_STATUSBAR_ITEM, ptClick, e);
169101
+ }
169102
+ }
169103
+
169104
+ this.UIOnContextMenu=function(e)
169105
+ {
169106
+ if (e) //去掉系统右键菜单
169107
+ {
169108
+ if (e.preventDefault) e.preventDefault();
169109
+ if (e.stopPropagation) e.stopPropagation();
169110
+ e.returnValue=false;
169111
+ }
169112
+ }
169113
+
169114
+ this.GetChartTooltipData=function(x,y,option)
169115
+ {
169116
+ var toolTip=new TooltipData();
169117
+ for(var i=0;i<this.ChartPaint.length;++i)
169118
+ {
169119
+ var item=this.ChartPaint[i];
169120
+ if (item.GetTooltipData(x,y,toolTip))
169121
+ {
169122
+ return toolTip;
169123
+ }
169124
+ }
169125
+
169126
+ return null;
169127
+ }
169128
+
169129
+ this.UIOnMouseMove=function(e)
169130
+ {
169131
+ var pixelTatio = GetDevicePixelRatio();
169132
+ var x = (e.clientX-this.UIElement.getBoundingClientRect().left)*pixelTatio;
169133
+ var y = (e.clientY-this.UIElement.getBoundingClientRect().top)*pixelTatio;
169134
+
169135
+ //var bShowKLineTooltip=false;
169136
+ var bShowMinuteTooltip=false;
169137
+ var chartTooltipData=null;
169138
+ var tooltipData=this.GetChartTooltipData(x,y);
169139
+
169140
+ if (tooltipData)
169141
+ {
169142
+ if (tooltipData.Type==121)
169143
+ {
169144
+ var item=tooltipData.Data;
169145
+ if (item && item.Data && item.Data.Symbol)
169146
+ {
169147
+ bShowMinuteTooltip=true;
169148
+ chartTooltipData={ Symbol:item.Data.Symbol, Rect:item.Rect, Position:1 };
169149
+ }
169150
+ }
169151
+ }
169152
+
169153
+ //if (!bShowKLineTooltip) this.HideKLineChartTooltip();
169154
+ if (!bShowMinuteTooltip) this.HideMinuteChartTooltip();
169155
+
169156
+ if (bShowMinuteTooltip) this.ShowMinuteChartTooltip(null, null, chartTooltipData);
169157
+ //if (bShowKLineTooltip) this.ShowKLineChartTooltip(null, null, chartTooltipData);
169158
+ }
169159
+
169160
+ this.UIOnMounseOut=function(e)
169161
+ {
169162
+ this.HideAllTooltip();
169163
+ }
169164
+
169165
+
169166
+
169167
+ this.TryClickPaintEvent=function(eventID, ptClick, e)
169168
+ {
169169
+ var event=this.GetEventCallback(eventID);
169170
+ if (!event) return false;
169171
+
169172
+ if (ptClick.X==e.clientX && ptClick.Y==e.clientY)
169173
+ {
169174
+ var pixelTatio = GetDevicePixelRatio();
169175
+ var x = (e.clientX-uielement.getBoundingClientRect().left)*pixelTatio;
169176
+ var y = (e.clientY-uielement.getBoundingClientRect().top)*pixelTatio;
169177
+
169178
+ var toolTip=new TooltipData();
169179
+ for(var i=0;i<this.ChartPaint.length;++i)
169180
+ {
169181
+ var item=this.ChartPaint[i];
169182
+ if (item.GetTooltipData(x,y,toolTip))
169183
+ {
169184
+ if (toolTip.Data)
169185
+ {
169186
+ var data= { X:e.clientX, Y:e.clientY, Tooltip:toolTip };
169187
+ event.Callback(event, data, this);
169188
+ return true;
169189
+ }
169190
+ }
169191
+ }
169192
+ }
169193
+
169194
+ return false;
169195
+ }
169196
+
169197
+ this.Draw=function()
169198
+ {
169199
+ if (this.UIElement.width<=0 || this.UIElement.height<=0) return;
169200
+
169201
+ this.Canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);
169202
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
169203
+ this.Canvas.lineWidth=pixelTatio; //手机端需要根据分辨率比调整线段宽度
169204
+
169205
+ this.Frame.Draw();
169206
+ this.Frame.DrawLogo();
169207
+
169208
+ //框架内图形
169209
+ for(var i=0;i<this.ChartPaint.length;++i)
169210
+ {
169211
+ var item=this.ChartPaint[i];
169212
+ item.Draw();
169213
+ }
169214
+ }
169215
+
169216
+ this.OnSize=function()
169217
+ {
169218
+ if (!this.Frame) return;
169219
+
169220
+ this.SetSizeChange(true);
169221
+ this.Draw();
169222
+ }
169223
+
169224
+ this.SetSizeChange=function(bChanged)
169225
+ {
169226
+ for(var i=0;i<this.ChartPaint.length;++i)
169227
+ {
169228
+ var chart=this.ChartPaint[i];
169229
+ if (chart) chart.SizeChange=bChanged;
169230
+ }
169231
+ }
169232
+
169233
+ this.ReloadResource=function(option)
169234
+ {
169235
+ this.Frame.ReloadResource(option);
169236
+
169237
+ for(var i=0;i<this.ChartPaint.length;++i)
169238
+ {
169239
+ var item=this.ChartPaint[i];
169240
+ if (item.ReloadResource) item.ReloadResource(option);
169241
+ }
169242
+
169243
+ if (option && (option.Redraw || option.Draw))
169244
+ {
169245
+ this.SetSizeChange(true);
169246
+ this.Draw();
169247
+ }
169248
+
169249
+ if (this.TooltipMinuteChart) this.TooltipMinuteChart.ReloadResource(option); //分时图
169250
+ }
169251
+
169252
+ this.SetColumn=function(aryColunm, option)
169253
+ {
169254
+ var chart=this.ChartPaint[0];
169255
+ if (!chart) return;
169256
+
169257
+ chart.SetColumn(aryColunm);
169258
+ chart.SizeChange=true;
169259
+
169260
+ if (option && option.Redraw) this.Draw();
169261
+ }
169262
+
169263
+ this.SetRightToolbar=function(toolbar, option)
169264
+ {
169265
+ var chart=this.ChartPaint[0];
169266
+ if (!chart) return;
169267
+
169268
+ chart.SetRightToolbar(toolbar);
169269
+ chart.SizeChange=true;
169270
+
169271
+ if (option && option.Redraw) this.Draw();
169272
+ }
169273
+
169274
+ this.GetStatusBarChart=function()
169275
+ {
169276
+ var chart=this.ChartPaint[0];
169277
+ if (!chart) return null;
169278
+
169279
+ return chart;
169280
+ }
169281
+
169282
+ //data={ Symbol }
169283
+ this.ShowMinuteChartTooltip=function(x,y, data)
169284
+ {
169285
+ if (!this.TooltipMinuteChart) return;
169286
+
169287
+ var rtClient=this.UIElement.getBoundingClientRect();
169288
+ var rtScroll=GetScrollPosition();
169289
+
169290
+ var offsetLeft=rtClient.left+rtScroll.Left;
169291
+ var offsetTop=rtClient.top+rtScroll.Top;
169292
+
169293
+ data.Offset={ Left:offsetLeft, Top:offsetTop };
169294
+
169295
+ this.TooltipMinuteChart.Show(data, x,y);
169296
+ }
169297
+
169298
+ this.HideMinuteChartTooltip=function()
169299
+ {
169300
+ if (!this.TooltipMinuteChart) return;
169301
+
169302
+ this.TooltipMinuteChart.Hide();
169303
+ }
169304
+
169305
+ this.HideAllTooltip=function()
169306
+ {
169307
+ //this.HideKLineChartTooltip();
169308
+ this.HideMinuteChartTooltip();
169309
+ }
169310
+
169311
+ }
169312
+
169313
+ function JSStatusBarFrame()
169314
+ {
169315
+ this.ChartBorder;
169316
+ this.Canvas; //画布
169317
+
169318
+ this.BorderLine=null; //1=上 2=下 4=左 8=右
169319
+ this.ClassName="JSStatusBarFrame";
169320
+
169321
+ this.BorderColor=g_JSChartResource.StatusBar.BorderColor; //边框线
169322
+
169323
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
169324
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
169325
+
169326
+ this.ReloadResource=function(resource)
169327
+ {
169328
+ this.BorderColor=g_JSChartResource.StatusBar.BorderColor; //边框线
169329
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
169330
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
169331
+ }
169332
+
169333
+ this.Draw=function()
169334
+ {
169335
+ var left=ToFixedPoint(this.ChartBorder.GetLeft());
169336
+ var top=ToFixedPoint(this.ChartBorder.GetTop());
169337
+ var right=ToFixedPoint(this.ChartBorder.GetRight());
169338
+ var bottom=ToFixedPoint(this.ChartBorder.GetBottom());
169339
+ var width=right-left;
169340
+ var height=bottom-top;
169341
+
169342
+ if (!IFrameSplitOperator.IsNumber(this.BorderLine))
169343
+ {
169344
+ this.Canvas.strokeStyle=this.BorderColor;
169345
+ this.Canvas.strokeRect(left,top,width,height);
169346
+ }
169347
+ else
169348
+ {
169349
+ this.Canvas.strokeStyle=this.BorderColor;
169350
+ this.Canvas.beginPath();
169351
+
169352
+ if ((this.BorderLine&1)>0) //上
169353
+ {
169354
+ this.Canvas.moveTo(left,top);
169355
+ this.Canvas.lineTo(right,top);
169356
+ }
169357
+
169358
+ if ((this.BorderLine&2)>0) //下
169359
+ {
169360
+ this.Canvas.moveTo(left,bottom);
169361
+ this.Canvas.lineTo(right,bottom);
169362
+ }
169363
+
169364
+ if ((this.BorderLine&4)>0) //左
169365
+ {
169366
+ this.Canvas.moveTo(left,top);
169367
+ this.Canvas.lineTo(left,bottom);
169368
+ }
169369
+
169370
+ if ((this.BorderLine&8)>0) //右
169371
+ {
169372
+ this.Canvas.moveTo(right,top);
169373
+ this.Canvas.lineTo(right,bottom);
169374
+ }
169375
+
169376
+ this.Canvas.stroke();
169377
+ }
169378
+ }
169379
+
169380
+ this.DrawLogo=function()
169381
+ {
169382
+ /*
169383
+ var text=g_JSChartResource.FrameLogo.Text;
169384
+ if (!IFrameSplitOperator.IsString(text)) return;
169385
+
169386
+ this.Canvas.fillStyle=this.LogoTextColor;
169387
+ this.Canvas.font=this.LogoTextFont;
169388
+ this.Canvas.textAlign = 'right';
169389
+ this.Canvas.textBaseline = 'bottom';
169390
+
169391
+ var x=this.ChartBorder.GetRight()-30;
169392
+ var y=this.ChartBorder.GetBottom()-5;
169393
+ this.Canvas.fillText(text,x,y);
169394
+ */
169395
+ }
169396
+ }
169397
+
169398
+
169399
+ function ChartStatusBarStockData()
169400
+ {
169401
+ this.Canvas; //画布
169402
+ this.ChartBorder; //边框信息
169403
+ this.ChartFrame; //框架画法
169404
+ this.Name; //名称
169405
+ this.ClassName='ChartStatusBarStockData'; //类名
169406
+ this.UIElement;
169407
+ this.GetEventCallback; //获取事件
169408
+ this.Data; //数据
169409
+ this.SizeChange=true;
169410
+
169411
+ this.UpColor=g_JSChartResource.StatusBar.UpTextColor;
169412
+ this.DownColor=g_JSChartResource.StatusBar.DownTextColor;
169413
+ this.UnchangeColor=g_JSChartResource.StatusBar.UnchangeTextColor;
169414
+
169415
+ this.TableConfig=CloneData(g_JSChartResource.StatusBar.Table);
169416
+ this.DateTimeConfig=CloneData(g_JSChartResource.StatusBar.DateTime);
169417
+
169418
+ //显示的字段
169419
+ this.Column=
169420
+ [
169421
+ {
169422
+ Symbol:"000001.sh",
169423
+ Column:
169424
+ [
169425
+ { Name:"名称", Key:"Name", Text:"000001", },
169426
+ { Name:"现价", Key:"Price", ColorType:3, FloatPrecision:-1, MaxText:"88888.88" },
169427
+ { Name:"涨幅", Key:"Increase", ColorType:1, FloatPrecision:2, StringFormat:"{Value}%", MaxText:"888.88%" },
169428
+ { Name:"涨跌", Key:"UpDown",ColorType:1, FloatPrecision:-1 },
169429
+ { Name:"总额", Key:"Amount", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 }, ColorID:1 }
169430
+ ]
169431
+ },
169432
+
169433
+ {
169434
+ Symbol:"600000.sh",
169435
+ Column:
169436
+ [
169437
+ { Name:"名称", Key:"Name", Text:"600000", },
169438
+ { Name:"现价", Key:"Price", ColorType:3, FloatPrecision:-1 },
169439
+ { Name:"涨幅", Key:"Increase", ColorType:1, FloatPrecision:2, StringFormat:"{Value}%" },
169440
+ { Name:"涨跌", Key:"UpDown",ColorType:1, FloatPrecision:-1 },
169441
+ { Name:"总额", Key:"Amount", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }
169442
+ ]
169443
+ }
169444
+ ]
169445
+
169446
+ this.RightToolbarConfig=CloneData(g_JSChartResource.StatusBar.RightToolbar);
169447
+ this.MapToolbarFlash=new Map(); //key=id, Value:{ Counter:, Enable: }
169448
+
169449
+
169450
+ //右侧工具栏
169451
+ this.RightToolbar=
169452
+ {
169453
+ /*
169454
+ AryButton:
169455
+ [
169456
+ { ID:2, Type:1, Icon:[{ Symbol:"\ue609", Color:"rgb(180,180,180)"} ] },
169457
+
169458
+ {
169459
+ ID:1, Type:2, Icon:[{ Symbol:"\ue6d0", Color:"rgb(180,180,180)"} ],
169460
+ Flash:
169461
+ {
169462
+ AryIcon:
169463
+ [
169464
+ [{ Symbol:"\ue6cb", Color:"rgb(0,191,255)"}],
169465
+ [{ Symbol:"\ue6cb", Color:"rgb(255,165,0)"}],
169466
+ [{ Symbol:"\ue6cb", Color:"rgb(255,215,0)"}],
169467
+ ]
169468
+ }
169469
+ },
169470
+ ]
169471
+ */
169472
+ }
169473
+
169474
+ this.AryRectCell=[];
169475
+ this.AryRectButton=[];
169476
+
169477
+ this.ReloadResource=function(resource)
169478
+ {
169479
+ this.UpColor=g_JSChartResource.StatusBar.UpTextColor;
169480
+ this.DownColor=g_JSChartResource.StatusBar.DownTextColor;
169481
+ this.UnchangeColor=g_JSChartResource.StatusBar.UnchangeTextColor;
169482
+
169483
+ this.TableConfig=CloneData(g_JSChartResource.StatusBar.Table);
169484
+ this.DateTimeConfig=CloneData(g_JSChartResource.StatusBar.DateTime);
169485
+ }
169486
+
169487
+ this.SetColumn=function(aryColumn)
169488
+ {
169489
+ this.Column=[];
169490
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryColumn)) return;
169491
+
169492
+ for(var i=0;i<aryColumn.length;++i)
169493
+ {
169494
+ var item=aryColumn[i];
169495
+ if (!item) continue;
169496
+ this.Column.push(CloneData(item));
169497
+ }
169498
+ }
169499
+
169500
+ this.SetRightToolbar=function(toolbar, option)
169501
+ {
169502
+ if (IFrameSplitOperator.IsNonEmptyArray(toolbar.AryButton))
169503
+ {
169504
+ this.RightToolbar.AryButton=toolbar.AryButton.slice();
169505
+ for(var i=0;i<this.RightToolbar.AryButton.length;++i)
169506
+ {
169507
+ var item=this.RightToolbar.AryButton[i];
169508
+ if (item.Type===2)
169509
+ {
169510
+ var value={ Counter:1, Enable:true };
169511
+ if (IFrameSplitOperator.IsBool(item.Enable)) value.Enable=item.Enable;
169512
+ this.MapToolbarFlash.set(item.ID, value)
169513
+ }
169514
+ }
169515
+
169516
+ }
169517
+
169518
+
169519
+ }
169520
+
169521
+ this.Draw=function()
169522
+ {
169523
+ this.AryRectCell=[];
169524
+ this.AryRectButton=[];
169525
+
169526
+ var border=this.ChartBorder.GetBorder();
169527
+ var position = { Left:border.Left, Right:border.Right, Top:border.Top, Bottom:border.Bottom, Width:border.Right-border.Left, Border:border };
169528
+ this.DrawRightToolbar(position);
169529
+ this.DrawTable(position);
169530
+ }
169531
+
169532
+ this.DrawTable=function(position)
169533
+ {
169534
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Column)) return;
169535
+
169536
+ var config=this.TableConfig;
169537
+ var top=position.Top;
169538
+ var left=position.Left+config.Margin.Left;
169539
+
169540
+ var yText=top+config.Margin.Top;
169541
+ var xText=left;
169542
+
169543
+ this.Canvas.font=config.Font;
169544
+ this.Canvas.textAlign = 'left';
169545
+ this.Canvas.textBaseline = 'bottom';
169546
+ var cellHeight=this.Canvas.measureText("擎").width+config.CellMargin.Top+config.CellMargin.Bottom;
169547
+ var itemPos={ Left:xText, Right:position.Right, Top:yText, Height:cellHeight, Bottom:yText+cellHeight, IsBreak:false, CellCount:0 };
169548
+
169549
+ for(var i=0;i<this.Column.length;++i)
169550
+ {
169551
+ var item=this.Column[i];
169552
+ if (!item || !item.Symbol) continue;
169553
+
169554
+ var rtCell={ Left:itemPos.Left, Top:itemPos.Top, Bottom:itemPos.Bottom, Right:itemPos.Left };
169555
+ if (i>0) rtCell.Left-=config.Separator.Right;
169556
+ this.DrawCellItem(item, itemPos );
169557
+ if (itemPos.CellCount>0)
169558
+ {
169559
+ rtCell.Right=itemPos.Left;
169560
+ rtCell.Width=rtCell.Right-itemPos.Left;
169561
+ rtCell.Height=rtCell.Bottom-rtCell.Top;
169562
+
169563
+ this.AryRectCell.push({ Rect:rtCell, Data:item, Type:1 });
169564
+ }
169565
+
169566
+ if (itemPos.IsBreak)
169567
+ {
169568
+ break;
169569
+ }
169570
+
169571
+ itemPos.Left+=config.Separator.Left;
169572
+ if (config.Separator.Line && config.Separator.Line.Color) //分割线
169573
+ {
169574
+ if (itemPos.Left>=itemPos.Right) break;
169575
+
169576
+ var subConfig=config.Separator.Line;
169577
+ var lineWidth=1*GetDevicePixelRatio();
169578
+ if (IFrameSplitOperator.IsNumber(subConfig.Width)) lineWidth=subConfig.Width;
169579
+
169580
+ this.Canvas.strokeStyle=subConfig.Color;
169581
+ this.Canvas.beginPath();
169582
+ this.Canvas.moveTo(ToFixedPoint(itemPos.Left),itemPos.Top+subConfig.Top);
169583
+ this.Canvas.lineTo(ToFixedPoint(itemPos.Left),itemPos.Bottom-subConfig.Bottom);
169584
+ this.Canvas.stroke();
169585
+ }
169586
+
169587
+ itemPos.Left+=config.Separator.Right;
169588
+ }
169589
+ }
169590
+
169591
+ this.DrawCellItem=function(cellItem, itemPos)
169592
+ {
169593
+ var config=this.TableConfig;
169594
+ var xText=itemPos.Left;
169595
+ var yBottom=itemPos.Top+itemPos.Height-config.CellMargin.Bottom+config.CellMargin.YOffset;
169596
+ var text=null;
169597
+
169598
+ var stockItem=null;
169599
+ if (this.Data.MapSymbol.has(cellItem.Symbol)) stockItem=this.Data.MapSymbol.get(cellItem.Symbol);
169600
+
169601
+ for(var i=0;i<cellItem.Column.length ;++i)
169602
+ {
169603
+ var item=cellItem.Column[i];
169604
+ if (!item) continue;
169605
+
169606
+ var color=config.AryTextColor[0];
169607
+ var text=null;
169608
+ if (stockItem && stockItem.MapData.has(item.Key))
169609
+ {
169610
+ var dataItem=stockItem.MapData.get(item.Key);
169611
+ text=this.FormatValue(item, dataItem, stockItem);
169612
+
169613
+ if (IFrameSplitOperator.IsNumber(item.ColorID) && item.ColorID>=0 && item.ColorID<config.AryTextColor.length)
169614
+ color=config.AryTextColor[item.ColorID];
169615
+
169616
+ if (item.ColorType===3 && IFrameSplitOperator.IsNumber(dataItem.Value))
169617
+ color=this.GetPriceColor(dataItem.Value, stockItem);
169618
+ else if (item.ColorType==1 && IFrameSplitOperator.IsNumber(dataItem.Value))
169619
+ color=this.GetUpDownColor(dataItem.Value,0);
169620
+ else if (item.ColorType==4)
169621
+ color=this.UpColor;
169622
+ else if (item.ColorType==5)
169623
+ color=this.DownColor;
169624
+
169625
+ if (item.TextColor) color=item.TextColor;
169626
+ }
169627
+
169628
+ if (!text && item.Text) text=item.Text;
169629
+
169630
+ if (text)
169631
+ {
169632
+ var textWidth=this.Canvas.measureText(text).width;
169633
+ if (xText+textWidth+config.CellMargin.Left+config.CellMargin.Right>itemPos.Right)
169634
+ {
169635
+ itemPos.IsBreak=true;
169636
+ break;
169637
+ }
169638
+ this.Canvas.fillStyle=color;
169639
+ this.Canvas.fillText(text,xText+config.CellMargin.Left,yBottom);
169640
+ xText+=(textWidth+config.CellMargin.Left+config.CellMargin.Right);
169641
+ }
169642
+ else if (item.MaxText)
169643
+ {
169644
+ text=item.MaxText;
169645
+ var textWidth=this.Canvas.measureText(text).width;
169646
+ xText+=(textWidth+config.CellMargin.Left+config.CellMargin.Right);
169647
+ if (xText>itemPos.Right)
169648
+ {
169649
+ itemPos.IsBreak=true;
169650
+ break;
169651
+ }
169652
+ }
169653
+
169654
+ ++itemPos.CellCount;
169655
+ }
169656
+
169657
+ itemPos.Left=xText;
169658
+
169659
+ }
169660
+
169661
+
169662
+ this.FormatValue=function(column, data, stockItem)
169663
+ {
169664
+ var dec=0; //小数位数
169665
+ if (IFrameSplitOperator.IsNumber(column.FloatPrecision))
169666
+ {
169667
+ if (column.FloatPrecision===-1) dec=GetfloatPrecision(stockItem.Symbol);
169668
+ else dec=column.FloatPrecision;
169669
+ }
169670
+
169671
+ var text=null;
169672
+ if (!data) return text;
169673
+
169674
+ if (data.Text)
169675
+ {
169676
+ text=data.Text;
169677
+ }
169678
+ else if (IFrameSplitOperator.IsNumber(data.Value))
169679
+ {
169680
+ var value=data.Value;
169681
+ text=value.toFixed(dec);
169682
+
169683
+ //格式化
169684
+ if (column.Format && IFrameSplitOperator.IsNumber(column.Format.Type))
169685
+ {
169686
+ var format=column.Format;
169687
+ switch(format.Type)
169688
+ {
169689
+ case 1: //原始数据
169690
+ text=value.toFixed(dec);
169691
+ break;
169692
+ case 2: //千分位分割
169693
+ text=IFrameSplitOperator.FormatValueThousandsString(value, dec);
169694
+ break;
169695
+ case 3:
169696
+ var exfloatPrecision=1;
169697
+ if (IFrameSplitOperator.IsNumber(format.ExFloatPrecision)) exfloatPrecision=format.ExFloatPrecision;
169698
+ text=IFrameSplitOperator.FormatValueStringV2(value, dec,exfloatPrecision);
169699
+ break;
169700
+ }
169701
+ }
169702
+ }
169703
+
169704
+ if (column.StringFormat && text) text=column.StringFormat.replace('{Value}',text);
169705
+
169706
+ return text;
169707
+ }
169708
+
169709
+ this.GetPriceColor=function(price, stockItem)
169710
+ {
169711
+ var upperSymbol=null;
169712
+ if (stockItem.Symbol) upperSymbol=stockItem.Symbol.toUpperCase();
169713
+ if (MARKET_SUFFIX_NAME.IsChinaFutures(upperSymbol))
169714
+ {
169715
+ if (!IFrameSplitOperator.IsNumber(stockItem.YFClose)) return this.UnchangeColor;
169716
+ return this.GetUpDownColor(price, stockItem.YFClose);
169717
+ }
169718
+ else
169719
+ {
169720
+ if (!IFrameSplitOperator.IsNumber(stockItem.YClose)) return this.UnchangeColor;
169721
+ return this.GetUpDownColor(price, stockItem.YClose);
169722
+ }
169723
+ }
169724
+
169725
+ this.GetUpDownColor=function(price, price2)
169726
+ {
169727
+ if (price>price2) return this.UpColor;
169728
+ else if (price<price2) return this.DownColor;
169729
+ else return this.UnchangeColor;
169730
+ }
169731
+
169732
+ this.DrawRightToolbar=function(position)
169733
+ {
169734
+ var config=this.DateTimeConfig;
169735
+ var top=position.Top;
169736
+ var right=position.Right;
169737
+
169738
+ this.Canvas.font=config.Font;
169739
+ this.Canvas.textAlign = 'left';
169740
+ this.Canvas.textBaseline = 'bottom';
169741
+ var cellHeight=this.Canvas.measureText("擎").width+config.Margin.Top+config.Margin.Bottom;
169742
+
169743
+ var yBottom=top+cellHeight-config.Margin.Bottom+config.Margin.YOffset;
169744
+ var xText=right;
169745
+
169746
+ //时间
169747
+ var datetime=new Date();
169748
+ var text=IFrameSplitOperator.FormatDateTimeStringV2(datetime, config.Format);
169749
+ var textWidth=this.Canvas.measureText(config.MaxText).width+config.Margin.Left+config.Margin.Right;
169750
+ xText-=textWidth;
169751
+ this.Canvas.fillStyle=config.TitleColor;
169752
+ this.Canvas.fillText(text,xText+config.Margin.Left,yBottom);
169753
+
169754
+ position.Right=xText;
169755
+
169756
+ if (this.RightToolbar && IFrameSplitOperator.IsNonEmptyArray(this.RightToolbar.AryButton))
169757
+ {
169758
+ var config=this.RightToolbarConfig;
169759
+
169760
+ xText-=config.Margin.Right;
169761
+ for(var i=this.RightToolbar.AryButton.length-1;i>=0;--i)
169762
+ {
169763
+ var item=this.RightToolbar.AryButton[i];
169764
+ var aryItem=null;
169765
+ if (item.Type==2) aryItem=this.GetFlashToolbarItem(item);
169766
+ else aryItem=item.Icon;
169767
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryItem)) continue;
169768
+ var iconFont=`${config.Icon.Size}px ${config.Icon.Family}`;
169769
+ this.Canvas.font=iconFont;
169770
+ var textWidth=config.Icon.Size+config.CellMargin.Left+config.CellMargin.Right;
169771
+ xText-=textWidth;
169772
+ yBottom=top+config.Margin.Top+(config.Icon.Size+config.CellMargin.Top+config.CellMargin.Bottom)-config.CellMargin.Bottom+config.CellMargin.YOffset;
169773
+ for(var j=0;j<aryItem.length;++j)
169774
+ {
169775
+ var iconItem=aryItem[j];
169776
+ var text=iconItem.Symbol;
169777
+ this.Canvas.fillStyle=iconItem.Color;
169778
+ this.Canvas.fillText(text,xText+config.CellMargin.Left,yBottom);
169779
+ }
169780
+
169781
+ var rtButton={ Left:xText, Bottom:yBottom, Height:config.Icon.Size, Width:config.Icon.Size };
169782
+ rtButton.Right=rtButton.Left+rtButton.Width;
169783
+ rtButton.Top=rtButton.Bottom-rtButton.Height;
169784
+ this.AryRectButton.push({ Rect:rtButton, Data:item, Type:2 });
169785
+ }
169786
+ }
169787
+
169788
+ position.Right=xText;
169789
+ }
169790
+
169791
+ this.GetFlashToolbarItem=function(btnItem)
169792
+ {
169793
+ if (!btnItem.Flash || !IFrameSplitOperator.IsNonEmptyArray(btnItem.Flash.AryIcon)) return btnItem.Icon;
169794
+ if (!this.MapToolbarFlash.has(btnItem.ID)) return btnItem.Icon;
169795
+
169796
+ var item=this.MapToolbarFlash.get(btnItem.ID);
169797
+ if (!item.Enable) return btnItem.Icon;
169798
+
169799
+ item.Counter++;
169800
+
169801
+ var index=item.Counter%btnItem.Flash.AryIcon.length;
169802
+
169803
+ return btnItem.Flash.AryIcon[index];
169804
+ }
169805
+
169806
+ this.GetTooltipData=function(x,y,tooltip)
169807
+ {
169808
+ for(var i=0;i<this.AryRectCell.length;++i)
169809
+ {
169810
+ var item=this.AryRectCell[i];
169811
+ if (Path2DHelper.PtInRect(x,y, item.Rect))
169812
+ {
169813
+ tooltip.Data=item;
169814
+ tooltip.ChartPaint=this;
169815
+ tooltip.Type=121;
169816
+ return true;
169817
+ }
169818
+ }
169819
+
169820
+ for(var i=0;i<this.AryRectButton.length;++i)
169821
+ {
169822
+ var item=this.AryRectButton[i];
169823
+ if (Path2DHelper.PtInRect(x,y, item.Rect))
169824
+ {
169825
+ tooltip.Data=item;
169826
+ tooltip.ChartPaint=this;
169827
+ tooltip.Type=122;
169828
+ return true;
169829
+ }
169830
+ }
169831
+
169832
+ return false;
169833
+ }
169834
+ }
169835
+
169836
+
169837
+
169838
+
169839
+
169840
+
169841
+ /*
169842
+ Copyright (c) 2018 jones
169843
+
169844
+ http://www.apache.org/licenses/LICENSE-2.0
169845
+
169846
+ 开源项目 https://github.com/jones2000/HQChart
169847
+
169848
+ jones_2000@163.com
169849
+
169850
+ 股票买卖5档 (H5版本)
169851
+ 不提供内置测试数据
169852
+ */
169853
+
169854
+ function JSStockInfoChart(divElement)
169855
+ {
169856
+ this.DivElement=divElement;
169857
+ this.JSChartContainer; //表格控件
169858
+ this.ResizeListener; //大小变动监听
169859
+
169860
+ //h5 canvas
169861
+ this.CanvasElement=document.createElement("canvas");
169862
+ this.CanvasElement.className='jsstockinfo-drawing';
169863
+ this.CanvasElement.id=Guid();
169864
+ this.CanvasElement.setAttribute("tabindex",0);
169865
+ if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
169866
+ if(divElement.hasChildNodes())
169867
+ {
169868
+ JSConsole.Chart.Log("[JSStockInfoChart::JSStockInfoChart] divElement hasChildNodes", divElement.childNodes);
169869
+ }
169870
+ divElement.appendChild(this.CanvasElement);
169871
+
169872
+
169873
+ this.OnSize=function()
169874
+ {
169875
+ //画布大小通过div获取 如果有style里的大小 使用style里的
169876
+ var height=this.DivElement.offsetHeight;
169877
+ var width=this.DivElement.offsetWidth;
169878
+ if (this.DivElement.style.height && this.DivElement.style.width)
169879
+ {
169880
+ if (this.DivElement.style.height.includes("px"))
169881
+ height=parseInt(this.DivElement.style.height.replace("px",""));
169882
+ if (this.DivElement.style.width.includes("px"))
169883
+ width=parseInt(this.DivElement.style.width.replace("px",""));
169884
+ }
169885
+
169886
+ this.CanvasElement.height=height;
169887
+ this.CanvasElement.width=width;
169888
+ this.CanvasElement.style.width=this.CanvasElement.width+'px';
169889
+ this.CanvasElement.style.height=this.CanvasElement.height+'px';
169890
+
169891
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
169892
+ this.CanvasElement.height*=pixelTatio;
169893
+ this.CanvasElement.width*=pixelTatio;
169894
+
169895
+ JSConsole.Chart.Log(`[JSStockInfoChart::OnSize] devicePixelRatio=${window.devicePixelRatio}, height=${this.CanvasElement.height}, width=${this.CanvasElement.width}`);
169896
+
169897
+ if (this.JSChartContainer && this.JSChartContainer.OnSize)
169898
+ {
169899
+ this.JSChartContainer.OnSize();
169900
+ }
169901
+ }
169902
+
169903
+ this.SetOption=function(option)
169904
+ {
169905
+ var chart=this.CreateJSStockInfoChartContainer(option);
169906
+
169907
+ if (!chart) return false;
169908
+
169909
+ if (option.OnCreatedCallback) option.OnCreatedCallback(chart);
169910
+
169911
+ this.JSChartContainer=chart;
169912
+ this.DivElement.JSChart=this; //div中保存一份
169913
+
169914
+ if (option.EnableResize==true) this.CreateResizeListener();
169915
+
169916
+ if (option.Symbol)
169917
+ {
169918
+ chart.ChangeSymbol(option.Symbol); //下载列表码表
169919
+ }
169920
+ else
169921
+ {
169922
+ chart.Draw();
169923
+ }
169924
+ }
169925
+
169926
+ this.CreateResizeListener=function()
169927
+ {
169928
+ this.ResizeListener = new ResizeObserver((entries)=>{ this.OnDivResize(entries); });
169929
+ this.ResizeListener.observe(this.DivElement);
169930
+ }
169931
+
169932
+ this.OnDivResize=function(entries)
169933
+ {
169934
+ JSConsole.Chart.Log("[JSStockInfoChart::OnDivResize] entries=", entries);
169935
+
169936
+ this.OnSize();
169937
+ }
169938
+
169939
+ //切换股票代码接口
169940
+ this.ChangeSymbol=function(symbol, option)
169941
+ {
169942
+ if (this.JSChartContainer) this.JSChartContainer.ChangeSymbol(symbol,option);
169943
+ }
169944
+
169945
+ this.CreateJSStockInfoChartContainer=function(option)
169946
+ {
169947
+ var chart=new JSStockInfoChartContainer(this.CanvasElement);
169948
+ chart.Create(option);
169949
+
169950
+ this.SetChartBorder(chart, option);
169951
+
169952
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) chart.SetColumn(option.Column);
169953
+ if (IFrameSplitOperator.IsNonEmptyArray(option.HeaderColumn)) chart.SetHeaderColumn(option.HeaderColumn);
169954
+ if (IFrameSplitOperator.IsNonEmptyArray(option.MouseOnKey)) chart.SetMouseOnKey(option.MouseOnKey);
169955
+
169956
+ //是否自动更新
169957
+ if (option.NetworkFilter) chart.NetworkFilter=option.NetworkFilter;
169958
+
169959
+ if (option.IsAutoUpdate!=null) chart.IsAutoUpdate=option.IsAutoUpdate;
169960
+ if (option.AutoUpdateFrequency>0) chart.AutoUpdateFrequency=option.AutoUpdateFrequency;
169961
+
169962
+ //注册事件
169963
+ if (option.EventCallback)
169964
+ {
169965
+ for(var i=0;i<option.EventCallback.length;++i)
169966
+ {
169967
+ var item=option.EventCallback[i];
169968
+ chart.AddEventCallback(item);
169969
+ }
169970
+ }
169971
+
169972
+ return chart;
169973
+ }
169974
+
169975
+ this.SetChartBorder=function(chart, option)
169976
+ {
169977
+ if (!option.Border) return;
169978
+
169979
+ var item=option.Border;
169980
+ if (IFrameSplitOperator.IsNumber(option.Border.Left)) chart.Frame.ChartBorder.Left=option.Border.Left;
169981
+ if (IFrameSplitOperator.IsNumber(option.Border.Right)) chart.Frame.ChartBorder.Right=option.Border.Right;
169982
+ if (IFrameSplitOperator.IsNumber(option.Border.Top)) chart.Frame.ChartBorder.Top=option.Border.Top;
169983
+ if (IFrameSplitOperator.IsNumber(option.Border.Bottom)) chart.Frame.ChartBorder.Bottom=option.Border.Bottom;
169984
+
169985
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
169986
+ chart.Frame.ChartBorder.Left*=pixelTatio;
169987
+ chart.Frame.ChartBorder.Right*=pixelTatio;
169988
+ chart.Frame.ChartBorder.Top*=pixelTatio;
169989
+ chart.Frame.ChartBorder.Bottom*=pixelTatio;
169990
+ }
169991
+
169992
+ //事件回调
169993
+ this.AddEventCallback=function(obj)
169994
+ {
169995
+ if(this.JSChartContainer && typeof(this.JSChartContainer.AddEventCallback)=='function')
169996
+ {
169997
+ JSConsole.Chart.Log('[JSStockInfoChart:AddEventCallback] obj=', obj);
169998
+ this.JSChartContainer.AddEventCallback(obj);
169999
+ }
170000
+ }
170001
+
170002
+ //重新加载配置
170003
+ this.ReloadResource=function(option)
170004
+ {
170005
+ if(this.JSChartContainer && typeof(this.JSChartContainer.ReloadResource)=='function')
170006
+ {
170007
+ JSConsole.Chart.Log('[JSStockInfoChart:ReloadResource] ');
170008
+ this.JSChartContainer.ReloadResource(option);
170009
+ }
170010
+ }
170011
+
170012
+ this.ChartDestroy=function()
170013
+ {
170014
+ if (this.JSChartContainer && typeof (this.JSChartContainer.ChartDestroy) == 'function')
170015
+ {
170016
+ this.JSChartContainer.ChartDestroy();
170017
+ }
170018
+ }
170019
+
170020
+ this.Draw=function()
170021
+ {
170022
+ if(this.JSChartContainer && typeof(this.JSChartContainer.Draw)=='function')
170023
+ {
170024
+ JSConsole.Chart.Log('[JSStockInfoChart:Draw] ');
170025
+ this.JSChartContainer.Draw();
170026
+ }
170027
+ }
170028
+ }
170029
+
170030
+ JSStockInfoChart.Init=function(divElement)
170031
+ {
170032
+ var jsChartControl=new JSStockInfoChart(divElement);
170033
+ jsChartControl.OnSize();
170034
+
170035
+ return jsChartControl;
170036
+ }
170037
+
170038
+ //自定义风格
170039
+ JSStockInfoChart.SetStyle=function(option)
170040
+ {
170041
+ if (option) g_JSChartResource.SetStyle(option);
170042
+ }
170043
+
170044
+ //获取颜色配置 (JSStockInfoChart.Init()之前)
170045
+ JSStockInfoChart.GetResource=function()
170046
+ {
170047
+ return g_JSChartResource;
170048
+ }
170049
+
170050
+ JSStockInfoChart.GetfloatPrecision=function(symbol)
170051
+ {
170052
+ return GetfloatPrecision(symbol);
170053
+ }
170054
+
170055
+
170056
+ function JSStockInfoChartContainer(uielement)
170057
+ {
170058
+ this.ClassName='JSStockInfoChartContainer';
170059
+ this.Frame; //框架画法
170060
+ this.ChartPaint=[]; //图形画法
170061
+ this.ChartSplashPaint=null; //等待提示
170062
+ this.LoadDataSplashTitle="数据加载中"; //下载数据提示信息
170063
+
170064
+ this.Canvas=uielement.getContext("2d"); //画布
170065
+
170066
+ this.Symbol; //代码
170067
+ this.NetworkFilter; //数据回调接口
170068
+ this.Data=
170069
+ {
170070
+ Name:null,
170071
+ YClose:null, //昨收盘
170072
+ YFClose:null, //昨计算价
170073
+ Symbol:null,
170074
+
170075
+ Buys:
170076
+ [
170077
+ { Name:"买一", Price:null, Vol:null, Amount:null },
170078
+ { Name:"买二", Price:null, Vol:null, Amount:null },
170079
+ { Name:"买三", Price:null, Vol:null, Amount:null },
170080
+ { Name:"买四", Price:null, Vol:null, Amount:null },
170081
+ { Name:"买五", Price:null, Vol:null, Amount:null },
170082
+ { Name:"买六", Price:null, Vol:null, Amount:null },
170083
+ { Name:"买七", Price:null, Vol:null, Amount:null },
170084
+ { Name:"买八", Price:null, Vol:null, Amount:null },
170085
+ { Name:"买九", Price:null, Vol:null, Amount:null },
170086
+ { Name:"买十", Price:null, Vol:null, Amount:null },
170087
+ ],
170088
+
170089
+ Sells:
170090
+ [
170091
+ { Name:"卖一", Price:null, Vol:null, Amount:null },
170092
+ { Name:"卖二", Price:null, Vol:null, Amount:null },
170093
+ { Name:"卖三", Price:null, Vol:null, Amount:null },
170094
+ { Name:"卖四", Price:null, Vol:null, Amount:null },
170095
+ { Name:"卖五", Price:null, Vol:null, Amount:null },
170096
+ { Name:"卖六", Price:null, Vol:null, Amount:null },
170097
+ { Name:"卖七", Price:null, Vol:null, Amount:null },
170098
+ { Name:"卖八", Price:null, Vol:null, Amount:null },
170099
+ { Name:"卖九", Price:null, Vol:null, Amount:null },
170100
+ { Name:"卖十", Price:null, Vol:null, Amount:null },
170101
+ ],
170102
+
170103
+ MapData:new Map(), //key=, { Value:, Text:, }
170104
+ };
170105
+ //股票数据
170106
+ this.BorderData={ MapData:null }; //key=Field Value:[null, {ExePrice} ,{ExePrice} ]
170107
+
170108
+ this.MapStockData;
170109
+
170110
+ //事件回调
170111
+ this.mapEvent=new Map(); //通知外部调用 key:JSCHART_EVENT_ID value:{Callback:回调,}
170112
+
170113
+ this.AutoUpdateTimer=null;
170114
+ this.AutoUpdateFrequency=15000; //15秒更新一次数据
170115
+
170116
+ this.UIElement=uielement;
170117
+
170118
+ this.IsDestroy=false; //是否已经销毁了
170119
+
170120
+ this.ChartDestroy=function() //销毁
170121
+ {
170122
+ this.IsDestroy=true;
170123
+ this.StopAutoUpdate();
170124
+ }
170125
+
170126
+ //设置事件回调
170127
+ //{event:事件id, callback:回调函数}
170128
+ this.AddEventCallback=function(object)
170129
+ {
170130
+ if (!object || !object.event || !object.callback) return;
170131
+
170132
+ var data={Callback:object.callback, Source:object};
170133
+ this.mapEvent.set(object.event,data);
170134
+ }
170135
+
170136
+ this.ClearData=function()
170137
+ {
170138
+ this.Data.Name=null;
170139
+ this.Data.YClose=null;
170140
+ this.Data.YFClose=null;
170141
+
170142
+ this.Data.Buys=
170143
+ [
170144
+ { Name:"买一", Price:null, Vol:null, Amount:null },
170145
+ { Name:"买二", Price:null, Vol:null, Amount:null },
170146
+ { Name:"买三", Price:null, Vol:null, Amount:null },
170147
+ { Name:"买四", Price:null, Vol:null, Amount:null },
170148
+ { Name:"买五", Price:null, Vol:null, Amount:null },
170149
+ { Name:"买六", Price:null, Vol:null, Amount:null },
170150
+ { Name:"买七", Price:null, Vol:null, Amount:null },
170151
+ { Name:"买八", Price:null, Vol:null, Amount:null },
170152
+ { Name:"买九", Price:null, Vol:null, Amount:null },
170153
+ { Name:"买十", Price:null, Vol:null, Amount:null },
170154
+ ];
170155
+
170156
+ this.Data.Sells=
170157
+ [
170158
+ { Name:"卖一", Price:null, Vol:null, Amount:null },
170159
+ { Name:"卖二", Price:null, Vol:null, Amount:null },
170160
+ { Name:"卖三", Price:null, Vol:null, Amount:null },
170161
+ { Name:"卖四", Price:null, Vol:null, Amount:null },
170162
+ { Name:"卖五", Price:null, Vol:null, Amount:null },
170163
+ { Name:"卖六", Price:null, Vol:null, Amount:null },
170164
+ { Name:"卖七", Price:null, Vol:null, Amount:null },
170165
+ { Name:"卖八", Price:null, Vol:null, Amount:null },
170166
+ { Name:"卖九", Price:null, Vol:null, Amount:null },
170167
+ { Name:"卖十", Price:null, Vol:null, Amount:null },
170168
+ ];
170169
+
170170
+ this.Data.MapData=new Map();
170171
+ }
170172
+
170173
+ this.ChangeSymbol=function(symbol, option)
170174
+ {
170175
+ this.CancelAutoUpdate();
170176
+ this.ClearData();
170177
+ this.Symbol=symbol;
170178
+ this.Data.Symbol=symbol;
170179
+
170180
+ if (option)
170181
+ {
170182
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) this.SetColumn(option.Column);
170183
+ if (IFrameSplitOperator.IsNumber(option.BuySellCount)) this.SetBuySellCount(option.BuySellCount);
170184
+ if (IFrameSplitOperator.IsNonEmptyArray(option.MouseOnKey)) this.SetMouseOnKey(option.MouseOnKey);
170185
+ }
170186
+
170187
+ this.Draw();
170188
+ this.RequestStockData();
170189
+
170190
+ if (this.IsAutoUpdate)
170191
+ {
170192
+ var frequency=this.AutoUpdateFrequency;
170193
+ setInterval(()=>
170194
+ {
170195
+ var marketStatus=MARKET_SUFFIX_NAME.GetMarketStatus(this.Symbol);
170196
+ if (marketStatus==0 || marketStatus==3) //闭市,盘后
170197
+ return;
170198
+
170199
+ this.RequestStockData();
170200
+ }, frequency)
170201
+ }
170202
+ }
170203
+
170204
+ this.CancelAutoUpdate=function() //关闭停止更新
170205
+ {
170206
+ if (this.AutoUpdateTimer)
170207
+ {
170208
+ clearInterval(this.AutoUpdateTimer);
170209
+ this.AutoUpdateTimer = null;
170210
+ }
170211
+ }
170212
+
170213
+ this.StopAutoUpdate=function()
170214
+ {
170215
+ this.CancelAutoUpdate();
170216
+ if (!this.IsAutoUpdate) return;
170217
+ this.IsAutoUpdate=false;
170218
+ }
170219
+
170220
+ this.RequestStockData=function()
170221
+ {
170222
+ if (this.NetworkFilter)
170223
+ {
170224
+ var obj=
170225
+ {
170226
+ Name:'JSStockInfoChartContainer::RequestStockData', //类名::函数名
170227
+ Explain:'股票5档实时数据',
170228
+ Request: { Data:{symbol:this.Symbol} },
170229
+ Self:this,
170230
+ PreventDefault:false
170231
+ };
170232
+
170233
+ this.NetworkFilter(obj, (data)=>
170234
+ {
170235
+ this.RecvStockData(data);
170236
+ });
170237
+
170238
+ if (obj.PreventDefault==true) return; //已被上层替换,不调用默认的网络请求
170239
+ }
170240
+ }
170241
+
170242
+ this.RecvStockData=function(recv)
170243
+ {
170244
+ if (!recv) return;
170245
+
170246
+ if (recv.name) this.Data.Name=recv.Name;
170247
+ if (IFrameSplitOperator.IsNumber(recv.yclose)) this.Data.YClose=recv.yclose;
170248
+ if (IFrameSplitOperator.IsNumber(recv.yfclose)) this.Data.YFClose=recv.yfclose;
170249
+
170250
+ if (recv.name) this.Data.Name=recv.name;
170251
+
170252
+ if (IFrameSplitOperator.IsNonEmptyArray(recv.data))
170253
+ {
170254
+ for(var i=0;i<recv.data.length;++i)
170255
+ {
170256
+ var item=recv.data[i];
170257
+ if (item.Name=="Buys")
170258
+ {
170259
+ if (IFrameSplitOperator.IsNonEmptyArray(item.Value))
170260
+ {
170261
+ for(var j=0;j<item.Value.length && j<this.Data.Buys.length;++j)
170262
+ {
170263
+ var srcItem=item.Value[j];
170264
+ var destItem=this.Data.Buys[j];
170265
+ destItem.Price=srcItem.Price;
170266
+ destItem.Vol=srcItem.Vol;
170267
+ }
170268
+ }
170269
+ }
170270
+ else if (item.Name=="Sells")
170271
+ {
170272
+ if (IFrameSplitOperator.IsNonEmptyArray(item.Value))
170273
+ {
170274
+ for(var j=0;j<item.Value.length && j<this.Data.Sells.length;++j)
170275
+ {
170276
+ var srcItem=item.Value[j];
170277
+ var destItem=this.Data.Sells[j];
170278
+ destItem.Price=srcItem.Price;
170279
+ destItem.Vol=srcItem.Vol;
170280
+ }
170281
+ }
170282
+ }
170283
+ else if (item.Name=="Symbol")
170284
+ {
170285
+ this.Data.Symbol=item.Value.Text;
170286
+ }
170287
+ else
170288
+ {
170289
+ this.Data.MapData.set(item.Name, item.Value);
170290
+ }
170291
+ }
170292
+ }
170293
+
170294
+ this.Draw();
170295
+ }
170296
+
170297
+ //创建
170298
+ this.Create=function(option)
170299
+ {
170300
+ this.UIElement.JSChartContainer=this;
170301
+
170302
+ //创建框架
170303
+ this.Frame=new JSStockInfoFrame();
170304
+ this.Frame.ChartBorder=new ChartBorder();
170305
+ this.Frame.ChartBorder.UIElement=this.UIElement;
170306
+ this.Frame.ChartBorder.Top=30;
170307
+ this.Frame.ChartBorder.Left=5;
170308
+ this.Frame.ChartBorder.Bottom=20;
170309
+ this.Frame.Canvas=this.Canvas;
170310
+
170311
+ //创建表格
170312
+ var chart=new ChartStockData();
170313
+ chart.Frame=this.Frame;
170314
+ chart.ChartBorder=this.Frame.ChartBorder;
170315
+ chart.Canvas=this.Canvas;
170316
+ chart.UIElement=this.UIElement;
170317
+ chart.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
170318
+ chart.Data=this.Data;
170319
+ chart.BorderData=this.BorderData;
170320
+ chart.GlobalOption=this.GlobalOption;
170321
+ chart.FixedRowData=this.FixedRowData;
170322
+ chart.SortInfo=this.SortInfo;
170323
+ this.ChartPaint[0]=chart;
170324
+
170325
+
170326
+ if (option)
170327
+ {
170328
+
170329
+ }
170330
+
170331
+
170332
+ this.UIElement.oncontextmenu=(e)=> { this.UIOnContextMenu(e); }
170333
+ this.UIElement.onmousedown=(e)=> { this.UIOnMouseDown(e); }
170334
+ this.UIElement.onmousemove=(e)=>{ this.UIOnMouseMove(e);}
170335
+ this.UIElement.onmouseout=(e)=>{ this.UIOnMounseOut(e); }
170336
+ this.UIElement.onmouseleave=(e)=>{ this.UIOnMouseleave(e); }
170337
+ /*
170338
+ this.UIElement.ondblclick=(e)=>{ this.UIOnDblClick(e); }
170339
+
170340
+ */
170341
+ }
170342
+
170343
+ this.UIOnMouseDown=function(e)
170344
+ {
170345
+ var pixelTatio = GetDevicePixelRatio();
170346
+ this.ClickDownPoint={ X:e.clientX, Y:e.clientY };
170347
+ var x = (e.clientX-this.UIElement.getBoundingClientRect().left)*pixelTatio;
170348
+ var y = (e.clientY-this.UIElement.getBoundingClientRect().top)*pixelTatio;
170349
+ }
170350
+
170351
+ this.UIOnContextMenu=function(e)
170352
+ {
170353
+ if (e) //去掉系统右键菜单
170354
+ {
170355
+ if (e.preventDefault) e.preventDefault();
170356
+ if (e.stopPropagation) e.stopPropagation();
170357
+ e.returnValue=false;
170358
+ }
170359
+ }
170360
+
170361
+ this.UIOnMouseMove=function(e)
170362
+ {
170363
+ var pixelTatio = GetDevicePixelRatio();
170364
+ var x = (e.clientX-this.UIElement.getBoundingClientRect().left)*pixelTatio;
170365
+ var y = (e.clientY-this.UIElement.getBoundingClientRect().top)*pixelTatio;
170366
+
170367
+ var option={ Update:false };
170368
+
170369
+ this.OnChartMouseMove(x,y,e,option);
170370
+
170371
+ if (option.Update===true) this.Draw();
170372
+ }
170373
+
170374
+ this.OnChartMouseMove=function(x, y, e, option)
170375
+ {
170376
+ for(var i=0;i<this.ChartPaint.length;++i)
170377
+ {
170378
+ var item=this.ChartPaint[i];
170379
+ if (item && item.OnMouseMove)
170380
+ {
170381
+ if (item.OnMouseMove(x,y,e,option)) return true;
170382
+ }
170383
+ }
170384
+
170385
+ return false;
170386
+ }
170387
+
170388
+ this.UIOnMouseleave=function(e)
170389
+ {
170390
+ var option={ Update:false }
170391
+
170392
+ this.ChartClearMouseOnData(option);
170393
+
170394
+ if (option.Update===true) this.Draw();
170395
+ }
170396
+
170397
+ this.UIOnMounseOut=function(e)
170398
+ {
170399
+ var option={ Update:false }
170400
+
170401
+ this.ChartClearMouseOnData(option);
170402
+
170403
+ if (option.Update===true) this.Draw();
170404
+
170405
+ //this.HideAllTooltip();
170406
+ }
170407
+
170408
+ this.ChartClearMouseOnData=function(option)
170409
+ {
170410
+ for(var i=0;i<this.ChartPaint.length;++i)
170411
+ {
170412
+ var item=this.ChartPaint[i];
170413
+ if (item && item.ClearMouseOnData)
170414
+ {
170415
+ item.ClearMouseOnData(option);
170416
+ }
170417
+ }
170418
+ }
170419
+
170420
+
170421
+ this.Draw=function()
170422
+ {
170423
+ if (this.UIElement.width<=0 || this.UIElement.height<=0) return;
170424
+
170425
+ this.Canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);
170426
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
170427
+ this.Canvas.lineWidth=pixelTatio; //手机端需要根据分辨率比调整线段宽度
170428
+
170429
+ this.Frame.Draw();
170430
+ this.Frame.DrawLogo();
170431
+
170432
+ //框架内图形
170433
+ for(var i=0;i<this.ChartPaint.length;++i)
170434
+ {
170435
+ var item=this.ChartPaint[i];
170436
+ item.Draw();
170437
+ }
170438
+ }
170439
+
170440
+ this.OnSize=function()
170441
+ {
170442
+ if (!this.Frame) return;
170443
+
170444
+ this.SetSizeChange(true);
170445
+ this.Draw();
170446
+ }
170447
+
170448
+ this.SetSizeChange=function(bChanged)
170449
+ {
170450
+ for(var i=0;i<this.ChartPaint.length;++i)
170451
+ {
170452
+ var chart=this.ChartPaint[i];
170453
+ if (chart) chart.SizeChange=bChanged;
170454
+ }
170455
+ }
170456
+
170457
+ this.ReloadResource=function(option)
170458
+ {
170459
+ this.Frame.ReloadResource(option);
170460
+
170461
+ for(var i=0;i<this.ChartPaint.length;++i)
170462
+ {
170463
+ var item=this.ChartPaint[i];
170464
+ if (item.ReloadResource) item.ReloadResource(option);
170465
+ }
170466
+
170467
+ if (option && (option.Redraw || option.Draw))
170468
+ {
170469
+ this.SetSizeChange(true);
170470
+ this.Draw();
170471
+ }
170472
+ }
170473
+
170474
+ this.SetColumn=function(aryColunm, option)
170475
+ {
170476
+ var chart=this.ChartPaint[0];
170477
+ if (!chart) return;
170478
+
170479
+ chart.SetColumn(aryColunm);
170480
+ chart.SizeChange=true;
170481
+
170482
+ if (option && option.Redraw) this.Draw();
170483
+ }
170484
+
170485
+ this.SetHeaderColumn=function(aryColunm, option)
170486
+ {
170487
+ var chart=this.ChartPaint[0];
170488
+ if (!chart) return;
170489
+
170490
+ chart.SetHeaderColumn(aryColunm);
170491
+ chart.SizeChange=true;
170492
+
170493
+ if (option && option.Redraw) this.Draw();
170494
+ }
170495
+
170496
+ this.SetBuySellCount=function(count, option)
170497
+ {
170498
+ var chart=this.ChartPaint[0];
170499
+ if (!chart) return;
170500
+
170501
+ chart.BuySellCount=count;
170502
+ chart.SizeChange=true;
170503
+
170504
+ if (option && option.Redraw) this.Draw();
170505
+ }
170506
+
170507
+ this.SetMouseOnKey=function(aryKey)
170508
+ {
170509
+ var chart=this.ChartPaint[0];
170510
+ if (!chart) return;
170511
+
170512
+ chart.SetMouseOnKey(aryKey);
170513
+ }
170514
+ }
170515
+
170516
+ function JSStockInfoFrame()
170517
+ {
170518
+ this.ChartBorder;
170519
+ this.Canvas; //画布
170520
+
170521
+ this.BorderLine=null; //1=上 2=下 4=左 8=右
170522
+ this.ClassName="JSStockInfoFrame";
170523
+
170524
+ this.BorderColor=g_JSChartResource.StockInfo.BorderColor; //边框线
170525
+
170526
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
170527
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
170528
+
170529
+ this.ReloadResource=function(resource)
170530
+ {
170531
+ this.BorderColor=g_JSChartResource.StockInfo.BorderColor; //边框线
170532
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
170533
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
170534
+ }
170535
+
170536
+ this.Draw=function()
170537
+ {
170538
+ var left=ToFixedPoint(this.ChartBorder.GetLeft());
170539
+ var top=ToFixedPoint(this.ChartBorder.GetTop());
170540
+ var right=ToFixedPoint(this.ChartBorder.GetRight());
170541
+ var bottom=ToFixedPoint(this.ChartBorder.GetBottom());
170542
+ var width=right-left;
170543
+ var height=bottom-top;
170544
+
170545
+ if (!IFrameSplitOperator.IsNumber(this.BorderLine))
170546
+ {
170547
+ this.Canvas.strokeStyle=this.BorderColor;
170548
+ this.Canvas.strokeRect(left,top,width,height);
170549
+ }
170550
+ else
170551
+ {
170552
+ this.Canvas.strokeStyle=this.BorderColor;
170553
+ this.Canvas.beginPath();
170554
+
170555
+ if ((this.BorderLine&1)>0) //上
170556
+ {
170557
+ this.Canvas.moveTo(left,top);
170558
+ this.Canvas.lineTo(right,top);
170559
+ }
170560
+
170561
+ if ((this.BorderLine&2)>0) //下
170562
+ {
170563
+ this.Canvas.moveTo(left,bottom);
170564
+ this.Canvas.lineTo(right,bottom);
170565
+ }
170566
+
170567
+ if ((this.BorderLine&4)>0) //左
170568
+ {
170569
+ this.Canvas.moveTo(left,top);
170570
+ this.Canvas.lineTo(left,bottom);
170571
+ }
170572
+
170573
+ if ((this.BorderLine&8)>0) //右
170574
+ {
170575
+ this.Canvas.moveTo(right,top);
170576
+ this.Canvas.lineTo(right,bottom);
170577
+ }
170578
+
170579
+ this.Canvas.stroke();
170580
+ }
170581
+ }
170582
+
170583
+ this.DrawLogo=function()
170584
+ {
170585
+ var text=g_JSChartResource.FrameLogo.Text;
170586
+ if (!IFrameSplitOperator.IsString(text)) return;
170587
+
170588
+ this.Canvas.fillStyle=this.LogoTextColor;
170589
+ this.Canvas.font=this.LogoTextFont;
170590
+ this.Canvas.textAlign = 'right';
170591
+ this.Canvas.textBaseline = 'bottom';
170592
+
170593
+ var x=this.ChartBorder.GetRight()-30;
170594
+ var y=this.ChartBorder.GetBottom()-5;
170595
+ this.Canvas.fillText(text,x,y);
170596
+ }
170597
+ }
170598
+
170599
+
170600
+ function ChartStockData()
170601
+ {
170602
+ this.Canvas; //画布
170603
+ this.ChartBorder; //边框信息
170604
+ this.ChartFrame; //框架画法
170605
+ this.Name; //名称
170606
+ this.ClassName='ChartStockData'; //类名
170607
+ this.UIElement;
170608
+ this.GetEventCallback; //获取事件
170609
+ this.Data; //数据
170610
+ this.BorderData;
170611
+ this.SizeChange=true;
170612
+ this.Decimal=2; //价格小数位数
170613
+
170614
+ this.UpColor=g_JSChartResource.StockInfo.UpTextColor;
170615
+ this.DownColor=g_JSChartResource.StockInfo.DownTextColor;
170616
+ this.UnchangeColor=g_JSChartResource.StockInfo.UnchangeTextColor;
170617
+
170618
+ this.HeaderConfig=CloneData(g_JSChartResource.StockInfo.Header);
170619
+ this.HeaderColumn=
170620
+ [
170621
+ { Name:"现价", Key:"Price", ColorType:3, FloatPrecision:-1, DefaultText:"--.--" },
170622
+ { Name:"涨幅", Key:"Increase", ColorType:1, FloatPrecision:2, StringFormat:"{Value}%", DefaultText:"--.--%" },
170623
+ { Name:"涨跌", Key:"UpDown",ColorType:1, FloatPrecision:-1, DefaultText:"--.--" }
170624
+ ]
170625
+
170626
+ //买卖5档配置
170627
+ this.BuySellConfig=CloneData(g_JSChartResource.StockInfo.BuySell);
170628
+ this.BuySellCount=5; //显示几档买卖盘
170629
+
170630
+ this.TableConfig=CloneData(g_JSChartResource.StockInfo.Table);
170631
+
170632
+ //显示的字段
170633
+ this.Column=
170634
+ [
170635
+ [{ Name:"涨停价", Key:"UpLimit",ColorType:3, FloatPrecision:-1 }, { Name:"跌停价", Key:"DownLimit" , ColorType:3, FloatPrecision:-1 }],
170636
+ [{ Name:"现价", Key:"Price", ColorType:3, FloatPrecision:-1 }, { Name:"今开", Key:"Open",ColorType:3, FloatPrecision:-1 }],
170637
+ [{ Name:"最高", Key:"High",ColorType:3, FloatPrecision:-1 }, { Name:"最低", Key:"Low",ColorType:3, FloatPrecision:-1 }],
170638
+ [{ Name:"涨幅", Key:"Increase", ColorType:1, FloatPrecision:2, StringFormat:"{Value}%" }, { Name:"涨跌", Key:"UpDown",ColorType:1, FloatPrecision:-1 }],
170639
+ [{ Name:"振幅", Key:"Amplitude", FloatPrecision:2, StringFormat:"{Value}%" }, { Name:"换手率", Key:"Exchange", FloatPrecision:2, StringFormat:"{Value}%" }],
170640
+
170641
+ [{ Name:"总量", Key:"Vol", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }, { Name:"总额", Key:"Amount", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }],
170642
+ [{ Name:"内盘", Key:"InVol", ColorType:4, FloatPrecision:0 }, { Name:"外盘", Key:"OutVol",ColorType:5, FloatPrecision:0 }],
170643
+ [{ Name:"TTM", Key:"PE_TTM", FloatPrecision:2 }, { Name:"市净率", Key:"PB", FloatPrecision:2 }],
170644
+ [{ Name:"流通市值", Key:"FlowMarketValue", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }, { Name:"总市值", Key:"TotalMarketValue", FloatPrecision:0, Format:{ Type:3, ExFloatPrecision:2 } }],
170645
+ ];
170646
+
170647
+ this.AryCellRect=[];
170648
+ this.MouseOnItem=null; //{ Key:, Rect: }
170649
+ //this.MouseOnItem={ Key:"SELL_PRICE_0" };
170650
+ this.MouseOnConfig=CloneData(g_JSChartResource.StockInfo.MouseOn);
170651
+
170652
+ this.MapMouseOnKey=new Map();
170653
+
170654
+
170655
+ this.ReloadResource=function(resource)
170656
+ {
170657
+ this.UpColor=g_JSChartResource.StockInfo.UpTextColor;
170658
+ this.DownColor=g_JSChartResource.StockInfo.DownTextColor;
170659
+ this.UnchangeColor=g_JSChartResource.StockInfo.UnchangeTextColor;
170660
+
170661
+ this.HeaderConfig=CloneData(g_JSChartResource.StockInfo.Header);
170662
+
170663
+ //买卖5档配置
170664
+ this.BuySellConfig=CloneData(g_JSChartResource.StockInfo.BuySell);
170665
+
170666
+ this.TableConfig=CloneData(g_JSChartResource.StockInfo.Table);
170667
+
170668
+ this.MouseOnConfig=CloneData(g_JSChartResource.StockInfo.MouseOn);
170669
+ }
170670
+
170671
+ this.ClearMouseOnData=function(option)
170672
+ {
170673
+ if (!this.MouseOnItem)
170674
+ {
170675
+ this.MouseOnItem=null;
170676
+ if (option) option.Update=true; //需要更新
170677
+ }
170678
+ }
170679
+
170680
+ this.SetColumn=function(aryColumn)
170681
+ {
170682
+ this.Column=[];
170683
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryColumn)) return;
170684
+
170685
+ for(var i=0;i<aryColumn.length;++i)
170686
+ {
170687
+ var item=aryColumn[i];
170688
+ if (!item) continue;
170689
+ this.Column.push(CloneData(item));
170690
+ }
170691
+ }
170692
+
170693
+ this.SetHeaderColumn=function(aryColumn)
170694
+ {
170695
+ this.HeaderColumn=[];
170696
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryColumn)) return;
170697
+
170698
+ for(var i=0;i<aryColumn.length;++i)
170699
+ {
170700
+ var item=aryColumn[i];
170701
+ if (!item) continue;
170702
+ this.HeaderColumn.push(CloneData(item));
170703
+ }
170704
+ }
170705
+
170706
+ this.SetMouseOnKey=function(aryKey)
170707
+ {
170708
+ this.MapMouseOnKey.clear();
170709
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryKey)) return;
170710
+
170711
+ for(var i=0;i<aryKey.length;++i)
170712
+ {
170713
+ var key=aryKey[i];
170714
+ if (!key) continue;
170715
+
170716
+ this.MapMouseOnKey.set(key, { Key:key });
170717
+ }
170718
+
170719
+ }
170720
+
170721
+ this.OnMouseMove=function(x, y, e, option)
170722
+ {
170723
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryCellRect)) return false;
170724
+
170725
+ if (this.MouseOnItem && this.MouseOnItem.Rect)
170726
+ {
170727
+ var rect=this.MouseOnItem.Rect;
170728
+ if (Path2DHelper.PtInRect(x,y,rect )) return true;
170729
+ }
170730
+
170731
+ for(var i=0;i<this.AryCellRect.length;++i)
170732
+ {
170733
+ var item=this.AryCellRect[i];
170734
+ var rect=item.Rect;
170735
+ if (Path2DHelper.PtInRect(x,y, rect))
170736
+ {
170737
+ this.MouseOnItem={ Key:item.Data.Key, Rect:rect };
170738
+ if (option) option.Update=true;
170739
+ return true;
170740
+ }
170741
+ }
170742
+
170743
+ if (this.MouseOnItem)
170744
+ {
170745
+ this.MouseOnItem=null;
170746
+ if (option) option.Update=true;
170747
+ }
170748
+
170749
+ return false;
170750
+ }
170751
+
170752
+ this.Draw=function()
170753
+ {
170754
+ this.AryCellRect=[];
170755
+ this.Decimal=GetfloatPrecision(this.Data.Symbol);
170756
+ var border=this.ChartBorder.GetBorder();
170757
+ var position = { Left:border.Left, Right:border.Right, Top:border.Top, Width:border.Right-border.Left, Border:border };
170758
+ this.DrawHeader(position);
170759
+ this.DrawBuySell(position);
170760
+ this.DrawTable(position);
170761
+ }
170762
+
170763
+ this.DrawHeader=function(position)
170764
+ {
170765
+ var config=this.HeaderConfig;
170766
+ var top=position.Top;
170767
+ var left=position.Left;
170768
+ var xText=left;
170769
+ var yText=top;
170770
+
170771
+ this.Canvas.font=config.Name.Font;
170772
+ var nameHeight=this.Canvas.measureText("擎").width;
170773
+ nameHeight+=config.Name.Margin.Top+config.Name.Margin.Bottom;
170774
+
170775
+ this.Canvas.font=config.Symbol.Font;
170776
+ var symbolHeight=this.Canvas.measureText("擎").width;
170777
+ symbolHeight+=config.Symbol.Margin.Top+config.Symbol.Margin.Bottom;
170778
+
170779
+ var lineHeight=Math.max(symbolHeight, nameHeight);
170780
+
170781
+ this.Canvas.textAlign = 'left';
170782
+ this.Canvas.textBaseline = 'bottom';
170783
+ if (this.Data.Name)
170784
+ {
170785
+ var text=this.Data.Name;
170786
+ xText+=config.Name.Margin.Left;
170787
+ var yBottom=yText+lineHeight-config.Name.Margin.Bottom+config.Name.Margin.YOffset;
170788
+
170789
+ this.Canvas.font=config.Name.Font;
170790
+ this.Canvas.fillStyle=config.Name.Color;
170791
+ this.Canvas.fillText(text,xText,yBottom);
170792
+ var textWidth=this.Canvas.measureText(text).width;
170793
+
170794
+ xText+=textWidth+config.Name.Margin.Right;
170795
+ }
170796
+
170797
+ if (this.Data.Symbol)
170798
+ {
170799
+ var text=MARKET_SUFFIX_NAME.GetShortSymbol(this.Data.Symbol);
170800
+ xText+=config.Symbol.Margin.Left;
170801
+ var yBottom=yText+lineHeight-config.Symbol.Margin.Bottom+config.Symbol.Margin.YOffset;
170802
+
170803
+ this.Canvas.font=config.Symbol.Font;
170804
+ this.Canvas.fillStyle=config.Symbol.Color;
170805
+ this.Canvas.fillText(text,xText,yBottom);
170806
+ var textWidth=this.Canvas.measureText(text).width;
170807
+
170808
+ xText+=textWidth+config.Symbol.Margin.Right;
170809
+ }
170810
+
170811
+ yText+=lineHeight;
170812
+
170813
+ if (IFrameSplitOperator.IsNonEmptyArray(this.HeaderColumn))
170814
+ {
170815
+ lineHeight=0;
170816
+ for(var i=0;i<this.HeaderColumn.length && i<config.AryCell.length;++i)
170817
+ {
170818
+ var subConfig=config.AryCell[i];
170819
+ this.Canvas.font=subConfig.Font;
170820
+ var textHeight=this.Canvas.measureText("擎").width;
170821
+ textHeight+=subConfig.Margin.Top+subConfig.Margin.Bottom;
170822
+ if (lineHeight<textHeight) lineHeight=textHeight;
170823
+ }
170824
+
170825
+ var xText=left;
170826
+ for(var i=0;i<this.HeaderColumn.length && i<config.AryCell.length;++i)
170827
+ {
170828
+ var item=this.HeaderColumn[i];
170829
+ var text="--.--";
170830
+ color=config.TextColor;
170831
+ if (item.DefaultText) text=item.DefaultText;
170832
+ var subConfig=config.AryCell[i];
170833
+ if (this.Data.MapData && this.Data.MapData.has(item.Key))
170834
+ {
170835
+ var dataItem=this.Data.MapData.get(item.Key);
170836
+ var text=this.FormatValue(item, dataItem);
170837
+
170838
+ if (item.ColorType===3 && IFrameSplitOperator.IsNumber(dataItem.Value))
170839
+ color=this.GetPriceColor(dataItem.Value);
170840
+ else if (item.ColorType==1 && IFrameSplitOperator.IsNumber(dataItem.Value))
170841
+ color=this.GetUpDownColor(dataItem.Value,0);
170842
+ else if (item.ColorType==4)
170843
+ color=this.UpColor;
170844
+ else if (item.ColorType==5)
170845
+ color=this.DownColor;
170846
+ }
170847
+
170848
+ if (item.TextColor) color=item.TextColor;
170849
+
170850
+ if (text)
170851
+ {
170852
+ this.Canvas.font=subConfig.Font;
170853
+ var textWidth=this.Canvas.measureText(text).width;
170854
+ var x=xText+subConfig.Margin.Left;
170855
+ this.Canvas.fillStyle=color;
170856
+ var yBottom=yText+lineHeight-subConfig.Margin.Bottom+subConfig.Margin.YOffset;
170857
+ this.Canvas.fillText(text,x,yBottom);
170858
+
170859
+ xText+=subConfig.Margin.Left+subConfig.Margin.Right+textWidth;
170860
+ }
170861
+ }
170862
+
170863
+ yText+=lineHeight;
170864
+ }
170865
+
170866
+ position.Top=yText;
170867
+
170868
+ if (config.BottomLine && config.BottomLine.Enable)
170869
+ {
170870
+ var xLeft=position.Border.Left, xRight=position.Border.Right;
170871
+ this.Canvas.strokeStyle=config.BottomLine.Color;
170872
+ var lineWidth=1*GetDevicePixelRatio();;
170873
+ this.Canvas.lineWidth=lineWidth;
170874
+ this.Canvas.beginPath();
170875
+ this.Canvas.moveTo(xLeft,ToFixedPoint(yText));
170876
+ this.Canvas.lineTo(xRight,ToFixedPoint(yText));
170877
+ this.Canvas.stroke();
170878
+ position.Top=ToFixedPoint(yText);
170879
+ }
170880
+ }
170881
+
170882
+ //买卖5档
170883
+ this.DrawBuySell=function(position)
170884
+ {
170885
+ if (this.BuySellCount<=0) return;
170886
+
170887
+ var config=this.BuySellConfig;
170888
+ var top=position.Top;
170889
+ var left=position.Left+config.Margin.Left;
170890
+ var cellWidth=(position.Width-config.Margin.Left-config.Margin.Right)/4;
170891
+
170892
+ var yText=top+config.Margin.Top;
170893
+ var xText=left;
170894
+
170895
+ this.Canvas.font=config.Font;
170896
+ this.Canvas.textAlign = 'left';
170897
+ this.Canvas.textBaseline = 'bottom';
170898
+ var cellHeight=this.Canvas.measureText("擎").width+config.CellMargin.Top+config.CellMargin.Bottom;
170899
+ var count=this.BuySellCount;
170900
+ var sellVol=0, buyVol=0;
170901
+ for(var i=count-1;i>=0;--i)
170902
+ {
170903
+ xText=left;
170904
+ var item=this.Data.Sells[i];
170905
+ this.DrawBuySellItem(item, xText, yText, cellWidth, cellHeight, { Type:1, Index:i});
170906
+ if (IFrameSplitOperator.IsNumber(item.Vol)) sellVol+=item.Vol;
170907
+ yText+=cellHeight;
170908
+ }
170909
+
170910
+ var yCenter=null;
170911
+ if (config.CenterLine) //留出画线的位置
170912
+ {
170913
+ yCenter=yText;
170914
+ var lineConfig=config.CenterLine;
170915
+ var lineWidth=lineConfig.Width;
170916
+ yText+=lineWidth;
170917
+ }
170918
+
170919
+
170920
+ for(var i=0;i<count && i<this.Data.Buys.length;++i)
170921
+ {
170922
+ xText=left;
170923
+ var item=this.Data.Buys[i];
170924
+ this.DrawBuySellItem(item, xText, yText, cellWidth, cellHeight, { Type:2, Index:i});
170925
+ if (IFrameSplitOperator.IsNumber(item.Vol)) buyVol+=item.Vol;
170926
+ yText+=cellHeight;
170927
+ }
170928
+
170929
+ position.Top=yText;
170930
+
170931
+ if (IFrameSplitOperator.IsNumber(yCenter) && config.CenterLine)
170932
+ {
170933
+ var lineConfig=config.CenterLine;
170934
+ var xLeft=position.Border.Left, xRight=position.Border.Right;
170935
+ var lineWidth=lineConfig.Width;
170936
+ if (buyVol+sellVol>0)
170937
+ {
170938
+ var buyRate=buyVol/(buyVol+sellVol);
170939
+ var barWidth=xRight-xLeft;
170940
+ var buyWidth=barWidth*buyRate;
170941
+ var xCenter=xLeft+buyWidth;
170942
+ this.Canvas.lineWidth=lineWidth;
170943
+ this.Canvas.strokeStyle=lineConfig.BuyColor;
170944
+ this.Canvas.beginPath();
170945
+ this.Canvas.moveTo(xLeft,ToFixedPoint2(lineWidth,yCenter));
170946
+ this.Canvas.lineTo(xCenter,ToFixedPoint2(lineWidth,yCenter));
170947
+ this.Canvas.stroke();
170948
+
170949
+ this.Canvas.strokeStyle=lineConfig.SellColor;
170950
+ this.Canvas.beginPath();
170951
+ this.Canvas.moveTo(xCenter,ToFixedPoint2(lineWidth,yCenter,));
170952
+ this.Canvas.lineTo(xRight,ToFixedPoint2(lineWidth,yCenter));
170953
+ this.Canvas.stroke();
170954
+ }
170955
+ else
170956
+ {
170957
+ this.Canvas.strokeStyle=lineConfig.NoneColor;
170958
+ this.Canvas.lineWidth=lineWidth;
170959
+ this.Canvas.beginPath();
170960
+ this.Canvas.moveTo(xLeft,ToFixedPoint2(lineWidth,yCenter));
170961
+ this.Canvas.lineTo(xRight,ToFixedPoint2(lineWidth,yCenter));
170962
+ this.Canvas.stroke();
170963
+ }
170964
+ }
170965
+
170966
+ if (config.BottomLine && config.BottomLine.Enable)
170967
+ {
170968
+ var xLeft=position.Border.Left, xRight=position.Border.Right;
170969
+ this.Canvas.strokeStyle=config.BottomLine.Color;
170970
+ this.Canvas.lineWidth=1*GetDevicePixelRatio();
170971
+ this.Canvas.beginPath();
170972
+ this.Canvas.moveTo(xLeft,ToFixedPoint(yText));
170973
+ this.Canvas.lineTo(xRight,ToFixedPoint(yText));
170974
+ this.Canvas.stroke();
170975
+ }
170976
+
170977
+ if (config.TopLine && config.TopLine.Enable)
170978
+ {
170979
+ var xLeft=position.Border.Left, xRight=position.Border.Right;
170980
+ this.Canvas.strokeStyle=config.BottomLine.Color;
170981
+ this.Canvas.lineWidth=1*GetDevicePixelRatio();
170982
+ this.Canvas.beginPath();
170983
+ this.Canvas.moveTo(xLeft,ToFixedPoint(top));
170984
+ this.Canvas.lineTo(xRight,ToFixedPoint(top));
170985
+ this.Canvas.stroke();
170986
+ }
170987
+ }
170988
+
170989
+ //itemInfo={ Type:2(1=买 2=卖), Index:数据索引 }
170990
+ this.DrawBuySellItem=function(item, left, top, cellWidth, cellHeight, itemInfo)
170991
+ {
170992
+ var config=this.BuySellConfig;
170993
+ var xText=left;
170994
+ var yBottom=top+cellHeight-config.CellMargin.Bottom+config.CellMargin.YOffset;
170995
+
170996
+ if (item.Name)
170997
+ {
170998
+ this.Canvas.fillStyle=config.TitleColor;
170999
+ this.Canvas.fillText(item.Name,xText+config.CellMargin.Left,yBottom);
171000
+ }
171001
+ xText+=cellWidth;
171002
+
171003
+ if (IFrameSplitOperator.IsNumber(item.Price))
171004
+ {
171005
+ var key=`${itemInfo.Type==1?"BUY":"SELL"}_PRICE_${itemInfo.Index}`;
171006
+ var mouseOnItem=this.IsMouseOn(key);
171007
+
171008
+ var text=item.Price.toFixed(this.Decimal);
171009
+ var textWidth=this.Canvas.measureText(text).width;
171010
+ var x=xText+cellWidth-textWidth-config.CellMargin.Right;
171011
+ var rtCell={ Left:xText, Width:cellWidth, Top:top, Height:cellHeight };
171012
+ rtCell.Right=rtCell.Left+rtCell.Width;
171013
+ rtCell.Bottom=rtCell.Top+rtCell.Height;
171014
+ if (mouseOnItem) this.DrawMouseOnRect(rtCell);
171015
+
171016
+ this.Canvas.fillStyle=this.GetPriceColor(item.Price);
171017
+ this.Canvas.fillText(text,x,yBottom);
171018
+
171019
+ if (this.MapMouseOnKey.has(key))
171020
+ this.AryCellRect.push({ Rect:rtCell, Data:{ Type:1, Key:key, Value:item.Price }});
171021
+ }
171022
+ xText+=cellWidth;
171023
+
171024
+ xText+=cellWidth;
171025
+
171026
+ if (IFrameSplitOperator.IsNumber(item.Vol))
171027
+ {
171028
+ var text=item.Vol.toFixed(0);
171029
+ var textWidth=this.Canvas.measureText(text).width;
171030
+ var x=xText+cellWidth-textWidth-config.CellMargin.Right;
171031
+ this.Canvas.fillStyle=config.VolColor;
171032
+ this.Canvas.fillText(text,x,yBottom);
171033
+ }
171034
+ }
171035
+
171036
+ this.IsMouseOn=function(key)
171037
+ {
171038
+ if (!this.MouseOnItem) return null;
171039
+
171040
+ if (this.MouseOnItem.Key===key) return this.MouseOnItem;
171041
+
171042
+ return null;
171043
+ }
171044
+
171045
+ this.DrawMouseOnRect=function(rect)
171046
+ {
171047
+ if (!this.MouseOnItem) return;
171048
+
171049
+ this.Canvas.fillStyle=this.MouseOnConfig.BGColor;
171050
+ this.Canvas.fillRect(rect.Left, rect.Top, rect.Width, rect.Height);
171051
+
171052
+ this.MouseOnItem.Rect=rect;
171053
+ }
171054
+
171055
+
171056
+ this.DrawTable=function(position)
171057
+ {
171058
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Column)) return;
171059
+
171060
+ var config=this.TableConfig;
171061
+ var top=position.Top;
171062
+ var left=position.Left+config.Margin.Left;
171063
+ var cellWidth=(position.Width-config.Margin.Left-config.Margin.Right)/4;
171064
+
171065
+ var yText=top+config.Margin.Top;
171066
+ var xText=left;
171067
+
171068
+ this.Canvas.font=config.Font;
171069
+ this.Canvas.textAlign = 'left';
171070
+ this.Canvas.textBaseline = 'bottom';
171071
+ var cellHeight=this.Canvas.measureText("擎").width+config.CellMargin.Top+config.CellMargin.Bottom;
171072
+
171073
+ for(var i=0;i<this.Column.length;++i)
171074
+ {
171075
+ xText=left;
171076
+ var item=this.Column[i];
171077
+ if (!item || !IFrameSplitOperator.IsNonEmptyArray(item)) continue;
171078
+ this.DrawRowItem(item, xText, yText, cellWidth, cellHeight);
171079
+
171080
+ yText+=cellHeight;
171081
+ }
171082
+ }
171083
+
171084
+ this.DrawRowItem=function(aryData, left, top, cellWidth, cellHeight)
171085
+ {
171086
+ var config=this.TableConfig;
171087
+ var xText=left;
171088
+ var yBottom=top+cellHeight-config.CellMargin.Bottom+config.CellMargin.YOffset;
171089
+
171090
+ for(var i=0;i<aryData.length && i<2;++i)
171091
+ {
171092
+ var item=aryData[i];
171093
+ if (item)
171094
+ {
171095
+ if (item.Name)
171096
+ {
171097
+ this.Canvas.fillStyle=config.TitleColor;
171098
+ this.Canvas.fillText(item.Name,xText+config.CellMargin.Left,yBottom);
171099
+ }
171100
+ xText+=cellWidth;
171101
+
171102
+ if (this.Data.MapData && this.Data.MapData.has(item.Key))
171103
+ {
171104
+ var dataItem=this.Data.MapData.get(item.Key);
171105
+ color=config.TextColor;
171106
+
171107
+ var text=this.FormatValue(item, dataItem);
171108
+
171109
+ if (item.ColorType===3 && IFrameSplitOperator.IsNumber(dataItem.Value))
171110
+ color=this.GetPriceColor(dataItem.Value);
171111
+ else if (item.ColorType==1 && IFrameSplitOperator.IsNumber(dataItem.Value))
171112
+ color=this.GetUpDownColor(dataItem.Value,0);
171113
+ else if (item.ColorType==4)
171114
+ color=this.UpColor;
171115
+ else if (item.ColorType==5)
171116
+ color=this.DownColor;
171117
+
171118
+ if (item.TextColor) color=item.TextColor;
171119
+
171120
+ if (text)
171121
+ {
171122
+ if (i==0 && item.ShowType==1) //整行显示
171123
+ {
171124
+ var mouseOnItem=this.IsMouseOn(item.Key);
171125
+ var textWidth=this.Canvas.measureText(text).width;
171126
+ var x=xText+(cellWidth*3)-textWidth-config.CellMargin.Right;
171127
+ var rtCell={ Left:xText+cellWidth, Top:top, Width:cellWidth*2, Height:cellHeight};
171128
+ rtCell.Right=rtCell.Left+rtCell.Width;
171129
+ rtCell.Bottom=rtCell.Top+rtCell.Height;
171130
+ if (mouseOnItem) this.DrawMouseOnRect(rtCell);
171131
+
171132
+ this.Canvas.fillStyle=color;
171133
+ this.Canvas.fillText(text,x,yBottom);
171134
+
171135
+ if (this.MapMouseOnKey.has(item.Key))
171136
+ this.AryCellRect.push({ Rect:rtCell, Data:{ Type:2, Key:item.Key, Value:dataItem }});
171137
+ break;
171138
+ }
171139
+ else
171140
+ {
171141
+ var mouseOnItem=this.IsMouseOn(item.Key);
171142
+ var textWidth=this.Canvas.measureText(text).width;
171143
+ var x=xText+cellWidth-textWidth-config.CellMargin.Right;
171144
+ var rtCell={ Left:xText, Top:top, Width:cellWidth, Height:cellHeight};
171145
+ rtCell.Right=rtCell.Left+rtCell.Width;
171146
+ rtCell.Bottom=rtCell.Top+rtCell.Height;
171147
+ if (mouseOnItem) this.DrawMouseOnRect(rtCell);
171148
+
171149
+ this.Canvas.fillStyle=color;
171150
+ this.Canvas.fillText(text,x,yBottom);
171151
+
171152
+ if (this.MapMouseOnKey.has(item.Key))
171153
+ this.AryCellRect.push({ Rect:rtCell, Data:{ Type:2, Key:item.Key, Value:dataItem }});
171154
+ }
171155
+
171156
+ }
171157
+ }
171158
+ xText+=cellWidth;
171159
+ }
171160
+ else
171161
+ {
171162
+ xText+=cellWidth+cellWidth;
171163
+ }
171164
+ }
171165
+
171166
+ }
171167
+
171168
+
171169
+ this.FormatValue=function(column, data)
171170
+ {
171171
+ var dec=0; //小数位数
171172
+ if (IFrameSplitOperator.IsNumber(column.FloatPrecision))
171173
+ {
171174
+ if (column.FloatPrecision===-1) dec=this.Decimal;
171175
+ else dec=column.FloatPrecision;
171176
+ }
171177
+
171178
+ var text=null;
171179
+ if (!data) return text;
171180
+
171181
+ if (data.Text)
171182
+ {
171183
+ text=data.Text;
171184
+ }
171185
+ else if (IFrameSplitOperator.IsNumber(data.Value))
171186
+ {
171187
+ var value=data.Value;
171188
+ text=value.toFixed(dec);
171189
+
171190
+ //格式化
171191
+ if (column.Format && IFrameSplitOperator.IsNumber(column.Format.Type))
171192
+ {
171193
+ var format=column.Format;
171194
+ switch(format.Type)
171195
+ {
171196
+ case 1: //原始数据
171197
+ text=value.toFixed(dec);
171198
+ break;
171199
+ case 2: //千分位分割
171200
+ text=IFrameSplitOperator.FormatValueThousandsString(value, dec);
171201
+ break;
171202
+ case 3:
171203
+ var exfloatPrecision=1;
171204
+ if (IFrameSplitOperator.IsNumber(format.ExFloatPrecision)) exfloatPrecision=format.ExFloatPrecision;
171205
+ text=IFrameSplitOperator.FormatValueStringV2(value, dec,exfloatPrecision);
171206
+ break;
171207
+ }
171208
+ }
171209
+ }
171210
+
171211
+ if (column.StringFormat && text) text=column.StringFormat.replace('{Value}',text);
171212
+
171213
+ return text;
171214
+ }
171215
+
171216
+ this.GetPriceColor=function(price)
171217
+ {
171218
+ var upperSymbol=null;
171219
+ if (this.Data.Symbol) upperSymbol=this.Data.Symbol.toUpperCase();
171220
+ if (MARKET_SUFFIX_NAME.IsChinaFutures(upperSymbol))
171221
+ {
171222
+ if (!IFrameSplitOperator.IsNumber(this.Data.YFClose)) return this.UnchangeColor;
171223
+ return this.GetUpDownColor(price, this.Data.YFClose);
171224
+ }
171225
+ else
171226
+ {
171227
+ if (!IFrameSplitOperator.IsNumber(this.Data.YClose)) return this.UnchangeColor;
171228
+ return this.GetUpDownColor(price, this.Data.YClose);
171229
+ }
171230
+ }
171231
+
171232
+ this.GetUpDownColor=function(price, price2)
171233
+ {
171234
+ if (price>price2) return this.UpColor;
171235
+ else if (price<price2) return this.DownColor;
171236
+ else return this.UnchangeColor;
171237
+ }
171238
+ }
171239
+
171240
+
171241
+
171242
+
171243
+
171244
+
171245
+
168595
171246
  /********************************************************************************
168596
171247
  * 版本信息输出
168597
171248
  *
@@ -168599,7 +171250,7 @@ function HQChartScriptWorker()
168599
171250
 
168600
171251
 
168601
171252
 
168602
- var HQCHART_VERSION="1.1.15448";
171253
+ var HQCHART_VERSION="1.1.15454";
168603
171254
 
168604
171255
  function PrintHQChartVersion()
168605
171256
  {
@@ -168722,6 +171373,9 @@ export default {
168722
171373
  //X轴滚动条
168723
171374
  JSScrollBarChart:JSScrollBarChart,
168724
171375
 
171376
+ JSStockInfoChart:JSStockInfoChart, //5档买卖
171377
+ JSStatusBarChart:JSStatusBarChart, //底部状态栏
171378
+
168725
171379
  //图形基类导出
168726
171380
  IChartPainting:IChartPainting, //图形
168727
171381
  IExtendChartPainting:IExtendChartPainting, //扩展图形