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.
@@ -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
  }
@@ -10883,16 +10883,9 @@ function AverageWidthFrame()
10883
10883
  }
10884
10884
  }
10885
10885
 
10886
- if (item.BG && item.BG.Color)
10887
- {
10888
- var bgItem=item.BG;
10889
- this.Canvas.fillStyle=bgItem.Color;
10890
- var xStart=this.GetXFromIndex(bgItem.Index.Start);
10891
- var xEnd=this.GetXFromIndex(bgItem.Index.End);
10892
- var bgHeight=this.ChartBorder.Bottom;
10893
- if (IFrameSplitOperator.IsNumber(bgItem.Height)) bgHeight=bgItem.Height;
10894
- var rtBG={Left:xStart, Width:xEnd-xStart, Top:border.Bottom, Height: bgHeight };
10895
- this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
10886
+ if (item.BG && this.DrawDayVertical)
10887
+ {
10888
+ this.DrawDayVertical(item, x, border);
10896
10889
  }
10897
10890
 
10898
10891
  if (this.VerticalInfo[i].Message[0]!=null)
@@ -12445,6 +12438,67 @@ function MinuteFrame()
12445
12438
  }
12446
12439
  }
12447
12440
 
12441
+ this.DrawDayVertical=function(dayItem, x, border)
12442
+ {
12443
+ if (!dayItem.BG) return;
12444
+
12445
+ var bgItem=dayItem.BG;
12446
+ var xStart=this.GetXFromIndex(bgItem.Index.Start);
12447
+ var xEnd=this.GetXFromIndex(bgItem.Index.End);
12448
+ var maxWidth=xEnd-xStart;
12449
+ var bgHeight=this.ChartBorder.Bottom;
12450
+ if (IFrameSplitOperator.IsNumber(bgItem.Height)) bgHeight=bgItem.Height;
12451
+
12452
+ if (bgItem.Color)
12453
+ {
12454
+ this.Canvas.fillStyle=bgItem.Color;
12455
+ var rtBG={Left:xStart, Width:maxWidth, Top:border.Bottom, Height: bgHeight };
12456
+ this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
12457
+ }
12458
+
12459
+ if (IFrameSplitOperator.IsNonEmptyArray(dayItem.AryText)) //[ [{Text:, Color:},], []]
12460
+ {
12461
+ this.Canvas.textAlign="left";
12462
+ this.Canvas.textBaseline="top";
12463
+ var yText=border.Bottom+2;
12464
+ var lineHeight=this.Canvas.measureText("擎").width+2;
12465
+ for(var i=0,j=0;i<dayItem.AryText.length;++i)
12466
+ {
12467
+ var aryText=dayItem.AryText[i];
12468
+ var itemWidth=0;
12469
+ var aryOut=[];
12470
+ for(j=0;j<aryText.length;++j)
12471
+ {
12472
+ var item=aryText[j];
12473
+ var textWidth=this.Canvas.measureText(item.Text).width;
12474
+ if (itemWidth+textWidth>maxWidth) break;
12475
+
12476
+ var newItem={ Text:item.Text, Width:textWidth, Color:item.Color, Space:item.Space };
12477
+ itemWidth+=textWidth;
12478
+ item.Width=textWidth;
12479
+ if (item.Space>=1) itemWidth+=item.Space;
12480
+ aryOut.push(newItem);
12481
+ }
12482
+
12483
+ var xText=xStart+(maxWidth-itemWidth)/2;
12484
+ for(var j=0;j<aryOut.length;++j)
12485
+ {
12486
+ var item=aryOut[j];
12487
+ if (!IFrameSplitOperator.IsNumber(item.Width)) break;
12488
+ if (item.Color) this.Canvas.fillStyle=item.Color;
12489
+ else if (dayItem.TextColor) this.Canvas.fillStyle=dayItem.TextColor;
12490
+
12491
+ this.Canvas.fillText(item.Text,xText,yText);
12492
+ xText+=item.Width;
12493
+ if (item.Space>=1) xText+=item.Space;
12494
+ }
12495
+
12496
+ yText+=lineHeight;
12497
+ }
12498
+ }
12499
+
12500
+ }
12501
+
12448
12502
  //分割x,y轴坐标信息
