hqchart 1.1.13062 → 1.1.13068

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.
@@ -9168,7 +9168,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
9168
9168
  var item=this.ExtendChartPaint[i];
9169
9169
  if (item.IsCallbackDraw)
9170
9170
  {
9171
- if (["KLineYAxisBGPaint","DepthMapPaint","BackgroundPaint","MinuteBackgroundPaint"].includes(item.ClassName))
9171
+ if (["KLineYAxisBGPaint","DepthMapPaint","BackgroundPaint","MinuteBackgroundPaint", "SessionBreaksPaint"].includes(item.ClassName))
9172
9172
  {
9173
9173
  if (item.FrameID==frame.Identify) item.Draw();
9174
9174
  }
@@ -14775,16 +14775,9 @@ function AverageWidthFrame()
14775
14775
  }
14776
14776
  }
14777
14777
 
14778
- if (item.BG && item.BG.Color)
14779
- {
14780
- var bgItem=item.BG;
14781
- this.Canvas.fillStyle=bgItem.Color;
14782
- var xStart=this.GetXFromIndex(bgItem.Index.Start);
14783
- var xEnd=this.GetXFromIndex(bgItem.Index.End);
14784
- var bgHeight=this.ChartBorder.Bottom;
14785
- if (IFrameSplitOperator.IsNumber(bgItem.Height)) bgHeight=bgItem.Height;
14786
- var rtBG={Left:xStart, Width:xEnd-xStart, Top:border.Bottom, Height: bgHeight };
14787
- this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
14778
+ if (item.BG && this.DrawDayVertical)
14779
+ {
14780
+ this.DrawDayVertical(item, x, border);
14788
14781
  }
14789
14782
 
14790
14783
  if (this.VerticalInfo[i].Message[0]!=null)
@@ -16337,6 +16330,67 @@ function MinuteFrame()
16337
16330
  }
16338
16331
  }
16339
16332
 
16333
+ this.DrawDayVertical=function(dayItem, x, border)
16334
+ {
16335
+ if (!dayItem.BG) return;
16336
+
16337
+ var bgItem=dayItem.BG;
16338
+ var xStart=this.GetXFromIndex(bgItem.Index.Start);
16339
+ var xEnd=this.GetXFromIndex(bgItem.Index.End);
16340
+ var maxWidth=xEnd-xStart;
16341
+ var bgHeight=this.ChartBorder.Bottom;
16342
+ if (IFrameSplitOperator.IsNumber(bgItem.Height)) bgHeight=bgItem.Height;
16343
+
16344
+ if (bgItem.Color)
16345
+ {
16346
+ this.Canvas.fillStyle=bgItem.Color;
16347
+ var rtBG={Left:xStart, Width:maxWidth, Top:border.Bottom, Height: bgHeight };
16348
+ this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
16349
+ }
16350
+
16351
+ if (IFrameSplitOperator.IsNonEmptyArray(dayItem.AryText)) //[ [{Text:, Color:},], []]
16352
+ {
16353
+ this.Canvas.textAlign="left";
16354
+ this.Canvas.textBaseline="top";
16355
+ var yText=border.Bottom+2;
16356
+ var lineHeight=this.Canvas.measureText("擎").width+2;
16357
+ for(var i=0,j=0;i<dayItem.AryText.length;++i)
16358
+ {
16359
+ var aryText=dayItem.AryText[i];
16360
+ var itemWidth=0;
16361
+ var aryOut=[];
16362
+ for(j=0;j<aryText.length;++j)
16363
+ {
16364
+ var item=aryText[j];
16365
+ var textWidth=this.Canvas.measureText(item.Text).width;
16366
+ if (itemWidth+textWidth>maxWidth) break;
16367
+
16368
+ var newItem={ Text:item.Text, Width:textWidth, Color:item.Color, Space:item.Space };
16369
+ itemWidth+=textWidth;
16370
+ item.Width=textWidth;
16371
+ if (item.Space>=1) itemWidth+=item.Space;
16372
+ aryOut.push(newItem);
16373
+ }
16374
+
16375
+ var xText=xStart+(maxWidth-itemWidth)/2;
16376
+ for(var j=0;j<aryOut.length;++j)
16377
+ {
16378
+ var item=aryOut[j];
16379
+ if (!IFrameSplitOperator.IsNumber(item.Width)) break;
16380
+ if (item.Color) this.Canvas.fillStyle=item.Color;
16381
+ else if (dayItem.TextColor) this.Canvas.fillStyle=dayItem.TextColor;
16382
+
16383
+ this.Canvas.fillText(item.Text,xText,yText);
16384
+ xText+=item.Width;
16385
+ if (item.Space>=1) xText+=item.Space;
16386
+ }
16387
+
16388
+ yText+=lineHeight;
16389
+ }
16390
+ }
16391
+
16392
+ }
16393
+
16340
16394
  //分割x,y轴坐标信息
