hqchart 1.1.14834 → 1.1.14843

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.
@@ -57669,6 +57669,8 @@ HQData.Report_APIIndex=function(data, callback)
57669
57669
  HQData.APIIndex_KLINE_TABLE(data, callback);
57670
57670
  else if (request.Data.indexname=="API_DRAWSVG")
57671
57671
  HQData.APIIndex_DRAWSVG(data, callback);
57672
+ else if (request.Data.indexname=="API_BASELINE_BAR")
57673
+ HQData.APIIndex_BASELINE_BAR(data, callback);
57672
57674
  }
57673
57675
 
57674
57676
 
@@ -59017,3 +59019,41 @@ HQData.RequestVolumeProfileData=function(data, callback)
59017
59019
  }
59018
59020
 
59019
59021
 
59022
+ HQData.APIIndex_BASELINE_BAR=function(data, callback)
59023
+ {
59024
+ data.PreventDefault=true;
59025
+ var hqchart=data.HQChart;
59026
+ var kData=hqchart.GetKData();
59027
+
59028
+ var pointData=
59029
+ {
59030
+ name:"BASELINE_BAR", type:1,
59031
+ Draw:
59032
+ {
59033
+ Name:"BASELINE_BAR",
59034
+ DrawType:"BASELINE_BAR",
59035
+ DrawData:[],
59036
+ Config:{ },
59037
+ },
59038
+ };
59039
+
59040
+ for(var i=0;i<kData.Data.length;++i)
59041
+ {
59042
+ var kItem=kData.Data[i];
59043
+
59044
+ var item={ Date:kItem.Date, Time:kItem.Time, Up:kItem.Vol*0.2, Down:(kItem.Vol*0.35)*-1 };
59045
+ pointData.Draw.DrawData.push(item);
59046
+ }
59047
+
59048
+ var apiData=
59049
+ {
59050
+ code:0,
59051
+ stock:{ name:hqchart.Name, symbol:hqchart.Symbol },
59052
+ outdata: { date:kData.GetDate(), time:kData.GetTime(), outvar:[ pointData] },
59053
+ };
59054
+
59055
+ console.log('[HQData.APIIndex_BASELINE_BAR] apiData ', apiData);
59056
+ callback(apiData);
59057
+ }
59058
+
59059
+
@@ -20260,7 +20260,8 @@ var SCRIPT_CHART_NAME=
20260
20260
 
20261
20261
  CLIP_COLOR_STICK:"CLIP_COLOR_STICK", //上下柱子 裁剪
20262
20262
 
20263
- DRAW_KLINE:"DRAWKLINE"
20263
+ DRAW_KLINE:"DRAWKLINE",
20264
+ BASELINE_BAR:"BASELINE_BAR"
20264
20265
  }
20265
20266
 
20266
20267
 
@@ -22323,6 +22324,31 @@ function ScriptIndex(name,script,args,option)
22323
22324
  hqChart.ChartPaint.push(chart);
22324
22325
  }
22325
22326
 
22327
+ this.CreateBaseLineBar=function(hqChart,windowIndex,varItem,id)
22328
+ {
22329
+ var chart=new ChartBaseLineBar();
22330
+ chart.Canvas=hqChart.Canvas;
22331
+ chart.Name=varItem.Name;
22332
+ chart.ChartBorder=hqChart.Frame.SubFrame[windowIndex].Frame.ChartBorder;
22333
+ chart.ChartFrame=hqChart.Frame.SubFrame[windowIndex].Frame;
22334
+ chart.HQChart=hqChart;
22335
+ chart.Identify=this.Guid;
22336
+
22337
+ chart.Data=hqChart.GetKData(); //绑定K线
22338
+ chart.AryData=varItem.Draw.DrawData;
22339
+
22340
+ var config=varItem.Draw.Config;
22341
+ if (config)
22342
+ {
22343
+ if (config.UpColor) chart.UpColor=config.UpColor;
22344
+ if (config.DownColor) chart.DownColor=config.DownColor;
22345
+ }
22346
+
22347
+ chart.BuildCacheData();
22348
+ this.SetChartIndexName(chart);
22349
+ hqChart.ChartPaint.push(chart);
22350
+ }
22351
+
22326
22352
 
22327
22353
  this.CreateClipColorStick=function(hqChart,windowIndex,varItem,id)
22328
22354
  {
@@ -22695,6 +22721,9 @@ function ScriptIndex(name,script,args,option)
22695
22721
  case SCRIPT_CHART_NAME.CLIP_COLOR_STICK:
22696
22722
  this.CreateClipColorStick(hqChart,windowIndex,item,i);
22697
22723
  break;
22724
+ case SCRIPT_CHART_NAME.BASELINE_BAR:
22725
+ this.CreateBaseLineBar(hqChart,windowIndex,item,i);
22726
+ break;
22698
22727
  default:
22699
22728
  {
22700
22729
  var find=g_ScriptIndexChartFactory.Get(item.Draw.DrawType); //外部挂接
@@ -23048,6 +23077,9 @@ function OverlayScriptIndex(name,script,args,option)
23048
23077
  case SCRIPT_CHART_NAME.OVERLAY_BARS:
23049
23078
  this.CreateStackedBar(hqChart,windowIndex,item,i);
23050
23079
  break;
23080
+ case SCRIPT_CHART_NAME.BASELINE_BAR:
23081
+ this.CreateBaseLineBar(hqChart,windowIndex,item,i);
23082
+ break;
23051
23083
  case "DRAWCOLORKLINE":
23052
23084
  this.CreateDrawColorKLine(hqChart,windowIndex,item,i);
23053
23085
  break;
@@ -23860,6 +23892,32 @@ function OverlayScriptIndex(name,script,args,option)
23860
23892
  frame.ChartPaint.push(chart);
23861
23893
  }
23862
23894
 
23895
+ this.CreateBaseLineBar=function(hqChart,windowIndex,varItem,id)
23896
+ {
23897
+ var overlayIndex=this.OverlayIndex;
23898
+ var frame=overlayIndex.Frame;
23899
+ var chart=new ChartBaseLineBar();
23900
+ chart.Canvas=hqChart.Canvas;
23901
+ chart.Name=varItem.Name;
23902
+ chart.HQChart=hqChart;
23903
+ chart.ChartBorder=frame.Frame.ChartBorder;
23904
+ chart.ChartFrame=frame.Frame;
23905
+ chart.Identify=overlayIndex.Identify;
23906
+
23907
+ chart.Data=hqChart.GetKData(); //绑定K线
23908
+ chart.AryData=varItem.Draw.DrawData;
23909
+
23910
+ var config=varItem.Draw.Config;
23911
+ if (config)
23912
+ {
23913
+ if (config.UpColor) chart.UpColor=config.UpColor;
23914
+ if (config.DownColor) chart.DownColor=config.DownColor;
23915
+ }
23916
+
23917
+ chart.BuildCacheData();
23918
+ frame.ChartPaint.push(chart);
23919
+ }
23920
+
23863
23921
 
23864
23922
  //创建通道
23865
23923
  this.CreateChannel=function(hqChart,windowIndex,varItem,id)
@@ -25769,6 +25827,17 @@ function APIScriptIndex(name,script,args,option, isOverlay)
25769
25827
  if (draw.Option) outVarItem.Option=draw.Option;
25770
25828
  result.push(outVarItem);
25771
25829
  }
25830
+ else if (draw.DrawType==SCRIPT_CHART_NAME.BASELINE_BAR)
25831
+ {
25832
+ drawItem.Name=draw.Name;
25833
+ drawItem.Type=draw.Type;
25834
+ drawItem.DrawType=draw.DrawType;
25835
+ drawItem.DrawData=draw.DrawData;
25836
+ drawItem.Config=draw.Config;
25837
+
25838
+ outVarItem.Draw=drawItem;
25839
+ result.push(outVarItem);
25840
+ }
25772
25841
  else if (draw.DrawType=='MULTI_LINE')
25773
25842
  {
25774
25843
  drawItem.Text=draw.Text;
@@ -1144,7 +1144,7 @@ JSDealChartContainer.JsonDataToDealData=function(data)
1144
1144
 
1145
1145
  if (item[11]) dealItem.Symbol=item[11]; //股票代码
1146
1146
  if (item[12]) dealItem.Name=item[12]; //股票名称
1147
- if (item[13]) dealItem.BGColor=item[13]; //整行颜色
1147
+ if (item[13] || item[13]===null) dealItem.BGColor=item[13]; //整行颜色
1148
1148
 
1149
1149
  if (item[100]) dealItem.Guid=item[100];
1150
1150
 
@@ -41447,6 +41447,199 @@ function ChartMACD()
41447
41447
  }
41448
41448
  }
41449
41449
 
41450
+ //基准线上下柱子
41451
+ function ChartBaseLineBar()
41452
+ {
41453
+ this.newMethod=IChartPainting; //派生
41454
+ this.newMethod();
41455
+ delete this.newMethod;
41456
+
41457
+ this.ClassName="ChartBaseLineBar";
41458
+ this.UpColor=g_JSChartResource.ChartBaseLineBar.UpColor;
41459
+ this.DownColor=g_JSChartResource.ChartBaseLineBar.DownColor;
41460
+ this.LineWidth=1;
41461
+ this.IsDrawFirst=true;
41462
+ this.AryData=[]; //{ Date, Time, Up, Down }
41463
+
41464
+ this.MaxValue;
41465
+ this.YBaseLine;
41466
+ this.BarMaxHeight; //{ Up:, Down: }
41467
+
41468
+ this.Draw=function()
41469
+ {
41470
+ this.YBaseLine=null;
41471
+ this.BarMaxHeight=null;
41472
+ if (!this.IsShow || this.ChartFrame.IsMinSize || !this.IsVisible) return;
41473
+ if (this.IsShowIndexTitleOnly()) return;
41474
+ if (this.IsHideScriptIndex()) return;
41475
+ if (!this.HQChart) return;
41476
+ if(!this.Data || !IFrameSplitOperator.IsNonEmptyArray(this.Data.Data)) return;
41477
+ if (!IFrameSplitOperator.IsNumber(this.MaxValue)) return;
41478
+ this.CalculateBaseLine();
41479
+
41480
+ if (!IFrameSplitOperator.IsNumber(this.YBaseLine)) return;
41481
+ if (!IFrameSplitOperator.IsPlusNumber(this.BarMaxHeight)) return;
41482
+
41483
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
41484
+ var bMinute=this.IsMinuteFrame();
41485
+ var dataWidth=this.ChartFrame.DataWidth;
41486
+ var distanceWidth=this.ChartFrame.DistanceWidth;
41487
+ var xPointCount=this.ChartFrame.XPointCount;
41488
+ var border=this.ChartFrame.GetBorder();
41489
+
41490
+ if (bHScreen)
41491
+ {
41492
+ var chartright=border.BottomEx;
41493
+ var xOffset=border.TopEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
41494
+ }
41495
+ else
41496
+ {
41497
+ var xOffset=border.LeftEx+distanceWidth/2.0+g_JSChartResource.FrameLeftMargin;
41498
+ var chartright=border.RightEx;
41499
+ }
41500
+
41501
+ var yCenter=this.YBaseLine;
41502
+ var aryUpBar=[], aryDownBar=[];
41503
+ for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
41504
+ {
41505
+ var kItem=this.Data.Data[i];
41506
+ if (!kItem) continue;
41507
+ var key=this.BuildKey(kItem);
41508
+ if (!this.MapCache.has(key)) continue;
41509
+
41510
+ var item=this.MapCache.get(key);
41511
+
41512
+ if (bMinute)
41513
+ {
41514
+ var x=this.ChartFrame.GetXFromIndex(j);
41515
+ }
41516
+ else
41517
+ {
41518
+ var left=xOffset;
41519
+ var right=xOffset+dataWidth;
41520
+ if (right>chartright) break;
41521
+ var x=left+(right-left)/2;
41522
+ }
41523
+
41524
+ if (IFrameSplitOperator.IsNumber(item.Up))
41525
+ {
41526
+ var y=yCenter-(item.Up*this.BarMaxHeight/this.MaxValue);
41527
+ aryUpBar.push({ X:x, Y:y});
41528
+ }
41529
+
41530
+ if (IFrameSplitOperator.IsNumber(item.Down))
41531
+ {
41532
+ var y=yCenter+(Math.abs(item.Down)*this.BarMaxHeight/this.MaxValue);
41533
+ aryDownBar.push({X:x, Y:y});
41534
+ }
41535
+ }
41536
+
41537
+ this.DrawBars(aryUpBar, this.UpColor);
41538
+ this.DrawBars(aryDownBar,this.DownColor);
41539
+ }
41540
+
41541
+ this.CalculateBaseLine=function()
41542
+ {
41543
+ if (!this.HQChart) return;
41544
+
41545
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
41546
+ var bMinute=this.IsMinuteFrame();
41547
+ var border=this.ChartFrame.GetBorder();
41548
+
41549
+ if (bMinute)
41550
+ {
41551
+ var chart=this.HQChart.ChartPaint[0];
41552
+ if (!chart || !IFrameSplitOperator.IsNumber(chart.YClose)) return;
41553
+
41554
+ this.YBaseLine=this.ChartFrame.GetYFromData(chart.YClose);
41555
+ if (bHScreen)
41556
+ {
41557
+ this.BarMaxHeight=(border.RightEx-this.YBaseLine)/3;
41558
+ }
41559
+ else
41560
+ {
41561
+ this.BarMaxHeight=(this.YBaseLine-border.TopEx)/3;
41562
+ }
41563
+ }
41564
+ else
41565
+ {
41566
+ //TODO:K线
41567
+ }
41568
+ }
41569
+
41570
+ this.DrawBars=function(aryBar, barColor)
41571
+ {
41572
+ var bHScreen=(this.ChartFrame.IsHScreen===true);
41573
+ var yCenter=this.YBaseLine;
41574
+ this.Canvas.strokeStyle=barColor;
41575
+ this.Canvas.beginPath();
41576
+ var barCount=0;
41577
+ for (var i=0;i<aryBar.length;++i)
41578
+ {
41579
+ var item=aryBar[i];
41580
+ var x=ToFixedPoint(item.X)
41581
+ if (bHScreen)
41582
+ {
41583
+ this.Canvas.moveTo(yCenter,x);
41584
+ this.Canvas.lineTo(item.Y,x);
41585
+ }
41586
+ else
41587
+ {
41588
+ this.Canvas.moveTo(x,yCenter);
41589
+ this.Canvas.lineTo(x,item.Y);
41590
+ }
41591
+ ++barCount;
41592
+ }
41593
+ if (barCount>0) this.Canvas.stroke();
41594
+ }
41595
+
41596
+ this.BuildCacheData=function()
41597
+ {
41598
+ this.MaxValue=null;
41599
+ var mapData=new Map();
41600
+ this.MapCache=mapData;
41601
+ if (!IFrameSplitOperator.IsNonEmptyArray(this.AryData)) return;
41602
+
41603
+ var max=null, min=null;
41604
+ for(var i=0;i<this.AryData.length;++i)
41605
+ {
41606
+ var item=this.AryData[i];
41607
+ if (!item) continue;
41608
+
41609
+ var key=this.BuildKey(item);
41610
+ mapData.set(key,item);
41611
+
41612
+ if (IFrameSplitOperator.IsNumber(item.Up))
41613
+ {
41614
+ if (!max) max={ Value:item.Up };
41615
+ else if (max.Value<item.Up) max.Value=item.Up;
41616
+
41617
+ if (!min) min={ Value:item.Up };
41618
+ else if (min.Value>item.Up) min.Value=item.Up;
41619
+ }
41620
+
41621
+ if (IFrameSplitOperator.IsNumber(item.Down))
41622
+ {
41623
+ if (!max) max={ Value:item.Down };
41624
+ else if (max.Value<item.Down) max.Value=item.Down;
41625
+
41626
+ if (!min) min={ Value:item.Down };
41627
+ else if (min.Value>item.Down) min.Value=item.Down;
41628
+ }
41629
+ }
41630
+
41631
+ if (max && min)
41632
+ {
41633
+ this.MaxValue=Math.max(Math.abs(max.Value),Math.abs(min.Value));
41634
+ }
41635
+ }
41636
+
41637
+ this.GetMaxMin=function()
41638
+ {
41639
+ return {Min:null, Max:null};
41640
+ }
41641
+ }
41642
+
41450
41643
  function ChartClipColorStick()
41451
41644
  {
41452
41645
  this.newMethod=IChartPainting; //派生
@@ -75534,6 +75727,12 @@ function JSChartResource()
75534
75727
  ],
75535
75728
  }
75536
75729
 
75730
+ this.ChartBaseLineBar=
75731
+ {
75732
+ UpColor:"rgb(238,21,21)",
75733
+ DownColor:"rgb(25,158,0)"
75734
+ }
75735
+
75537
75736
  //手机端tooltip
75538
75737
  this.TooltipPaint = {
75539
75738
  BGColor:'rgba(250,250,250,0.8)', //背景色
@@ -76886,6 +77085,8 @@ function JSChartResource()
76886
77085
  if (style.ChartSimpleDoughnut) this.SetChartSimpleDoughnut(style.ChartSimpleDoughnut);
76887
77086
 
76888
77087
  if (style.ChartSimpleRadar) this.SetChartSimpleRadar(style.ChartSimpleRadar);
77088
+
77089
+ if (style.ChartBaseLineBar) this.SetChartBaseLineBar(style.ChartBaseLineBar);
76889
77090
 
76890
77091
  if (style.DRAWICON)
76891
77092
  {
@@ -78043,6 +78244,14 @@ function JSChartResource()
78043
78244
  if (IFrameSplitOperator.IsNonEmptyArray(style.AryArea)) dest.AryArea=style.AryArea.slice();
78044
78245
  }
78045
78246
 
78247
+ this.SetChartBaseLineBar=function(style)
78248
+ {
78249
+ var dest=this.ChartBaseLineBar;
78250
+
78251
+ if (style.UpColor) dest.UpColor=style.UpColor;
78252
+ if (style.DownColor) dest.DownColor=style.DownColor;
78253
+ }
78254
+
78046
78255
  this.SetIndexLock=function(style)
78047
78256
  {
78048
78257
  var item=style;
@@ -81206,7 +81415,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
81206
81415
  else
81207
81416
  {
81208
81417
  self.AutoUpdateEvent(true,'KLineChartContainer::RequestHistoryData');
81209
- self.AutoUpdate();
81418
+ self.AutoUpdate(500);
81210
81419
  }
81211
81420
  });