12449
12503
  this.SplitXYCoordinate=function()
12450
12504
  {
@@ -38985,7 +39039,8 @@ function ExtendChartPaintFactory()
38985
39039
  [
38986
39040
  ["FrameSplitPaint", { Create:function() { return new FrameSplitPaint(); } }],
38987
39041
  ["RectSelectPaint", { Create:function() { return new RectSelectPaint(); } }],
38988
- ["DragMovePaint", { Create:function() { return new DragMovePaint(); } }]
39042
+ ["DragMovePaint", { Create:function() { return new DragMovePaint(); } }],
39043
+ ["SessionBreaksPaint", { Create:function() { return new SessionBreaksPaint(); }}]
38989
39044
  ]
38990
39045
  );
38991
39046
 
@@ -43243,6 +43298,266 @@ function DragMovePaint()
43243
43298
  }
43244
43299
 
43245
43300
 
43301
+ function SessionBreaksPaint()
43302
+ {
43303
+ this.newMethod=IExtendChartPainting; //派生
43304
+ this.newMethod();
43305
+ delete this.newMethod;
43306
+
43307
+ this.ClassName='SessionBreaksPaint';
43308
+ this.IsDynamic=false;
43309
+ this.IsCallbackDraw=true; //在回调函数里绘制, 不在Draw()中绘制
43310
+ this.FrameID=0;
43311
+ this.KDataFeature; //数据特征 { Symbol, Period, DataCount }
43312
+ this.Data;
43313
+ this.ChartFrame;
43314
+
43315
+ this.BGColor=g_JSChartResource.SessionBreaksPaint.BGColor.slice();
43316
+ this.SplitLine=
43317
+ {
43318
+ Color:g_JSChartResource.SessionBreaksPaint.SplitLine.Color,
43319
+ Width:g_JSChartResource.SessionBreaksPaint.SplitLine.Width,
43320
+ Dash:g_JSChartResource.SessionBreaksPaint.SplitLine.Dash
43321
+ };
43322
+
43323
+ this.MapPeriod=new Map(
43324
+ [
43325
+ [0, { SplitType:1 }], //日
43326
+ [1, { SplitType:1 }], //周
43327
+ [2, { SplitType:2 }], //月
43328
+ [21, { SplitType:2 }], //双周
43329
+
43330
+ [4, { SplitType:3 }], //1分钟
43331
+ [5, { SplitType:3 }], //5分钟
43332
+ [6, { SplitType:3 }], //15分钟
43333
+ [7, { SplitType:3 }],
43334
+ [8, { SplitType:3 }],
43335
+ ]); //周期和分割对应关系
43336
+
43337
+ this.SetOption=function(option) //设置
43338
+ {
43339
+ if (option.FrameID>0) this.FrameID=option.FrameID;
43340
+ }
43341
+
43342
+ this.Draw=function()
43343
+ {
43344
+ if (!this.HQChart) return;
43345
+ var hisData=this.HQChart.ChartOperator_Temp_GetHistroyData();;
43346
+ if (!hisData) return; //数据还没有到达
43347
+ if (!IFrameSplitOperator.IsNonEmptyArray(hisData.Data)) return;
43348
+
43349
+ if (this.IsKDataChange(hisData))
43350
+ {
43351
+ this.BuildCacheData(hisData);
43352
+ }
43353
+
43354
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data)) return;
43355
+
43356
+ var mainFrame=this.HQChart.Frame.SubFrame[0].Frame;
43357
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
43358
+ var dataWidth=mainFrame.DataWidth;
43359
+ var distanceWidth=mainFrame.DistanceWidth;
43360
+ var xPointCount=mainFrame.XPointCount;
43361
+
43362
+ if (bHScreen)
43363
+ {
43364
+ var border=this.ChartBorder.GetHScreenBorder();
43365
+ var chartright=border.BottomEx;
43366
+ var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
43367
+ }
43368
+ else
43369
+ {
43370
+ var border=this.ChartBorder.GetBorder();
43371
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
43372
+ var chartright=border.RightEx;
43373
+ }
43374
+
43375
+ var preID=null;
43376
+ var aryBG=[];
43377
+ var bgItem=null;
43378
+ for(var i=hisData.DataOffset,j=0;i<hisData.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
43379
+ {
43380
+ var item=this.Data[i];
43381
+ if (!item) continue;
43382
+
43383
+ var left=xOffset;
43384
+ var right=xOffset+dataWidth;
43385
+ if (right>chartright) break;
43386
+ var x=left+(right-left)/2;
43387
+
43388
+ var xStart=left-distanceWidth/2;
43389
+ var xEnd=right+distanceWidth/2;
43390
+
43391
+ var id=item.ID;
43392
+ if (!IFrameSplitOperator.IsNumber(id)) continue;
43393
+
43394
+ if (preID==null)
43395
+ {
43396
+ bgItem={ Start:{ X:xStart }, End:{ X:xEnd }, ColorIndex:id, Count:1, IsStart:false, IsEnd:false };
43397
+ preID=id;
43398
+ if (i-1>=0)
43399
+ {
43400
+ var preItem=this.Data[i-1];
43401
+ if (preItem && preItem.ID!=id) bgItem.IsStart=true;
43402
+ }
43403
+ }
43404
+ else if (preID!=id)
43405
+ {
43406
+ bgItem.End.X=xStart;
43407
+ bgItem.IsEnd=true;
43408
+ aryBG.push(bgItem);
43409
+
43410
+ bgItem={ Start:{ X:xStart }, End:{ X:xEnd }, ColorIndex:id, Count:1, IsStart:true, IsEnd:false };
43411
+ preID=id;
43412
+ }
43413
+ else
43414
+ {
43415
+ bgItem.End.X=xEnd;
43416
+ ++bgItem.Count;
43417
+ }
43418
+ }
43419
+
43420
+ if (bgItem && bgItem.Count>=2) aryBG.push(bgItem);
43421
+
43422
+ this.Canvas.save();
43423
+ this.DrawBG(aryBG);
43424
+ this.Canvas.restore();
43425
+ }
43426
+
43427
+ this.DrawBG=function(aryBG)
43428
+ {
43429
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryBG)) return;
43430
+
43431
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
43432
+ if (bHScreen)
43433
+ {
43434
+ var border=this.ChartBorder.GetHScreenBorder();
43435
+ var top=border.RightEx;
43436
+ var bottom=border.Left;
43437
+ var height=bottom-top;
43438
+ }
43439
+ else
43440
+ {
43441
+ var border=this.ChartBorder.GetBorder();
43442
+ var top=border.TopEx;
43443
+ var bottom=border.BottomEx;
43444
+ var height=bottom-top;
43445
+ }
43446
+
43447
+
43448
+ var bDrawSplitLine=false;
43449
+ if (this.SplitLine.Color) bDrawSplitLine=true;
43450
+ var lineCount=0;
43451
+ for(var i=0;i<aryBG.length;++i)
43452
+ {
43453
+ var item=aryBG[i];
43454
+ var xLeft=item.Start.X;
43455
+ var xRight=item.End.X;
43456
+
43457
+ var index=item.ColorIndex%this.BGColor.length;
43458
+ var bgColor=this.BGColor[index];
43459
+ if (bgColor)
43460
+ {
43461
+ this.Canvas.fillStyle=bgColor;
43462
+ if (bHScreen)
43463
+ this.Canvas.fillRect(ToFixedPoint(top),ToFixedPoint(xLeft),ToFixedRect(height),ToFixedRect(xRight-xLeft));
43464
+ else
43465
+ this.Canvas.fillRect(ToFixedPoint(xLeft),ToFixedPoint(top),ToFixedRect(xRight-xLeft),ToFixedRect(height));
43466
+ }
43467
+
43468
+ if (bDrawSplitLine && item.IsStart)
43469
+ {
43470
+ if (lineCount==0) this.Canvas.beginPath();
43471
+ if (bHScreen)
43472
+ {
43473
+ this.Canvas.moveTo(top, ToFixedPoint(xLeft));
43474
+ this.Canvas.lineTo(bottom, ToFixedPoint(xLeft));
43475
+ }
43476
+ else
43477
+ {
43478
+ this.Canvas.moveTo(ToFixedPoint(xLeft), top);
43479
+ this.Canvas.lineTo(ToFixedPoint(xLeft), bottom);
43480
+ }
43481
+
43482
+ ++lineCount;
43483
+ }
43484
+ }
43485
+
43486
+ if (bDrawSplitLine && lineCount>=1)
43487
+ {
43488
+ if (this.SplitLine.Width>=1) this.Canvas.linewidth=this.SplitLine.Width;
43489
+ if (this.SplitLine.Dash) this.Canvas.setLineDash(this.SplitLine.Dash);
43490
+ if (this.SplitLine.Color) this.Canvas.strokeStyle=this.SplitLine.Color;
43491
+
43492
+ this.Canvas.stroke();
43493
+ }
43494
+ }
43495
+
43496
+ this.IsKDataChange=function(hisData)
43497
+ {
43498
+ if (!this.KDataFeature) return true;
43499
+
43500
+ if (this.KDataFeature.Symbol!=this.HQChart.Symbol) return true;
43501
+ if (this.KDataFeature.Period!=this.HQChart.Period) return true;
43502
+ if (this.KDataFeature.DataCount!=hisData.Data.length) return true;
43503
+
43504
+ return false;
43505
+ }
43506
+
43507
+ this.BuildCacheData=function(hisData)
43508
+ {
43509
+ var period=this.HQChart.Period;
43510
+ if (!this.MapPeriod.has(period))
43511
+ {
43512
+ this.Data=[];
43513
+ this.KDataFeature={ Symbol:this.HQChart.Symbol, Period:period, DataCount:hisData.Data.length };
43514
+ return;
43515
+ }
43516
+
43517
+ var splitType=this.MapPeriod.get(period).SplitType; //1=month 2=year 3=day 4=1hour
43518
+
43519
+ var startDate=0;
43520
+ var index=-1;
43521
+ this.Data=[];
43522
+ for(var i=0;i<hisData.Data.length;++i)
43523
+ {
43524
+ var item=hisData.Data[i];
43525
+ switch(splitType)
43526
+ {
43527
+ case 1: //月
43528
+ if (parseInt(item.Date/100)!=parseInt(startDate/100))
43529
+ {
43530
+ startDate=item.Date;
43531
+ ++index;
43532
+ }
43533
+ this.Data.push({ ID:index, Date:item.Date });
43534
+ break;
43535
+ case 2: //年
43536
+ if (parseInt(item.Date/10000)!=parseInt(startDate/10000))
43537
+ {
43538
+ startDate=item.Date;
43539
+ ++index;
43540
+ }
43541
+ this.Data.push({ ID:index, Date:item.Date });
43542
+ break;
43543
+ case 3: //日
43544
+ if (item.Date!=startDate)
43545
+ {
43546
+ startDate=item.Date;
43547
+ ++index;
43548
+ }
43549
+ this.Data.push({ ID:index, Date:item.Date });
43550
+ break;
43551
+ }
43552
+
43553
+ }
43554
+
43555
+
43556
+ this.KDataFeature={ Symbol:this.HQChart.Symbol, Period:period, DataCount:hisData.Data.length };
43557
+ }
43558
+ }
43559
+
43560
+
43246
43561
 