16341
16395
  this.SplitXYCoordinate=function()
16342
16396
  {
@@ -42877,7 +42931,8 @@ function ExtendChartPaintFactory()
42877
42931
  [
42878
42932
  ["FrameSplitPaint", { Create:function() { return new FrameSplitPaint(); } }],
42879
42933
  ["RectSelectPaint", { Create:function() { return new RectSelectPaint(); } }],
42880
- ["DragMovePaint", { Create:function() { return new DragMovePaint(); } }]
42934
+ ["DragMovePaint", { Create:function() { return new DragMovePaint(); } }],
42935
+ ["SessionBreaksPaint", { Create:function() { return new SessionBreaksPaint(); }}]
42881
42936
  ]
42882
42937
  );
42883
42938
 
@@ -47135,6 +47190,266 @@ function DragMovePaint()
47135
47190
  }
47136
47191
 
47137
47192
 
47193
+ function SessionBreaksPaint()
47194
+ {
47195
+ this.newMethod=IExtendChartPainting; //派生
47196
+ this.newMethod();
47197
+ delete this.newMethod;
47198
+
47199
+ this.ClassName='SessionBreaksPaint';
47200
+ this.IsDynamic=false;
47201
+ this.IsCallbackDraw=true; //在回调函数里绘制, 不在Draw()中绘制
47202
+ this.FrameID=0;
47203
+ this.KDataFeature; //数据特征 { Symbol, Period, DataCount }
47204
+ this.Data;
47205
+ this.ChartFrame;
47206
+
47207
+ this.BGColor=g_JSChartResource.SessionBreaksPaint.BGColor.slice();
47208
+ this.SplitLine=
47209
+ {
47210
+ Color:g_JSChartResource.SessionBreaksPaint.SplitLine.Color,
47211
+ Width:g_JSChartResource.SessionBreaksPaint.SplitLine.Width,
47212
+ Dash:g_JSChartResource.SessionBreaksPaint.SplitLine.Dash
47213
+ };
47214
+
47215
+ this.MapPeriod=new Map(
47216
+ [
47217
+ [0, { SplitType:1 }], //日
47218
+ [1, { SplitType:1 }], //周
47219
+ [2, { SplitType:2 }], //月
47220
+ [21, { SplitType:2 }], //双周
47221
+
47222
+ [4, { SplitType:3 }], //1分钟
47223
+ [5, { SplitType:3 }], //5分钟
47224
+ [6, { SplitType:3 }], //15分钟
47225
+ [7, { SplitType:3 }],
47226
+ [8, { SplitType:3 }],
47227
+ ]); //周期和分割对应关系
47228
+
47229
+ this.SetOption=function(option) //设置
47230
+ {
47231
+ if (option.FrameID>0) this.FrameID=option.FrameID;
47232
+ }
47233
+
47234
+ this.Draw=function()
47235
+ {
47236
+ if (!this.HQChart) return;
47237
+ var hisData=this.HQChart.ChartOperator_Temp_GetHistroyData();;
47238
+ if (!hisData) return; //数据还没有到达
47239
+ if (!IFrameSplitOperator.IsNonEmptyArray(hisData.Data)) return;
47240
+
47241
+ if (this.IsKDataChange(hisData))
47242
+ {
47243
+ this.BuildCacheData(hisData);
47244
+ }
47245
+
47246
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data)) return;
47247
+
47248
+ var mainFrame=this.HQChart.Frame.SubFrame[0].Frame;
47249
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
47250
+ var dataWidth=mainFrame.DataWidth;
47251
+ var distanceWidth=mainFrame.DistanceWidth;
47252
+ var xPointCount=mainFrame.XPointCount;
47253
+
47254
+ if (bHScreen)
47255
+ {
47256
+ var border=this.ChartBorder.GetHScreenBorder();
47257
+ var chartright=border.BottomEx;
47258
+ var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
47259
+ }
47260
+ else
47261
+ {
47262
+ var border=this.ChartBorder.GetBorder();
47263
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
47264
+ var chartright=border.RightEx;
47265
+ }
47266
+
47267
+ var preID=null;
47268
+ var aryBG=[];
47269
+ var bgItem=null;
47270
+ for(var i=hisData.DataOffset,j=0;i<hisData.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
47271
+ {
47272
+ var item=this.Data[i];
47273
+ if (!item) continue;
47274
+
47275
+ var left=xOffset;
47276
+ var right=xOffset+dataWidth;
47277
+ if (right>chartright) break;
47278
+ var x=left+(right-left)/2;
47279
+
47280
+ var xStart=left-distanceWidth/2;
47281
+ var xEnd=right+distanceWidth/2;
47282
+
47283
+ var id=item.ID;
47284
+ if (!IFrameSplitOperator.IsNumber(id)) continue;
47285
+
47286
+ if (preID==null)
47287
+ {
47288
+ bgItem={ Start:{ X:xStart }, End:{ X:xEnd }, ColorIndex:id, Count:1, IsStart:false, IsEnd:false };
47289
+ preID=id;
47290
+ if (i-1>=0)
47291
+ {
47292
+ var preItem=this.Data[i-1];
47293
+ if (preItem && preItem.ID!=id) bgItem.IsStart=true;
47294
+ }
47295
+ }
47296
+ else if (preID!=id)
47297
+ {
47298
+ bgItem.End.X=xStart;
47299
+ bgItem.IsEnd=true;
47300
+ aryBG.push(bgItem);
47301
+
47302
+ bgItem={ Start:{ X:xStart }, End:{ X:xEnd }, ColorIndex:id, Count:1, IsStart:true, IsEnd:false };
47303
+ preID=id;
47304
+ }
47305
+ else
47306
+ {
47307
+ bgItem.End.X=xEnd;
47308
+ ++bgItem.Count;
47309
+ }
47310
+ }
47311
+
47312
+ if (bgItem && bgItem.Count>=2) aryBG.push(bgItem);
47313
+
47314
+ this.Canvas.save();
47315
+ this.DrawBG(aryBG);
47316
+ this.Canvas.restore();
47317
+ }
47318
+
47319
+ this.DrawBG=function(aryBG)
47320
+ {
47321
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryBG)) return;
47322
+
47323
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
47324
+ if (bHScreen)
47325
+ {
47326
+ var border=this.ChartBorder.GetHScreenBorder();
47327
+ var top=border.RightEx;
47328
+ var bottom=border.Left;
47329
+ var height=bottom-top;
47330
+ }
47331
+ else
47332
+ {
47333
+ var border=this.ChartBorder.GetBorder();
47334
+ var top=border.TopEx;
47335
+ var bottom=border.BottomEx;
47336
+ var height=bottom-top;
47337
+ }
47338
+
47339
+
47340
+ var bDrawSplitLine=false;
47341
+ if (this.SplitLine.Color) bDrawSplitLine=true;
47342
+ var lineCount=0;
47343
+ for(var i=0;i<aryBG.length;++i)
47344
+ {
47345
+ var item=aryBG[i];
47346
+ var xLeft=item.Start.X;
47347
+ var xRight=item.End.X;
47348
+
47349
+ var index=item.ColorIndex%this.BGColor.length;
47350
+ var bgColor=this.BGColor[index];
47351
+ if (bgColor)
47352
+ {
47353
+ this.Canvas.fillStyle=bgColor;
47354
+ if (bHScreen)
47355
+ this.Canvas.fillRect(ToFixedPoint(top),ToFixedPoint(xLeft),ToFixedRect(height),ToFixedRect(xRight-xLeft));
47356
+ else
47357
+ this.Canvas.fillRect(ToFixedPoint(xLeft),ToFixedPoint(top),ToFixedRect(xRight-xLeft),ToFixedRect(height));
47358
+ }
47359
+
47360
+ if (bDrawSplitLine && item.IsStart)
47361
+ {
47362
+ if (lineCount==0) this.Canvas.beginPath();
47363
+ if (bHScreen)
47364
+ {
47365
+ this.Canvas.moveTo(top, ToFixedPoint(xLeft));
47366
+ this.Canvas.lineTo(bottom, ToFixedPoint(xLeft));
47367
+ }
47368
+ else
47369
+ {
47370
+ this.Canvas.moveTo(ToFixedPoint(xLeft), top);
47371
+ this.Canvas.lineTo(ToFixedPoint(xLeft), bottom);
47372
+ }
47373
+
47374
+ ++lineCount;
47375
+ }
47376
+ }
47377
+
47378
+ if (bDrawSplitLine && lineCount>=1)
47379
+ {
47380
+ if (this.SplitLine.Width>=1) this.Canvas.linewidth=this.SplitLine.Width;
47381
+ if (this.SplitLine.Dash) this.Canvas.setLineDash(this.SplitLine.Dash);
47382
+ if (this.SplitLine.Color) this.Canvas.strokeStyle=this.SplitLine.Color;
47383
+
47384
+ this.Canvas.stroke();
47385
+ }
47386
+ }
47387
+
47388
+ this.IsKDataChange=function(hisData)
47389
+ {
47390
+ if (!this.KDataFeature) return true;
47391
+
47392
+ if (this.KDataFeature.Symbol!=this.HQChart.Symbol) return true;
47393
+ if (this.KDataFeature.Period!=this.HQChart.Period) return true;
47394
+ if (this.KDataFeature.DataCount!=hisData.Data.length) return true;
47395
+
47396
+ return false;
47397
+ }
47398
+
47399
+ this.BuildCacheData=function(hisData)
47400
+ {
47401
+ var period=this.HQChart.Period;
47402
+ if (!this.MapPeriod.has(period))
47403
+ {
47404
+ this.Data=[];
47405
+ this.KDataFeature={ Symbol:this.HQChart.Symbol, Period:period, DataCount:hisData.Data.length };
47406
+ return;
47407
+ }
47408
+
47409
+ var splitType=this.MapPeriod.get(period).SplitType; //1=month 2=year 3=day 4=1hour
47410
+
47411
+ var startDate=0;
47412
+ var index=-1;
47413
+ this.Data=[];
47414
+ for(var i=0;i<hisData.Data.length;++i)
47415
+ {
47416
+ var item=hisData.Data[i];
47417
+ switch(splitType)
47418
+ {
47419
+ case 1: //月
47420
+ if (parseInt(item.Date/100)!=parseInt(startDate/100))
47421
+ {
47422
+ startDate=item.Date;
47423
+ ++index;
47424
+ }
47425
+ this.Data.push({ ID:index, Date:item.Date });
47426
+ break;
47427
+ case 2: //年
47428
+ if (parseInt(item.Date/10000)!=parseInt(startDate/10000))
47429
+ {
47430
+ startDate=item.Date;
47431
+ ++index;
47432
+ }
47433
+ this.Data.push({ ID:index, Date:item.Date });
47434
+ break;
47435
+ case 3: //日
47436
+ if (item.Date!=startDate)
47437
+ {
47438
+ startDate=item.Date;
47439
+ ++index;
47440
+ }
47441
+ this.Data.push({ ID:index, Date:item.Date });
47442
+ break;
47443
+ }
47444
+
47445
+ }
47446
+
47447
+
47448
+ this.KDataFeature={ Symbol:this.HQChart.Symbol, Period:period, DataCount:hisData.Data.length };
47449
+ }
47450
+ }
47451
+
47452
+
47138
47453
 