81212
81421
 
@@ -81526,7 +81735,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
81526
81735
  else
81527
81736
  {
81528
81737
  self.AutoUpdateEvent(true,'KLineChartContainer::ReqeustHistoryMinuteData');
81529
- self.AutoUpdate();
81738
+ self.AutoUpdate(500);
81530
81739
  }
81531
81740
  });
81532
81741
 
@@ -86022,6 +86231,7 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
86022
86231
  }
86023
86232
 
86024
86233
  var frequency=this.AutoUpdateFrequency;
86234
+ if (IFrameSplitOperator.IsPlusNumber(waitTime)) frequency=waitTime;
86025
86235
  if (marketStatus==1) //盘前
86026
86236
  {
86027
86237
  this.AutoUpdateTimer=setTimeout(function()
@@ -2155,6 +2155,8 @@ HQData.Report_APIIndex=function(data, callback)
2155
2155
  HQData.APIIndex_KLINE_TABLE(data, callback);
2156
2156
  else if (request.Data.indexname=="API_DRAWSVG")
2157
2157
  HQData.APIIndex_DRAWSVG(data, callback);
2158
+ else if (request.Data.indexname=="API_BASELINE_BAR")
2159
+ HQData.APIIndex_BASELINE_BAR(data, callback);
2158
2160
  }
2159
2161
 
2160
2162
 
@@ -3503,3 +3505,41 @@ HQData.RequestVolumeProfileData=function(data, callback)
3503
3505
  }
3504
3506
 
3505
3507
 
3508
+ HQData.APIIndex_BASELINE_BAR=function(data, callback)
3509
+ {
3510
+ data.PreventDefault=true;
3511
+ var hqchart=data.HQChart;
3512
+ var kData=hqchart.GetKData();
3513
+
3514
+ var pointData=
3515
+ {
3516
+ name:"BASELINE_BAR", type:1,
3517
+ Draw:
3518
+ {
3519
+ Name:"BASELINE_BAR",
3520
+ DrawType:"BASELINE_BAR",
3521
+ DrawData:[],
3522
+ Config:{ },
3523
+ },
3524
+ };
3525
+
3526
+ for(var i=0;i<kData.Data.length;++i)
3527
+ {
3528
+ var kItem=kData.Data[i];
3529
+
3530
+ var item={ Date:kItem.Date, Time:kItem.Time, Up:kItem.Vol*0.2, Down:(kItem.Vol*0.35)*-1 };
3531
+ pointData.Draw.DrawData.push(item);
3532
+ }
3533
+
3534
+ var apiData=
3535
+ {
3536
+ code:0,
3537
+ stock:{ name:hqchart.Name, symbol:hqchart.Symbol },
3538
+ outdata: { date:kData.GetDate(), time:kData.GetTime(), outvar:[ pointData] },
3539
+ };
3540
+
3541
+ console.log('[HQData.APIIndex_BASELINE_BAR] apiData ', apiData);
3542
+ callback(apiData);
3543
+ }
3544
+
3545
+