hqchart 1.1.14836 → 1.1.14846

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.
@@ -45587,6 +45587,201 @@ function ChartMACD()
45587
45587
  }
45588
45588
  }
45589
45589
 
45590
+ //基准线上下柱子
45591
+ function ChartBaseLineBar()
45592
+ {
45593
+ this.newMethod=IChartPainting; //派生
45594
+ this.newMethod();
45595
+ delete this.newMethod;
45596
+
45597
+ this.ClassName="ChartBaseLineBar";
45598
+ this.UpColor=g_JSChartResource.ChartBaseLineBar.UpColor;
45599
+ this.DownColor=g_JSChartResource.ChartBaseLineBar.DownColor;
45600
+ this.LineWidth=1;
45601
+ this.IsDrawFirst=true;
45602
+ this.AryData=[]; //{ Date, Time, Up, Down }
45603
+ this.DefaultMax; //默认最大值
45604
+
45605
+ this.MaxValue;
45606
+ this.YBaseLine;
45607
+ this.BarMaxHeight; //{ Up:, Down: }
45608
+
45609
+ this.Draw=function()
45610
+ {
45611
+ this.YBaseLine=null;
45612
+ this.BarMaxHeight=null;
45613
+ if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
45614
+ if (this.IsShowIndexTitleOnly()) return;
45615
+ if (this.IsHideScriptIndex()) return;
45616
+ if (!this.HQChart) return;
45617
+ if(!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
45618
+ if (!IFrameSplitOperator.IsNumber(this.MaxValue)) return;
45619
+ this.CalculateBaseLine();
45620
+
45621
+ if (!IFrameSplitOperator.IsNumber(this.YBaseLine)) return;
45622
+ if (!IFrameSplitOperator.IsPlusNumber(this.BarMaxHeight)) return;
45623
+
45624
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
45625
+ var bMinute=this.IsMinuteFrame();
45626
+ var dataWidth=this.ChartFrame.DataWidth;
45627
+ var distanceWidth=this.ChartFrame.DistanceWidth;
45628
+ var xPointCount=this.ChartFrame.XPointCount;
45629
+ var border=this.ChartFrame.GetBorder();
45630
+
45631
+ if (bHScreen)
45632
+ {
45633
+ var chartright=border.BottomEx;
45634
+ var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
45635
+ }
45636
+ else
45637
+ {
45638
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
45639
+ var chartright=border.RightEx;
45640
+ }
45641
+
45642
+ var yCenter=this.YBaseLine;
45643
+ var aryUpBar=[], aryDownBar=[];
45644
+ for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
45645
+ {
45646
+ var kItem=this.Data.Data[i];
45647
+ if (!kItem) continue;
45648
+ var key=this.BuildKey(kItem);
45649
+ if (!this.MapCache.has(key)) continue;
45650
+
45651
+ var item=this.MapCache.get(key);
45652
+
45653
+ if (bMinute)
45654
+ {
45655
+ var x=this.ChartFrame.GetXFromIndex(j);
45656
+ }
45657
+ else
45658
+ {
45659
+ var left=xOffset;
45660
+ var right=xOffset+dataWidth;
45661
+ if (right>chartright) break;
45662
+ var x=left+(right-left)/2;
45663
+ }
45664
+
45665
+ if (IFrameSplitOperator.IsNumber(item.Up))
45666
+ {
45667
+ var y=yCenter-(item.Up*this.BarMaxHeight/this.MaxValue);
45668
+ aryUpBar.push({ X:x, Y:y});
45669
+ }
45670
+
45671
+ if (IFrameSplitOperator.IsNumber(item.Down))
45672
+ {
45673
+ var y=yCenter+(Math.abs(item.Down)*this.BarMaxHeight/this.MaxValue);
45674
+ aryDownBar.push({X:x, Y:y});
45675
+ }
45676
+ }
45677
+
45678
+ this.DrawBars(aryUpBar, this.UpColor);
45679
+ this.DrawBars(aryDownBar,this.DownColor);
45680
+ }
45681
+
45682
+ this.CalculateBaseLine=function()
45683
+ {
45684
+ if (!this.HQChart) return;
45685
+
45686
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
45687
+ var bMinute=this.IsMinuteFrame();
45688
+ var border=this.ChartFrame.GetBorder();
45689
+
45690
+ if (bMinute)
45691
+ {
45692
+ var chart=this.HQChart.ChartPaint[0];
45693
+ if (!chart || !IFrameSplitOperator.IsNumber(chart.YClose)) return;
45694
+
45695
+ this.YBaseLine=this.ChartFrame.GetYFromData(chart.YClose);
45696
+ if (bHScreen)
45697
+ {
45698
+ this.BarMaxHeight=(border.RightEx-this.YBaseLine)/3;
45699
+ }
45700
+ else
45701
+ {
45702
+ this.BarMaxHeight=(this.YBaseLine-border.TopEx)/3;
45703
+ }
45704
+ }
45705
+ else
45706
+ {
45707
+ //TODO:K线
45708
+ }
45709
+ }
45710
+
45711
+ this.DrawBars=function(aryBar, barColor)
45712
+ {
45713
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
45714
+ var yCenter=this.YBaseLine;
45715
+ this.Canvas.strokeStyle=barColor;
45716
+ this.Canvas.beginPath();
45717
+ var barCount=0;
45718
+ for (var i=0;i<aryBar.length;++i)
45719
+ {
45720
+ var item=aryBar[i];
45721
+ var x=ToFixedPoint(item.X)
45722
+ if (bHScreen)
45723
+ {
45724
+ this.Canvas.moveTo(yCenter,x);
45725
+ this.Canvas.lineTo(item.Y,x);
45726
+ }
45727
+ else
45728
+ {
45729
+ this.Canvas.moveTo(x,yCenter);
45730
+ this.Canvas.lineTo(x,item.Y);
45731
+ }
45732
+ ++barCount;
45733
+ }
45734
+ if (barCount>0) this.Canvas.stroke();
45735
+ }
45736
+
45737
+ this.BuildCacheData=function()
45738
+ {
45739
+ this.MaxValue=null;
45740
+ var mapData=new Map();
45741
+ this.MapCache=mapData;
45742
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryData)) return;
45743
+
45744
+ var max=null, min=null;
45745
+ for(var i=0;i<this.AryData.length;++i)
45746
+ {
45747
+ var item=this.AryData[i];
45748
+ if (!item) continue;
45749
+
45750
+ var key=this.BuildKey(item);
45751
+ mapData.set(key,item);
45752
+
45753
+ if (IFrameSplitOperator.IsNumber(item.Up))
45754
+ {
45755
+ if (!max) max={ Value:item.Up };
45756
+ else if (max.Value<item.Up) max.Value=item.Up;
45757
+
45758
+ if (!min) min={ Value:item.Up };
45759
+ else if (min.Value>item.Up) min.Value=item.Up;
45760
+ }
45761
+
45762
+ if (IFrameSplitOperator.IsNumber(item.Down))
45763
+ {
45764
+ if (!max) max={ Value:item.Down };
45765
+ else if (max.Value<item.Down) max.Value=item.Down;
45766
+
45767
+ if (!min) min={ Value:item.Down };
45768
+ else if (min.Value>item.Down) min.Value=item.Down;
45769
+ }
45770
+ }
45771
+
45772
+ if (max && min)
45773
+ {
45774
+ this.MaxValue=Math.max(Math.abs(max.Value),Math.abs(min.Value));
45775
+ if (IFrameSplitOperator.IsNumber(this.DefaultMax)) this.MaxValue=Math.max(this.DefaultMax,this.MaxValue);
45776
+ }
45777
+ }
45778
+
45779
+ this.GetMaxMin=function()
45780
+ {
45781
+ return {Min:null, Max:null};
45782
+ }
45783
+ }
45784
+
45590
45785
  function ChartClipColorStick()