47139
47454
  //弹幕数据 { X:X偏移, Y:Y偏移, Text:内容, Color:颜色 }
47140
47455
  function BarrageList()
@@ -67380,6 +67695,12 @@ function JSChartResource()
67380
67695
  Font:14*GetDevicePixelRatio() +"px 微软雅黑"
67381
67696
  }
67382
67697
 
67698
+ this.SessionBreaksPaint=
67699
+ {
67700
+ BGColor:[null, "rgb(245,246,246)"],
67701
+ SplitLine:{ Color:'rgb(73,133,231)', Width:1*GetDevicePixelRatio(), Dash:[5*GetDevicePixelRatio(),5*GetDevicePixelRatio()] }
67702
+ }
67703
+
67383
67704
 
67384
67705
  //成交明细
67385
67706
  this.DealList=
@@ -68324,6 +68645,19 @@ function JSChartResource()
68324
68645
  if (item.Font) this.DragMovePaint.Font=item.Font;
68325
68646
  }
68326
68647
 
68648
+ if (style.SessionBreaksPaint)
68649
+ {
68650
+ var item=style.SessionBreaksPaint;
68651
+ if (IFrameSplitOperator.IsNonEmptyArray(item.BGColor)) this.SessionBreaksPaint.BGColor=item.BGColor.slice();
68652
+ if (item.SplitLine)
68653
+ {
68654
+ var subItem=item.SplitLine;
68655
+ if (subItem.Color) this.SessionBreaksPaint.SplitLine.Color=subItem.Color;
68656
+ if (IFrameSplitOperator.IsNumber(subItem.Width)) this.SessionBreaksPaint.SplitLine.Width=subItem.Width;
68657
+ this.SessionBreaksPaint.SplitLine.Dash=subItem.Dash;
68658
+ }
68659
+ }
68660
+
68327
68661
  if (IFrameSplitOperator.IsNumber(style.ToolbarButtonStyle)) this.ToolbarButtonStyle=style.ToolbarButtonStyle;
68328
68662
 
68329
68663
  if (style.Buttons)
@@ -88710,6 +89044,39 @@ function KLineRightMenu(divElement)
88710
89044
  return data;
88711
89045
  }
88712
89046
 
89047
+ this.GetBGSplit=function(chart)
89048
+ {
89049
+ var data=
89050
+ [
89051
+ {
89052
+ text: "启用",
89053
+ click: function ()
89054
+ {
89055
+ chart.CreateExtendChart("SessionBreaksPaint", { });
89056
+ chart.Draw();
89057
+ }
89058
+ },
89059
+ {
89060
+ text: "关闭",
89061
+ click: function ()
89062
+ {
89063
+ var finder=chart.GetExtendChartByClassName("SessionBreaksPaint");
89064
+ if (finder)
89065
+ {
89066
+ chart.DeleteExtendChartByID(finder.Chart.ID);
89067
+ chart.Draw();
89068
+ }
89069
+ }
89070
+ },
89071
+ ];
89072
+
89073
+ var finder=chart.GetExtendChartByClassName("SessionBreaksPaint");
89074
+ if (finder) data[0].selected=true;
89075
+ else data[1].selected=true;
89076
+
89077
+ return data;
89078
+ }
89079
+
88713
89080
 
88714
89081
  this.GetKLineInfo=function(chart)
88715
89082
  {
@@ -88816,6 +89183,10 @@ function KLineRightMenu(divElement)
88816
89183
  {
88817
89184
  text:"工具",
88818
89185
  children:this.GetTools(chart)
89186
+ },
89187
+ {
89188
+ text:"背景分割",
89189
+ children:this.GetBGSplit(chart)
88819
89190
  }
88820
89191
  ];
88821
89192
 
@@ -119892,6 +120263,12 @@ function GetBlackStyle()
119892
120263
  TextColor:"rgb(255,255,255)",
119893
120264
  //Font:14*GetDevicePixelRatio() +"px 微软雅黑"
119894
120265
  },
120266
+
120267
+ SessionBreaksPaint:
120268
+ {
120269
+ BGColor:[null, "rgb(42,46,57)"],
120270
+ SplitLine:{ Color:'rgb(73,133,231)', Width:1*GetDevicePixelRatio(), Dash:[5*GetDevicePixelRatio(),5*GetDevicePixelRatio()] }
120271
+ },
119895
120272
 
119896
120273
  //成交明细
119897
120274
  DealList:
@@ -130350,7 +130727,7 @@ function ScrollBarBGChart()
130350
130727
 
130351
130728
 
130352
130729
 
130353
- var HQCHART_VERSION="1.1.13061";
130730
+ var HQCHART_VERSION="1.1.13067";
130354
130731
 
130355
130732
  function PrintHQChartVersion()
130356
130733
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var HQCHART_VERSION="1.1.13061";
8
+ var HQCHART_VERSION="1.1.13067";
9
9
 
10
10
  function PrintHQChartVersion()
11
11
  {