hqchart 1.1.14291 → 1.1.14299

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hqchart",
3
- "version": "1.1.14291",
3
+ "version": "1.1.14299",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -55745,6 +55745,8 @@ HQData.Minute_RequestMinuteData=function(data, callback)
55745
55745
  }
55746
55746
  */
55747
55747
 
55748
+ stockItem.minute.length=50;
55749
+
55748
55750
  var hqchartData={code:0, stock:[stockItem] };
55749
55751
 
55750
55752
 
@@ -57370,6 +57372,8 @@ HQData.Report_APIIndex=function(data, callback)
57370
57372
  HQData.APIIndex_MULTI_SVGICON(data, callback);
57371
57373
  else if (request.Data.indexname=="API-DRAWTEXT_LINE")
57372
57374
  HQData.APIIndex_DRAWTEXT_LINE(data, callback);
57375
+ else if (request.Data.indexname=="API_DRAW_SIMPLE_TABLE")
57376
+ HQData.APIIndex_DRAW_SIMPLE_TABLE(data, callback);
57373
57377
  }
57374
57378
 
57375
57379
 
@@ -57792,4 +57796,48 @@ HQData.APIIndex_DRAWTEXT_LINE=function(data, callback)
57792
57796
  callback(apiData);
57793
57797
  }
57794
57798
 
57799
+ HQData.APIIndex_DRAW_SIMPLE_TABLE=function(data, callback)
57800
+ {
57801
+ data.PreventDefault=true;
57802
+ var hqchart=data.HQChart;
57803
+ var kData=hqchart.GetKData();
57804
+
57805
+ var tableData=
57806
+ {
57807
+ name:'DRAW_SIMPLE_TABLE', type:1,
57808
+ Draw:
57809
+ {
57810
+ DrawType:'DRAW_SIMPLE_TABLE',
57811
+ DrawData:
57812
+ {
57813
+ //BGColor:"rgba(250,250,210,0.8)",
57814
+ //BorderColor:"rgb(0,0,255)",
57815
+ //TextColor:"rgb(0,191,255)",
57816
+ TableData:
57817
+ [
57818
+ { AryCell:[{ Text:"股票代码"}, { Text:"主营业务", TextAlign:'center'}, { Text:"每股收益(元)"}] },
57819
+ { AryCell:[{ Text:"美丽生态"}, { Text:"园林绿化"}, { Text:"13.5", Color:"rgb(139,0,139)"}] },
57820
+ { AryCell:[{ Text:"深物业A"}, { Text:"房地产及相关业务", BGColor:"rgb(200,200,200)"}, { Text:"0.12"}] },
57821
+ { AryCell:[{ Text:"深科技"}, { Text:"计算机硬件、通讯设备等"}, { Text:"5.4"}] },
57822
+ ],
57823
+
57824
+ //TextFont:{ Size:16, Name:"微软雅黑"},
57825
+ //XOffset:-10,
57826
+ //YOffset:-15,
57827
+ }
57828
+ }
57829
+ };
57830
+
57831
+ var apiData=
57832
+ {
57833
+ code:0,
57834
+ stock:{ name:hqchart.Name, symbol:hqchart.Symbol },
57835
+ outdata: { date:kData.GetDate(), time:kData.GetTime() , outvar:[tableData] }
57836
+ };
57837
+
57838
+
57839
+ console.log('[HQData.APIIndex_DRAW_SIMPLE_TABLE] apiData ', apiData);
57840
+ callback(apiData);
57841
+ }
57842
+
57795
57843
 
@@ -179,7 +179,7 @@ function JSPopKeyboard()
179
179
  }
180
180
  }
181
181
 
