hqchart 1.1.13062 → 1.1.13065

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.
@@ -5276,7 +5276,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
5276
5276
  var item=this.ExtendChartPaint[i];
5277
5277
  if (item.IsCallbackDraw)
5278
5278
  {
5279
- if (["KLineYAxisBGPaint","DepthMapPaint","BackgroundPaint","MinuteBackgroundPaint"].includes(item.ClassName))
5279
+ if (["KLineYAxisBGPaint","DepthMapPaint","BackgroundPaint","MinuteBackgroundPaint", "SessionBreaksPaint"].includes(item.ClassName))
5280
5280
  {
5281
5281
  if (item.FrameID==frame.Identify) item.Draw();
5282
5282
  }
@@ -38985,7 +38985,8 @@ function ExtendChartPaintFactory()
38985
38985
  [
38986
38986
  ["FrameSplitPaint", { Create:function() { return new FrameSplitPaint(); } }],
38987
38987
  ["RectSelectPaint", { Create:function() { return new RectSelectPaint(); } }],
38988
- ["DragMovePaint", { Create:function() { return new DragMovePaint(); } }]
38988
+ ["DragMovePaint", { Create:function() { return new DragMovePaint(); } }],
38989
+ ["SessionBreaksPaint", { Create:function() { return new SessionBreaksPaint(); }}]
38989
38990
  ]
38990
38991
  );
38991
38992
 
@@ -43243,6 +43244,266 @@ function DragMovePaint()
43243
43244
  }
43244
43245
 
43245
43246
 