45591
45786
  {
45592
45787
  this.newMethod=IChartPainting; //派生
@@ -79674,6 +79869,12 @@ function JSChartResource()
79674
79869
  ],
79675
79870
  }
79676
79871
 
79872
+ this.ChartBaseLineBar=
79873
+ {
79874
+ UpColor:"rgb(238,21,21)",
79875
+ DownColor:"rgb(25,158,0)"
79876
+ }
79877
+
79677
79878
  //手机端tooltip
79678
79879
  this.TooltipPaint = {
79679
79880
  BGColor:'rgba(250,250,250,0.8)', //背景色
@@ -81026,6 +81227,8 @@ function JSChartResource()
81026
81227
  if (style.ChartSimpleDoughnut) this.SetChartSimpleDoughnut(style.ChartSimpleDoughnut);
81027
81228
 
81028
81229
  if (style.ChartSimpleRadar) this.SetChartSimpleRadar(style.ChartSimpleRadar);
81230
+
81231
+ if (style.ChartBaseLineBar) this.SetChartBaseLineBar(style.ChartBaseLineBar);
81029
81232
 
81030
81233
  if (style.DRAWICON)
81031
81234
  {
@@ -82183,6 +82386,14 @@ function JSChartResource()
82183
82386
  if (IFrameSplitOperator.IsNonEmptyArray(style.AryArea)) dest.AryArea=style.AryArea.slice();
82184
82387
  }
82185
82388
 
82389
+ this.SetChartBaseLineBar=function(style)
82390
+ {
82391
+ var dest=this.ChartBaseLineBar;
82392
+
82393
+ if (style.UpColor) dest.UpColor=style.UpColor;
82394
+ if (style.DownColor) dest.DownColor=style.DownColor;
82395
+ }
82396
+
82186
82397
  this.SetIndexLock=function(style)
82187
82398
  {
82188
82399
  var item=style;
@@ -82267,6 +82478,7 @@ function JSChartLocalization()
82267
82478
  ['DialogTooltip-AC-AvPrice', {CN:'匹配均价', EN:'AVPrice', TC:'匹配均價'}],
82268
82479
  ['DialogTooltip-AC-Increase', {CN:'竞价涨幅', EN:'Increase', TC:'競價漲幅'}],
82269
82480
  ['DialogTooltip-AC-Vol', {CN:'匹配量', EN:'Vol', TC:'匹配量'}],
82481
+ ['DialogTooltip-AC-NotMatchVol', {CN:'未匹配量:', EN:'NV:', TC:'未匹配量'}],
82270
82482
  ['DialogTooltip-Value', {CN:'数值', EN:'Value', TC:'数值'}],
82271
82483
 
82272
82484
  ['FloatTooltip-Date', {CN:'日期', EN:'Date', TC:'日期'}],
@@ -85346,7 +85558,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
85346
85558
  else
85347
85559
  {
85348
85560
  self.AutoUpdateEvent(true,'KLineChartContainer::RequestHistoryData');
85349
- self.AutoUpdate();
85561
+ self.AutoUpdate(500);
85350
85562
  }
85351
85563
  });
85352
85564
 
@@ -85666,7 +85878,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
85666
85878
  else
85667
85879
  {
85668
85880
  self.AutoUpdateEvent(true,'KLineChartContainer::ReqeustHistoryMinuteData');
85669
- self.AutoUpdate();
85881
+ self.AutoUpdate(500);
85670
85882
  }
85671
85883
  });
85672
85884
 
@@ -90162,6 +90374,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
90162
90374
  }
90163
90375
 
90164
90376
  var frequency=this.AutoUpdateFrequency;
90377
+ if (IFrameSplitOperator.IsPlusNumber(waitTime)) frequency=waitTime;
90165
90378
  if (marketStatus==1) //盘前
90166
90379
  {
90167
90380
  this.AutoUpdateTimer=setTimeout(function()
@@ -126965,7 +127178,8 @@ var SCRIPT_CHART_NAME=
126965
127178
 
126966
127179
  CLIP_COLOR_STICK:"CLIP_COLOR_STICK", //上下柱子 裁剪
126967
127180
 
126968
- DRAW_KLINE:"DRAWKLINE"
127181
+ DRAW_KLINE:"DRAWKLINE",
127182
+ BASELINE_BAR:"BASELINE_BAR"
126969
127183
  }
126970
127184
 
126971
127185
 
@@ -129028,6 +129242,32 @@ function ScriptIndex(name,script,args,option)
129028
129242
  hqChart.ChartPaint.push(chart);
129029
129243
  }
129030
129244
 
129245
+ this.CreateBaseLineBar=function(hqChart,windowIndex,varItem,id)
129246
+ {
129247
+ var chart=new ChartBaseLineBar();
129248
+ chart.Canvas=hqChart.Canvas;
129249
+ chart.Name=varItem.Name;
129250
+ chart.ChartBorder=hqChart.Frame.SubFrame[windowIndex].Frame.ChartBorder;
129251
+ chart.ChartFrame=hqChart.Frame.SubFrame[windowIndex].Frame;
129252
+ chart.HQChart=hqChart;
129253
+ chart.Identify=this.Guid;
129254
+
129255
+ chart.Data=hqChart.GetKData(); //绑定K线
129256
+ chart.AryData=varItem.Draw.DrawData;
129257
+
129258
+ var config=varItem.Draw.Config;
129259
+ if (config)
129260
+ {
129261
+ if (config.UpColor) chart.UpColor=config.UpColor;
129262
+ if (config.DownColor) chart.DownColor=config.DownColor;
129263
+ if (IFrameSplitOperator.IsNumber(config.DefaultMax)) chart.DefaultMax=config.DefaultMax;
129264
+ }
129265
+
129266
+ chart.BuildCacheData();
129267
+ this.SetChartIndexName(chart);
129268
+ hqChart.ChartPaint.push(chart);
129269
+ }
129270
+
129031
129271
 
129032
129272
  this.CreateClipColorStick=function(hqChart,windowIndex,varItem,id)
129033
129273
  {
@@ -129400,6 +129640,9 @@ function ScriptIndex(name,script,args,option)
129400
129640
  case SCRIPT_CHART_NAME.CLIP_COLOR_STICK:
129401
129641
  this.CreateClipColorStick(hqChart,windowIndex,item,i);
129402
129642
  break;
129643
+ case SCRIPT_CHART_NAME.BASELINE_BAR:
129644
+ this.CreateBaseLineBar(hqChart,windowIndex,item,i);
129645
+ break;
129403
129646
  default:
129404
129647
  {
129405
129648
  var find=g_ScriptIndexChartFactory.Get(item.Draw.DrawType); //外部挂接
@@ -129753,6 +129996,9 @@ function OverlayScriptIndex(name,script,args,option)
129753
129996
  case SCRIPT_CHART_NAME.OVERLAY_BARS:
129754
129997
  this.CreateStackedBar(hqChart,windowIndex,item,i);
129755
129998
  break;
129999
+ case SCRIPT_CHART_NAME.BASELINE_BAR:
130000
+ this.CreateBaseLineBar(hqChart,windowIndex,item,i);
130001
+ break;
129756
130002
  case "DRAWCOLORKLINE":
129757
130003
  this.CreateDrawColorKLine(hqChart,windowIndex,item,i);
129758
130004
  break;
@@ -130565,6 +130811,33 @@ function OverlayScriptIndex(name,script,args,option)
130565
130811
  frame.ChartPaint.push(chart);
130566
130812
  }
130567
130813
 
130814
+ this.CreateBaseLineBar=function(hqChart,windowIndex,varItem,id)
130815
+ {
130816
+ var overlayIndex=this.OverlayIndex;
130817
+ var frame=overlayIndex.Frame;
130818
+ var chart=new ChartBaseLineBar();
130819
+ chart.Canvas=hqChart.Canvas;
130820
+ chart.Name=varItem.Name;
130821
+ chart.HQChart=hqChart;
130822
+ chart.ChartBorder=frame.Frame.ChartBorder;
130823
+ chart.ChartFrame=frame.Frame;
130824
+ chart.Identify=overlayIndex.Identify;
130825
+
130826
+ chart.Data=hqChart.GetKData(); //绑定K线
130827
+ chart.AryData=varItem.Draw.DrawData;
130828
+
130829
+ var config=varItem.Draw.Config;
130830
+ if (config)
130831
+ {
130832
+ if (config.UpColor) chart.UpColor=config.UpColor;
130833
+ if (config.DownColor) chart.DownColor=config.DownColor;
130834
+ if (IFrameSplitOperator.IsNumber(config.DefaultMax)) chart.DefaultMax=config.DefaultMax;
130835
+ }
130836
+
130837
+ chart.BuildCacheData();
130838
+ frame.ChartPaint.push(chart);
130839
+ }
130840
+
130568
130841
 
130569
130842
  //创建通道
130570
130843
  this.CreateChannel=function(hqChart,windowIndex,varItem,id)
@@ -132474,6 +132747,17 @@ function APIScriptIndex(name,script,args,option, isOverlay)
132474
132747
  if (draw.Option) outVarItem.Option=draw.Option;
132475
132748
  result.push(outVarItem);
132476
132749
  }
132750
+ else if (draw.DrawType==SCRIPT_CHART_NAME.BASELINE_BAR)
132751
+ {
132752
+ drawItem.Name=draw.Name;
132753
+ drawItem.Type=draw.Type;
132754
+ drawItem.DrawType=draw.DrawType;
132755
+ drawItem.DrawData=draw.DrawData;
132756
+ drawItem.Config=draw.Config;
132757
+
132758
+ outVarItem.Draw=drawItem;
132759
+ result.push(outVarItem);
132760
+ }
132477
132761
  else if (draw.DrawType=='MULTI_LINE')
132478
132762
  {
132479
132763
  drawItem.Text=draw.Text;
@@ -156988,17 +157272,31 @@ function JSDialogTooltip()
156988
157272
  {
156989
157273
  var item=data.Data.Data;
156990
157274
  if (!item) item={ Vol:[] };
156991
-
156992
- var timeForamt="HH:MM:SS";
156993
- if (item.Ver===1) timeForamt="HH:MM"
156994
- aryText=
156995
- [
156996
- this.ForamtDate(item.Date,this.Style==1?"MM/DD/W":"YYYY/MM/DD/W",'DialogTooltip-Date' ),
156997
- this.FormatTime(item.Time, null, timeForamt, 'DialogTooltip-Time'),
156998
- this.ForamtPrice(item.Price,item.YClose, defaultfloatPrecision,'DialogTooltip-AC-Price',1),
156999
- this.FormatIncrease(item.Price,item.YClose,defaultfloatPrecision,'DialogTooltip-AC-Increase',1),
157000
- this.FormatVol(item.Vol[0]/unit,'DialogTooltip-AC-Vol' ),
157001
- ];
157275
+ if (data.Data.Ver===1)
157276
+ {
157277
+ var timeForamt="HH:MM"
157278
+ aryText=
157279
+ [
157280
+ this.ForamtDate(item.Date,this.Style==1?"MM/DD/W":"YYYY/MM/DD/W",'DialogTooltip-Date' ),
157281
+ this.FormatTime(item.Time, null, timeForamt, 'DialogTooltip-Time'),
157282
+ this.ForamtPrice(item.Price,item.YClose, defaultfloatPrecision,'DialogTooltip-AC-Price',1),
157283
+ this.FormatIncrease(item.Price,item.YClose,defaultfloatPrecision,'DialogTooltip-AC-Increase',1),
157284
+ this.FormatVol(item.Vol[0]/unit,'DialogTooltip-AC-Vol'),
157285
+ ];
157286
+ }
157287
+ else
157288
+ {
157289
+ var timeForamt="HH:MM:SS";
157290
+ aryText=
157291
+ [
157292
+ this.ForamtDate(item.Date,this.Style==1?"MM/DD/W":"YYYY/MM/DD/W",'DialogTooltip-Date' ),
157293
+ this.FormatTime(item.Time, null, timeForamt, 'DialogTooltip-Time'),
157294
+ this.ForamtPrice(item.Price,item.YClose, defaultfloatPrecision,'DialogTooltip-AC-Price',1),
157295
+ this.FormatIncrease(item.Price,item.YClose,defaultfloatPrecision,'DialogTooltip-AC-Increase',1),
157296
+ this.FormatVol(item.Vol[0]/unit,'DialogTooltip-AC-Vol', 2),
157297
+ this.FormatVol(item.Vol[1]/unit,'DialogTooltip-AC-NotMatchVol', 2),
157298
+ ];
157299
+ }
157002
157300
  }
157003
157301
  else
157004
157302
  {
@@ -157119,7 +157417,7 @@ function JSDialogTooltip()
157119
157417
  return item;
157120
157418
  }
157121
157419
 
157122
- this.FormatVol=function(vol, TitleID)
157420
+ this.FormatVol=function(vol, TitleID, floatPrecision)
157123
157421
  {
157124
157422
  var item=
157125
157423
  {
@@ -157130,7 +157428,10 @@ function JSDialogTooltip()
157130
157428
 
157131
157429
  if (!IFrameSplitOperator.IsNumber(vol)) return item;
157132
157430
 
157133
- item.Text=IFrameSplitOperator.FormatValueStringV2(vol,0,2,this.LanguageID);
157431
+ var decimal=0; //小数位数
157432
+ if (IFrameSplitOperator.IsNumber(floatPrecision)) decimal=floatPrecision;
157433
+
157434
+ item.Text=IFrameSplitOperator.FormatValueStringV2(vol,decimal,2,this.LanguageID);
157134
157435
 
157135
157436
  return item;
157136
157437
  }
@@ -160808,7 +161109,7 @@ function HQChartScriptWorker()
160808
161109
 
160809
161110
 
160810
161111
 
160811
- var HQCHART_VERSION="1.1.14835";
161112
+ var HQCHART_VERSION="1.1.14845";
160812
161113
 
160813
161114
  function PrintHQChartVersion()
160814
161115
  {