182
- if ((code>=48 && code<=57) || (code>=65 && code<=90) || (code>=97 && code<=122) || code==8)
182
+ if ((code>=48 && code<=57) || (code>=65 && code<=90) || (code>=96 && code<=122) || code==8)
183
183
  {
184
184
  var strText=this.InputDOM.value;
185
185
  strText=strText.toUpperCase();
@@ -277,7 +277,7 @@ function JSPopKeyboard()
277
277
  var code=event.keyCode;
278
278
  if (code==116) return; //F5不处理
279
279
 
280
- if (!this.IsShow() && (code>=48 && code<=57) || (code>=65 && code<=90) || (code>=97 && code<=122))
280
+ if (!this.IsShow() && (code>=48 && code<=57) || (code>=65 && code<=90) || (code>=96 && code<=122))
281
281
  {
282
282
  this.Show();
283
283
  this.InputDOM.focus();
@@ -11489,10 +11489,24 @@ function JSDraw(errorHandler,symbolData)
11489
11489
  }
11490
11490
 
11491
11491
  //表格
11492
- this.TABLE_CELL=function(text, color, textAlign)
11492
+ this.TABLE_CELL=function(data, color, textAlign, bgColor)
11493
11493
  {
11494
+ var text=null;
11495
+ if (IFrameSplitOperator.IsString(data))
11496
+ {
11497
+ text=data;
11498
+ }
11499
+ else if (IFrameSplitOperator.IsNonEmptyArray(data))
11500
+ {
11501
+ var precision=2;
11502
+ var lastValue=data[data.length-1];
11503
+ if (IFrameSplitOperator.IsNumber(lastValue)) text=lastValue.toFixed(precision);
11504
+ else if (IFrameSplitOperator.IsString(lastValue)) text=lastValue;
11505
+ }
11506
+
11494
11507
  var cellItem={ Text:text };
11495
11508
  if (color) cellItem.Color=color;
11509
+ if (bgColor) cellItem.BGColor=bgColor;
11496
11510
  if (IFrameSplitOperator.IsString(textAlign))
11497
11511
  {
11498
11512
  var strValue=textAlign.toLowerCase(); //转小写
@@ -18452,7 +18466,7 @@ function JSExecute(ast,option)
18452
18466
 
18453
18467
  //表格函数
18454
18468
  case "TABLE_CELL":
18455
- node.Out=this.Draw.TABLE_CELL(args[0],args[1],args[2]);
18469
+ node.Out=this.Draw.TABLE_CELL(args[0],args[1],args[2],args[3]);
18456
18470
  break;
18457
18471
  case "TABLE_ROW":
18458
18472
  node.Out=this.Draw.TABLE_ROW(args);
@@ -19359,6 +19373,10 @@ function JSExplainer(ast,option)
19359
19373
  ["L2_VOLNUM", { Name:"L2_VOLNUM", Param:{ Count:2 }, ToString:function(args) { return `单数分档`; } }],
19360
19374
  ["L2_VOL", { Name:"L2_VOL", Param:{ Count:2 }, ToString:function(args) { return `成交量分档`; } }],
19361
19375
  ["L2_AMO", { Name:"L2_AMO", Param:{ Count:2 }, ToString:function(args) { return `成交额分档`; } }],
19376
+
19377
+ ["TABLE_CELL", { Name:"TABLE_CELL",Param:{ Dynamic:true }, ToString:function(args) { return `创建表格单元格`; } }],
19378
+ ["TABLE_ROW", { Name:"TABLE_ROW",Param:{ Dynamic:true }, ToString:function(args) { return `创建表格行`; } }],
19379
+ ["DRAWTABLE", { Name:"DRAWTABLE",Param:{ Dynamic:true }, ToString:function(args) { return `绘制表格`; } }]
19362
19380
 
19363
19381
  ]
19364
19382
  );
@@ -31761,6 +31761,127 @@ function ChartSimpleTable()
31761
31761
  }
31762
31762
  }
31763
31763
 
31764
+
31765
+ //饼图
31766
+ function ChartPie()
31767
+ {
31768
+ this.newMethod=IChartPainting; //派生
31769
+ this.newMethod();
31770
+ delete this.newMethod;
31771
+
31772
+ this.Radius = 100; //半径默认值
31773
+ this.Width=40;
31774
+ this.Height=50;
31775
+
31776
+ //this.Distance = 30; //指示线超出圆饼的距离
31777
+ //this.txtLine = 20; // 文本下划线
31778
+ //this.paddingX = 20 / 3;// 设置文本的移动
31779
+
31780
+
31781
+
31782
+ this.RectClient={ };
31783
+
31784
+ this.Draw=function()
31785
+ {
31786
+ if (!this.Data || !this.Data.Data || !(this.Data.Data.length>0)) return this.DrawEmptyData();
31787
+
31788
+
31789
+
31790
+ let left=this.ChartBorder.GetLeft();
31791
+ let right=this.ChartBorder.GetRight();
31792
+ let top=this.ChartBorder.GetTop();
31793
+ let bottom=this.ChartBorder.GetBottom();
31794
+ let width=this.ChartBorder.GetWidth();
31795
+ let height=this.ChartBorder.GetHeight();
31796
+
31797
+ if(isNaN(this.Radius)){
31798
+ let str = this.Radius.replace("%","");
31799
+ str = str/100;
31800
+ if(width >= height){
31801
+ this.Radius = str*height;
31802
+ }
31803
+ if(width < height) this.Radius = str*width;
31804
+ }
31805
+
31806
+
31807
+ this.Canvas.save();
31808
+ this.Canvas.translate(width/2,height/2);
31809
+
31810
+ let totalValue=0; //求和
31811
+ for(let i in this.Data.Data)
31812
+ {
31813
+ totalValue += this.Data.Data[i].Value;
31814
+ }
31815
+ let start = 0;
31816
+ let end = 0;
31817
+ //画饼图
31818
+ for(let i in this.Data.Data)
31819
+ {
31820
+ let item =this.Data.Data[i];
31821
+ let rate=(item.Value/totalValue).toFixed(2); //占比
31822
+ //JSConsole.Chart.Log('[ChartPie::Draw]', i, rate, item);
31823
+
31824
+ // 绘制扇形
31825
+ this.Canvas.beginPath();
31826
+ this.Canvas.moveTo(0,0);
31827
+
31828
+ end += rate*2*Math.PI;//终止角度
31829
+ this.Canvas.strokeStyle = "white";
31830
+ this.Canvas.fillStyle = item.Color;
31831
+ this.Canvas.arc(0,0,this.Radius,start,end);
31832
+ this.Canvas.fill();
31833
+ this.Canvas.closePath();
31834
+ this.Canvas.stroke();
31835
+
31836
+ // 绘制直线
31837
+ this.Canvas.beginPath();
31838
+ this.Canvas.strokeStyle = item.Color;
31839
+ this.Canvas.moveTo(0,0);
31840
+ let x = (this.Radius + this.Distance)*Math.cos(end- (end-start)/2);
31841
+ let y = (this.Radius + this.Distance)*Math.sin(end - (end-start)/2);
31842
+ this.Canvas.lineTo(x,y);
31843
+ // JSConsole.Chart.Log(x,y,"xy")
31844
+
31845
+ // 绘制横线
31846
+ let txtLine = this.txtLine;
31847
+ let paddingX = this.paddingX;
31848
+ this.Canvas.textAlign = 'left';
31849
+ if( end - (end-start)/2 < 1.5*Math.PI && end - (end-start)/2 > 0.5*Math.PI ){
31850
+
31851
+ txtLine = - this.txtLine;
31852
+ paddingX = - this.paddingX;
31853
+ this.Canvas.textAlign = 'right';
31854
+ }
31855
+ this.Canvas.lineTo( x + txtLine, y );
31856
+ this.Canvas.stroke();
31857
+
31858
+ // 写文字
31859
+ if(item.Text){
31860
+ this.Canvas.fillText( item.Text, x + txtLine + paddingX, y );
31861
+ }else{
31862
+ let text = `${item.Name}:${item.Value}`;
31863
+ this.Canvas.fillText( text, x + txtLine + paddingX, y );
31864
+ }
31865
+
31866
+
31867
+ start += rate*2*Math.PI;//起始角度
31868
+ }
31869
+
31870
+ this.Canvas.restore();
31871
+ }
31872
+
31873
+ //空数据
31874
+ this.DrawEmptyData=function()
31875
+ {
31876
+ JSConsole.Chart.Log('[ChartPie::DrawEmptyData]')
31877
+ }
31878
+
31879
+ this.GetMaxMin=function()
31880
+ {
31881
+ return { Min:null, Max:null };
31882
+ }
31883
+ }
31884
+
31764
31885
  //分钟成交量 支持横屏
31765
31886
  function ChartMinuteVolumBar()
31766
31887
  {
@@ -81216,18 +81337,31 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
81216
81337
  }
81217
81338
 
81218
81339
  //十字光标解锁
81219
- this.UnlockCorssCursor=function()
81340
+ this.UnlockCorssCursor=function(option)
81220
81341
  {
81221
81342
  var xItem=this.GlobalOption.LockCorssCursor.X;
81222
81343
  xItem.Enable=false;
81223
81344
  xItem.KLine=null;
81345
+
81346
+ if (option && option.Draw) this.Draw();
81224
81347
  }
81225
81348
 
81226
- this.LockCorssCursor=function()
81349
+ this.LockCorssCursor=function(option)
81227
81350
  {
81351
+ if (this.CursorIndex<0) return false;
81352
+ var kData=this.GetKData();
81353
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return false;
81354
+
81355
+ var dataIndex=kData.DataOffset+parseInt(this.CursorIndex.toFixed(0));
81356
+ var kItem=kData.Data[dataIndex];
81357
+ if (!kItem) return false;
81358
+
81228
81359
  var xItem=this.GlobalOption.LockCorssCursor.X;
81229
- xItem.KLine={ DataIndex:null, Date:null, Time:null };
81360
+ xItem.KLine={ DataIndex:dataIndex, Date:kItem.Date, Time:kItem.Time };
81230
81361
  xItem.Enable=true;
81362
+
81363
+ if (option && option.Draw) this.Draw();
81364
+ return true;
81231
81365
  }
81232
81366
 
81233
81367
  this.GetCorssCursorPosition=function()
@@ -81243,7 +81377,19 @@ function KLineChartContainer(uielement,OffscreenElement, cacheElement)
81243
81377
  var xItem=this.GlobalOption.LockCorssCursor.X;
81244
81378
  if (xItem.Enable && xItem.KLine)
81245
81379
  {
81246
- position.CursorIndex=xItem.KLine.CursorIndex;
81380
+ var kData=this.GetKData();
81381
+ if (!kData || !IFrameSplitOperator.IsNonEmptyArray(kData.Data)) return position;
81382
+
81383
+ position.CursorIndex=xItem.KLine.DataIndex-kData.DataOffset;
81384
+ position.LastPoint.X=this.Frame.GetXFromIndex(position.CursorIndex);
81385
+
81386
+ var border=this.Frame.ChartBorder.GetBorder();
81387
+ if (position.LastPoint.Y<border.Top || position.LastPoint.Y>border.Bottom) //超出图形框子, 调整为收盘价
81388
+ {
81389
+ var kItem=kData.Data[xItem.KLine.DataIndex];
81390
+ var y = this.Frame.SubFrame[0].Frame.GetYFromData(kItem.Close);
81391
+ position.LastPoint.Y=y;
81392
+ }
81247
81393
  }
81248
81394
 
81249
81395
  return position;
@@ -82436,13 +82582,13 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
82436
82582
  }
82437
82583
  }
82438
82584
 
82439
- this.LockCorssCursor=function()
82585
+ this.LockCorssCursor=function(option)
82440
82586
  {
82441
82587
  var xItem=this.GlobalOption.LockCorssCursor.X;
82442
82588
 
82443
82589
  if (this.EnableNewIndex)
82444
82590
  {
82445
- if (this.CorssCursorIndex.Type!=1 && this.CorssCursorIndex.Type!=10) return; //目前只支持连续交易时间段
82591
+ if (this.CorssCursorIndex.Type!=1 && this.CorssCursorIndex.Type!=10) return false; //目前只支持连续交易时间段
82446
82592
 
82447
82593
  xItem.Minute=
82448
82594
  {
@@ -82458,13 +82604,19 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
82458
82604
  }
82459
82605
 
82460
82606
  xItem.Enable=true;
82607
+
82608
+ if (option && option.Draw) this.Draw();
82609
+
82610
+ return true;
82461
82611
  }
82462
82612
 
82463
- this.UnlockCorssCursor=function()
82613
+ this.UnlockCorssCursor=function(option)
82464
82614
  {
82465
82615
  var xItem=this.GlobalOption.LockCorssCursor.X;
82466
82616
  xItem.Enable=false;
82467
82617
  xItem.Minute=null;
82618
+
82619
+ if (option && option.Draw) this.Draw();
82468
82620
  }
82469
82621
 
82470
82622
  this.GetCorssCursorPosition=function()
@@ -82503,6 +82655,7 @@ function MinuteChartContainer(uielement,offscreenElement,cacheElement)
82503
82655
  if (kData && IFrameSplitOperator.IsNonEmptyArray(kData.Data))
82504
82656
  {
82505
82657
  var index=parseInt(position.CursorIndex.toFixed(0));
82658
+ if (index>=kData.Data.length) index=kData.Data.length-1; //未开盘的时间,取最后一个数据的收盘价
82506
82659
  var item=kData.Data[index];
82507
82660
  if (item && IFrameSplitOperator.IsNumber(item.Close))
82508
82661
  {
@@ -231,6 +231,8 @@ HQData.Minute_RequestMinuteData=function(data, callback)
231
231
  }
232
232
  */
233
233
 
234
+ stockItem.minute.length=50;
235
+
234
236
  var hqchartData={code:0, stock:[stockItem] };
235
237
 
236
238
 
@@ -1856,6 +1858,8 @@ HQData.Report_APIIndex=function(data, callback)
1856
1858
  HQData.APIIndex_MULTI_SVGICON(data, callback);
1857
1859
  else if (request.Data.indexname=="API-DRAWTEXT_LINE")
1858
1860
  HQData.APIIndex_DRAWTEXT_LINE(data, callback);
1861
+ else if (request.Data.indexname=="API_DRAW_SIMPLE_TABLE")
1862
+ HQData.APIIndex_DRAW_SIMPLE_TABLE(data, callback);
1859
1863
  }
1860
1864
 
1861
1865
 
@@ -2278,4 +2282,48 @@ HQData.APIIndex_DRAWTEXT_LINE=function(data, callback)
2278
2282
  callback(apiData);
2279
2283
  }
2280
2284
 
2285
+ HQData.APIIndex_DRAW_SIMPLE_TABLE=function(data, callback)
2286
+ {
2287
+ data.PreventDefault=true;
2288
+ var hqchart=data.HQChart;
2289
+ var kData=hqchart.GetKData();
2290
+
2291
+ var tableData=
2292
+ {
2293
+ name:'DRAW_SIMPLE_TABLE', type:1,
2294
+ Draw:
2295
+ {
2296
+ DrawType:'DRAW_SIMPLE_TABLE',
2297
+ DrawData:
2298
+ {
2299
+ //BGColor:"rgba(250,250,210,0.8)",
2300
+ //BorderColor:"rgb(0,0,255)",
2301
+ //TextColor:"rgb(0,191,255)",
2302
+ TableData:
2303
+ [
2304
+ { AryCell:[{ Text:"股票代码"}, { Text:"主营业务", TextAlign:'center'}, { Text:"每股收益(元)"}] },
2305
+ { AryCell:[{ Text:"美丽生态"}, { Text:"园林绿化"}, { Text:"13.5", Color:"rgb(139,0,139)"}] },
2306
+ { AryCell:[{ Text:"深物业A"}, { Text:"房地产及相关业务", BGColor:"rgb(200,200,200)"}, { Text:"0.12"}] },
2307
+ { AryCell:[{ Text:"深科技"}, { Text:"计算机硬件、通讯设备等"}, { Text:"5.4"}] },
2308
+ ],
2309
+
2310
+ //TextFont:{ Size:16, Name:"微软雅黑"},
2311
+ //XOffset:-10,
2312
+ //YOffset:-15,
2313
+ }
2314
+ }
2315
+ };
2316
+
2317
+ var apiData=
2318
+ {
2319
+ code:0,
2320
+ stock:{ name:hqchart.Name, symbol:hqchart.Symbol },
2321
+ outdata: { date:kData.GetDate(), time:kData.GetTime() , outvar:[tableData] }
2322
+ };
2323
+
2324
+
2325
+ console.log('[HQData.APIIndex_DRAW_SIMPLE_TABLE] apiData ', apiData);
2326
+ callback(apiData);
2327
+ }
2328
+
2281
2329