43247
43562
  //弹幕数据 { X:X偏移, Y:Y偏移, Text:内容, Color:颜色 }
43248
43563
  function BarrageList()
@@ -63488,6 +63803,12 @@ function JSChartResource()
63488
63803
  Font:14*GetDevicePixelRatio() +"px 微软雅黑"
63489
63804
  }
63490
63805
 
63806
+ this.SessionBreaksPaint=
63807
+ {
63808
+ BGColor:[null, "rgb(245,246,246)"],
63809
+ SplitLine:{ Color:'rgb(73,133,231)', Width:1*GetDevicePixelRatio(), Dash:[5*GetDevicePixelRatio(),5*GetDevicePixelRatio()] }
63810
+ }
63811
+
63491
63812
 
63492
63813
  //成交明细
63493
63814
  this.DealList=
@@ -64432,6 +64753,19 @@ function JSChartResource()
64432
64753
  if (item.Font) this.DragMovePaint.Font=item.Font;
64433
64754
  }
64434
64755
 
64756
+ if (style.SessionBreaksPaint)
64757
+ {
64758
+ var item=style.SessionBreaksPaint;
64759
+ if (IFrameSplitOperator.IsNonEmptyArray(item.BGColor)) this.SessionBreaksPaint.BGColor=item.BGColor.slice();
64760
+ if (item.SplitLine)
64761
+ {
64762
+ var subItem=item.SplitLine;
64763
+ if (subItem.Color) this.SessionBreaksPaint.SplitLine.Color=subItem.Color;
64764
+ if (IFrameSplitOperator.IsNumber(subItem.Width)) this.SessionBreaksPaint.SplitLine.Width=subItem.Width;
64765
+ this.SessionBreaksPaint.SplitLine.Dash=subItem.Dash;
64766
+ }
64767
+ }
64768
+
64435
64769
  if (IFrameSplitOperator.IsNumber(style.ToolbarButtonStyle)) this.ToolbarButtonStyle=style.ToolbarButtonStyle;
