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.
@@ -9212,7 +9212,7 @@ function JSChartContainer(uielement, OffscreenElement, cacheElement)
9212
9212
  var item=this.ExtendChartPaint[i];
9213
9213
  if (item.IsCallbackDraw)
9214
9214
  {
9215
- if (["KLineYAxisBGPaint","DepthMapPaint","BackgroundPaint","MinuteBackgroundPaint"].includes(item.ClassName))
9215
+ if (["KLineYAxisBGPaint","DepthMapPaint","BackgroundPaint","MinuteBackgroundPaint", "SessionBreaksPaint"].includes(item.ClassName))
9216
9216
  {
9217
9217
  if (item.FrameID==frame.Identify) item.Draw();
9218
9218
  }
@@ -14819,16 +14819,9 @@ function AverageWidthFrame()
14819
14819
  }
14820
14820
  }
14821
14821
 
14822
- if (item.BG && item.BG.Color)
14823
- {
14824
- var bgItem=item.BG;
14825
- this.Canvas.fillStyle=bgItem.Color;
14826
- var xStart=this.GetXFromIndex(bgItem.Index.Start);
14827
- var xEnd=this.GetXFromIndex(bgItem.Index.End);
14828
- var bgHeight=this.ChartBorder.Bottom;
14829
- if (IFrameSplitOperator.IsNumber(bgItem.Height)) bgHeight=bgItem.Height;
14830
- var rtBG={Left:xStart, Width:xEnd-xStart, Top:border.Bottom, Height: bgHeight };
14831
- this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
14822
+ if (item.BG && this.DrawDayVertical)
14823
+ {
14824
+ this.DrawDayVertical(item, x, border);
14832
14825
  }
14833
14826
 
14834
14827
  if (this.VerticalInfo[i].Message[0]!=null)
@@ -16381,6 +16374,67 @@ function MinuteFrame()
16381
16374
  }
16382
16375
  }
16383
16376
 
16377
+ this.DrawDayVertical=function(dayItem, x, border)
16378
+ {
16379
+ if (!dayItem.BG) return;
16380
+
16381
+ var bgItem=dayItem.BG;
16382
+ var xStart=this.GetXFromIndex(bgItem.Index.Start);
16383
+ var xEnd=this.GetXFromIndex(bgItem.Index.End);
16384
+ var maxWidth=xEnd-xStart;
16385
+ var bgHeight=this.ChartBorder.Bottom;
16386
+ if (IFrameSplitOperator.IsNumber(bgItem.Height)) bgHeight=bgItem.Height;
16387
+
16388
+ if (bgItem.Color)
16389
+ {
16390
+ this.Canvas.fillStyle=bgItem.Color;
16391
+ var rtBG={Left:xStart, Width:maxWidth, Top:border.Bottom, Height: bgHeight };
16392
+ this.Canvas.fillRect(rtBG.Left, rtBG.Top, rtBG.Width, rtBG.Height);
16393
+ }
16394
+
16395
+ if (IFrameSplitOperator.IsNonEmptyArray(dayItem.AryText)) //[ [{Text:, Color:},], []]
16396
+ {
16397
+ this.Canvas.textAlign="left";
16398
+ this.Canvas.textBaseline="top";
16399
+ var yText=border.Bottom+2;
16400
+ var lineHeight=this.Canvas.measureText("擎").width+2;
16401
+ for(var i=0,j=0;i<dayItem.AryText.length;++i)
16402
+ {
16403
+ var aryText=dayItem.AryText[i];
16404
+ var itemWidth=0;
16405
+ var aryOut=[];
16406
+ for(j=0;j<aryText.length;++j)
16407
+ {
16408
+ var item=aryText[j];
16409
+ var textWidth=this.Canvas.measureText(item.Text).width;
16410
+ if (itemWidth+textWidth>maxWidth) break;
16411
+
16412
+ var newItem={ Text:item.Text, Width:textWidth, Color:item.Color, Space:item.Space };
16413
+ itemWidth+=textWidth;
16414
+ item.Width=textWidth;
16415
+ if (item.Space>=1) itemWidth+=item.Space;
16416
+ aryOut.push(newItem);
16417
+ }
16418
+
16419
+ var xText=xStart+(maxWidth-itemWidth)/2;
16420
+ for(var j=0;j<aryOut.length;++j)
16421
+ {
16422
+ var item=aryOut[j];
16423
+ if (!IFrameSplitOperator.IsNumber(item.Width)) break;
16424
+ if (item.Color) this.Canvas.fillStyle=item.Color;
16425
+ else if (dayItem.TextColor) this.Canvas.fillStyle=dayItem.TextColor;
16426
+
16427
+ this.Canvas.fillText(item.Text,xText,yText);
16428
+ xText+=item.Width;
16429
+ if (item.Space>=1) xText+=item.Space;
16430
+ }
16431
+
16432
+ yText+=lineHeight;
16433
+ }
16434
+ }
16435
+
16436
+ }
16437
+
16384
16438
  //分割x,y轴坐标信息
16385
16439
  this.SplitXYCoordinate=function()
16386
16440
  {
@@ -42921,7 +42975,8 @@ function ExtendChartPaintFactory()
42921
42975
  [
42922
42976
  ["FrameSplitPaint", { Create:function() { return new FrameSplitPaint(); } }],
42923
42977
  ["RectSelectPaint", { Create:function() { return new RectSelectPaint(); } }],
42924
- ["DragMovePaint", { Create:function() { return new DragMovePaint(); } }]
42978
+ ["DragMovePaint", { Create:function() { return new DragMovePaint(); } }],
42979
+ ["SessionBreaksPaint", { Create:function() { return new SessionBreaksPaint(); }}]
42925
42980
  ]
42926
42981
  );
42927
42982
 
@@ -47179,6 +47234,266 @@ function DragMovePaint()
47179
47234
  }
47180
47235
 
47181
47236
 
47237
+ function SessionBreaksPaint()
47238
+ {
47239
+ this.newMethod=IExtendChartPainting; //派生
47240
+ this.newMethod();
47241
+ delete this.newMethod;
47242
+
47243
+ this.ClassName='SessionBreaksPaint';
47244
+ this.IsDynamic=false;
47245
+ this.IsCallbackDraw=true; //在回调函数里绘制, 不在Draw()中绘制
47246
+ this.FrameID=0;
47247
+ this.KDataFeature; //数据特征 { Symbol, Period, DataCount }
47248
+ this.Data;
47249
+ this.ChartFrame;
47250
+
47251
+ this.BGColor=g_JSChartResource.SessionBreaksPaint.BGColor.slice();
47252
+ this.SplitLine=
47253
+ {
47254
+ Color:g_JSChartResource.SessionBreaksPaint.SplitLine.Color,
47255
+ Width:g_JSChartResource.SessionBreaksPaint.SplitLine.Width,
47256
+ Dash:g_JSChartResource.SessionBreaksPaint.SplitLine.Dash
47257
+ };
47258
+
47259
+ this.MapPeriod=new Map(
47260
+ [
47261
+ [0, { SplitType:1 }], //日
47262
+ [1, { SplitType:1 }], //周
47263
+ [2, { SplitType:2 }], //月
47264
+ [21, { SplitType:2 }], //双周
47265
+
47266
+ [4, { SplitType:3 }], //1分钟
47267
+ [5, { SplitType:3 }], //5分钟
47268
+ [6, { SplitType:3 }], //15分钟
47269
+ [7, { SplitType:3 }],
47270
+ [8, { SplitType:3 }],
47271
+ ]); //周期和分割对应关系
47272
+
47273
+ this.SetOption=function(option) //设置
47274
+ {
47275
+ if (option.FrameID>0) this.FrameID=option.FrameID;
47276
+ }
47277
+
47278
+ this.Draw=function()
47279
+ {
47280
+ if (!this.HQChart) return;
47281
+ var hisData=this.HQChart.ChartOperator_Temp_GetHistroyData();;
47282
+ if (!hisData) return; //数据还没有到达
47283
+ if (!IFrameSplitOperator.IsNonEmptyArray(hisData.Data)) return;
47284
+
47285
+ if (this.IsKDataChange(hisData))
47286
+ {
47287
+ this.BuildCacheData(hisData);
47288
+ }
47289
+
47290
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.Data)) return;
47291
+
47292
+ var mainFrame=this.HQChart.Frame.SubFrame[0].Frame;
47293
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
47294
+ var dataWidth=mainFrame.DataWidth;
47295
+ var distanceWidth=mainFrame.DistanceWidth;
47296
+ var xPointCount=mainFrame.XPointCount;
47297
+
47298
+ if (bHScreen)
47299
+ {
47300
+ var border=this.ChartBorder.GetHScreenBorder();
47301
+ var chartright=border.BottomEx;
47302
+ var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
47303
+ }
47304
+ else
47305
+ {
47306
+ var border=this.ChartBorder.GetBorder();
47307
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
47308
+ var chartright=border.RightEx;
47309
+ }
47310
+
47311
+ var preID=null;
47312
+ var aryBG=[];
47313
+ var bgItem=null;
47314
+ for(var i=hisData.DataOffset,j=0;i<hisData.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
47315
+ {
47316
+ var item=this.Data[i];
47317
+ if (!item) continue;
47318
+
47319
+ var left=xOffset;
47320
+ var right=xOffset+dataWidth;
47321
+ if (right>chartright) break;
47322
+ var x=left+(right-left)/2;
47323
+
47324
+ var xStart=left-distanceWidth/2;
47325
+ var xEnd=right+distanceWidth/2;
47326
+
47327
+ var id=item.ID;
47328
+ if (!IFrameSplitOperator.IsNumber(id)) continue;
47329
+
47330
+ if (preID==null)
47331
+ {
47332
+ bgItem={ Start:{ X:xStart }, End:{ X:xEnd }, ColorIndex:id, Count:1, IsStart:false, IsEnd:false };
47333
+ preID=id;
47334
+ if (i-1>=0)
47335
+ {
47336
+ var preItem=this.Data[i-1];
47337
+ if (preItem && preItem.ID!=id) bgItem.IsStart=true;
47338
+ }
47339
+ }
47340
+ else if (preID!=id)
47341
+ {
47342
+ bgItem.End.X=xStart;
47343
+ bgItem.IsEnd=true;
47344
+ aryBG.push(bgItem);
47345
+
47346
+ bgItem={ Start:{ X:xStart }, End:{ X:xEnd }, ColorIndex:id, Count:1, IsStart:true, IsEnd:false };
47347
+ preID=id;
47348
+ }
47349
+ else
47350
+ {
47351
+ bgItem.End.X=xEnd;
47352
+ ++bgItem.Count;
47353
+ }
47354
+ }
47355
+
47356
+ if (bgItem && bgItem.Count>=2) aryBG.push(bgItem);
47357
+
47358
+ this.Canvas.save();
47359
+ this.DrawBG(aryBG);
47360
+ this.Canvas.restore();
47361
+ }
47362
+
47363
+ this.DrawBG=function(aryBG)
47364
+ {
47365
+ if (!IFrameSplitOperator.IsNonEmptyArray(aryBG)) return;
47366
+
47367
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
47368
+ if (bHScreen)
47369
+ {
47370
+ var border=this.ChartBorder.GetHScreenBorder();
47371
+ var top=border.RightEx;
47372
+ var bottom=border.Left;
47373
+ var height=bottom-top;
47374
+ }
47375
+ else
47376
+ {
47377
+ var border=this.ChartBorder.GetBorder();
47378
+ var top=border.TopEx;
47379
+ var bottom=border.BottomEx;
47380
+ var height=bottom-top;
47381
+ }
47382
+
47383
+
47384
+ var bDrawSplitLine=false;
47385
+ if (this.SplitLine.Color) bDrawSplitLine=true;
47386
+ var lineCount=0;
47387
+ for(var i=0;i<aryBG.length;++i)
47388
+ {
47389
+ var item=aryBG[i];
47390
+ var xLeft=item.Start.X;
47391
+ var xRight=item.End.X;
47392
+
47393
+ var index=item.ColorIndex%this.BGColor.length;
47394
+ var bgColor=this.BGColor[index];
47395
+ if (bgColor)
47396
+ {
47397
+ this.Canvas.fillStyle=bgColor;
47398
+ if (bHScreen)
47399
+ this.Canvas.fillRect(ToFixedPoint(top),ToFixedPoint(xLeft),ToFixedRect(height),ToFixedRect(xRight-xLeft));
47400
+ else
47401
+ this.Canvas.fillRect(ToFixedPoint(xLeft),ToFixedPoint(top),ToFixedRect(xRight-xLeft),ToFixedRect(height));
47402
+ }
47403
+
47404
+ if (bDrawSplitLine && item.IsStart)
47405
+ {
47406
+ if (lineCount==0) this.Canvas.beginPath();
47407
+ if (bHScreen)
47408
+ {
47409
+ this.Canvas.moveTo(top, ToFixedPoint(xLeft));
47410
+ this.Canvas.lineTo(bottom, ToFixedPoint(xLeft));
47411
+ }
47412
+ else
47413
+ {
47414
+ this.Canvas.moveTo(ToFixedPoint(xLeft), top);
47415
+ this.Canvas.lineTo(ToFixedPoint(xLeft), bottom);
47416
+ }
47417
+
47418
+ ++lineCount;
47419
+ }
47420
+ }
47421
+
47422
+ if (bDrawSplitLine && lineCount>=1)
47423
+ {
47424
+ if (this.SplitLine.Width>=1) this.Canvas.linewidth=this.SplitLine.Width;
47425
+ if (this.SplitLine.Dash) this.Canvas.setLineDash(this.SplitLine.Dash);
47426
+ if (this.SplitLine.Color) this.Canvas.strokeStyle=this.SplitLine.Color;
47427
+
47428
+ this.Canvas.stroke();
47429
+ }
47430
+ }
47431
+
47432
+ this.IsKDataChange=function(hisData)
47433
+ {
47434
+ if (!this.KDataFeature) return true;
47435
+
47436
+ if (this.KDataFeature.Symbol!=this.HQChart.Symbol) return true;
47437
+ if (this.KDataFeature.Period!=this.HQChart.Period) return true;
47438
+ if (this.KDataFeature.DataCount!=hisData.Data.length) return true;
47439
+
47440
+ return false;
47441
+ }
47442
+
47443
+ this.BuildCacheData=function(hisData)
47444
+ {
47445
+ var period=this.HQChart.Period;
47446
+ if (!this.MapPeriod.has(period))
47447
+ {
47448
+ this.Data=[];
47449
+ this.KDataFeature={ Symbol:this.HQChart.Symbol, Period:period, DataCount:hisData.Data.length };
47450
+ return;
47451
+ }
47452
+
47453
+ var splitType=this.MapPeriod.get(period).SplitType; //1=month 2=year 3=day 4=1hour
47454
+
47455
+ var startDate=0;
47456
+ var index=-1;
47457
+ this.Data=[];
47458
+ for(var i=0;i<hisData.Data.length;++i)
47459
+ {
47460
+ var item=hisData.Data[i];
47461
+ switch(splitType)
47462
+ {
47463
+ case 1: //月
47464
+ if (parseInt(item.Date/100)!=parseInt(startDate/100))
47465
+ {
47466
+ startDate=item.Date;
47467
+ ++index;
47468
+ }
47469
+ this.Data.push({ ID:index, Date:item.Date });
47470
+ break;
47471
+ case 2: //年
47472
+ if (parseInt(item.Date/10000)!=parseInt(startDate/10000))
47473
+ {
47474
+ startDate=item.Date;
47475
+ ++index;
47476
+ }
47477
+ this.Data.push({ ID:index, Date:item.Date });
47478
+ break;
47479
+ case 3: //日
47480
+ if (item.Date!=startDate)
47481
+ {
47482
+ startDate=item.Date;
47483
+ ++index;
47484
+ }
47485
+ this.Data.push({ ID:index, Date:item.Date });
47486
+ break;
47487
+ }
47488
+
47489
+ }
47490
+
47491
+
47492
+ this.KDataFeature={ Symbol:this.HQChart.Symbol, Period:period, DataCount:hisData.Data.length };
47493
+ }
47494
+ }
47495
+
47496
+
47182
47497
 
47183
47498
  //弹幕数据 { X:X偏移, Y:Y偏移, Text:内容, Color:颜色 }
47184
47499
  function BarrageList()
@@ -67424,6 +67739,12 @@ function JSChartResource()
67424
67739
  Font:14*GetDevicePixelRatio() +"px 微软雅黑"
67425
67740
  }
67426
67741
 
67742
+ this.SessionBreaksPaint=
67743
+ {
67744
+ BGColor:[null, "rgb(245,246,246)"],
67745
+ SplitLine:{ Color:'rgb(73,133,231)', Width:1*GetDevicePixelRatio(), Dash:[5*GetDevicePixelRatio(),5*GetDevicePixelRatio()] }
67746
+ }
67747
+
67427
67748
 
67428
67749
  //成交明细
67429
67750
  this.DealList=
@@ -68368,6 +68689,19 @@ function JSChartResource()
68368
68689
  if (item.Font) this.DragMovePaint.Font=item.Font;
68369
68690
  }
68370
68691
 
68692
+ if (style.SessionBreaksPaint)
68693
+ {
68694
+ var item=style.SessionBreaksPaint;
68695
+ if (IFrameSplitOperator.IsNonEmptyArray(item.BGColor)) this.SessionBreaksPaint.BGColor=item.BGColor.slice();
68696
+ if (item.SplitLine)
68697
+ {
68698
+ var subItem=item.SplitLine;
68699
+ if (subItem.Color) this.SessionBreaksPaint.SplitLine.Color=subItem.Color;
68700
+ if (IFrameSplitOperator.IsNumber(subItem.Width)) this.SessionBreaksPaint.SplitLine.Width=subItem.Width;
68701
+ this.SessionBreaksPaint.SplitLine.Dash=subItem.Dash;
68702
+ }
68703
+ }
68704
+
68371
68705
  if (IFrameSplitOperator.IsNumber(style.ToolbarButtonStyle)) this.ToolbarButtonStyle=style.ToolbarButtonStyle;
68372
68706
 
68373
68707
  if (style.Buttons)
@@ -88754,6 +89088,39 @@ function KLineRightMenu(divElement)
88754
89088
  return data;
88755
89089
  }
88756
89090
 
89091
+ this.GetBGSplit=function(chart)
89092
+ {
89093
+ var data=
89094
+ [
89095
+ {
89096
+ text: "启用",
89097
+ click: function ()
89098
+ {
89099
+ chart.CreateExtendChart("SessionBreaksPaint", { });
89100
+ chart.Draw();
89101
+ }
89102
+ },
89103
+ {
89104
+ text: "关闭",
89105
+ click: function ()
89106
+ {
89107
+ var finder=chart.GetExtendChartByClassName("SessionBreaksPaint");
89108
+ if (finder)
89109
+ {
89110
+ chart.DeleteExtendChartByID(finder.Chart.ID);
89111
+ chart.Draw();
89112
+ }
89113
+ }
89114
+ },
89115
+ ];
89116
+
89117
+ var finder=chart.GetExtendChartByClassName("SessionBreaksPaint");
89118
+ if (finder) data[0].selected=true;
89119
+ else data[1].selected=true;
89120
+
89121
+ return data;
89122
+ }
89123
+
88757
89124
 
88758
89125
  this.GetKLineInfo=function(chart)
88759
89126
  {
@@ -88860,6 +89227,10 @@ function KLineRightMenu(divElement)
88860
89227
  {
88861
89228
  text:"工具",
88862
89229
  children:this.GetTools(chart)
89230
+ },
89231
+ {
89232
+ text:"背景分割",
89233
+ children:this.GetBGSplit(chart)
88863
89234
  }
88864
89235
  ];
88865
89236
 
@@ -119936,6 +120307,12 @@ function GetBlackStyle()
119936
120307
  TextColor:"rgb(255,255,255)",
119937
120308
  //Font:14*GetDevicePixelRatio() +"px 微软雅黑"
119938
120309
  },
120310
+
120311
+ SessionBreaksPaint:
120312
+ {
120313
+ BGColor:[null, "rgb(42,46,57)"],
120314
+ SplitLine:{ Color:'rgb(73,133,231)', Width:1*GetDevicePixelRatio(), Dash:[5*GetDevicePixelRatio(),5*GetDevicePixelRatio()] }
120315
+ },
119939
120316
 
119940
120317
  //成交明细
119941
120318
  DealList:
@@ -130508,7 +130885,7 @@ function HQChartScriptWorker()
130508
130885
 
130509
130886
 
130510
130887
 
130511
- var HQCHART_VERSION="1.1.13061";
130888
+ var HQCHART_VERSION="1.1.13067";
130512
130889
 
130513
130890
  function PrintHQChartVersion()
130514
130891
  {