43247
+ function SessionBreaksPaint()
43248
+ {
43249
+ this.newMethod=IExtendChartPainting; //派生
43250
+ this.newMethod();
43251
+ delete this.newMethod;
43252
+
43253
+ this.ClassName='SessionBreaksPaint';
43254
+ this.IsDynamic=false;
43255
+ this.IsCallbackDraw=true; //在回调函数里绘制, 不在Draw()中绘制
43256
+ this.FrameID=0;
43257
+ this.KDataFeature; //数据特征 { Symbol, Period, DataCount }
43258
+ this.Data;
43259
+ this.ChartFrame;
43260
+
43261
+ this.BGColor=g_JSChartResource.SessionBreaksPaint.BGColor.slice();
43262
+ this.SplitLine=
43263
+ {
43264
+ Color:g_JSChartResource.SessionBreaksPaint.SplitLine.Color,
43265
+ Width:g_JSChartResource.SessionBreaksPaint.SplitLine.Width,
43266
+ Dash:g_JSChartResource.SessionBreaksPaint.SplitLine.Dash
43267
+ };
43268
+
43269
+ this.MapPeriod=new Map(
43270
+ [
43271
+ [0, { SplitType:1 }], //日
43272
+ [1, { SplitType:1 }], //周
43273
+ [2, { SplitType:2 }], //月
43274
+ [21, { SplitType:2 }], //双周
43275
+
43276
+ [4, { SplitType:3 }], //1分钟
43277
+ [5, { SplitType:3 }], //5分钟
43278
+ [6, { SplitType:3 }], //15分钟
43279
+ [7, { SplitType:3 }],
43280
+ [8, { SplitType:3 }],
43281
+ ]); //周期和分割对应关系
43282
+
43283
+ this.SetOption=function(option) //设置
43284
+ {
43285
+ if (option.FrameID>0) this.FrameID=option.FrameID;
43286
+ }
43287
+
43288
+ this.Draw=function()
43289
+ {
43290
+ if (!this.HQChart) return;
43291
+ var hisData=this.HQChart.ChartOperator_Temp_GetHistroyData();;
43292
+ if (!hisData) return; //数据还没有到达
43293
+ if (!IFrameSplitOperator.IsNonEmptyArray(hisData.Data)) return;
43294
+
43295
+ if (this.IsKDataChange(hisData))
43296
+ {
43297
+ this.BuildCacheData(hisData);
43298
+ }
43299
+
43300
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data)) return;
43301
+
43302
+ var mainFrame=this.HQChart.Frame.SubFrame[0].Frame;
43303
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
43304
+ var dataWidth=mainFrame.DataWidth;
43305
+ var distanceWidth=mainFrame.DistanceWidth;
43306
+ var xPointCount=mainFrame.XPointCount;
43307
+
43308
+ if (bHScreen)
43309
+ {
43310
+ var border=this.ChartBorder.GetHScreenBorder();
43311
+ var chartright=border.BottomEx;
43312
+ var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
43313
+ }
43314
+ else
43315
+ {
43316
+ var border=this.ChartBorder.GetBorder();
43317
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
43318
+ var chartright=border.RightEx;
43319
+ }
43320
+
43321
+ var preID=null;
43322
+ var aryBG=[];
43323
+ var bgItem=null;
43324
+ for(var i=hisData.DataOffset,j=0;i<hisData.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
43325
+ {
43326
+ var item=this.Data[i];
43327
+ if (!item) continue;
43328
+
43329
+ var left=xOffset;
43330
+ var right=xOffset+dataWidth;
43331
+ if (right>chartright) break;
43332
+ var x=left+(right-left)/2;
43333
+
43334
+ var xStart=left-distanceWidth/2;
43335
+ var xEnd=right+distanceWidth/2;
43336
+
43337
+ var id=item.ID;
43338
+ if (!IFrameSplitOperator.IsNumber(id)) continue;
43339
+
43340
+ if (preID==null)
43341
+ {
43342
+ bgItem={ Start:{ X:xStart }, End:{ X:xEnd }, ColorIndex:id, Count:1, IsStart:false, IsEnd:false };
43343
+ preID=id;
43344
+ if (i-1>=0)
43345
+ {
43346
+ var preItem=this.Data[i-1];
43347
+ if (preItem && preItem.ID!=id) bgItem.IsStart=true;
43348
+ }
43349
+ }
43350
+ else if (preID!=id)
43351
+ {
43352
+ bgItem.End.X=xStart;
43353
+ bgItem.IsEnd=true;
43354
+ aryBG.push(bgItem);
43355
+
43356
+ bgItem={ Start:{ X:xStart }, End:{ X:xEnd }, ColorIndex:id, Count:1, IsStart:true, IsEnd:false };
43357
+ preID=id;
43358
+ }
43359
+ else
43360
+ {
43361
+ bgItem.End.X=xEnd;
43362
+ ++bgItem.Count;
43363
+ }
43364
+ }
43365
+
43366
+ if (bgItem && bgItem.Count>=2) aryBG.push(bgItem);
43367
+
43368
+ this.Canvas.save();
43369
+ this.DrawBG(aryBG);
43370
+ this.Canvas.restore();
43371
+ }
43372
+
43373
+ this.DrawBG=function(aryBG)
43374
+ {
43375
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryBG)) return;
43376
+
43377
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
43378
+ if (bHScreen)
43379
+ {
43380
+ var border=this.ChartBorder.GetHScreenBorder();
43381
+ var top=border.RightEx;
43382
+ var bottom=border.Left;
43383
+ var height=bottom-top;
43384
+ }
43385
+ else
43386
+ {
43387
+ var border=this.ChartBorder.GetBorder();
43388
+ var top=border.TopEx;
43389
+ var bottom=border.BottomEx;
43390
+ var height=bottom-top;
43391
+ }
43392
+
43393
+
43394
+ var bDrawSplitLine=false;
43395
+ if (this.SplitLine.Color) bDrawSplitLine=true;
43396
+ var lineCount=0;
43397
+ for(var i=0;i<aryBG.length;++i)
43398
+ {
43399
+ var item=aryBG[i];
43400
+ var xLeft=item.Start.X;
43401
+ var xRight=item.End.X;
43402
+
43403
+ var index=item.ColorIndex%this.BGColor.length;
43404
+ var bgColor=this.BGColor[index];
43405
+ if (bgColor)
43406
+ {
43407
+ this.Canvas.fillStyle=bgColor;
43408
+ if (bHScreen)
43409
+ this.Canvas.fillRect(ToFixedPoint(top),ToFixedPoint(xLeft),ToFixedRect(height),ToFixedRect(xRight-xLeft));
43410
+ else
43411
+ this.Canvas.fillRect(ToFixedPoint(xLeft),ToFixedPoint(top),ToFixedRect(xRight-xLeft),ToFixedRect(height));
43412
+ }
43413
+
43414
+ if (bDrawSplitLine && item.IsStart)
43415
+ {
43416
+ if (lineCount==0) this.Canvas.beginPath();
43417
+ if (bHScreen)
43418
+ {
43419
+ this.Canvas.moveTo(top, ToFixedPoint(xLeft));
43420
+ this.Canvas.lineTo(bottom, ToFixedPoint(xLeft));
43421
+ }
43422
+ else
43423
+ {
43424
+ this.Canvas.moveTo(ToFixedPoint(xLeft), top);
43425
+ this.Canvas.lineTo(ToFixedPoint(xLeft), bottom);
43426
+ }
43427
+
43428
+ ++lineCount;
43429
+ }
43430
+ }
43431
+
43432
+ if (bDrawSplitLine && lineCount>=1)
43433
+ {
43434
+ if (this.SplitLine.Width>=1) this.Canvas.linewidth=this.SplitLine.Width;
43435
+ if (this.SplitLine.Dash) this.Canvas.setLineDash(this.SplitLine.Dash);
43436
+ if (this.SplitLine.Color) this.Canvas.strokeStyle=this.SplitLine.Color;
43437
+
43438
+ this.Canvas.stroke();
43439
+ }
43440
+ }
43441
+
43442
+ this.IsKDataChange=function(hisData)
43443
+ {
43444
+ if (!this.KDataFeature) return true;
43445
+
43446
+ if (this.KDataFeature.Symbol!=this.HQChart.Symbol) return true;
43447
+ if (this.KDataFeature.Period!=this.HQChart.Period) return true;
43448
+ if (this.KDataFeature.DataCount!=hisData.Data.length) return true;
43449
+
43450
+ return false;
43451
+ }
43452
+
43453
+ this.BuildCacheData=function(hisData)
43454
+ {
43455
+ var period=this.HQChart.Period;
43456
+ if (!this.MapPeriod.has(period))
43457
+ {
43458
+ this.Data=[];
43459
+ this.KDataFeature={ Symbol:this.HQChart.Symbol, Period:period, DataCount:hisData.Data.length };
43460
+ return;
43461
+ }
43462
+
43463
+ var splitType=this.MapPeriod.get(period).SplitType; //1=month 2=year 3=day 4=1hour
43464
+
43465
+ var startDate=0;
43466
+ var index=-1;
43467
+ this.Data=[];
43468
+ for(var i=0;i<hisData.Data.length;++i)
43469
+ {
43470
+ var item=hisData.Data[i];
43471
+ switch(splitType)
43472
+ {
43473
+ case 1: //月
43474
+ if (parseInt(item.Date/100)!=parseInt(startDate/100))
43475
+ {
43476
+ startDate=item.Date;
43477
+ ++index;
43478
+ }
43479
+ this.Data.push({ ID:index, Date:item.Date });
43480
+ break;
43481
+ case 2: //年
43482
+ if (parseInt(item.Date/10000)!=parseInt(startDate/10000))
43483
+ {
43484
+ startDate=item.Date;
43485
+ ++index;
43486
+ }
43487
+ this.Data.push({ ID:index, Date:item.Date });
43488
+ break;
43489
+ case 3: //日
43490
+ if (item.Date!=startDate)
43491
+ {
43492
+ startDate=item.Date;
43493
+ ++index;
43494
+ }
43495
+ this.Data.push({ ID:index, Date:item.Date });
43496
+ break;
43497
+ }
43498
+
43499
+ }
43500
+
43501
+
43502
+ this.KDataFeature={ Symbol:this.HQChart.Symbol, Period:period, DataCount:hisData.Data.length };
43503
+ }
43504
+ }
43505
+
43506
+
43246
43507
 