64436
64770
 
64437
64771
  if (style.Buttons)
@@ -84818,6 +85152,39 @@ function KLineRightMenu(divElement)
84818
85152
  return data;
84819
85153
  }
84820
85154
 
85155
+ this.GetBGSplit=function(chart)
85156
+ {
85157
+ var data=
85158
+ [
85159
+ {
85160
+ text: "启用",
85161
+ click: function ()
85162
+ {
85163
+ chart.CreateExtendChart("SessionBreaksPaint", { });
85164
+ chart.Draw();
85165
+ }
85166
+ },
85167
+ {
85168
+ text: "关闭",
85169
+ click: function ()
85170
+ {
85171
+ var finder=chart.GetExtendChartByClassName("SessionBreaksPaint");
85172
+ if (finder)
85173
+ {
85174
+ chart.DeleteExtendChartByID(finder.Chart.ID);
85175
+ chart.Draw();
85176
+ }
85177
+ }
85178
+ },
85179
+ ];
85180
+
85181
+ var finder=chart.GetExtendChartByClassName("SessionBreaksPaint");
85182
+ if (finder) data[0].selected=true;
85183
+ else data[1].selected=true;
85184
+
85185
+ return data;
85186
+ }
85187
+
84821
85188
 
84822
85189
  this.GetKLineInfo=function(chart)
84823
85190
  {
@@ -84924,6 +85291,10 @@ function KLineRightMenu(divElement)
84924
85291
  {
84925
85292
  text:"工具",
84926
85293
  children:this.GetTools(chart)
85294
+ },
85295
+ {
85296
+ text:"背景分割",
85297
+ children:this.GetBGSplit(chart)
84927
85298
  }
84928
85299
  ];
84929
85300
 
@@ -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: