hqchart 1.1.13081 → 1.1.13085

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.
@@ -6422,6 +6422,11 @@ var JSCHART_EVENT_ID=
6422
6422
 
6423
6423
  //T型报价
6424
6424
  ON_TREPORT_MARKET_STATUS:121, //T型报价列表交易状态
6425
+ ON_DBCLICK_TREPORT_ROW:122, //双击T型报报价列表
6426
+ ON_RCLICK_TREPORT_ROW:123, //右键点击T型报价列表
6427
+ ON_CLICK_TREPORT_HEADER:124, //单击T型报价表头
6428
+ ON_RCLICK_TREPORT_HEADER:125, //右键点击T型报价表头
6429
+ ON_TREPORT_LOCAL_SORT:126, //T型报价列表本地排序
6425
6430
  }
6426
6431
 
6427
6432
  var JSCHART_OPERATOR_ID=
@@ -67921,7 +67926,7 @@ function JSChartResource()
67921
67926
  this.TReport=
67922
67927
  {
67923
67928
  BorderColor:'rgb(192,192,192)', //边框线
67924
- SelectedColor:"rgb(180,240,240)", //选中行
67929
+ SelectedColor:"rgb(3,89,245)", //选中行
67925
67930
  Header:
67926
67931
  {
67927
67932
  Color:"rgb(60,60,60)", //表头文字颜色
@@ -67939,6 +67944,13 @@ function JSChartResource()
67939
67944
  SymbolFont:{ Size:12, Name:"微软雅黑" }
67940
67945
  },
67941
67946
 
67947
+ CenterItem:
67948
+ {
67949
+ TextColor:"rgb(60,60,83)",
67950
+ BaseTextColor:"rgb(60,60,83)",
67951
+ BGColor:"rgb(180,180,180)"
67952
+ },
67953
+
67942
67954
  FieldColor:
67943
67955
  {
67944
67956
  Index:"rgb(60,60,60)", //序号
@@ -67952,22 +67964,14 @@ function JSChartResource()
67952
67964
 
67953
67965
  UpTextColor:"rgb(238,21,21)", //上涨文字颜色
67954
67966
  DownTextColor:"rgb(25,158,0)", //下跌文字颜色
67955
- UnchagneTextColor:"rgb(90,90,90)", //平盘文字颜色
67967
+ UnchangeTextColor:"rgb(90,90,90)", //平盘文字颜色
67956
67968
 
67957
- CloseLine:
67958
- {
67959
- CloseColor:"rgb(30,144,255)",
67960
- YCloseColor:"rgba(105,105,105,0.5)", //昨收线
67961
- AreaColor:'rgba(0,191,255,0.2)',
67962
- },
67969
+ UpBGColor:"rgb(255,220,220)",
67970
+ DownBGColor:"rgb(190,220,190)",
67963
67971
 
67964
- KLine:
67972
+ MarkBorder:
67965
67973
  {
67966
- UpColor:"rgb(255,0,0)",
67967
- DownColor:"rgb(0,128,0)",
67968
- UnchagneColor:'rgb(90,90,90)',
67969
- DataWidth:16,
67970
- DistanceWidth:3
67974
+ MaxPositionColor:"rgb(192,192,192)"
67971
67975
  },
67972
67976
  },
67973
67977
 
@@ -68751,6 +68755,8 @@ function JSChartResource()
68751
68755
  }
68752
68756
  }
68753
68757
 
68758
+ if (style.TReport) this.SetTReportStyle(style.TReport);
68759
+
68754
68760
  if (style.SelectedChart)
68755
68761
  {
68756
68762
  var item=style.SelectedChart;
@@ -68850,6 +68856,103 @@ function JSChartResource()
68850
68856
 
68851
68857
  }
68852
68858
  }
68859
+
68860
+ this.SetTReportStyle=function(style)
68861
+ {
68862
+ var item=style;
68863
+ var dest=this.TReport;
68864
+
68865
+ if (item.BorderColor) dest.BorderColor=item.BorderColor;
68866
+ if (item.UpTextColor) dest.UpTextColor=item.UpTextColor;
68867
+ if (item.DownTextColor) dest.DownTextColor=item.DownTextColor;
68868
+ if (item.UnchangeTextColor) dest.UnchangeTextColor=item.UnchangeTextColor;
68869
+ if (item.BorderColor) dest.SelectedColor=item.SelectedColor;
68870
+
68871
+ if (item.UpBGColor) dest.UpBGColor=item.UpBGColor;
68872
+ if (item.DownBGColor) dest.DownBGColor=item.DownBGColor;
68873
+
68874
+ if (item.Header)
68875
+ {
68876
+ var header=item.Header;
68877
+ if (header.Color) dest.Header.Color=header.Color;
68878
+ if (header.SortColor) dest.Header.SortColor=header.SortColor;
68879
+ if (header.Mergin)
68880
+ {
68881
+ var mergin=header.Mergin;
68882
+ if (IFrameSplitOperator.IsNumber(mergin.Left)) dest.Header.Mergin.Left=mergin.Left;
68883
+ if (IFrameSplitOperator.IsNumber(mergin.Right)) dest.Header.Mergin.Left=mergin.Right;
68884
+ if (IFrameSplitOperator.IsNumber(mergin.Top)) dest.Header.Mergin.Top=mergin.Top;
68885
+ if (IFrameSplitOperator.IsNumber(mergin.Bottom)) dest.Header.Mergin.Bottom=mergin.Bottom;
68886
+ }
68887
+ if (header.Font)
68888
+ {
68889
+ var font=header.Font;
68890
+ if (font.Name) dest.Header.Font.Name=font.Name;
68891
+ if (IFrameSplitOperator.IsNumber(font.Size)) dest.Header.Font.Size=font.Size;
68892
+ }
68893
+ }
68894
+
68895
+ if (item.CenterItem)
68896
+ {
68897
+ var cell=item.CenterItem;
68898
+ if (cell.TextColor) dest.CenterItem.TextColor=cell.TextColor;
68899
+ if (cell.BaseTextColor) dest.CenterItem.BaseTextColor=cell.BaseTextColor;
68900
+ if (cell.BGColor) dest.CenterItem.BGColor=cell.BGColor;
68901
+ }
68902
+
68903
+ if (item.Item)
68904
+ {
68905
+ var row=item.Item;
68906
+ if (row.Mergin)
68907
+ {
68908
+ var mergin=row.Mergin;
68909
+ if (IFrameSplitOperator.IsNumber(mergin.Left)) dest.Item.Mergin.Left=mergin.Left;
68910
+ if (IFrameSplitOperator.IsNumber(mergin.Right)) dest.Item.Mergin.Right=mergin.Right;
68911
+ if (IFrameSplitOperator.IsNumber(mergin.Top)) dest.Item.Mergin.Top=mergin.Top;
68912
+ if (IFrameSplitOperator.IsNumber(mergin.Bottom)) dest.Item.Mergin.Bottom=mergin.Bottom;
68913
+ }
68914
+
68915
+ if (row.Font)
68916
+ {
68917
+ var font=row.Font;
68918
+ if (font.Name) dest.Item.Font.Name=font.Name;
68919
+ if (IFrameSplitOperator.IsNumber(font.Size)) dest.Item.Font.Size=font.Size;
68920
+ }
68921
+
68922
+ if (row.NameFont)
68923
+ {
68924
+ var font=row.NameFont;
68925
+ if (font.Name) dest.Item.NameFont.Name=font.Name;
68926
+ if (IFrameSplitOperator.IsNumber(font.Size)) dest.Item.NameFont.Size=font.Size;
68927
+ }
68928
+
68929
+ if (row.SymbolFont)
68930
+ {
68931
+ var font=row.SymbolFont;
68932
+ if (font.Name) dest.Item.SymbolFont.Name=font.Name;
68933
+ if (IFrameSplitOperator.IsNumber(font.Size)) dest.Item.SymbolFont.Size=font.Size;
68934
+ }
68935
+ }
68936
+
68937
+ if (item.FieldColor)
68938
+ {
68939
+ var filed=item.FieldColor;
68940
+ if (filed.Name) dest.FieldColor.Name=filed.Name;
68941
+ if (filed.Symbol) dest.FieldColor.Symbol=filed.Symbol;
68942
+ if (filed.Vol) dest.FieldColor.Vol=filed.Vol;
68943
+ if (filed.Amount) dest.FieldColor.Amount=filed.Amount;
68944
+ if (filed.Index) dest.FieldColor.Index=filed.Index;
68945
+ if (filed.Text) dest.FieldColor.Text=filed.Text;
68946
+ if (filed.Position) dest.FieldColor.Position=filed.Position;
68947
+ }
68948
+
68949
+ if (item.MarkBorder)
68950
+ {
68951
+ var subIem=item.MarkBorder;
68952
+ if (subIem.MaxPositionColor) dest.MarkBorder.MaxPositionColor=subIem.MaxPositionColor;
68953
+ }
68954
+
68955
+ }
68853
68956
  }
68854
68957
 
68855
68958
  var g_JSChartResource=new JSChartResource();
@@ -120527,6 +120630,59 @@ function GetBlackStyle()
120527
120630
  }
120528
120631
  },
120529
120632
 
120633
+ //T型报价
120634
+ TReport:
120635
+ {
120636
+ BorderColor:'rgb(38,38,41)', //边框线
120637
+ SelectedColor:"rgb(180,180,180)", //选中行
120638
+ Header:
120639
+ {
120640
+ Color:"rgb(187,187,187)", //表头文字颜色
120641
+ SortColor:"rgb(255,0,0)", //排序箭头颜色
120642
+ Mergin:{ Left:5, Right:5, Top:4, Bottom:2}, //表头四周间距
120643
+ Font:{ Size:14, Name:"微软雅黑" } //表头字体
120644
+ },
120645
+
120646
+ Item:
120647
+ {
120648
+ Mergin:{ Top:2, Bottom:0,Left:5, Right:5 }, //单元格四周间距
120649
+ Font:{ Size:15, Name:"微软雅黑"},
120650
+ BarMergin:{ Top:2, Left:3, Right:3, Bottom:2 },//单元格字体
120651
+ NameFont:{ Size:14, Name:"微软雅黑" },
120652
+ SymbolFont:{ Size:12, Name:"微软雅黑" }
120653
+ },
120654
+
120655
+ CenterItem:
120656
+ {
120657
+ TextColor:"rgb(16,226,217)",
120658
+ BaseTextColor:"rgb(60,60,83)",
120659
+ BGColor:"rgb(65,65,65)"
120660
+ },
120661
+
120662
+ FieldColor:
120663
+ {
120664
+ Index:"rgb(250,250,250)", //序号
120665
+ Symbol:"rgb(60,60,60)",
120666
+ Name:"rgb(250,250,250)",
120667
+ Vol:"rgb(192,165,3)", //成交量
120668
+ Position:"rgb(250,250,250)", //持仓量
120669
+ Amount:"rgb(16,226,217)", //成交金额
120670
+ Text:"rgb(250,250,250)", //默认文本
120671
+ },
120672
+
120673
+ UpTextColor:"rgb(238,21,21)", //上涨文字颜色
120674
+ DownTextColor:"rgb(25,158,0)", //下跌文字颜色
120675
+ UnchangeTextColor:"rgb(187,187,187)", //平盘文字颜色
120676
+
120677
+ UpBGColor:"rgb(35,5,5)",
120678
+ DownBGColor:"rgb(5,35,5)",
120679
+
120680
+ MarkBorder:
120681
+ {
120682
+ MaxPositionColor:"rgb(192,192,0)"
120683
+ },
120684
+ },
120685
+
120530
120686
  ScrollBar:
120531
120687
  {
120532
120688
  BorderColor:'rgb(38,38,41)', //边框线
@@ -125490,7 +125646,7 @@ function ChartReport()
125490
125646
  }
125491
125647
  else
125492
125648
  {
125493
- result.Star=0;
125649
+ result.Start=0;
125494
125650
  result.End=0;
125495
125651
  result.IsEnd=true;
125496
125652
  result.IsSinglePage=true;
@@ -127844,25 +128000,24 @@ function ChartReportPageInfo()
127844
128000
 
127845
128001
  jones_2000@163.com
127846
128002
 
127847
- 封装键盘精灵控件 (页面版 不支持手机)
128003
+ 封装T型报价列表控件 (H5版本)
128004
+ 不提供内置测试数据
127848
128005
  */
127849
128006
 
127850
-
127851
-
127852
- function JSKeyboardChart(divElement)
128007
+ function JSTReportChart(divElement)
127853
128008
  {
127854
128009
  this.DivElement=divElement;
127855
128010
  this.JSChartContainer; //表格控件
127856
128011
 
127857
128012
  //h5 canvas
127858
128013
  this.CanvasElement=document.createElement("canvas");
127859
- this.CanvasElement.className='jskeyboard-drawing';
128014
+ this.CanvasElement.className='jstreport-drawing';
127860
128015
  this.CanvasElement.id=Guid();
127861
128016
  this.CanvasElement.setAttribute("tabindex",0);
127862
128017
  if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
127863
128018
  if(divElement.hasChildNodes())
127864
128019
  {
127865
- JSConsole.Chart.Log("[JSKeyboardChart::JSRepoJSKeyboardChartrtChart] divElement hasChildNodes", divElement.childNodes);
128020
+ JSConsole.Chart.Log("[JSTReportChart::JSReportChart] divElement hasChildNodes", divElement.childNodes);
127866
128021
  }
127867
128022
  divElement.appendChild(this.CanvasElement);
127868
128023
 
@@ -127880,7 +128035,7 @@ function JSKeyboardChart(divElement)
127880
128035
  this.CanvasElement.height*=pixelTatio;
127881
128036
  this.CanvasElement.width*=pixelTatio;
127882
128037
 
127883
- JSConsole.Chart.Log(`[JSKeyboardChart::OnSize] devicePixelRatio=${window.devicePixelRatio}, height=${this.CanvasElement.height}, width=${this.CanvasElement.width}`);
128038
+ JSConsole.Chart.Log(`[JSTReportChart::OnSize] devicePixelRatio=${window.devicePixelRatio}, height=${this.CanvasElement.height}, width=${this.CanvasElement.width}`);
127884
128039
 
127885
128040
  if (this.JSChartContainer && this.JSChartContainer.OnSize)
127886
128041
  {
@@ -127890,7 +128045,7 @@ function JSKeyboardChart(divElement)
127890
128045
 
127891
128046
  this.SetOption=function(option)
127892
128047
  {
127893
- var chart=this.CreateJSKeyboardChartContainer(option);
128048
+ var chart=this.CreateJSTReportChartContainer(option);
127894
128049
 
127895
128050
  if (!chart) return false;
127896
128051
 
@@ -127899,20 +128054,43 @@ function JSKeyboardChart(divElement)
127899
128054
  this.JSChartContainer=chart;
127900
128055
  this.DivElement.JSChart=this; //div中保存一份
127901
128056
 
127902
- chart.Draw();
128057
+ if (option.Symbol)
128058
+ {
128059
+ chart.Draw();
128060
+
128061
+ var name=option.Symbol;
128062
+ if (option.Name) name=option.Name;
128063
+ chart.ChangeSymbol(option.Symbol, {Name:name}); //下载列表码表
128064
+ }
128065
+
127903
128066
  }
127904
128067
 
127905
- this.CreateJSKeyboardChartContainer=function(option)
128068
+ this.CreateJSTReportChartContainer=function(option)
127906
128069
  {
127907
- var chart=new JSKeyboardChartContainer(this.CanvasElement);
128070
+ var chart=new JSTReportChartContainer(this.CanvasElement);
127908
128071
  chart.Create(option);
127909
128072
 
127910
128073
  if (option.NetworkFilter) chart.NetworkFilter=option.NetworkFilter;
127911
128074
  if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) chart.SetColumn(option.Column);
127912
- if (IFrameSplitOperator.IsNumber(option.BorderLine)) chart.Frame.BorderLine=option.BorderLine;
128075
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Tab)) chart.SetTab(option.Tab);
128076
+ if (IFrameSplitOperator.IsNumber(option.TabSelected)) chart.SetSelectedTab(option.TabSelected);
128077
+ if (IFrameSplitOperator.IsBool(option.EnableDragRow)) chart.EnableDragRow=option.EnableDragRow;
128078
+ if (IFrameSplitOperator.IsNumber(option.DragRowType)) chart.DragRowType=option.DragRowType;
128079
+ if (IFrameSplitOperator.IsBool(option.EnableDragHeader)) chart.EnableDragHeader=option.EnableDragHeader;
128080
+ if (option.SortInfo)
128081
+ {
128082
+ var item=option.SortInfo;
128083
+ if (IFrameSplitOperator.IsNumber(item.Field)) chart.SortInfo.Field=item.Field;
128084
+ if (IFrameSplitOperator.IsNumber(item.Sort)) chart.SortInfo.Sort=item.Sort;
128085
+ }
127913
128086
 
127914
128087
  this.SetChartBorder(chart, option);
127915
128088
 
128089
+ //是否自动更新
128090
+ if (option.IsAutoUpdate!=null) chart.IsAutoUpdate=option.IsAutoUpdate;
128091
+ if (option.AutoUpdateFrequency>0) chart.AutoUpdateFrequency=option.AutoUpdateFrequency;
128092
+ if (IFrameSplitOperator.IsBool(option.EnableFilter)) chart.EnableFilter=option.EnableFilter;
128093
+
127916
128094
  //注册事件
127917
128095
  if (option.EventCallback)
127918
128096
  {
@@ -127945,6 +128123,13 @@ function JSKeyboardChart(divElement)
127945
128123
 
127946
128124
  /////////////////////////////////////////////////////////////////////////////
127947
128125
  //对外接口
128126
+
128127
+ //切换股票代码接口
128128
+ this.ChangeSymbol=function(symbol, option)
128129
+ {
128130
+ if (this.JSChartContainer) this.JSChartContainer.ChangeSymbol(symbol,option);
128131
+ }
128132
+
127948
128133
  this.SetColumn=function(aryColumn, option)
127949
128134
  {
127950
128135
  if (this.JSChartContainer) this.JSChartContainer.SetColumn(aryColumn,option);
@@ -127955,7 +128140,7 @@ function JSKeyboardChart(divElement)
127955
128140
  {
127956
128141
  if(this.JSChartContainer && typeof(this.JSChartContainer.AddEventCallback)=='function')
127957
128142
  {
127958
- JSConsole.Chart.Log('[JSKeyboardChart:AddEventCallback] obj=', obj);
128143
+ JSConsole.Chart.Log('[JSTReportChart:AddEventCallback] obj=', obj);
127959
128144
  this.JSChartContainer.AddEventCallback(obj);
127960
128145
  }
127961
128146
  }
@@ -127965,7 +128150,7 @@ function JSKeyboardChart(divElement)
127965
128150
  {
127966
128151
  if(this.JSChartContainer && typeof(this.JSChartContainer.ReloadResource)=='function')
127967
128152
  {
127968
- JSConsole.Chart.Log('[JSKeyboardChart:ReloadResource] ');
128153
+ JSConsole.Chart.Log('[JSTReportChart:ReloadResource] ');
127969
128154
  this.JSChartContainer.ReloadResource(option);
127970
128155
  }
127971
128156
  }
@@ -127982,173 +128167,126 @@ function JSKeyboardChart(divElement)
127982
128167
  {
127983
128168
  if(this.JSChartContainer && typeof(this.JSChartContainer.Draw)=='function')
127984
128169
  {
127985
- JSConsole.Chart.Log('[JSKeyboardChart:Draw] ');
128170
+ JSConsole.Chart.Log('[JSTReportChart:Draw] ');
127986
128171
  this.JSChartContainer.Draw();
127987
128172
  }
127988
128173
  }
127989
-
127990
- this.SetSymbolData=function(arySymbol)
127991
- {
127992
- if(this.JSChartContainer && typeof(this.JSChartContainer.Draw)=='function')
127993
- {
127994
- JSConsole.Chart.Log('[JSKeyboardChart:SetSymbolData] ', arySymbol);
127995
- this.JSChartContainer.SetSymbolData(arySymbol);
127996
- }
127997
- }
127998
-
127999
- this.Search=function(strText)
128000
- {
128001
- if(this.JSChartContainer && typeof(this.JSChartContainer.Search)=='function')
128002
- {
128003
- JSConsole.Chart.Log('[JSKeyboardChart:Search] ', strText);
128004
- this.JSChartContainer.Search(strText);
128005
- }
128006
- }
128007
-
128008
- this.OnKeyDown=function(event)
128009
- {
128010
- if(this.JSChartContainer && typeof(this.JSChartContainer.OnKeyDown)=='function')
128011
- {
128012
- JSConsole.Chart.Log('[JSKeyboardChart:OnKeyDown] ', event);
128013
- this.JSChartContainer.OnKeyDown(event);
128014
- }
128015
- }
128016
-
128017
- this.ClearSearch=function(option)
128018
- {
128019
- if(this.JSChartContainer && typeof(this.JSChartContainer.ClearSearch)=='function')
128020
- {
128021
- JSConsole.Chart.Log('[JSKeyboardChart:ClearSearch] ', option);
128022
- this.JSChartContainer.ClearSearch(option);
128023
- }
128024
- }
128025
128174
  }
128026
128175
 
128027
- JSKeyboardChart.Init=function(divElement)
128176
+ JSTReportChart.Init=function(divElement)
128028
128177
  {
128029
- var jsChartControl=new JSKeyboardChart(divElement);
128178
+ var jsChartControl=new JSTReportChart(divElement);
128030
128179
  jsChartControl.OnSize();
128031
128180
 
128032
128181
  return jsChartControl;
128033
128182
  }
128034
128183
 
128035
128184
  //自定义风格
128036
- JSKeyboardChart.SetStyle=function(option)
128185
+ JSTReportChart.SetStyle=function(option)
128037
128186
  {
128038
128187
  if (option) g_JSChartResource.SetStyle(option);
128039
128188
  }
128040
128189
 
128041
-
128042
- function JSKeyboardChartContainer(uielement)
128190
+ //获取颜色配置 (设置配必须啊在JSChart.Init()之前)
128191
+ JSTReportChart.GetResource=function()
128043
128192
  {
128044
- this.ClassName='JSKeyboardChartContainer';
128045
- this.Frame; //框架画法
128046
- this.ChartPaint=[]; //图形画法
128047
- this.Canvas=uielement.getContext("2d"); //画布
128048
- this.ShowCanvas=null;
128049
-
128050
- this.NetworkFilter; //数据回调接口
128051
- this.Data={ XOffset:0, YOffset:0, Data:[] }; //股票列表
128052
- this.MapSymbol=new Map();
128053
- this.SourceData={ Data:[] } //码表数据 Data:[ { Symbol:, Spell, Name:, Color:}]
128193
+ return g_JSChartResource;
128194
+ }
128054
128195
 
128055
- //事件回调
128056
- this.mapEvent=new Map(); //通知外部调用 key:JSCHART_EVENT_ID value:{Callback:回调,}
128196
+ function HQTReportItem()
128197
+ {
128198
+ this.Symbol;
128199
+ this.Name;
128200
+ this.YClose;
128201
+ this.Open;
128202
+ this.Price;
128203
+ this.High;
128204
+ this.Low;
128205
+ this.Amount;
128206
+ this.Vol;
128207
+ this.Positon; //持仓量
128057
128208
 
128058
- this.UIElement=uielement;
128059
- this.LastPoint=new Point(); //鼠标位置
128060
-
128061
- //拖拽滚动条
128062
- this.DragYScroll=null; //{Start:{x,y}, End:{x, y}}
128063
- this.IsDestroy=false; //是否已经销毁了
128209
+ this.Increase; //涨幅
128210
+ this.UpDown; //涨跌
128211
+ this.Exchange; //换手
128212
+ this.Amplitude; //振幅
128064
128213
 
128065
- this.ChartDestory=function() //销毁
128066
- {
128067
- this.IsDestroy=true;
128068
- }
128214
+ this.BuyPrice; //买价/量
128215
+ this.BuyVol;
128216
+ this.SellPrice; //卖价/量
128217
+ this.SellVol;
128069
128218
 
128070
- this.ClearSearch=function(option)
128071
- {
128072
- this.Data.Data=[];
128073
- this.Data.XOffset=0;
128074
- this.Data.YOffset=0;
128219
+ this.AvPrice; //均价
128075
128220
 
128076
- if (option && option.Redraw==true) this.Draw();
128077
- }
128221
+ this.LimitHigh; //涨停价
128222
+ this.LimitLow; //跌停价
128078
128223
 
128079
- this.Search=function(strText)
128080
- {
128081
- var aryExactQuery=[]; //精确查询
128082
- var aryFuzzyQuery=[]; //模糊查询
128083
- this.MapSymbol.clear();
128084
- this.Data.Data=[];
128085
- this.Data.XOffset=0;
128086
- this.Data.YOffset=0;
128224
+ this.CloseLine; //{Data:[], Max:, Min:, Count: }
128087
128225
 
128088
- var strSearch=strText.trim();
128089
- if (strSearch.length>0)
128090
- {
128091
- for(var i=0;i<this.SourceData.Data.length;++i)
128092
- {
128093
- var item=this.SourceData.Data[i];
128094
- if (this.SearchSymbol(item, strSearch, aryExactQuery, aryFuzzyQuery)) continue;
128095
- else if (this.SearchSpell(item, strSearch, aryExactQuery, aryFuzzyQuery)) continue;
128096
- }
128097
- }
128098
-
128099
- if (IFrameSplitOperator.IsNonEmptyArray(aryExactQuery) || IFrameSplitOperator.IsNonEmptyArray(aryFuzzyQuery))
128100
- this.Data.Data=aryExactQuery.concat(aryFuzzyQuery);
128226
+ this.ExtendData; //扩展数据
128227
+ }
128101
128228
 
128102
- this.ChartPaint[0].SelectedRow=0;
128229
+ function JSTReportChartContainer(uielement)
128230
+ {
128231
+ this.ClassName='JSTReportChartContainer';
128232
+ this.Frame; //框架画法
128233
+ this.ChartPaint=[]; //图形画法
128234
+ this.ChartSplashPaint=null; //等待提示
128235
+ this.LoadDataSplashTitle="数据加载中"; //下载数据提示信息
128103
128236
 
128104
- JSConsole.Chart.Log(`[JSKeyboardChart:Search] search=${strSearch}, source=${this.SourceData.Data.length} match=${this.Data.Data.length}`);
128237
+ this.SplashTitle={ StockList:"下载码表中....." } ;
128238
+ this.Canvas=uielement.getContext("2d"); //画布
128105
128239
 
128106
- this.Draw();
128107
- }
128240
+ this.Tooltip=document.createElement("div");
128241
+ this.Tooltip.className='jstreport-tooltip';
128242
+ this.Tooltip.style.background=g_JSChartResource.TooltipBGColor;
128243
+ this.Tooltip.style.opacity=g_JSChartResource.TooltipAlpha;
128244
+ this.Tooltip.style["pointer-events"]="none";
128245
+ this.Tooltip.id=Guid();
128246
+ uielement.parentNode.appendChild(this.Tooltip);
128108
128247
 
128109
- this.SearchSymbol=function(item, strText, aryExactQuery, aryFuzzyQuery)
128110
- {
128111
- var find=item.Symbol.indexOf(strText);
128112
- if (find<0) return false;
128248
+ this.Symbol; //期权对应的品种代码
128249
+ this.Name; //期权对应的品种名称
128250
+ this.NetworkFilter; //数据回调接口
128251
+ this.Data={ XOffset:0, YOffset:0, Data:[], BaseExePrice:null }; //股票列表 BaseExePrice=基准
128252
+ this.BorderData={ MapData:null }; //key=Field Value:[null, {ExePrice} ,{ExePrice} ]
128253
+ this.SourceData={ Data:[] } ; //原始股票顺序(排序还原用) {ExePrice=行权价格 LeftData:, RightData}
128113
128254
 
128114
- if (find==0) aryExactQuery.push(item.Symbol);
128115
- else aryFuzzyQuery.push(item.Symbol);
128255
+ this.DelayUpdateTimer=null; //延迟更新
128256
+ this.DelayUpdateFrequency=500; //延迟更新时间
128116
128257
 
128117
- this.MapSymbol.set(item.Symbol, item);
128118
-
128119
- return true;
128120
- }
128258
+ this.MapStockData;
128259
+ this.MapExePriceData;
128121
128260
 
128122
- this.SearchSpell=function(item, strText, aryExactQuery, aryFuzzyQuery)
128123
- {
128124
- if (!IFrameSplitOperator.IsString(item.Spell)) return false;
128261
+ this.FlashBG=new Map();
128262
+ this.FlashBGTimer=null; //闪烁背景 Value:{ LastTime:数据最后的时间, Data: { Key:ID, BGColor:, Time: , Count: 次数 } };
128263
+ this.GlobalOption={ FlashBGCount:0 }
128125
128264
 
128126
- var find=item.Spell.indexOf(strText);
128265
+ this.SortInfo={ Field:-1, Sort:0 }; //排序信息 {Field:排序字段id, Sort:0 不排序 1升序 2降序 }
128127
128266
 
128128
- if (find!=0) return false;
128267
+ //事件回调
128268
+ this.mapEvent=new Map(); //通知外部调用 key:JSCHART_EVENT_ID value:{Callback:回调,}
128129
128269
 
128130
- aryExactQuery.push(item.Symbol);
128131
- this.MapSymbol.set(item.Symbol, item);
128270
+ this.AutoUpdateTimer=null;
128271
+ this.AutoUpdateFrequency=15000; //15秒更新一次数据
128132
128272
 
128133
- return true;
128134
- }
128273
+ this.UIElement=uielement;
128274
+ this.LastPoint=new Point(); //鼠标位置
128275
+ this.IsOnTouch=false;
128276
+ this.TouchDrag;
128277
+ this.TouchMoveMinAngle=70; //左右移动最小角度
128278
+ this.YStepPixel=5*GetDevicePixelRatio();
128279
+ this.XStepPixel=10*GetDevicePixelRatio();
128280
+
128281
+ //拖拽滚动条
128282
+ this.DragXScroll=null; //{Start:{x,y}, End:{x, y}}
128135
128283
 
128284
+ this.IsDestroy=false; //是否已经销毁了
128136
128285
 
128137
- this.SetSymbolData=function(arySymbol)
128286
+ this.ChartDestory=function() //销毁
128138
128287
  {
128139
- this.SourceData.Data=arySymbol;
128140
-
128141
- /*
128142
- //测试
128143
- this.MapSymbol.clear();
128144
- for(var i=0;i<this.SourceData.Data.length && i<3050 ;++i)
128145
- {
128146
- var item=this.SourceData.Data[i];
128147
- this.Data.Data.push(item.Symbol);
128148
- this.MapSymbol.set(item.Symbol, item);
128149
- }
128150
- this.ChartPaint[0].SelectedRow=0;
128151
- */
128288
+ this.IsDestroy=true;
128289
+ this.StopAutoUpdate();
128152
128290
  }
128153
128291
 
128154
128292
  //创建
@@ -128156,8 +128294,14 @@ function JSKeyboardChartContainer(uielement)
128156
128294
  {
128157
128295
  this.UIElement.JSChartContainer=this;
128158
128296
 
128297
+ //创建等待提示
128298
+ this.ChartSplashPaint = new ChartSplashPaint();
128299
+ this.ChartSplashPaint.Canvas = this.Canvas;
128300
+ this.ChartSplashPaint.SetTitle(this.LoadDataSplashTitle);
128301
+ this.ChartSplashPaint.IsEnableSplash=true;
128302
+
128159
128303
  //创建框架
128160
- this.Frame=new JSKeyboardFrame();
128304
+ this.Frame=new JSTReportFrame();
128161
128305
  this.Frame.ChartBorder=new ChartBorder();
128162
128306
  this.Frame.ChartBorder.UIElement=this.UIElement;
128163
128307
  this.Frame.ChartBorder.Top=30;
@@ -128165,20 +128309,32 @@ function JSKeyboardChartContainer(uielement)
128165
128309
  this.Frame.ChartBorder.Bottom=20;
128166
128310
  this.Frame.Canvas=this.Canvas;
128167
128311
 
128312
+ this.ChartSplashPaint.Frame = this.Frame;
128313
+
128168
128314
  //创建表格
128169
- var chart=new ChartSymbolList();
128315
+ var chart=new ChartTReport();
128170
128316
  chart.Frame=this.Frame;
128171
128317
  chart.ChartBorder=this.Frame.ChartBorder;
128172
128318
  chart.Canvas=this.Canvas;
128173
128319
  chart.UIElement=this.UIElement;
128174
128320
  chart.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
128175
- chart.GetStockDataCallback=(symbol)=>{ return this.GetStockData(symbol);}
128321
+ chart.GetExePriceDataCallback=(exePrice)=>{ return this.GetExePriceData(exePrice);}
128322
+ chart.GetFlashBGDataCallback=(symbol, time)=>{ return this.GetFlashBGData(symbol, time); }
128176
128323
  chart.Data=this.Data;
128324
+ chart.BorderData=this.BorderData;
128325
+ chart.GlobalOption=this.GlobalOption;
128326
+ chart.SortInfo=this.SortInfo;
128177
128327
  this.ChartPaint[0]=chart;
128178
128328
 
128329
+
128179
128330
  if (option)
128180
128331
  {
128181
-
128332
+ if (IFrameSplitOperator.IsBool(option.IsShowHeader)) chart.IsShowHeader=option.IsShowHeader; //是否显示表头
128333
+ if (IFrameSplitOperator.IsNumber(option.FixedColumn)) chart.FixedColumn=option.FixedColumn; //固定列
128334
+
128335
+ if (IFrameSplitOperator.IsNumber(option.BorderLine)) this.Frame.BorderLine=option.BorderLine; //边框
128336
+ if (IFrameSplitOperator.IsBool(option.ItemBorder)) chart.IsDrawBorder=option.ItemBorder; //单元格边框
128337
+ if (IFrameSplitOperator.IsNumber(option.SelectedModel)) chart.SelectedModel=option.SelectedModel;
128182
128338
  }
128183
128339
 
128184
128340
  var bRegisterKeydown=true;
@@ -128189,13 +128345,13 @@ function JSKeyboardChartContainer(uielement)
128189
128345
  if (option.KeyDown===false)
128190
128346
  {
128191
128347
  bRegisterKeydown=false;
128192
- JSConsole.Chart.Log('[JSKeyboardChartContainer::Create] not register keydown event.');
128348
+ JSConsole.Chart.Log('[JSTReportChartContainer::Create] not register keydown event.');
128193
128349
  }
128194
128350
 
128195
128351
  if (option.Wheel===false)
128196
128352
  {
128197
128353
  bRegisterWheel=false;
128198
- JSConsole.Chart.Log('[JSKeyboardChartContainer::Create] not register wheel event.');
128354
+ JSConsole.Chart.Log('[JSTReportChartContainer::Create] not register wheel event.');
128199
128355
  }
128200
128356
  }
128201
128357
 
@@ -128205,10 +128361,20 @@ function JSKeyboardChartContainer(uielement)
128205
128361
 
128206
128362
  this.UIElement.ondblclick=(e)=>{ this.UIOnDblClick(e); }
128207
128363
  this.UIElement.onmousedown=(e)=> { this.UIOnMouseDown(e); }
128364
+
128365
+ /*
128366
+ this.UIElement.onmouseup=(e)=>{ this.UIOnMounseUp(e); }
128208
128367
  this.UIElement.oncontextmenu=(e)=> { this.UIOnContextMenu(e); }
128209
128368
  this.UIElement.onmousemove=(e)=>{ this.UIOnMouseMove(e);}
128210
128369
  this.UIElement.onmouseout=(e)=>{ this.UIOnMounseOut(e); }
128211
128370
  this.UIElement.onmouseleave=(e)=>{ this.UIOnMouseleave(e); }
128371
+
128372
+
128373
+ //手机拖拽
128374
+ this.UIElement.ontouchstart=(e)=> { this.OnTouchStart(e); }
128375
+ this.UIElement.ontouchmove=(e)=> {this.OnTouchMove(e); }
128376
+ this.UIElement.ontouchend=(e)=> {this.OnTouchEnd(e); }
128377
+ */
128212
128378
  }
128213
128379
 
128214
128380
  this.Draw=function()
@@ -128219,6 +128385,13 @@ function JSKeyboardChartContainer(uielement)
128219
128385
  var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
128220
128386
  this.Canvas.lineWidth=pixelTatio; //手机端需要根据分辨率比调整线段宽度
128221
128387
 
128388
+ if (this.ChartSplashPaint && this.ChartSplashPaint.IsEnableSplash)
128389
+ {
128390
+ this.Frame.Draw( { IsEnableSplash:this.ChartSplashPaint.IsEnableSplash} );
128391
+ this.ChartSplashPaint.Draw();
128392
+ return;
128393
+ }
128394
+
128222
128395
  this.Frame.Draw();
128223
128396
  this.Frame.DrawLogo();
128224
128397
 
@@ -128236,30 +128409,2280 @@ function JSKeyboardChartContainer(uielement)
128236
128409
  if (!item.IsDrawFirst)
128237
128410
  item.Draw();
128238
128411
  }
128412
+
128413
+ if (this.GlobalOption.FlashBGCount>0)
128414
+ {
128415
+ this.DelayDraw(500);
128416
+ }
128239
128417
  }
128240
128418
 
128241
- this.GetStockData=function(symbol)
128419
+ this.DelayDraw=function(frequency)
128242
128420
  {
128243
- if (!this.MapSymbol.has(symbol)) return null;
128244
-
128245
- return this.MapSymbol.get(symbol);
128246
- }
128421
+ if (typeof (this.FlashBGTimer) == 'number')
128422
+ {
128423
+ clearTimeout(this.FlashBGTimer);
128424
+ this.FlashBGTimer = null;
128425
+ }
128247
128426
 
128427
+ this.FlashBGTimer=setTimeout(()=>
128428
+ {
128429
+ this.Draw();
128430
+ },frequency);
128431
+ }
128248
128432
 
128249
- this.ResetStatus=function()
128433
+ this.ClearData=function()
128250
128434
  {
128251
- this.Data.XOffset=0;
128252
- this.Data.YOffset=0;
128435
+ this.SourceData.Data=[];
128436
+ this.Data.Data=[];
128437
+ this.Data.BaseExePrice=null;
128438
+ this.MapStockData=null;
128439
+ this.MapExePriceData=null;
128440
+ this.BorderData.MapData=null;
128253
128441
  }
128254
128442
 
128255
- this.ResetSelectStatus=function()
128443
+ this.StopAutoUpdate=function()
128256
128444
  {
128257
- var chart=this.GetReportChart();
128258
- if (chart)
128259
- {
128260
- chart.SelectedRow=-1;
128261
- chart.SelectedFixedRow=-1;
128262
- }
128445
+ this.CancelAutoUpdate();
128446
+ this.AutoUpdateEvent(false,'JSTReportChartContainer::StopAutoUpdate');
128447
+ if (!this.IsAutoUpdate) return;
128448
+ this.IsAutoUpdate=false;
128449
+ }
128450
+
128451
+ //设置事件回调
128452
+ //{event:事件id, callback:回调函数}
128453
+ this.AddEventCallback=function(object)
128454
+ {
128455
+ if (!object || !object.event || !object.callback) return;
128456
+
128457
+ var data={Callback:object.callback, Source:object};
128458
+ this.mapEvent.set(object.event,data);
128459
+ }
128460
+
128461
+ this.RemoveEventCallback=function(eventid)
128462
+ {
128463
+ if (!this.mapEvent.has(eventid)) return;
128464
+
128465
+ this.mapEvent.delete(eventid);
128466
+ }
128467
+
128468
+ this.GetEventCallback=function(id) //获取事件回调
128469
+ {
128470
+ if (!this.mapEvent.has(id)) return null;
128471
+ var item=this.mapEvent.get(id);
128472
+ return item;
128473
+ }
128474
+
128475
+ this.OnSize=function()
128476
+ {
128477
+ if (!this.Frame) return;
128478
+
128479
+ this.SetSizeChange(true);
128480
+ this.Draw();
128481
+ this.DelayUpdateStockData();
128482
+ }
128483
+
128484
+ this.SetSizeChange=function(bChanged)
128485
+ {
128486
+ for(var i=0;i<this.ChartPaint.length;++i)
128487
+ {
128488
+ var chart=this.ChartPaint[i];
128489
+ if (chart) chart.SizeChange=bChanged;
128490
+ }
128491
+ }
128492
+
128493
+ this.ChangeSymbol=function(symbol, option)
128494
+ {
128495
+ this.CancelAutoUpdate();
128496
+ this.ClearData();
128497
+ this.Symbol=symbol;
128498
+ this.Name=symbol;
128499
+ if (option)
128500
+ {
128501
+ if (option.Name) this.Name=option.Name;
128502
+ }
128503
+
128504
+ this.RequestStockListData();
128505
+ }
128506
+
128507
+ this.CancelAutoUpdate=function() //关闭停止更新
128508
+ {
128509
+ if (typeof (this.AutoUpdateTimer) == 'number')
128510
+ {
128511
+ clearTimeout(this.AutoUpdateTimer);
128512
+ this.AutoUpdateTimer = null;
128513
+ }
128514
+ }
128515
+
128516
+ this.SetColumn=function(aryColunm, option)
128517
+ {
128518
+ var chart=this.ChartPaint[0];
128519
+ if (!chart) return;
128520
+
128521
+ chart.SetColumn(aryColunm);
128522
+ chart.SizeChange=true;
128523
+
128524
+ if (option && option.Redraw) this.Draw();
128525
+ }
128526
+
128527
+ //请求列表
128528
+ this.RequestStockListData=function()
128529
+ {
128530
+ this.ChartSplashPaint.SetTitle(this.SplashTitle.StockList);
128531
+ this.ChartSplashPaint.EnableSplash(true);
128532
+ this.Draw();
128533
+
128534
+ var self=this;
128535
+ if (this.NetworkFilter)
128536
+ {
128537
+ var obj=
128538
+ {
128539
+ Name:'JSTReportChartContainer::RequestStockListData', //类名::
128540
+ Explain:'T型报价列表数据',
128541
+ Self:this,
128542
+ PreventDefault:false
128543
+ };
128544
+
128545
+ this.NetworkFilter(obj, function(data)
128546
+ {
128547
+ if (!data) return;
128548
+ if (data.symbol!=self.Symbol) return;
128549
+
128550
+ self.ChartSplashPaint.EnableSplash(false);
128551
+ self.RecvStockListData(data);
128552
+ });
128553
+
128554
+ if (obj.PreventDefault==true) return; //已被上层替换,不调用默认的网络请求
128555
+ }
128556
+
128557
+ throw { Name:'JSTReportChartContainer::RequestStockListData', Error:'(T型报价列表数据)不提供内置测试数据' };
128558
+ }
128559
+
128560
+ this.RecvStockListData=function(data)
128561
+ {
128562
+ if (IFrameSplitOperator.IsNonEmptyArray(data.data))
128563
+ {
128564
+ this.MapExePriceData=new Map();
128565
+ this.MapStockData=new Map();
128566
+ //0=行权价格 1=左边期权代码 2=右侧期权代码 3=左侧期权名称 4=右侧期权名称
128567
+ for(var i=0;i<data.data.length;++i)
128568
+ {
128569
+ var item=data.data[i];
128570
+ var exePrice=item[0];
128571
+
128572
+ var leftData=new HQTReportItem();
128573
+ leftData.Symbol=leftData.Name=item[1];
128574
+ if (item[3]) leftData.Name=item[3];
128575
+
128576
+ var rightData=new HQTReportItem();
128577
+ rightData.Symbol=rightData.Name=item[2];
128578
+ if (item[4]) rightData.Name=item[4];
128579
+
128580
+ this.MapStockData.set(leftData.Symbol, leftData);
128581
+ this.MapStockData.set(rightData.Symbol, rightData);
128582
+
128583
+ var dataItem={ ExePrice:exePrice, LeftData:leftData, RightData:rightData };
128584
+ this.MapExePriceData.set(dataItem.ExePrice, dataItem);
128585
+
128586
+ this.SourceData.Data.push(exePrice);
128587
+ this.Data.Data.push(exePrice);
128588
+ }
128589
+ }
128590
+
128591
+ if (IFrameSplitOperator.IsNumber(data.baseExePrice))
128592
+ {
128593
+ this.Data.BaseExePrice=data.baseExePrice;
128594
+ }
128595
+
128596
+ this.Draw();
128597
+
128598
+ this.UpdateStockData();
128599
+ }
128600
+
128601
+ this.GetExePriceData=function(exePrice)
128602
+ {
128603
+ if (!this.MapExePriceData) return null;
128604
+ if (!this.MapExePriceData.has(exePrice)) return null;
128605
+
128606
+ return this.MapExePriceData.get(exePrice);
128607
+ }
128608
+
128609
+ this.UpdateStockData=function()
128610
+ {
128611
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
128612
+ if (this.MapStockData.size<=0) return;
128613
+
128614
+ var arySymbol=[];
128615
+ for(var mapItem of this.MapStockData)
128616
+ {
128617
+ arySymbol.push(mapItem[0]);
128618
+ }
128619
+
128620
+ if (!IFrameSplitOperator.IsNonEmptyArray(arySymbol)) return;
128621
+ this.RequestStockData(arySymbol);
128622
+ }
128623
+
128624
+ //下载期权数据
128625
+ this.RequestStockData=function(arySymbol)
128626
+ {
128627
+ var self=this;
128628
+ if (this.NetworkFilter)
128629
+ {
128630
+ var obj=
128631
+ {
128632
+ Name:'JSTReportChartContainer::RequestStockData', //类名::函数名
128633
+ Explain:'T型报价列表期权数据',
128634
+ Request:{ Data: { stocks: arySymbol, symbol:this.Symbol } },
128635
+ Self:this,
128636
+ PreventDefault:false
128637
+ };
128638
+
128639
+ this.NetworkFilter(obj, function(data)
128640
+ {
128641
+ self.RecvStockData(data);
128642
+ self.AutoUpdate();
128643
+ });
128644
+
128645
+ if (obj.PreventDefault==true) return;
128646
+ }
128647
+
128648
+ throw { Name:'JSTReportChartContainer::RequestStockData', Error:'(T型报价列表期权数据)不提供内置测试数据' };
128649
+ }
128650
+
128651
+ this.RecvStockData=function(data)
128652
+ {
128653
+ var setUpdateSymbol=new Set(); //更新的股票列表
128654
+ if (IFrameSplitOperator.IsNonEmptyArray(data.data))
128655
+ {
128656
+ for(var i=0;i<data.data.length;++i)
128657
+ {
128658
+ var item=data.data[i];
128659
+ var symbol=item[0]; //0=证券代码;
128660
+ if (!symbol) continue;
128661
+ var stock=null;
128662
+ if (this.MapStockData.has(symbol))
128663
+ {
128664
+ stock=this.MapStockData.get(symbol);
128665
+ }
128666
+ else
128667
+ {
128668
+ stock=new HQTReportItem();
128669
+ stock.Symbol=symbol;
128670
+ this.MapStockData.set(symbol, stock);
128671
+ }
128672
+
128673
+ this.ReadStockJsonData(stock, item);
128674
+
128675
+ if (!setUpdateSymbol.has(symbol)) setUpdateSymbol.add(symbol);
128676
+ }
128677
+ }
128678
+
128679
+ //实时数据排序
128680
+ var chart=this.ChartPaint[0];
128681
+ if (chart && (this.SortInfo.Sort==1 || this.SortInfo.Sort==2 ) && IFrameSplitOperator.IsNumber(this.SortInfo.Field) && this.SortInfo.Field>=0)
128682
+ {
128683
+ var column=chart.Column[this.SortInfo.Field];
128684
+ var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_TREPORT_LOCAL_SORT);
128685
+ if (event && event.Callback)
128686
+ {
128687
+ var sendData={ Column:column, SortInfo:this.SortInfo, SymbolList:this.Data.Data, Result:null };
128688
+ event.Callback (event, sendData, this);
128689
+ if (Array.isArray(sendData.Result)) this.Data.Data=sendData.Result;
128690
+ }
128691
+ else
128692
+ {
128693
+ this.Data.Data.sort((left, right)=> { return this.LocalSort(left, right, column, this.SortInfo.Sort, this.SortInfo.CellType); });
128694
+ }
128695
+ }
128696
+
128697
+ this.CalculateData();
128698
+
128699
+ this.Draw();
128700
+ }
128701
+
128702
+ //计算统计数据
128703
+ this.CalculateData=function()
128704
+ {
128705
+ if (!this.MapExePriceData || this.MapExePriceData.size<=0) return;
128706
+
128707
+ var leftMaxPosition={ Max:null, ExePrice:null, CellType:1 };
128708
+ var rightMaxPosition={ Max:null,ExePrice:null, CellType:2 };
128709
+ this.BorderData.MapData=new Map();
128710
+ for(var mapItem of this.MapExePriceData)
128711
+ {
128712
+ var item=mapItem[1];
128713
+ var leftData=item.LeftData;
128714
+ var rightData=item.RightData;
128715
+ if (leftData && IFrameSplitOperator.IsNumber(leftData.Position))
128716
+ {
128717
+ if (leftMaxPosition.Max==null || leftMaxPosition.Max<leftData.Position)
128718
+ {
128719
+ leftMaxPosition.Max=leftData.Position;
128720
+ leftMaxPosition.ExePrice=mapItem[0];
128721
+ }
128722
+ }
128723
+
128724
+ if (rightData && IFrameSplitOperator.IsNumber(rightData.Position))
128725
+ {
128726
+ if (leftMaxPosition.Max==null || leftMaxPosition.Max<rightData.Position)
128727
+ {
128728
+ rightMaxPosition.Max=rightData.Position;
128729
+ rightMaxPosition.ExePrice=mapItem[0];
128730
+ }
128731
+ }
128732
+ }
128733
+
128734
+ var aryData=[null, null, null];
128735
+ if (leftMaxPosition.ExePrice) aryData[1]=leftMaxPosition;
128736
+ if (rightMaxPosition.ExePrice) aryData[2]=rightMaxPosition;
128737
+
128738
+ this.BorderData.MapData.set(TREPORT_COLUMN_ID.POSITION_ID, { Data:aryData });
128739
+ }
128740
+
128741
+ //读取单条股票json数据
128742
+ this.ReadStockJsonData=function(stock, item)
128743
+ {
128744
+ //0=证券代码 1=股票名称 2=昨收 3=开 4=高 5=低 6=收 7=成交量 8=成交金额, 9=买价 10=买量 11=卖价 12=卖量 13=均价 14=持仓 16=涨停价 17=跌停价
128745
+ //21=涨幅% 22=涨跌 24=振幅%
128746
+ //30=全局扩展数据 31=当前板块扩展数据
128747
+
128748
+ if (IFrameSplitOperator.IsString(item[1])) stock.Name=item[1];
128749
+ if (IFrameSplitOperator.IsNumber(item[2])) stock.YClose=item[2];
128750
+ if (IFrameSplitOperator.IsNumber(item[3])) stock.Open=item[3];
128751
+ if (IFrameSplitOperator.IsNumber(item[4])) stock.High=item[4];
128752
+ if (IFrameSplitOperator.IsNumber(item[5])) stock.Low=item[5];
128753
+ if (IFrameSplitOperator.IsNumber(item[6])) stock.Price=item[6];
128754
+ if (IFrameSplitOperator.IsNumber(item[7])) stock.Vol=item[7];
128755
+ if (IFrameSplitOperator.IsNumber(item[8])) stock.Amount=item[8];
128756
+ if (IFrameSplitOperator.IsNumber(item[9])) stock.BuyPrice=item[9];
128757
+ if (IFrameSplitOperator.IsNumber(item[10])) stock.BuyVol=item[10];
128758
+ if (IFrameSplitOperator.IsNumber(item[11])) stock.SellPrice=item[11];
128759
+ if (IFrameSplitOperator.IsNumber(item[12])) stock.SellVol=item[12];
128760
+ if (IFrameSplitOperator.IsNumber(item[13])) stock.AvPrice=item[13]; //均价
128761
+ if (IFrameSplitOperator.IsNumber(item[14])) stock.Position=item[14]; //持仓
128762
+
128763
+ if (IFrameSplitOperator.IsNumber(item[16])) stock.LimitHigh=item[16]; //涨停价
128764
+ if (IFrameSplitOperator.IsNumber(item[17])) stock.LimitLow=item[17]; //跌停价
128765
+
128766
+ if (IFrameSplitOperator.IsNumber(item[21])) stock.Increase=item[21]; //涨幅%
128767
+ if (IFrameSplitOperator.IsNumber(item[22])) stock.UpDown=item[22]; //涨跌
128768
+
128769
+ if (IFrameSplitOperator.IsNumber(item[24])) stock.Amplitude=item[24]; //振幅%
128770
+
128771
+ if (item[27]) stock.NameEx=item[27]; //扩展名字
128772
+
128773
+ //衍生数据计算
128774
+ if (!IFrameSplitOperator.IsNumber(item[21])) //涨幅%
128775
+ {
128776
+ if (IFrameSplitOperator.IsNumber(stock.Price) && IFrameSplitOperator.IsNumber(stock.YClose) && stock.YClose!=0)
128777
+ stock.Increase=(stock.Price-stock.YClose)/stock.YClose*100;
128778
+ }
128779
+
128780
+ if (!IFrameSplitOperator.IsNumber(item[22])) //涨跌
128781
+ {
128782
+ if (IFrameSplitOperator.IsNumber(stock.Price) && IFrameSplitOperator.IsNumber(stock.YClose))
128783
+ stock.UpDown=stock.Price-stock.YClose;
128784
+ }
128785
+
128786
+ if (!IFrameSplitOperator.IsNumber(item[24])) //振幅%
128787
+ {
128788
+ if (IFrameSplitOperator.IsNumber(stock.High) && IFrameSplitOperator.IsNumber(stock.Low) && IFrameSplitOperator.IsNumber(stock.YClose) && stock.YClose!=0)
128789
+ stock.Amplitude=(stock.High-stock.Low)/stock.YClose*100;
128790
+ }
128791
+
128792
+ if (item[30])
128793
+ stock.ExtendData=item[30]; //30=全局扩展数据
128794
+
128795
+ if (item[32]) stock.CloseLine=item[32]; //32=收盘价线
128796
+ if (item[33]) stock.KLine=item[33]; //33=K线
128797
+ }
128798
+
128799
+
128800
+ this.AutoUpdate=function(waitTime) //waitTime 更新时间
128801
+ {
128802
+ this.CancelAutoUpdate();
128803
+ if (!this.IsAutoUpdate) return;
128804
+
128805
+ var self = this;
128806
+ var marketStatus=2;
128807
+ var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_TREPORT_MARKET_STATUS);
128808
+ if (event && event.Callback)
128809
+ {
128810
+ var sendData={ MarketStatus:2 };
128811
+ event.Callback(event, sendData, this);
128812
+ if (IFrameSplitOperator.IsNumber(sendData.MarketStatus)) marketStatus=sendData.MarketStatus;
128813
+ }
128814
+
128815
+ if (marketStatus==0 || marketStatus==3) return; //闭市,盘后
128816
+
128817
+ var frequency=this.AutoUpdateFrequency;
128818
+ if (marketStatus==1) //盘前
128819
+ {
128820
+ this.AutoUpdateTimer=setTimeout(function()
128821
+ {
128822
+ self.AutoUpdate();
128823
+ },frequency);
128824
+ }
128825
+ else if (marketStatus==2) //盘中
128826
+ {
128827
+ this.AutoUpdateTimer=setTimeout(function()
128828
+ {
128829
+ self.UpdateStockData();
128830
+ },frequency);
128831
+ }
128832
+ }
128833
+
128834
+ //delay=是否延迟
128835
+ this.DelayUpdateStockData=function()
128836
+ {
128837
+ if (this.DelayUpdateTimer!=null)
128838
+ {
128839
+ clearTimeout(this.DelayUpdateTimer);
128840
+ this.DelayUpdateTimer = null;
128841
+ }
128842
+
128843
+ var frequency=this.DelayUpdateFrequency;
128844
+ this.DelayUpdateTimer=setTimeout(()=>
128845
+ {
128846
+ this.UpdateStockData();
128847
+
128848
+ },frequency);
128849
+ }
128850
+
128851
+ this.UIOnMouseDown=function(e)
128852
+ {
128853
+ var pixelTatio = GetDevicePixelRatio();
128854
+ var x = (e.clientX-this.UIElement.getBoundingClientRect().left)*pixelTatio;
128855
+ var y = (e.clientY-this.UIElement.getBoundingClientRect().top)*pixelTatio;
128856
+
128857
+ var chart=this.ChartPaint[0];
128858
+ if (!chart) return;
128859
+
128860
+ var clickData=chart.OnMouseDown(x,y,e);
128861
+ if (!clickData) return;
128862
+
128863
+ if ((clickData.Type==2) && (e.button==0 || e.button==2)) //点击行
128864
+ {
128865
+ if (clickData.Redraw==true) this.Draw();
128866
+ }
128867
+ else if (clickData.Type==3 && e.button==0) //表头
128868
+ {
128869
+ this.OnClickHeader(clickData, e);
128870
+ }
128871
+
128872
+ //document.onmousemove=(e)=>{ this.DocOnMouseMove(e); }
128873
+ //document.onmouseup=(e)=> { this.DocOnMouseUp(e); }
128874
+ }
128875
+
128876
+ //点表头
128877
+ this.OnClickHeader=function(clickData, e)
128878
+ {
128879
+ var header=clickData.Header;
128880
+
128881
+ if (header.Column && header.Column.Sort==1)
128882
+ {
128883
+ var data={ CellType:header.CellType, ColumnIndex:header.ColumnIndex }
128884
+ this.SortHeader(header.Column, data);
128885
+ }
128886
+
128887
+ }
128888
+
128889
+ //排序
128890
+ this.SortHeader=function(column, sortData)
128891
+ {
128892
+ var sortInfo={ Field:this.SortInfo.Field, Sort:this.SortInfo.Sort, CellType:this.SortInfo.CellType };
128893
+ var arySortType=column.SortType;
128894
+
128895
+ if (sortInfo.Field!=sortData.ColumnIndex || sortInfo.CellType!=sortData.CellType)
128896
+ {
128897
+ sortInfo.Field=sortData.ColumnIndex;
128898
+ sortInfo.CellType=sortData.CellType;
128899
+ sortInfo.Sort=arySortType[0]
128900
+ }
128901
+ else
128902
+ {
128903
+ if (arySortType.length==1)
128904
+ {
128905
+ sortInfo.Sort=arySortType[0];
128906
+ }
128907
+ else
128908
+ {
128909
+ for(var i=0;i<arySortType.length;++i)
128910
+ {
128911
+ if (sortInfo.Sort==arySortType[i])
128912
+ {
128913
+ sortInfo.Sort=arySortType[(i+1)%arySortType.length];
128914
+ break;
128915
+ }
128916
+ }
128917
+ }
128918
+ }
128919
+
128920
+ if (sortInfo.Sort==0) //还原
128921
+ {
128922
+ this.Data.Data=[];
128923
+ for(var i=0;i<this.SourceData.Data.length;++i)
128924
+ {
128925
+ this.Data.Data.push(this.SourceData.Data[i]);
128926
+ }
128927
+ }
128928
+ else
128929
+ {
128930
+ var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_TREPORT_LOCAL_SORT);
128931
+ if (event && event.Callback)
128932
+ {
128933
+ var sendData={ Column:column, SortInfo:sortInfo, SymbolList:this.Data.Data, Result:null };
128934
+ event.Callback (event, sendData, this);
128935
+ if (Array.isArray(sendData.Result)) this.Data.Data=sendData.Result;
128936
+ }
128937
+ else
128938
+ {
128939
+ this.Data.Data.sort((left, right)=> { return this.LocalSort(left, right, column, sortInfo.Sort, sortInfo.CellType); });
128940
+ }
128941
+ }
128942
+
128943
+ this.Data.YOffset=0;
128944
+ this.SortInfo.Field=sortInfo.Field;
128945
+ this.SortInfo.Sort=sortInfo.Sort;
128946
+ this.SortInfo.CellType=sortInfo.CellType;
128947
+ this.Draw();
128948
+ this.DelayUpdateStockData();
128949
+ }
128950
+
128951
+ //本地排序
128952
+ this.LocalSort=function(left, right, column, sortType, cellType)
128953
+ {
128954
+ switch(column.Type)
128955
+ {
128956
+ case TREPORT_COLUMN_ID.SYMBOL_ID:
128957
+ case TREPORT_COLUMN_ID.NAME_ID:
128958
+ return this.LocalStringSort(left, right, column, sortType, cellType);
128959
+
128960
+ case TREPORT_COLUMN_ID.PRICE_ID:
128961
+ case TREPORT_COLUMN_ID.VOL_ID:
128962
+ case TREPORT_COLUMN_ID.UPDOWN_ID:
128963
+ case TREPORT_COLUMN_ID.BUY_PRICE_ID:
128964
+ case TREPORT_COLUMN_ID.SELL_PRICE_ID:
128965
+ case TREPORT_COLUMN_ID.AMOUNT_ID:
128966
+ case TREPORT_COLUMN_ID.BUY_VOL_ID:
128967
+ case TREPORT_COLUMN_ID.SELL_VOL_ID:
128968
+ case TREPORT_COLUMN_ID.YCLOSE_ID:
128969
+ case TREPORT_COLUMN_ID.OPEN_ID:
128970
+ case TREPORT_COLUMN_ID.HIGH_ID:
128971
+ case TREPORT_COLUMN_ID.LOW_ID:
128972
+ case TREPORT_COLUMN_ID.AVERAGE_PRICE_ID:
128973
+ case TREPORT_COLUMN_ID.EXE_PRICE_ID: //行权价格
128974
+ case TREPORT_COLUMN_ID.POSITION_ID: //持仓量
128975
+ case TREPORT_COLUMN_ID.AMPLITUDE_ID:
128976
+ case TREPORT_COLUMN_ID.INCREASE_ID:
128977
+ return this.LocalNumberSort(left, right, column, sortType, cellType);
128978
+
128979
+ default:
128980
+
128981
+ return 0;
128982
+ }
128983
+ }
128984
+
128985
+ this.LocalNumberSort=function(left, right, column, sortType, cellType)
128986
+ {
128987
+ var leftStock=this.GetExePriceData(left);
128988
+ var rightStock=this.GetExePriceData(right);
128989
+
128990
+ var leftValue=-99999999999999, rightValue=-99999999999999;
128991
+ if (sortType==2) leftValue=rightValue=99999999999999;
128992
+
128993
+ var filedName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
128994
+
128995
+ if (cellType==0) //行权价格
128996
+ {
128997
+ if (leftStock && IFrameSplitOperator.IsNumber(leftStock.ExePrice)) leftValue=leftStock.ExePrice;
128998
+ if (rightStock && IFrameSplitOperator.IsNumber(rightStock.ExePrice)) rightValue=rightStock.ExePrice;
128999
+ }
129000
+ else if (cellType==1)
129001
+ {
129002
+ if (leftStock && leftStock.LeftData)
129003
+ {
129004
+ var value=leftStock.LeftData[filedName];
129005
+ if (IFrameSplitOperator.IsNumber(value)) leftValue=value;
129006
+ }
129007
+ if (rightStock && rightStock.LeftData)
129008
+ {
129009
+ var value=rightStock.LeftData[filedName];
129010
+ if (IFrameSplitOperator.IsNumber(value)) rightValue=value;
129011
+ }
129012
+ }
129013
+ else if (cellType==2)
129014
+ {
129015
+ if (leftStock && leftStock.RightData)
129016
+ {
129017
+ var value=leftStock.RightData[filedName];
129018
+ if (IFrameSplitOperator.IsNumber(value)) leftValue=value;
129019
+ }
129020
+ if (rightStock && rightStock.RightData)
129021
+ {
129022
+ var value=rightStock.RightData[filedName]
129023
+ if (IFrameSplitOperator.IsNumber(value)) rightValue=value;
129024
+ }
129025
+ }
129026
+
129027
+ if (sortType==1)
129028
+ {
129029
+ if (rightValue<leftValue) return -1;
129030
+ else if (rightValue<leftValue) return 1;
129031
+ else return 0;
129032
+ }
129033
+ else
129034
+ {
129035
+ if (leftValue<rightValue) return -1;
129036
+ else if (leftValue>rightValue) return 1;
129037
+ else return 0;
129038
+ }
129039
+ }
129040
+
129041
+ this.GetTReportChart=function()
129042
+ {
129043
+ var chart=this.ChartPaint[0];
129044
+ return chart;
129045
+ }
129046
+
129047
+ this.OnWheel=function(e) //滚轴
129048
+ {
129049
+ JSConsole.Chart.Log('[JSTReportChartContainer::OnWheel]',e);
129050
+ if (this.ChartSplashPaint && this.ChartSplashPaint.IsEnableSplash == true) return;
129051
+ if (!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
129052
+
129053
+ var x = e.clientX-this.UIElement.getBoundingClientRect().left;
129054
+ var y = e.clientY-this.UIElement.getBoundingClientRect().top;
129055
+
129056
+ var isInClient=false;
129057
+ this.Canvas.beginPath();
129058
+ this.Canvas.rect(this.Frame.ChartBorder.GetLeft(),this.Frame.ChartBorder.GetTop(),this.Frame.ChartBorder.GetWidth(),this.Frame.ChartBorder.GetHeight());
129059
+ isInClient=this.Canvas.isPointInPath(x,y);
129060
+ if (!isInClient) return;
129061
+
129062
+ var chart=this.GetTReportChart();
129063
+ if (!chart) return;
129064
+
129065
+ var wheelValue=e.wheelDelta;
129066
+ if (!IFrameSplitOperator.IsObjectExist(e.wheelDelta))
129067
+ wheelValue=e.deltaY* -0.01;
129068
+
129069
+ if (wheelValue<0) //下
129070
+ {
129071
+ var result=this.MoveSelectedRow(1)
129072
+ if (result)
129073
+ {
129074
+ if (result.Redraw) this.Draw();
129075
+ if (result.Update) this.DelayUpdateStockData();
129076
+ }
129077
+ }
129078
+ else if (wheelValue>0) //上
129079
+ {
129080
+ var result=this.MoveSelectedRow(-1);
129081
+ if (result)
129082
+ {
129083
+ if (result.Redraw) this.Draw();
129084
+ if (result.Update) this.DelayUpdateStockData();
129085
+ }
129086
+ }
129087
+
129088
+ if(e.preventDefault) e.preventDefault();
129089
+ else e.returnValue = false;
129090
+ }
129091
+
129092
+ this.OnKeyDown=function(e)
129093
+ {
129094
+ if (this.ChartSplashPaint && this.ChartSplashPaint.IsEnableSplash == true) return;
129095
+ var reportChart=this.GetTReportChart();
129096
+ if (!reportChart) return;
129097
+
129098
+ var keyID = e.keyCode ? e.keyCode :e.which;
129099
+ switch(keyID)
129100
+ {
129101
+ /*
129102
+ case 33: //page up
129103
+ if (this.GotoPreviousPage(this.PageUpDownCycle))
129104
+ {
129105
+ this.Draw();
129106
+ this.DelayUpdateStockData();
129107
+ }
129108
+ break;
129109
+ case 34: //page down
129110
+ if (this.GotoNextPage(this.PageUpDownCycle))
129111
+ {
129112
+ this.Draw();
129113
+ this.DelayUpdateStockData();
129114
+ }
129115
+ break;
129116
+ */
129117
+ case 38: //up
129118
+ var result=this.MoveSelectedRow(-1);
129119
+ if (result)
129120
+ {
129121
+ if (result.Redraw) this.Draw();
129122
+ if (result.Update) this.DelayUpdateStockData();
129123
+ }
129124
+ break;
129125
+ case 40: //down
129126
+ var result=this.MoveSelectedRow(1)
129127
+ if (result)
129128
+ {
129129
+ if (result.Redraw) this.Draw();
129130
+ if (result.Update) this.DelayUpdateStockData();
129131
+ }
129132
+ break;
129133
+ }
129134
+
129135
+ //不让滚动条滚动
129136
+ if(e.preventDefault) e.preventDefault();
129137
+ else e.returnValue = false;
129138
+ }
129139
+
129140
+ this.MoveSelectedRow=function(step)
129141
+ {
129142
+ var chart=this.ChartPaint[0];
129143
+ if (!chart) return null;
129144
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return null;
129145
+
129146
+ var result={ Redraw:false, Update:false }; //Redraw=重绘, Update=更新数据
129147
+
129148
+ var pageStatus=chart.GetCurrentPageStatus();
129149
+ var pageSize=pageStatus.PageSize;
129150
+
129151
+ var selectedIndex=pageStatus.Start;
129152
+ var cellType=1;
129153
+ if (pageStatus.SelectedRow)
129154
+ {
129155
+ cellType=pageStatus.SelectedRow.CellType;
129156
+ for(var i=0;i<this.Data.Data.length;++i)
129157
+ {
129158
+ if (pageStatus.SelectedRow.ExePrice==this.Data.Data[i])
129159
+ {
129160
+ selectedIndex=i;
129161
+ break;
129162
+ }
129163
+ }
129164
+ }
129165
+
129166
+ if (step>0)
129167
+ {
129168
+ if (selectedIndex<0 || selectedIndex<pageStatus.Start || selectedIndex>pageStatus.End)
129169
+ {
129170
+ chart.SelectedRow={ ExePrice:this.Data.Data[pageStatus.Start], CellType:cellType };
129171
+ result.Redraw=true;
129172
+ return result;
129173
+ }
129174
+
129175
+ var offset=this.Data.YOffset;
129176
+ for(var i=0;i<step;++i)
129177
+ {
129178
+ ++selectedIndex;
129179
+ if (selectedIndex>pageStatus.End) ++offset;
129180
+
129181
+ if (selectedIndex>=this.Data.Data.length)
129182
+ {
129183
+ selectedIndex=0;
129184
+ offset=0;
129185
+ }
129186
+ }
129187
+
129188
+ result.Redraw=true;
129189
+ result.Update=(offset!=this.Data.YOffset);
129190
+
129191
+ chart.SelectedRow={ ExePrice:this.Data.Data[selectedIndex], CellType:cellType };
129192
+ this.Data.YOffset=offset;
129193
+
129194
+ return result;
129195
+ }
129196
+ else if (step<0)
129197
+ {
129198
+ if (selectedIndex<0 || selectedIndex<pageStatus.Start || selectedIndex>pageStatus.End)
129199
+ {
129200
+ chart.SelectedRow={ ExePrice:this.Data.Data[pageStatus.End], CellType:cellType };
129201
+ result.Redraw=true;
129202
+ return result;
129203
+ }
129204
+
129205
+ step=Math.abs(step);
129206
+ var offset=this.Data.YOffset;
129207
+ for(var i=0;i<step;++i)
129208
+ {
129209
+ --selectedIndex;
129210
+ if (selectedIndex<pageStatus.Start) --offset;
129211
+
129212
+ if (selectedIndex<0)
129213
+ {
129214
+ selectedIndex=this.Data.Data.length-1;
129215
+ offset=this.Data.Data.length-pageSize;
129216
+ if (offset<0) offset=0;
129217
+ }
129218
+ }
129219
+
129220
+ result.Redraw=true;
129221
+ result.Update=(offset!=this.Data.YOffset);
129222
+
129223
+ chart.SelectedRow={ ExePrice:this.Data.Data[selectedIndex], CellType:cellType };
129224
+ this.Data.YOffset=offset;
129225
+
129226
+ return result;
129227
+ }
129228
+
129229
+ return null;
129230
+ }
129231
+ }
129232
+
129233
+ function JSTReportFrame()
129234
+ {
129235
+ this.ChartBorder;
129236
+ this.Canvas; //画布
129237
+
129238
+ this.BorderLine=null; //1=上 2=下 4=左 8=右
129239
+ this.ClassName="JSTReportFrame";
129240
+
129241
+ this.BorderColor=g_JSChartResource.TReport.BorderColor; //边框线
129242
+
129243
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
129244
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
129245
+
129246
+ this.ReloadResource=function(resource)
129247
+ {
129248
+ this.BorderColor=g_JSChartResource.TReport.BorderColor; //边框线
129249
+ this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
129250
+ this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
129251
+ }
129252
+
129253
+ this.Draw=function()
129254
+ {
129255
+ var left=ToFixedPoint(this.ChartBorder.GetLeft());
129256
+ var top=ToFixedPoint(this.ChartBorder.GetTop());
129257
+ var right=ToFixedPoint(this.ChartBorder.GetRight());
129258
+ var bottom=ToFixedPoint(this.ChartBorder.GetBottom());
129259
+ var width=right-left;
129260
+ var height=bottom-top;
129261
+
129262
+ if (!IFrameSplitOperator.IsNumber(this.BorderLine))
129263
+ {
129264
+ this.Canvas.strokeStyle=this.BorderColor;
129265
+ this.Canvas.strokeRect(left,top,width,height);
129266
+ }
129267
+ else
129268
+ {
129269
+ this.Canvas.strokeStyle=this.BorderColor;
129270
+ this.Canvas.beginPath();
129271
+
129272
+ if ((this.BorderLine&1)>0) //上
129273
+ {
129274
+ this.Canvas.moveTo(left,top);
129275
+ this.Canvas.lineTo(right,top);
129276
+ }
129277
+
129278
+ if ((this.BorderLine&2)>0) //下
129279
+ {
129280
+ this.Canvas.moveTo(left,bottom);
129281
+ this.Canvas.lineTo(right,bottom);
129282
+ }
129283
+
129284
+ if ((this.BorderLine&4)>0) //左
129285
+ {
129286
+ this.Canvas.moveTo(left,top);
129287
+ this.Canvas.lineTo(left,bottom);
129288
+ }
129289
+
129290
+ if ((this.BorderLine&8)>0) //右
129291
+ {
129292
+ this.Canvas.moveTo(right,top);
129293
+ this.Canvas.lineTo(right,bottom);
129294
+ }
129295
+
129296
+ this.Canvas.stroke();
129297
+ }
129298
+ }
129299
+
129300
+ this.DrawLogo=function()
129301
+ {
129302
+ var text=g_JSChartResource.FrameLogo.Text;
129303
+ if (!IFrameSplitOperator.IsString(text)) return;
129304
+
129305
+ this.Canvas.fillStyle=this.LogoTextColor;
129306
+ this.Canvas.font=this.LogoTextFont;
129307
+ this.Canvas.textAlign = 'right';
129308
+ this.Canvas.textBaseline = 'bottom';
129309
+
129310
+ var x=this.ChartBorder.GetRight()-30;
129311
+ var y=this.ChartBorder.GetBottom()-5;
129312
+ this.Canvas.fillText(text,x,y);
129313
+ }
129314
+ }
129315
+
129316
+ var TREPORT_COLUMN_ID=
129317
+ {
129318
+ SYMBOL_ID:0,
129319
+ NAME_ID:1,
129320
+ PRICE_ID:2, //成交价格
129321
+ VOL_ID:3, //成交量
129322
+ INCREASE_ID:4, //涨幅
129323
+ UPDOWN_ID:5, //涨跌
129324
+ BUY_PRICE_ID:6, //买价
129325
+ SELL_PRICE_ID:7, //卖价
129326
+ AMOUNT_ID:8, //总金额
129327
+ BUY_VOL_ID:9, //买量
129328
+ SELL_VOL_ID:10, //卖量
129329
+ YCLOSE_ID:11, //昨收
129330
+ OPEN_ID:12,
129331
+ HIGH_ID:13,
129332
+ LOW_ID:14,
129333
+ AVERAGE_PRICE_ID:15,//均价
129334
+ INDEX_ID:16, //序号 从1开始
129335
+ EXE_PRICE_ID:17, //行权价格
129336
+ POSITION_ID:18, //持仓量
129337
+
129338
+ AMPLITUDE_ID:22, //振幅
129339
+
129340
+ LIMIT_HIGH_ID:23, //涨停价
129341
+ LIMIT_LOW_ID:24, //跌停价
129342
+
129343
+ VOL_IN_ID:25, //内盘
129344
+ VOL_OUT_ID:26, //外盘
129345
+ NAME_EX_ID:27, //扩展名字
129346
+ CLOSE_LINE_ID:28, //收盘价线
129347
+ KLINE_ID:29, //K线
129348
+
129349
+ CUSTOM_STRING_TEXT_ID:100, //自定义字符串文本
129350
+ CUSTOM_NUMBER_TEXT_ID:101, //自定义数值型
129351
+ CUSTOM_DATETIME_TEXT_ID:102, //自定义日期类型
129352
+ CUSTOM_ICON_ID:103, //自定义图标
129353
+ }
129354
+
129355
+ var MAP_TREPORT_COLUMN_FIELD=new Map(
129356
+ [
129357
+ [TREPORT_COLUMN_ID.SYMBOL_ID, "Symbol"],
129358
+ [TREPORT_COLUMN_ID.NAME_ID, "Name"],
129359
+ [TREPORT_COLUMN_ID.PRICE_ID, "Price"],
129360
+ [TREPORT_COLUMN_ID.INCREASE_ID, "Increase"],
129361
+ [TREPORT_COLUMN_ID.UPDOWN_ID, "UpDown"],
129362
+ [TREPORT_COLUMN_ID.VOL_ID, "Vol"],
129363
+ [TREPORT_COLUMN_ID.BUY_PRICE_ID, "BuyPrice"],
129364
+ [TREPORT_COLUMN_ID.SELL_PRICE_ID, "SellPrice"],
129365
+ [TREPORT_COLUMN_ID.AMOUNT_ID, "Amount"],
129366
+ [TREPORT_COLUMN_ID.BUY_VOL_ID, "BuyVol"],
129367
+ [TREPORT_COLUMN_ID.SELL_VOL_ID, "SellVol"],
129368
+ [TREPORT_COLUMN_ID.YCLOSE_ID, "YClose"],
129369
+ [TREPORT_COLUMN_ID.OPEN_ID, "Open"],
129370
+ [TREPORT_COLUMN_ID.HIGH_ID, "High"],
129371
+ [TREPORT_COLUMN_ID.LOW_ID, "Low"],
129372
+ [TREPORT_COLUMN_ID.AVERAGE_PRICE_ID,"AvPrice"],
129373
+ [TREPORT_COLUMN_ID.POSITION_ID,"Position"],
129374
+ ]);
129375
+
129376
+
129377
+ function ChartTReport()
129378
+ {
129379
+ this.Canvas; //画布
129380
+ this.ChartBorder; //边框信息
129381
+ this.ChartFrame; //框架画法
129382
+ this.Name; //名称
129383
+ this.ClassName='ChartTReport'; //类名
129384
+ this.UIElement;
129385
+ this.IsDrawFirst=false;
129386
+ this.GetEventCallback; //获取事件
129387
+ this.GetExePriceDataCallback; //获取行权价格数据
129388
+ this.GetFlashBGDataCallback; //获取闪烁背景
129389
+ this.GetBlockDataCallback; //获取当前板块的数据
129390
+ this.Data; //数据 { XOffset:0, YOffset:0, Data:[ 50000.0, 500025.0] }
129391
+ this.BorderData;
129392
+ this.FixedRowData; //固定行
129393
+ this.SortInfo; //排序信息 { Field:排序字段id, Sort:0 不排序 1升序 2降序, CellType: }
129394
+ this.FixedColumn=2; //固定列
129395
+ this.FixedRowCount=0; //固定行
129396
+
129397
+ this.IsShowHeader=true; //是否显示表头
129398
+ this.SizeChange=true;
129399
+
129400
+ this.SelectedRow; //{ ExePrice:exePrice, CellType:0 }
129401
+ this.RectSelectedRow;
129402
+ this.IsDrawBorder=1; //是否绘制单元格边框
129403
+
129404
+ this.ShowSymbol=[]; //显示的列表 { ExePrice:行权价格 }
129405
+
129406
+ this.GlobalOption;
129407
+
129408
+ //涨跌颜色
129409
+ this.UpColor=g_JSChartResource.TReport.UpTextColor;
129410
+ this.DownColor=g_JSChartResource.TReport.DownTextColor;
129411
+ this.UnchangeColor=g_JSChartResource.TReport.UnchangeTextColor;
129412
+
129413
+ this.BorderColor=g_JSChartResource.TReport.BorderColor; //边框线
129414
+ this.SelectedColor=g_JSChartResource.TReport.SelectedColor; //选中行
129415
+
129416
+ this.UpBGColor=g_JSChartResource.TReport.UpBGColor;
129417
+ this.DownBGColor=g_JSChartResource.TReport.DownBGColor;
129418
+
129419
+ //表头配置
129420
+ this.HeaderFontConfig={ Size:g_JSChartResource.TReport.Header.Font.Size, Name:g_JSChartResource.TReport.Header.Font.Name };
129421
+ this.HeaderColor=g_JSChartResource.TReport.Header.Color;
129422
+ this.SortColor=g_JSChartResource.TReport.Header.SortColor; //排序箭头颜色
129423
+ this.HeaderMergin=
129424
+ {
129425
+ Left:g_JSChartResource.TReport.Header.Mergin.Left,
129426
+ Right:g_JSChartResource.TReport.Header.Mergin.Right,
129427
+ Top:g_JSChartResource.TReport.Header.Mergin.Top,
129428
+ Bottom:g_JSChartResource.TReport.Header.Mergin.Bottom
129429
+ };
129430
+
129431
+ this.MarkBorderConfig={ MaxPositionColor: g_JSChartResource.TReport.MarkBorder.MaxPositionColor };
129432
+
129433
+ //表格内容配置
129434
+ this.ItemFontConfig={ Size:g_JSChartResource.TReport.Item.Font.Size, Name:g_JSChartResource.TReport.Item.Font.Name };
129435
+ this.ItemMergin=
129436
+ {
129437
+ Left:g_JSChartResource.TReport.Item.Mergin.Left,
129438
+ Right:g_JSChartResource.TReport.Item.Mergin.Right,
129439
+ Top:g_JSChartResource.TReport.Item.Mergin.Top,
129440
+ Bottom:g_JSChartResource.TReport.Item.Mergin.Bottom
129441
+ };
129442
+
129443
+ this.CenterItemConfig=
129444
+ {
129445
+ TextColor:g_JSChartResource.TReport.CenterItem.TextColor,
129446
+ BaseTextColor:g_JSChartResource.TReport.CenterItem.BaseTextColor,
129447
+ BGColor: g_JSChartResource.TReport.CenterItem.BGColor
129448
+ };
129449
+
129450
+ //缓存
129451
+ this.HeaderFont=12*GetDevicePixelRatio() +"px 微软雅黑";
129452
+ this.ItemFont=15*GetDevicePixelRatio() +"px 微软雅黑";
129453
+ this.ItemFixedFont=15*GetDevicePixelRatio() +"px 微软雅黑";
129454
+ this.ItemSymbolFont=12*GetDevicePixelRatio() +"px 微软雅黑";
129455
+ this.ItemNameFont=15*GetDevicePixelRatio() +"px 微软雅黑";
129456
+ this.ItemNameHeight=0;
129457
+ this.RowCount=0; //一屏显示行数
129458
+ this.HeaderHeight=0; //表头高度
129459
+ this.RowHeight=0; //行高度
129460
+ this.IsShowAllColumn=false; //是否已显示所有列
129461
+ this.ItemExtraWidth=0; //每列额外的宽度
129462
+
129463
+ this.Column= //{ Type:列id, Title:标题, TextAlign:文字对齐方式, MaxText:文字最大宽度 , TextColor:文字颜色, Sort:0=不支持排序 1=本地排序 0=远程排序 }
129464
+ [
129465
+ { Type:TREPORT_COLUMN_ID.PRICE_ID, Title:"现价", TextAlign:"right", Width:null, MaxText:"-888.88" },
129466
+ { Type:TREPORT_COLUMN_ID.INCREASE_ID, Title:"涨幅%", TextAlign:"right", Width:null, MaxText:"-888.88" },
129467
+ { Type:TREPORT_COLUMN_ID.BUY_PRICE_ID, Title:"买价", TextAlign:"right", Width:null, MaxText:"-888.88" },
129468
+ { Type:TREPORT_COLUMN_ID.BUY_VOL_ID, Title:"买量", TextAlign:"right", Width:null, MaxText:"88888", TextColor:g_JSChartResource.TReport.FieldColor.Vol },
129469
+
129470
+ //{ Type:TREPORT_COLUMN_ID.SELL_PRICE_ID, Title:"卖价", TextAlign:"right", Width:null, MaxText:"-888.88" },
129471
+ //{ Type:TREPORT_COLUMN_ID.SELL_VOL_ID, Title:"卖量", TextAlign:"right", Width:null, MaxText:"88888", TextColor:g_JSChartResource.TReport.FieldColor.Vol },
129472
+
129473
+ //{ Type:TREPORT_COLUMN_ID.POSITION_ID, Title:"持仓量", TextAlign:"right", Width:null, MaxText:"88888", TextColor:g_JSChartResource.TReport.FieldColor.Position },
129474
+
129475
+ { Type:TREPORT_COLUMN_ID.NAME_ID, Title:"合约代码", TextAlign:"right", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Name, MaxText:"AAAAAA-A-AAAA"},
129476
+
129477
+ ];
129478
+
129479
+ this.CenterColumn={ Type:TREPORT_COLUMN_ID.EXE_PRICE_ID, Title:"购<行权价>沽", TextAlign:"center", Width:null, MaxText:"99999.99", Sort:1, SortType:[1,2] }
129480
+
129481
+ this.RectClient={};
129482
+
129483
+ this.TooltipRect=[];
129484
+
129485
+ this.ReloadResource=function(resource)
129486
+ {
129487
+ }
129488
+
129489
+ this.SetColumn=function(aryColumn)
129490
+ {
129491
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryColumn)) return;
129492
+
129493
+ this.Column=[];
129494
+ for(var i=0;i<aryColumn.length;++i)
129495
+ {
129496
+ var item=aryColumn[i];
129497
+ var colItem=this.GetDefaultColunm(item.Type);
129498
+ if (!colItem) continue;
129499
+
129500
+ if (item.Title) colItem.Title=item.Title;
129501
+ if (item.TextAlign) colItem.TextAlign=item.TextAlign;
129502
+ if (item.TextColor) colItem.TextColor=item.TextColor;
129503
+ if (item.MaxText) colItem.MaxText=item.MaxText;
129504
+ if (item.ID) colItem.ID=item.ID;
129505
+ if (IFrameSplitOperator.IsNumber(item.Sort)) colItem.Sort=item.Sort;
129506
+ if (IFrameSplitOperator.IsBool(item.EnableTooltip)) colItem.EnableTooltip=item.EnableTooltip;
129507
+ if (IFrameSplitOperator.IsNumber(item.FixedWidth)) colItem.FixedWidth=item.FixedWidth;
129508
+
129509
+ if (item.Sort==1) //1本地排序 2=远程排序
129510
+ {
129511
+ colItem.SortType=[1,2]; //默认 降序 ,升序
129512
+ if (IFrameSplitOperator.IsNonEmptyArray(item.SortType)) colItem.SortType=item.SortType.slice();
129513
+ }
129514
+
129515
+ this.Column.push(colItem);
129516
+ }
129517
+ }
129518
+
129519
+ this.GetDefaultColunm=function(id)
129520
+ {
129521
+ var DEFAULT_COLUMN=
129522
+ [
129523
+ { Type:TREPORT_COLUMN_ID.INDEX_ID, Title:"序号", TextAlign:"center", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Index, MaxText:"8888"},
129524
+ { Type:TREPORT_COLUMN_ID.SYMBOL_ID, Title:"代码", TextAlign:"right", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Symbol, MaxText:"888888"},
129525
+ { Type:TREPORT_COLUMN_ID.NAME_ID, Title:"合约名称", TextAlign:"right", Width:null, TextColor:g_JSChartResource.TReport.FieldColor.Name, MaxText:"AAAAAA-A-AAAA" },
129526
+
129527
+ { Type:TREPORT_COLUMN_ID.INCREASE_ID, Title:"涨幅%", TextAlign:"right", Width:null, MaxText:"-888.88", Sort:1, SortType:[1,2,0] },
129528
+ { Type:TREPORT_COLUMN_ID.PRICE_ID, Title:"现价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
129529
+ { Type:TREPORT_COLUMN_ID.UPDOWN_ID, Title:"涨跌", TextAlign:"right", Width:null, MaxText:"-888.88", Sort:1, SortType:[1,2,0] },
129530
+ { Type:TREPORT_COLUMN_ID.AMPLITUDE_ID, Title:"振幅%", TextAlign:"right", Width:null, MaxText:"888.88", Sort:1, SortType:[1,2,0] },
129531
+ { Type:TREPORT_COLUMN_ID.BUY_PRICE_ID, Title:"买价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
129532
+ { Type:TREPORT_COLUMN_ID.SELL_PRICE_ID, Title:"卖价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
129533
+ { Type:TREPORT_COLUMN_ID.AVERAGE_PRICE_ID, Title:"均价", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
129534
+ { Type:TREPORT_COLUMN_ID.OPEN_ID, Title:"今开", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
129535
+ { Type:TREPORT_COLUMN_ID.HIGH_ID, Title:"最高", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
129536
+ { Type:TREPORT_COLUMN_ID.LOW_ID, Title:"最低", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
129537
+ { Type:TREPORT_COLUMN_ID.YCLOSE_ID, Title:"昨收", TextAlign:"right", Width:null, MaxText:"88888.88", Sort:1, SortType:[1,2,0] },
129538
+
129539
+ { Type:TREPORT_COLUMN_ID.POSITION_ID, Title:"持仓量", TextAlign:"right", Width:null, MaxText:"88888", Sort:1, SortType:[1,2,0], TextColor:g_JSChartResource.TReport.FieldColor.Position },
129540
+
129541
+ { Type:TREPORT_COLUMN_ID.VOL_ID, Title:"总量", TextAlign:"right", TextColor:g_JSChartResource.TReport.FieldColor.Vol, Width:null, MaxText:"88888", Sort:1, SortType:[1,2,0] },
129542
+ { Type:TREPORT_COLUMN_ID.AMOUNT_ID, Title:"总金额", TextAlign:"right", TextColor:g_JSChartResource.TReport.FieldColor.Amount, Width:null, MaxText:"8888.8擎", Sort:1, SortType:[1,2,0] },
129543
+
129544
+ { Type:TREPORT_COLUMN_ID.BUY_VOL_ID, Title:"买量", TextAlign:"right", TextColor:g_JSChartResource.TReport.FieldColor.Vol, Width:null, MaxText:"88888", Sort:1, SortType:[1,2,0] },
129545
+ { Type:TREPORT_COLUMN_ID.SELL_VOL_ID, Title:"卖量", TextAlign:"right", TextColor:g_JSChartResource.TReport.FieldColor.Vol, Width:null, MaxText:"88888", Sort:1, SortType:[1,2,0] },
129546
+ ];
129547
+
129548
+ for(var i=0;i<DEFAULT_COLUMN.length;++i)
129549
+ {
129550
+ var item=DEFAULT_COLUMN[i];
129551
+ if (item.Type==id) return item;
129552
+ }
129553
+
129554
+ return null;
129555
+ }
129556
+
129557
+ this.Draw=function()
129558
+ {
129559
+ this.ShowSymbol=[];
129560
+ this.TooltipRect=[];
129561
+ this.RectSelectedRow=null;
129562
+
129563
+ if (this.GlobalOption) this.GlobalOption.FlashBGCount=0;
129564
+
129565
+ if (this.SizeChange) this.CalculateSize();
129566
+ else this.UpdateCacheData();
129567
+
129568
+ this.Canvas.save();
129569
+
129570
+ this.Canvas.beginPath();
129571
+ this.Canvas.rect(this.RectClient.Left,this.RectClient.Top,(this.RectClient.Right-this.RectClient.Left),(this.RectClient.Bottom-this.RectClient.Top));
129572
+ //this.Canvas.stroke(); //调试用
129573
+ this.Canvas.clip();
129574
+
129575
+ this.DrawHeader();
129576
+ this.DrawBody();
129577
+ this.Canvas.restore();
129578
+
129579
+ //this.DrawBorder();
129580
+
129581
+ this.SizeChange=false;
129582
+ }
129583
+
129584
+ //更新缓存变量
129585
+ this.UpdateCacheData=function()
129586
+ {
129587
+ this.RectClient.Left=this.ChartBorder.GetLeft();
129588
+ this.RectClient.Right=this.ChartBorder.GetRight();
129589
+ this.RectClient.Top=this.ChartBorder.GetTop();
129590
+ this.RectClient.Bottom=this.ChartBorder.GetBottom();
129591
+ }
129592
+
129593
+ this.CalculateSize=function() //计算大小
129594
+ {
129595
+ this.UpdateCacheData();
129596
+
129597
+ var pixelRatio=GetDevicePixelRatio();
129598
+ this.HeaderFont=`${this.HeaderFontConfig.Size*pixelRatio}px ${ this.HeaderFontConfig.Name}`;
129599
+ this.ItemFont=`${this.ItemFontConfig.Size*pixelRatio}px ${ this.ItemFontConfig.Name}`;
129600
+
129601
+ this.RowHeight=this.GetFontHeight(this.ItemFont,"擎")+ this.ItemMergin.Top+ this.ItemMergin.Bottom;
129602
+
129603
+ this.Canvas.font=this.ItemFont;
129604
+ var itemWidth=0;
129605
+ for(var i=0;i<this.Column.length;++i)
129606
+ {
129607
+ var item=this.Column[i];
129608
+ if (IFrameSplitOperator.IsNumber(item.FixedWidth)) itemWidth=item.FixedWidth;
129609
+ else itemWidth=this.Canvas.measureText(item.MaxText).width;
129610
+
129611
+ item.Width=itemWidth+4+this.ItemMergin.Left+this.ItemMergin.Right;
129612
+ }
129613
+
129614
+ //表头中间列
129615
+ var item=this.CenterColumn;
129616
+ if (IFrameSplitOperator.IsNumber(item.FixedWidth)) itemWidth=item.FixedWidth;
129617
+ else itemWidth=this.Canvas.measureText(item.MaxText).width;
129618
+ item.Width=itemWidth+4+this.ItemMergin.Left+this.ItemMergin.Right;
129619
+
129620
+ this.Canvas.font=this.HeaderFont;
129621
+ for(var i=0;i<this.Column.length;++i)
129622
+ {
129623
+ var item=this.Column[i];
129624
+ if (!item.Title || item.Title.length<=0) continue;
129625
+ var text=item.Title;
129626
+ if (item.Sort>0) text+="↓";
129627
+ itemWidth=this.Canvas.measureText(text).width;
129628
+ itemWidth+=(4+this.HeaderMergin.Left+this.HeaderMergin.Right);
129629
+ if (item.Width<itemWidth) item.Width=itemWidth;
129630
+ }
129631
+
129632
+ //表头中间列
129633
+ var item=this.CenterColumn;
129634
+ if (!item.Title || item.Title.length>0)
129635
+ {
129636
+ var text=item.Title;
129637
+ if (item.Sort>0) text+="↓";
129638
+ itemWidth=this.Canvas.measureText(text).width;
129639
+ itemWidth+=(4+this.HeaderMergin.Left+this.HeaderMergin.Right);
129640
+ if (item.Width<itemWidth) item.Width=itemWidth;
129641
+ }
129642
+
129643
+
129644
+ this.HeaderHeight=this.GetFontHeight(this.HeaderFont,"擎")+ this.HeaderMergin.Top+ this.HeaderMergin.Bottom;
129645
+ if (!this.IsShowHeader) this.HeaderHeight=0;
129646
+
129647
+ this.RowCount=parseInt((this.RectClient.Bottom-this.RectClient.Top-this.HeaderHeight)/this.RowHeight);
129648
+
129649
+ var subWidth=this.CenterColumn.Width;
129650
+ var reportWidth=this.RectClient.Right-this.RectClient.Left;
129651
+ for(var i=0;i<this.Column.length;++i)
129652
+ {
129653
+ var item=this.Column[i];
129654
+ subWidth+=item.Width*2;
129655
+ }
129656
+
129657
+ if (subWidth<reportWidth)
129658
+ {
129659
+ this.IsShowAllColumn=true;
129660
+ this.ItemExtraWidth=0;
129661
+ if (reportWidth-subWidth-4>0)
129662
+ this.ItemExtraWidth=(reportWidth-subWidth-4)/(this.Column.length*2+1);
129663
+ }
129664
+ else
129665
+ {
129666
+ this.IsShowAllColumn=false;
129667
+ this.ItemExtraWidth=0;
129668
+ }
129669
+ }
129670
+
129671
+ this.DrawHeader=function()
129672
+ {
129673
+ if (!this.IsShowHeader) return;
129674
+
129675
+ var left=this.RectClient.Left;
129676
+ var top=this.RectClient.Top;
129677
+ var y=top+this.HeaderMergin.Top+(this.HeaderHeight-this.HeaderMergin.Top-this.HeaderMergin.Bottom)/2;
129678
+ var xCenter=(this.RectClient.Right-this.RectClient.Left)/2+this.RectClient.Left;
129679
+
129680
+ this.Canvas.font=this.HeaderFont;
129681
+ this.Canvas.fillStyle=this.HeaderColor;
129682
+
129683
+ var reportleft=this.RectClient.Left;
129684
+ var reportRight=this.RectClient.Right;
129685
+
129686
+ //中间列
129687
+ var item=this.CenterColumn;
129688
+ var rtCenterItem=this.GetCenterItemRect();
129689
+ if (this.SortInfo && this.SortInfo.Sort>0 && this.SortInfo.CellType==0)
129690
+ this.DrawSortHeader(item.Title,item.TextAlign,rtCenterItem.Left,y,rtCenterItem.TextWidth,this.SortInfo.Sort);
129691
+ else
129692
+ this.DrawText(item.Title,item.TextAlign,rtCenterItem.Left,y,rtCenterItem.TextWidth);
129693
+
129694
+ var xLeft=rtCenterItem.Left; //左边
129695
+ var xRight=rtCenterItem.Right;//右边
129696
+ for(var i=this.Data.XOffset;i<this.Column.length;++i)
129697
+ {
129698
+ var item=this.Column[i];
129699
+ var itemWidth=item.Width+this.ItemExtraWidth;
129700
+ var textWidth=itemWidth-this.HeaderMergin.Left-this.HeaderMergin.Right;
129701
+ var x=xLeft-itemWidth+this.HeaderMergin.Left;
129702
+
129703
+ if (xLeft-itemWidth<reportleft) break;
129704
+
129705
+ var bSort=(this.SortInfo && this.SortInfo.Field==i && this.SortInfo.Sort>0);
129706
+ if (bSort && this.SortInfo.CellType==1) this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort);
129707
+ else this.DrawText(item.Title,item.TextAlign,x,y,textWidth);
129708
+ xLeft-=itemWidth;
129709
+
129710
+ var x=xRight+this.HeaderMergin.Left;
129711
+ if (bSort && this.SortInfo.CellType==2) this.DrawSortHeader(item.Title,item.TextAlign,x,y,textWidth,this.SortInfo.Sort);
129712
+ else this.DrawText(item.Title,item.TextAlign,x,y,textWidth);
129713
+ xRight+=itemWidth;
129714
+ }
129715
+ }
129716
+
129717
+ this.DrawSortHeader=function(text, textAlign, x, y, width, sortType)
129718
+ {
129719
+ var sortText=sortType==1?"↓":"↑";
129720
+ var sortTextWidth=this.Canvas.measureText(sortText).width;
129721
+ var textWidth=this.Canvas.measureText(text).width+2;
129722
+ this.Canvas.textBaseline="middle";
129723
+ this.Canvas.textAlign="left";
129724
+
129725
+ if (textAlign=='center')
129726
+ {
129727
+ x=x+width/2-(sortTextWidth+textWidth)/2;
129728
+ }
129729
+ else if (textAlign=='right')
129730
+ {
129731
+ x=(x+width)-sortTextWidth-textWidth;
129732
+ }
129733
+ else
129734
+ {
129735
+
129736
+ }
129737
+
129738
+ this.Canvas.fillText(text,x,y);
129739
+ this.Canvas.fillStyle=this.SortColor;
129740
+ this.Canvas.fillText(sortText,x+textWidth,y);
129741
+ this.Canvas.fillStyle=this.HeaderColor;
129742
+ }
129743
+
129744
+ this.DrawText=function(text, textAlign, x, y, textWidth)
129745
+ {
129746
+ if (textAlign=='center')
129747
+ {
129748
+ x=x+textWidth/2;
129749
+ this.Canvas.textAlign="center";
129750
+ }
129751
+ else if (textAlign=='right')
129752
+ {
129753
+ x=x+textWidth;
129754
+ this.Canvas.textAlign="right";
129755
+ }
129756
+ else
129757
+ {
129758
+ this.Canvas.textAlign="left";
129759
+ }
129760
+
129761
+ this.Canvas.textBaseline="middle";
129762
+ this.Canvas.fillText(text,x,y);
129763
+ }
129764
+
129765
+ this.GetFontHeight=function(font,word)
129766
+ {
129767
+ return GetFontHeight(this.Canvas, font, word);
129768
+ }
129769
+
129770
+ this.DrawBody=function()
129771
+ {
129772
+ if (!this.Data) return;
129773
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
129774
+
129775
+ this.Canvas.font=this.ItemFont;
129776
+ var top=this.RectClient.Top+this.HeaderHeight;
129777
+ var left=this.RectClient.Left;
129778
+ var rowWidth=this.RectClient.Right-this.RectClient.Left;
129779
+
129780
+ var textTop=top;
129781
+ this.Canvas.font=this.ItemFont;
129782
+ for(var i=this.Data.YOffset, j=0; i<this.Data.Data.length && j<this.RowCount ;++i, ++j)
129783
+ {
129784
+ var exePrice=this.Data.Data[i];
129785
+
129786
+ this.DrawRow(exePrice, textTop, i);
129787
+
129788
+ this.ShowSymbol.push( { Index:i, ExePrice:exePrice } );
129789
+
129790
+ textTop+=this.RowHeight;
129791
+ }
129792
+
129793
+ if (this.RectSelectedRow)
129794
+ {
129795
+ this.Canvas.fillStyle=this.SelectedColor;
129796
+ var lineWidth=2;
129797
+ this.Canvas.fillRect(this.RectSelectedRow.Left,this.RectSelectedRow.Bottom-lineWidth, (this.RectSelectedRow.Right-this.RectSelectedRow.Left), lineWidth);
129798
+ }
129799
+ }
129800
+
129801
+ this.GetCenterItemRect=function()
129802
+ {
129803
+ var xCenter=(this.RectClient.Right-this.RectClient.Left)/2+this.RectClient.Left;
129804
+
129805
+ //中间列
129806
+ var item=this.CenterColumn;
129807
+ var itemWidth=item.Width+this.ItemExtraWidth;
129808
+ var left=xCenter-itemWidth/2;
129809
+ var right=xCenter+itemWidth/2;
129810
+ var textWidth=itemWidth-this.HeaderMergin.Left-this.HeaderMergin.Right;
129811
+
129812
+ return { Left:left, Right:right, TextWidth:textWidth, Width:itemWidth };
129813
+ }
129814
+
129815
+ this.DrawRow=function(exePrice, top, dataIndex)
129816
+ {
129817
+ var rtCenterItem=this.GetCenterItemRect();
129818
+
129819
+ var xLeft=rtCenterItem.Left; //左边
129820
+ var xRight=rtCenterItem.Right; //右边
129821
+
129822
+ var reportleft=this.RectClient.Left;
129823
+ var reportRight=this.RectClient.Right;
129824
+
129825
+ var data= { ExePrice:exePrice , TData:null };
129826
+ if (this.GetExePriceDataCallback) data.TData=this.GetExePriceDataCallback(exePrice);
129827
+ //if (this.GetFlashBGDataCallback) data.FlashBG=this.GetFlashBGDataCallback(exePrice, Date.now());
129828
+ data.Decimal=2;
129829
+
129830
+ var bSelected=false;
129831
+ if (this.SelectedRow && this.SelectedRow.ExePrice==exePrice) bSelected=true;
129832
+
129833
+ var rtItem={ Left:xLeft, Right:xRight, Top:top, Height:this.RowHeight };
129834
+ rtItem.Bottom=rtItem.Top+rtItem.Height;
129835
+ rtItem.Width=rtItem.Right-rtItem.Left;
129836
+ this.DrawCenterItem(dataIndex, data, this.CenterColumn, rtItem, 0);
129837
+ if (bSelected && this.SelectedRow.CellType==0) this.RectSelectedRow=rtItem;
129838
+
129839
+ if (IFrameSplitOperator.IsNumber(this.Data.BaseExePrice))
129840
+ {
129841
+ var leftBGColor=null, rightBGColor=null;
129842
+ if (exePrice>this.Data.BaseExePrice)
129843
+ {
129844
+ leftBGColor=this.UpBGColor;
129845
+ rightBGColor=this.DownBGColor;
129846
+ }
129847
+ else
129848
+ {
129849
+ leftBGColor=this.DownBGColor;
129850
+ rightBGColor=this.UpBGColor;
129851
+ }
129852
+
129853
+ if (leftBGColor)
129854
+ {
129855
+ var rtBG={Left:reportleft+1, Right:rtCenterItem.Left, Top:top, Height:this.RowHeight };
129856
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
129857
+ rtBG.Width=rtBG.Right-rtBG.Left;
129858
+ this.Canvas.fillStyle=leftBGColor;
129859
+ this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
129860
+ }
129861
+
129862
+ if (rightBGColor)
129863
+ {
129864
+ var rtBG={Left:rtCenterItem.Right, Right:reportRight, Top:top, Height:this.RowHeight };
129865
+ rtBG.Bottom=rtBG.Top+rtBG.Height;
129866
+ rtBG.Width=rtBG.Right-rtBG.Left;
129867
+ this.Canvas.fillStyle=rightBGColor;
129868
+ this.Canvas.fillRect(rtBG.Left,rtBG.Top,rtBG.Width,rtBG.Height);
129869
+ }
129870
+ }
129871
+
129872
+ for(var i=this.Data.XOffset;i<this.Column.length;++i)
129873
+ {
129874
+ var item=this.Column[i];
129875
+ var itemWidth=item.Width+this.ItemExtraWidth;
129876
+ xLeft-=itemWidth;
129877
+ if (xLeft<reportleft) break;
129878
+
129879
+ var leftData=null, rightData=null;
129880
+ if (data.TData) leftData=data.TData.LeftData;
129881
+ if (data.TData) rightData=data.TData.RightData;
129882
+
129883
+ rtItem={ Left:xLeft, Right:xLeft+itemWidth, Top:top, Height:this.RowHeight, Width:itemWidth };
129884
+ rtItem.Bottom=rtItem.Top+rtItem.Height;
129885
+
129886
+ this.DrawItem(dataIndex, data, leftData, item, rtItem, 1);
129887
+
129888
+ if (bSelected && this.SelectedRow.CellType==1)
129889
+ {
129890
+ if (!this.RectSelectedRow) this.RectSelectedRow=rtItem;
129891
+ else this.RectSelectedRow.Left=rtItem.Left;
129892
+ }
129893
+
129894
+ rtItem={ Left:xRight, Right:xRight+itemWidth, Top:top, Height:this.RowHeight, Width:itemWidth };
129895
+ rtItem.Bottom=rtItem.Top+rtItem.Height;
129896
+
129897
+ this.DrawItem(dataIndex, data, rightData, item, rtItem, 2);
129898
+ xRight+=itemWidth;
129899
+
129900
+ if (bSelected && this.SelectedRow.CellType==2)
129901
+ {
129902
+ if (!this.RectSelectedRow) this.RectSelectedRow=rtItem;
129903
+ else this.RectSelectedRow.Right=rtItem.Right;
129904
+ }
129905
+ }
129906
+ }
129907
+
129908
+ this.DrawCenterItem=function(index, data, column, rtItem, cellType) //cellType 0=中间字段 1=左侧 2=右侧
129909
+ {
129910
+ //tooltip提示
129911
+ if (column.EnableTooltip===true) this.TooltipRect.push({ Rect:rtItem, data:data, Index:index, Column:column, CellType:cellType });
129912
+
129913
+ var rtText={ Left:rtItem.Left+this.ItemMergin.Left, Right:rtItem.Right-this.ItemMergin.Right, Top:rtItem.Top+this.ItemMergin.Top, Bottom:rtItem.Bottom-this.ItemMergin.Bottom };
129914
+ rtText.Width=rtText.Right-rtText.Left;
129915
+ rtText.Height=rtText.Bottom-rtText.Top;
129916
+
129917
+ var drawInfo={ Text:null, TextColor:this.CenterItemConfig.TextColor, BGColor:this.CenterItemConfig.BGColor, TextAlign:column.TextAlign, Rect:rtItem, RectText:rtText };
129918
+ drawInfo.Text=`${data.ExePrice.toFixed(data.Decimal)}`;
129919
+
129920
+ this.DrawCell(drawInfo);
129921
+ }
129922
+
129923
+ this.DrawItem=function(index, exePriceData, data, column, rtItem, cellType)
129924
+ {
129925
+ if (column.EnableTooltip===true) this.TooltipRect.push({ Rect:rtItem, data:data, Index:index, Column:column, CellType:cellType });
129926
+
129927
+ var rtText={ Left:rtItem.Left+this.ItemMergin.Left, Right:rtItem.Right-this.ItemMergin.Right, Top:rtItem.Top+this.ItemMergin.Top, Bottom:rtItem.Bottom-this.ItemMergin.Bottom };
129928
+ rtText.Width=rtText.Right-rtText.Left;
129929
+ rtText.Height=rtText.Bottom-rtText.Top;
129930
+
129931
+ var drawInfo={ Text:null, TextColor:column.TextColor , TextAlign:column.TextAlign, Rect:rtItem, RectText:rtText };
129932
+
129933
+ if (data)
129934
+ {
129935
+ switch(column.Type)
129936
+ {
129937
+ case TREPORT_COLUMN_ID.SYMBOL_ID:
129938
+ case TREPORT_COLUMN_ID.NAME_ID:
129939
+ var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
129940
+ if (fieldName) drawInfo.Text=data[fieldName];
129941
+ break;
129942
+
129943
+ case TREPORT_COLUMN_ID.PRICE_ID: //最新价格
129944
+ case TREPORT_COLUMN_ID.BUY_PRICE_ID: //买价
129945
+ case TREPORT_COLUMN_ID.SELL_PRICE_ID: //卖价
129946
+ var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
129947
+ if (fieldName) this.GetPriceDrawInfo(data[fieldName], data, exePriceData, drawInfo);
129948
+ break;
129949
+
129950
+ case TREPORT_COLUMN_ID.SELL_VOL_ID: //卖量
129951
+ case TREPORT_COLUMN_ID.BUY_VOL_ID: //买量
129952
+ case TREPORT_COLUMN_ID.POSITION_ID: //持仓量
129953
+ var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
129954
+ if (fieldName) drawInfo.Text=this.FormatVolString(data[fieldName]);
129955
+ break;
129956
+ case TREPORT_COLUMN_ID.INCREASE_ID:
129957
+ case TREPORT_COLUMN_ID.UPDOWN_ID:
129958
+ case TREPORT_COLUMN_ID.AMPLITUDE_ID:
129959
+ var fieldName=MAP_TREPORT_COLUMN_FIELD.get(column.Type);
129960
+ if (fieldName)
129961
+ {
129962
+ var value=data[fieldName];
129963
+ if (IFrameSplitOperator.IsNumber(value))
129964
+ {
129965
+ drawInfo.Text=value.toFixed(2);
129966
+ drawInfo.TextColor=this.GetUpDownColor(value,0);
129967
+ }
129968
+ else
129969
+ {
129970
+ this.GetNullDrawInfo(drawInfo);
129971
+ }
129972
+ }
129973
+ break;
129974
+
129975
+ default:
129976
+ drawInfo.Text=`-----`;
129977
+ }
129978
+
129979
+ this.GetMarkBorderData(drawInfo, exePriceData.ExePrice, column.Type, cellType);
129980
+ }
129981
+
129982
+ this.DrawCell(drawInfo);
129983
+ }
129984
+
129985
+ this.GetMarkBorderData=function(drawInfo, exePrice, columnType, cellType)
129986
+ {
129987
+ if (!this.BorderData || !this.BorderData.MapData) return;
129988
+ if (!this.BorderData.MapData.has(columnType)) return;
129989
+ var borderData=this.BorderData.MapData.get(columnType);
129990
+ if (!IFrameSplitOperator.IsNonEmptyArray(borderData.Data)) return;
129991
+
129992
+ if (cellType==1)
129993
+ {
129994
+ var leftBorder=borderData.Data[1];
129995
+ if (!leftBorder) return;
129996
+
129997
+ if (leftBorder.ExePrice==exePrice)
129998
+ {
129999
+ drawInfo.BorderColor=this.MarkBorderConfig.MaxPositionColor;
130000
+ }
130001
+
130002
+ }
130003
+ else if (cellType==2)
130004
+ {
130005
+ var rightBorder=borderData.Data[2];
130006
+ if (!rightBorder) return;
130007
+ if (rightBorder.ExePrice==exePrice)
130008
+ {
130009
+ drawInfo.BorderColor=this.MarkBorderConfig.MaxPositionColor;
130010
+ }
130011
+ }
130012
+ }
130013
+
130014
+ this.GetNullDrawInfo=function(drawInfo)
130015
+ {
130016
+ drawInfo.Text="--";
130017
+ drawInfo.TextColor=this.UnchangeColor;
130018
+ }
130019
+
130020
+ this.GetPriceDrawInfo=function(price, stock, data, drawInfo)
130021
+ {
130022
+ if (!IFrameSplitOperator.IsNumber(price))
130023
+ {
130024
+ this.GetNullDrawInfo(drawInfo);
130025
+ return;
130026
+ }
130027
+
130028
+ drawInfo.Text=price.toFixed(data.Decimal);
130029
+ if (!IFrameSplitOperator.IsNumber(stock.YClose))
130030
+ drawInfo.TextColor=this.UnchangeColor;
130031
+ else
130032
+ drawInfo.TextColor=this.GetUpDownColor(price, stock.YClose);
130033
+ }
130034
+
130035
+ //单独处理成交量显示
130036
+ this.FormatVolString=function(value,languageID)
130037
+ {
130038
+ if (!IFrameSplitOperator.IsNumber(value)) return null;
130039
+
130040
+ return IFrameSplitOperator.FormatVolString(value, languageID);
130041
+ }
130042
+
130043
+ this.GetUpDownColor=function(price, price2)
130044
+ {
130045
+ if (price>price2) return this.UpColor;
130046
+ else if (price<price2) return this.DownColor;
130047
+ else return this.UnchangeColor;
130048
+ }
130049
+
130050
+ this.DrawCell=function(drawInfo)
130051
+ {
130052
+ var rtText=drawInfo.RectText;
130053
+ var yCenter=rtText.Top+(rtText.Height/2);
130054
+
130055
+ if (drawInfo.BGColor) //背景
130056
+ {
130057
+ var rtItem=drawInfo.Rect;
130058
+ this.Canvas.fillStyle=drawInfo.BGColor;
130059
+ this.Canvas.fillRect(rtItem.Left,rtItem.Top,rtItem.Width,rtItem.Height);
130060
+ }
130061
+
130062
+ if (drawInfo.BorderColor) //边框
130063
+ {
130064
+ var rtItem=drawInfo.Rect;
130065
+ this.Canvas.strokeStyle=drawInfo.BorderColor;
130066
+ this.Canvas.strokeRect(ToFixedPoint(rtItem.Left),ToFixedPoint(rtItem.Top+1),ToFixedRect(rtItem.Width),ToFixedRect(rtItem.Height-3));
130067
+ }
130068
+
130069
+ if (drawInfo.Text) //文字
130070
+ {
130071
+ if(drawInfo.TextColor) this.Canvas.fillStyle=drawInfo.TextColor;
130072
+ this.DrawText(drawInfo.Text, drawInfo.TextAlign, rtText.Left, yCenter, rtText.Width);
130073
+ }
130074
+ }
130075
+
130076
+ this.OnMouseDown=function(x,y,e) //Type: 2=行 3=表头
130077
+ {
130078
+ if (!this.Data) return null;
130079
+
130080
+ var pixelTatio = GetDevicePixelRatio();
130081
+ var insidePoint={X:x/pixelTatio, Y:y/pixelTatio};
130082
+
130083
+ if (this.UIElement)
130084
+ var uiElement={Left:this.UIElement.getBoundingClientRect().left, Top:this.UIElement.getBoundingClientRect().top};
130085
+ else
130086
+ var uiElement={Left:null, Top:null};
130087
+
130088
+ var row=this.PtInBody(x,y);
130089
+ if (row)
130090
+ {
130091
+ var bRedraw=false;
130092
+ if (!this.SelectedRow)
130093
+ {
130094
+ this.SelectedRow={ ExePrice:row.ExePrice, CellType:row.CellType };
130095
+ bRedraw=true;
130096
+ }
130097
+ else if (this.SelectedRow.ExePrice!=row.ExePrice || this.SelectedRow.CellType!=row.CellType)
130098
+ {
130099
+ this.SelectedRow.ExePrice=row.ExePrice;
130100
+ this.SelectedRow.CellType=row.CellType;
130101
+ bRedraw=true;
130102
+ }
130103
+
130104
+ var eventID=JSCHART_EVENT_ID.ON_CLICK_TREPORT_ROW;
130105
+ if (e.button==2) eventID=JSCHART_EVENT_ID.ON_RCLICK_TREPORT_ROW;
130106
+
130107
+ this.SendClickEvent(eventID, { Data:row, X:x, Y:y, e:e, Inside:insidePoint, UIElement:uiElement });
130108
+
130109
+ return { Type:2, Redraw:bRedraw, Row:row }; //行
130110
+ }
130111
+
130112
+ var header=this.PtInHeader(x,y);
130113
+ if (header)
130114
+ {
130115
+ var eventID=JSCHART_EVENT_ID.ON_CLICK_TREPORT_HEADER;
130116
+ if (e.button==2)
130117
+ {
130118
+ eventID=JSCHART_EVENT_ID.ON_RCLICK_TREPORT_HEADER;
130119
+ }
130120
+ else if (e.button==0)
130121
+ {
130122
+ eventID=JSCHART_EVENT_ID.ON_CLICK_TREPORT_HEADER;
130123
+ }
130124
+
130125
+ this.SendClickEvent(eventID, { Data:header, X:x, Y:y , e:e, Inside:insidePoint, UIElement:uiElement});
130126
+ return { Type:3, Redraw:bRedraw, Header:header }; //表头
130127
+ }
130128
+
130129
+ return null;
130130
+ }
130131
+
130132
+ this.PtInBody=function(x,y)
130133
+ {
130134
+ if (!this.Data) return null;
130135
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return null;
130136
+
130137
+ var top=this.RectClient.Top+this.HeaderHeight;
130138
+ var left=this.RectClient.Left;
130139
+ var right=this.RectClient.Right;
130140
+
130141
+ var textTop=top;
130142
+ for(var i=this.Data.YOffset, j=0; i<this.Data.Data.length && j<this.RowCount ;++i, ++j)
130143
+ {
130144
+ var exePrice=this.Data.Data[i];
130145
+ var rtRow={ Left:left, Top:textTop, Right:right, Bottom: textTop+this.RowHeight };
130146
+ rtRow.Height=rtRow.Bottom-rtRow.Top;
130147
+ rtRow.Width=rtRow.Right-rtRow.Left;
130148
+ if (x>=rtRow.Left && x<=rtRow.Right && y>=rtRow.Top && y<=rtRow.Bottom)
130149
+ {
130150
+ var data={ RectRow:rtRow, DataIndex:i, Index:j, ExePrice:exePrice };
130151
+ return this.PtInItem(x,y, data);
130152
+ }
130153
+
130154
+ textTop+=this.RowHeight;
130155
+ }
130156
+
130157
+ return null;
130158
+ }
130159
+
130160
+ this.PtInItem=function(x, y, info, exePrice)
130161
+ {
130162
+ var rtCenterItem=this.GetCenterItemRect();
130163
+ var rtRow=info.RectRow;
130164
+ var rtCenter={Left:rtCenterItem.Left, Right:rtCenterItem.Right, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom };
130165
+
130166
+ if (x>=rtCenter.Left && x<=rtCenter.Right && y>=rtCenter.Top && y<=rtCenter.Bottom)
130167
+ {
130168
+ var data={ Rect:rtCenter, DataIndex:info.DataIndex, Index:info.Index , ExePrice:info.ExePrice, CellType:0, Column:this.CenterColumn };
130169
+ data.Item=this.GetExePriceDataCallback(info.ExePrice);
130170
+ return data;
130171
+ }
130172
+
130173
+ var xLeft=rtCenterItem.Left; //左边
130174
+ var xRight=rtCenterItem.Right; //右边
130175
+
130176
+ var reportleft=this.RectClient.Left;
130177
+ var reportRight=this.RectClient.Right;
130178
+
130179
+ for(var i=this.Data.XOffset;i<this.Column.length;++i)
130180
+ {
130181
+ var item=this.Column[i];
130182
+ var itemWidth=item.Width+this.ItemExtraWidth;
130183
+ xLeft-=itemWidth;
130184
+ if (xLeft<reportleft) break;
130185
+
130186
+ var rtItem={ Left:xLeft, Right:xLeft+itemWidth, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom, Width:itemWidth };
130187
+ if (x>=rtItem.Left && x<=rtItem.Right && y>=rtItem.Top && y<=rtItem.Bottom)
130188
+ {
130189
+ var data={ Rect:rtCenter, DataIndex:info.DataIndex, Index:info.Index , ExePrice:info.ExePrice, CellType:1, ColumnIndex:i, Column:item };
130190
+ data.Item=this.GetExePriceDataCallback(info.ExePrice);
130191
+ return data;
130192
+ }
130193
+
130194
+ rtItem={ Left:xRight, Right:xRight+itemWidth, Top:rtRow.Top, Height:rtRow.Height, Bottom:rtRow.Bottom, Width:itemWidth };
130195
+ if (x>=rtItem.Left && x<=rtItem.Right && y>=rtItem.Top && y<=rtItem.Bottom)
130196
+ {
130197
+ var data={ Rect:rtCenter, DataIndex:info.DataIndex, Index:info.Index , ExePrice:info.ExePrice, CellType:2, ColumnIndex:i, Column:item };
130198
+ data.Item=this.GetExePriceDataCallback(info.ExePrice);
130199
+ return data;
130200
+ }
130201
+
130202
+ xRight+=itemWidth;
130203
+ }
130204
+
130205
+ return null;
130206
+ }
130207
+
130208
+ this.PtInHeader=function(x,y)
130209
+ {
130210
+ if (!this.IsShowHeader) return null;
130211
+
130212
+ var left=this.RectClient.Left;
130213
+ var right=this.RectClient.Right;
130214
+ var top=this.RectClient.Top;
130215
+ var bottom=top+this.HeaderHeight;
130216
+
130217
+ if (!(x>=left && x<=right && y>=top && y<=bottom)) return null;
130218
+
130219
+ var rtHeader={Left:left, Right:right, Top:top, Bottom:bottom};
130220
+ rtHeader.Width=rtHeader.Right-rtHeader.Left;
130221
+ rtHeader.Height=rtHeader.Bottom-rtHeader.Top;
130222
+ var data={ RectRow:rtHeader, DataIndex:-1, Index:-1, ExePrice:null };
130223
+ return this.PtInItem(x,y, data);
130224
+ }
130225
+
130226
+ this.SendClickEvent=function(id, data)
130227
+ {
130228
+ var event=this.GetEventCallback(id);
130229
+ if (event && event.Callback)
130230
+ {
130231
+ event.Callback(event,data,this);
130232
+ }
130233
+ }
130234
+
130235
+
130236
+ this.GetCurrentPageStatus=function() //{ Start:起始索引, End:结束索引(数据), PageSize:页面可以显示几条记录, IsEnd:是否是最后一页, IsSinglePage:是否只有一页数据}
130237
+ {
130238
+ var result={ Start:this.Data.YOffset, PageSize:this.RowCount, IsEnd:false, SelectedRow:this.SelectedRow, IsSinglePage:false, DataCount:0 };
130239
+ if (IFrameSplitOperator.IsNonEmptyArray(this.Data.Data))
130240
+ {
130241
+ result.End=this.Data.YOffset+this.RowCount-1;
130242
+ result.IsSinglePage=this.Data.Data.length<=this.RowCount;
130243
+ result.DataCount=this.Data.Data.length;
130244
+ if (result.End>=this.Data.Data.length-1) result.IsEnd=true;
130245
+ if (result.End>=this.Data.Data.length) result.End=this.Data.Data.length-1;
130246
+ }
130247
+ else
130248
+ {
130249
+ result.Start=0;
130250
+ result.End=0;
130251
+ result.IsEnd=true;
130252
+ result.IsSinglePage=true;
130253
+ }
130254
+
130255
+ return result;
130256
+ }
130257
+
130258
+ }
130259
+
130260
+
130261
+ /*
130262
+ Copyright (c) 2018 jones
130263
+
130264
+ http://www.apache.org/licenses/LICENSE-2.0
130265
+
130266
+ 开源项目 https://github.com/jones2000/HQChart
130267
+
130268
+ jones_2000@163.com
130269
+
130270
+ 封装键盘精灵控件 (页面版 不支持手机)
130271
+ */
130272
+
130273
+
130274
+
130275
+ function JSKeyboardChart(divElement)
130276
+ {
130277
+ this.DivElement=divElement;
130278
+ this.JSChartContainer; //表格控件
130279
+
130280
+ //h5 canvas
130281
+ this.CanvasElement=document.createElement("canvas");
130282
+ this.CanvasElement.className='jskeyboard-drawing';
130283
+ this.CanvasElement.id=Guid();
130284
+ this.CanvasElement.setAttribute("tabindex",0);
130285
+ if (this.CanvasElement.style) this.CanvasElement.style.outline='none';
130286
+ if(divElement.hasChildNodes())
130287
+ {
130288
+ JSConsole.Chart.Log("[JSKeyboardChart::JSRepoJSKeyboardChartrtChart] divElement hasChildNodes", divElement.childNodes);
130289
+ }
130290
+ divElement.appendChild(this.CanvasElement);
130291
+
130292
+
130293
+ this.OnSize=function()
130294
+ {
130295
+ //画布大小通过div获取
130296
+ var height=parseInt(this.DivElement.style.height.replace("px",""));
130297
+ this.CanvasElement.height=height;
130298
+ this.CanvasElement.width=parseInt(this.DivElement.style.width.replace("px",""));
130299
+ this.CanvasElement.style.width=this.CanvasElement.width+'px';
130300
+ this.CanvasElement.style.height=this.CanvasElement.height+'px';
130301
+
130302
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
130303
+ this.CanvasElement.height*=pixelTatio;
130304
+ this.CanvasElement.width*=pixelTatio;
130305
+
130306
+ JSConsole.Chart.Log(`[JSKeyboardChart::OnSize] devicePixelRatio=${window.devicePixelRatio}, height=${this.CanvasElement.height}, width=${this.CanvasElement.width}`);
130307
+
130308
+ if (this.JSChartContainer && this.JSChartContainer.OnSize)
130309
+ {
130310
+ this.JSChartContainer.OnSize();
130311
+ }
130312
+ }
130313
+
130314
+ this.SetOption=function(option)
130315
+ {
130316
+ var chart=this.CreateJSKeyboardChartContainer(option);
130317
+
130318
+ if (!chart) return false;
130319
+
130320
+ if (option.OnCreatedCallback) option.OnCreatedCallback(chart);
130321
+
130322
+ this.JSChartContainer=chart;
130323
+ this.DivElement.JSChart=this; //div中保存一份
130324
+
130325
+ chart.Draw();
130326
+ }
130327
+
130328
+ this.CreateJSKeyboardChartContainer=function(option)
130329
+ {
130330
+ var chart=new JSKeyboardChartContainer(this.CanvasElement);
130331
+ chart.Create(option);
130332
+
130333
+ if (option.NetworkFilter) chart.NetworkFilter=option.NetworkFilter;
130334
+ if (IFrameSplitOperator.IsNonEmptyArray(option.Column)) chart.SetColumn(option.Column);
130335
+ if (IFrameSplitOperator.IsNumber(option.BorderLine)) chart.Frame.BorderLine=option.BorderLine;
130336
+
130337
+ this.SetChartBorder(chart, option);
130338
+
130339
+ //注册事件
130340
+ if (option.EventCallback)
130341
+ {
130342
+ for(var i=0;i<option.EventCallback.length;++i)
130343
+ {
130344
+ var item=option.EventCallback[i];
130345
+ chart.AddEventCallback(item);
130346
+ }
130347
+ }
130348
+
130349
+ return chart;
130350
+ }
130351
+
130352
+ this.SetChartBorder=function(chart, option)
130353
+ {
130354
+ if (!option.Border) return;
130355
+
130356
+ var item=option.Border;
130357
+ if (IFrameSplitOperator.IsNumber(option.Border.Left)) chart.Frame.ChartBorder.Left=option.Border.Left;
130358
+ if (IFrameSplitOperator.IsNumber(option.Border.Right)) chart.Frame.ChartBorder.Right=option.Border.Right;
130359
+ if (IFrameSplitOperator.IsNumber(option.Border.Top)) chart.Frame.ChartBorder.Top=option.Border.Top;
130360
+ if (IFrameSplitOperator.IsNumber(option.Border.Bottom)) chart.Frame.ChartBorder.Bottom=option.Border.Bottom;
130361
+
130362
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
130363
+ chart.Frame.ChartBorder.Left*=pixelTatio;
130364
+ chart.Frame.ChartBorder.Right*=pixelTatio;
130365
+ chart.Frame.ChartBorder.Top*=pixelTatio;
130366
+ chart.Frame.ChartBorder.Bottom*=pixelTatio;
130367
+ }
130368
+
130369
+ /////////////////////////////////////////////////////////////////////////////
130370
+ //对外接口
130371
+ this.SetColumn=function(aryColumn, option)
130372
+ {
130373
+ if (this.JSChartContainer) this.JSChartContainer.SetColumn(aryColumn,option);
130374
+ }
130375
+
130376
+ //事件回调
130377
+ this.AddEventCallback=function(obj)
130378
+ {
130379
+ if(this.JSChartContainer && typeof(this.JSChartContainer.AddEventCallback)=='function')
130380
+ {
130381
+ JSConsole.Chart.Log('[JSKeyboardChart:AddEventCallback] obj=', obj);
130382
+ this.JSChartContainer.AddEventCallback(obj);
130383
+ }
130384
+ }
130385
+
130386
+ //重新加载配置
130387
+ this.ReloadResource=function(option)
130388
+ {
130389
+ if(this.JSChartContainer && typeof(this.JSChartContainer.ReloadResource)=='function')
130390
+ {
130391
+ JSConsole.Chart.Log('[JSKeyboardChart:ReloadResource] ');
130392
+ this.JSChartContainer.ReloadResource(option);
130393
+ }
130394
+ }
130395
+
130396
+ this.ChartDestory=function()
130397
+ {
130398
+ if (this.JSChartContainer && typeof (this.JSChartContainer.ChartDestory) == 'function')
130399
+ {
130400
+ this.JSChartContainer.ChartDestory();
130401
+ }
130402
+ }
130403
+
130404
+ this.Draw=function()
130405
+ {
130406
+ if(this.JSChartContainer && typeof(this.JSChartContainer.Draw)=='function')
130407
+ {
130408
+ JSConsole.Chart.Log('[JSKeyboardChart:Draw] ');
130409
+ this.JSChartContainer.Draw();
130410
+ }
130411
+ }
130412
+
130413
+ this.SetSymbolData=function(arySymbol)
130414
+ {
130415
+ if(this.JSChartContainer && typeof(this.JSChartContainer.Draw)=='function')
130416
+ {
130417
+ JSConsole.Chart.Log('[JSKeyboardChart:SetSymbolData] ', arySymbol);
130418
+ this.JSChartContainer.SetSymbolData(arySymbol);
130419
+ }
130420
+ }
130421
+
130422
+ this.Search=function(strText)
130423
+ {
130424
+ if(this.JSChartContainer && typeof(this.JSChartContainer.Search)=='function')
130425
+ {
130426
+ JSConsole.Chart.Log('[JSKeyboardChart:Search] ', strText);
130427
+ this.JSChartContainer.Search(strText);
130428
+ }
130429
+ }
130430
+
130431
+ this.OnKeyDown=function(event)
130432
+ {
130433
+ if(this.JSChartContainer && typeof(this.JSChartContainer.OnKeyDown)=='function')
130434
+ {
130435
+ JSConsole.Chart.Log('[JSKeyboardChart:OnKeyDown] ', event);
130436
+ this.JSChartContainer.OnKeyDown(event);
130437
+ }
130438
+ }
130439
+
130440
+ this.ClearSearch=function(option)
130441
+ {
130442
+ if(this.JSChartContainer && typeof(this.JSChartContainer.ClearSearch)=='function')
130443
+ {
130444
+ JSConsole.Chart.Log('[JSKeyboardChart:ClearSearch] ', option);
130445
+ this.JSChartContainer.ClearSearch(option);
130446
+ }
130447
+ }
130448
+ }
130449
+
130450
+ JSKeyboardChart.Init=function(divElement)
130451
+ {
130452
+ var jsChartControl=new JSKeyboardChart(divElement);
130453
+ jsChartControl.OnSize();
130454
+
130455
+ return jsChartControl;
130456
+ }
130457
+
130458
+ //自定义风格
130459
+ JSKeyboardChart.SetStyle=function(option)
130460
+ {
130461
+ if (option) g_JSChartResource.SetStyle(option);
130462
+ }
130463
+
130464
+
130465
+ function JSKeyboardChartContainer(uielement)
130466
+ {
130467
+ this.ClassName='JSKeyboardChartContainer';
130468
+ this.Frame; //框架画法
130469
+ this.ChartPaint=[]; //图形画法
130470
+ this.Canvas=uielement.getContext("2d"); //画布
130471
+ this.ShowCanvas=null;
130472
+
130473
+ this.NetworkFilter; //数据回调接口
130474
+ this.Data={ XOffset:0, YOffset:0, Data:[] }; //股票列表
130475
+ this.MapSymbol=new Map();
130476
+ this.SourceData={ Data:[] } //码表数据 Data:[ { Symbol:, Spell, Name:, Color:}]
130477
+
130478
+ //事件回调
130479
+ this.mapEvent=new Map(); //通知外部调用 key:JSCHART_EVENT_ID value:{Callback:回调,}
130480
+
130481
+ this.UIElement=uielement;
130482
+ this.LastPoint=new Point(); //鼠标位置
130483
+
130484
+ //拖拽滚动条
130485
+ this.DragYScroll=null; //{Start:{x,y}, End:{x, y}}
130486
+ this.IsDestroy=false; //是否已经销毁了
130487
+
130488
+ this.ChartDestory=function() //销毁
130489
+ {
130490
+ this.IsDestroy=true;
130491
+ }
130492
+
130493
+ this.ClearSearch=function(option)
130494
+ {
130495
+ this.Data.Data=[];
130496
+ this.Data.XOffset=0;
130497
+ this.Data.YOffset=0;
130498
+
130499
+ if (option && option.Redraw==true) this.Draw();
130500
+ }
130501
+
130502
+ this.Search=function(strText)
130503
+ {
130504
+ var aryExactQuery=[]; //精确查询
130505
+ var aryFuzzyQuery=[]; //模糊查询
130506
+ this.MapSymbol.clear();
130507
+ this.Data.Data=[];
130508
+ this.Data.XOffset=0;
130509
+ this.Data.YOffset=0;
130510
+
130511
+ var strSearch=strText.trim();
130512
+ if (strSearch.length>0)
130513
+ {
130514
+ for(var i=0;i<this.SourceData.Data.length;++i)
130515
+ {
130516
+ var item=this.SourceData.Data[i];
130517
+ if (this.SearchSymbol(item, strSearch, aryExactQuery, aryFuzzyQuery)) continue;
130518
+ else if (this.SearchSpell(item, strSearch, aryExactQuery, aryFuzzyQuery)) continue;
130519
+ }
130520
+ }
130521
+
130522
+ if (IFrameSplitOperator.IsNonEmptyArray(aryExactQuery) || IFrameSplitOperator.IsNonEmptyArray(aryFuzzyQuery))
130523
+ this.Data.Data=aryExactQuery.concat(aryFuzzyQuery);
130524
+
130525
+ this.ChartPaint[0].SelectedRow=0;
130526
+
130527
+ JSConsole.Chart.Log(`[JSKeyboardChart:Search] search=${strSearch}, source=${this.SourceData.Data.length} match=${this.Data.Data.length}`);
130528
+
130529
+ this.Draw();
130530
+ }
130531
+
130532
+ this.SearchSymbol=function(item, strText, aryExactQuery, aryFuzzyQuery)
130533
+ {
130534
+ var find=item.Symbol.indexOf(strText);
130535
+ if (find<0) return false;
130536
+
130537
+ if (find==0) aryExactQuery.push(item.Symbol);
130538
+ else aryFuzzyQuery.push(item.Symbol);
130539
+
130540
+ this.MapSymbol.set(item.Symbol, item);
130541
+
130542
+ return true;
130543
+ }
130544
+
130545
+ this.SearchSpell=function(item, strText, aryExactQuery, aryFuzzyQuery)
130546
+ {
130547
+ if (!IFrameSplitOperator.IsString(item.Spell)) return false;
130548
+
130549
+ var find=item.Spell.indexOf(strText);
130550
+
130551
+ if (find!=0) return false;
130552
+
130553
+ aryExactQuery.push(item.Symbol);
130554
+ this.MapSymbol.set(item.Symbol, item);
130555
+
130556
+ return true;
130557
+ }
130558
+
130559
+
130560
+ this.SetSymbolData=function(arySymbol)
130561
+ {
130562
+ this.SourceData.Data=arySymbol;
130563
+
130564
+ /*
130565
+ //测试
130566
+ this.MapSymbol.clear();
130567
+ for(var i=0;i<this.SourceData.Data.length && i<3050 ;++i)
130568
+ {
130569
+ var item=this.SourceData.Data[i];
130570
+ this.Data.Data.push(item.Symbol);
130571
+ this.MapSymbol.set(item.Symbol, item);
130572
+ }
130573
+ this.ChartPaint[0].SelectedRow=0;
130574
+ */
130575
+ }
130576
+
130577
+ //创建
130578
+ this.Create=function(option)
130579
+ {
130580
+ this.UIElement.JSChartContainer=this;
130581
+
130582
+ //创建框架
130583
+ this.Frame=new JSKeyboardFrame();
130584
+ this.Frame.ChartBorder=new ChartBorder();
130585
+ this.Frame.ChartBorder.UIElement=this.UIElement;
130586
+ this.Frame.ChartBorder.Top=30;
130587
+ this.Frame.ChartBorder.Left=5;
130588
+ this.Frame.ChartBorder.Bottom=20;
130589
+ this.Frame.Canvas=this.Canvas;
130590
+
130591
+ //创建表格
130592
+ var chart=new ChartSymbolList();
130593
+ chart.Frame=this.Frame;
130594
+ chart.ChartBorder=this.Frame.ChartBorder;
130595
+ chart.Canvas=this.Canvas;
130596
+ chart.UIElement=this.UIElement;
130597
+ chart.GetEventCallback=(id)=> { return this.GetEventCallback(id); }
130598
+ chart.GetStockDataCallback=(symbol)=>{ return this.GetStockData(symbol);}
130599
+ chart.Data=this.Data;
130600
+ this.ChartPaint[0]=chart;
130601
+
130602
+ if (option)
130603
+ {
130604
+
130605
+ }
130606
+
130607
+ var bRegisterKeydown=true;
130608
+ var bRegisterWheel=true;
130609
+
130610
+ if (option)
130611
+ {
130612
+ if (option.KeyDown===false)
130613
+ {
130614
+ bRegisterKeydown=false;
130615
+ JSConsole.Chart.Log('[JSKeyboardChartContainer::Create] not register keydown event.');
130616
+ }
130617
+
130618
+ if (option.Wheel===false)
130619
+ {
130620
+ bRegisterWheel=false;
130621
+ JSConsole.Chart.Log('[JSKeyboardChartContainer::Create] not register wheel event.');
130622
+ }
130623
+ }
130624
+
130625
+ if (bRegisterKeydown) this.UIElement.addEventListener("keydown", (e)=>{ this.OnKeyDown(e); }, true); //键盘消息
130626
+ if (bRegisterWheel) this.UIElement.addEventListener("wheel", (e)=>{ this.OnWheel(e); }, true); //上下滚动消息
130627
+
130628
+
130629
+ this.UIElement.ondblclick=(e)=>{ this.UIOnDblClick(e); }
130630
+ this.UIElement.onmousedown=(e)=> { this.UIOnMouseDown(e); }
130631
+ this.UIElement.oncontextmenu=(e)=> { this.UIOnContextMenu(e); }
130632
+ this.UIElement.onmousemove=(e)=>{ this.UIOnMouseMove(e);}
130633
+ this.UIElement.onmouseout=(e)=>{ this.UIOnMounseOut(e); }
130634
+ this.UIElement.onmouseleave=(e)=>{ this.UIOnMouseleave(e); }
130635
+ }
130636
+
130637
+ this.Draw=function()
130638
+ {
130639
+ if (this.UIElement.width<=0 || this.UIElement.height<=0) return;
130640
+
130641
+ this.Canvas.clearRect(0,0,this.UIElement.width,this.UIElement.height);
130642
+ var pixelTatio = GetDevicePixelRatio(); //获取设备的分辨率
130643
+ this.Canvas.lineWidth=pixelTatio; //手机端需要根据分辨率比调整线段宽度
130644
+
130645
+ this.Frame.Draw();
130646
+ this.Frame.DrawLogo();
130647
+
130648
+ //框架内图形
130649
+ for(var i=0;i<this.ChartPaint.length;++i)
130650
+ {
130651
+ var item=this.ChartPaint[i];
130652
+ if (item.IsDrawFirst)
130653
+ item.Draw();
130654
+ }
130655
+
130656
+ for(var i=0; i<this.ChartPaint.length; ++i)
130657
+ {
130658
+ var item=this.ChartPaint[i];
130659
+ if (!item.IsDrawFirst)
130660
+ item.Draw();
130661
+ }
130662
+ }
130663
+
130664
+ this.GetStockData=function(symbol)
130665
+ {
130666
+ if (!this.MapSymbol.has(symbol)) return null;
130667
+
130668
+ return this.MapSymbol.get(symbol);
130669
+ }
130670
+
130671
+
130672
+ this.ResetStatus=function()
130673
+ {
130674
+ this.Data.XOffset=0;
130675
+ this.Data.YOffset=0;
130676
+ }
130677
+
130678
+ this.ResetSelectStatus=function()
130679
+ {
130680
+ var chart=this.GetReportChart();
130681
+ if (chart)
130682
+ {
130683
+ chart.SelectedRow=-1;
130684
+ chart.SelectedFixedRow=-1;
130685
+ }
128263
130686
  }
128264
130687
 
128265
130688
  //设置事件回调
@@ -130967,7 +133390,7 @@ function HQChartScriptWorker()
130967
133390
 
130968
133391
 
130969
133392
 
130970
- var HQCHART_VERSION="1.1.13080";
133393
+ var HQCHART_VERSION="1.1.13083";
130971
133394
 
130972
133395
  function PrintHQChartVersion()
130973
133396
  {
@@ -131048,6 +133471,10 @@ export default {
131048
133471
  JSReportChart:JSReportChart,
131049
133472
  REPORT_COLUMN_ID:REPORT_COLUMN_ID,
131050
133473
 
133474
+ //T型报价
133475
+ JSTReportChart:JSTReportChart,
133476
+ TREPORT_COLUMN_ID:TREPORT_COLUMN_ID,
133477
+
131051
133478
  //键盘精灵
131052
133479
  JSKeyboardChart:JSKeyboardChart,
131053
133480
  KEYBOARD_COLUMN_ID:KEYBOARD_COLUMN_ID,