43247
43508
  //弹幕数据 { X:X偏移, Y:Y偏移, Text:内容, Color:颜色 }
43248
43509
  function BarrageList()
@@ -63488,6 +63749,12 @@ function JSChartResource()
63488
63749
  Font:14*GetDevicePixelRatio() +"px 微软雅黑"
63489
63750
  }
63490
63751
 
63752
+ this.SessionBreaksPaint=
63753
+ {
63754
+ BGColor:[null, "rgb(245,246,246)"],
63755
+ SplitLine:{ Color:'rgb(73,133,231)', Width:1*GetDevicePixelRatio(), Dash:[5*GetDevicePixelRatio(),5*GetDevicePixelRatio()] }
63756
+ }
63757
+
63491
63758
 
63492
63759
  //成交明细
63493
63760
  this.DealList=
@@ -64432,6 +64699,19 @@ function JSChartResource()
64432
64699
  if (item.Font) this.DragMovePaint.Font=item.Font;
64433
64700
  }
64434
64701
 
64702
+ if (style.SessionBreaksPaint)
64703
+ {
64704
+ var item=style.SessionBreaksPaint;
64705
+ if (IFrameSplitOperator.IsNonEmptyArray(item.BGColor)) this.SessionBreaksPaint.BGColor=item.BGColor.slice();
64706
+ if (item.SplitLine)
64707
+ {
64708
+ var subItem=item.SplitLine;
64709
+ if (subItem.Color) this.SessionBreaksPaint.SplitLine.Color=subItem.Color;
64710
+ if (IFrameSplitOperator.IsNumber(subItem.Width)) this.SessionBreaksPaint.SplitLine.Width=subItem.Width;
64711
+ this.SessionBreaksPaint.SplitLine.Dash=subItem.Dash;
64712
+ }
64713
+ }
64714
+
64435
64715
  if (IFrameSplitOperator.IsNumber(style.ToolbarButtonStyle)) this.ToolbarButtonStyle=style.ToolbarButtonStyle;
64436
64716
 
64437
64717
  if (style.Buttons)
@@ -84818,6 +85098,39 @@ function KLineRightMenu(divElement)
84818
85098
  return data;
84819
85099
  }
84820
85100
 
85101
+ this.GetBGSplit=function(chart)
85102
+ {
85103
+ var data=
85104
+ [
85105
+ {
85106
+ text: "启用",
85107
+ click: function ()
85108
+ {
85109
+ chart.CreateExtendChart("SessionBreaksPaint", { });
85110
+ chart.Draw();
85111
+ }
85112
+ },
85113
+ {
85114
+ text: "关闭",
85115
+ click: function ()
85116
+ {
85117
+ var finder=chart.GetExtendChartByClassName("SessionBreaksPaint");
85118
+ if (finder)
85119
+ {
85120
+ chart.DeleteExtendChartByID(finder.Chart.ID);
85121
+ chart.Draw();
85122
+ }
85123
+ }
85124
+ },
85125
+ ];
85126
+
85127
+ var finder=chart.GetExtendChartByClassName("SessionBreaksPaint");
85128
+ if (finder) data[0].selected=true;
85129
+ else data[1].selected=true;
85130
+
85131
+ return data;
85132
+ }
85133
+
84821
85134
 
84822
85135
  this.GetKLineInfo=function(chart)
84823
85136
  {
@@ -84924,6 +85237,10 @@ function KLineRightMenu(divElement)
84924
85237
  {
84925
85238
  text:"工具",
84926
85239
  children:this.GetTools(chart)
85240
+ },
85241
+ {
85242
+ text:"背景分割",
85243
+ children:this.GetBGSplit(chart)
84927
85244
  }
84928
85245
  ];
84929
85246
 
@@ -460,6 +460,12 @@ function GetBlackStyle()
460
460
  TextColor:"rgb(255,255,255)",
461
461
  //Font:14*GetDevicePixelRatio() +"px 微软雅黑"
462
462
  },
463
+
464
+ SessionBreaksPaint:
465
+ {
466
+ BGColor:[null, "rgb(42,46,57)"],
467
+ SplitLine:{ Color:'rgb(73,133,231)', Width:1*GetDevicePixelRatio(), Dash:[5*GetDevicePixelRatio(),5*GetDevicePixelRatio()] }
468
+ },
463
469
 
464
470
  //成交明细
465
471
  DealList: