hqchart 1.1.13928 → 1.1.13944

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.13928",
3
+ "version": "1.1.13944",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -16,6 +16,7 @@ function JSDialogTooltip()
16
16
  this.DivDialog=null;
17
17
  this.DragTitle=null;
18
18
  this.TitleBox=null; //{ DivTitle, DivName, DivName }
19
+ this.Style=0; //0=一行一个, 1=2行一个
19
20
 
20
21
  this.HQChart=null;
21
22
 
@@ -41,10 +42,16 @@ function JSDialogTooltip()
41
42
 
42
43
  this.KItemCache=null;
43
44
  this.KItemCacheID=null;
45
+ this.LastValueCache=null; //最后的鼠标位置对应的数值
46
+ this.LastValueCacheID=null;
44
47
 
45
- this.Inital=function(hqchart)
48
+ this.Inital=function(hqchart, option)
46
49
  {
47
- this.HQChart=hqchart;
50
+ this.HQChart=hqchart;
51
+ if (option)
52
+ {
53
+ if (IFrameSplitOperator.IsNumber(option.Style)) this.Style=option.Style;
54
+ }
48
55
  }
49
56
 
50
57
  this.Destroy=function()
@@ -107,36 +114,78 @@ function JSDialogTooltip()
107
114
  table.appendChild(tbody);
108
115
 
109
116
  this.AryData=[];
110
- for(var i=0;i<this.MaxRowCount;++i)
117
+ if (this.Style==1)
111
118
  {
112
- var rowItem={ Tr:null, TitleSpan:null, TextSpan:null };
113
-
114
- var trDom=document.createElement("tr");
115
- trDom.className='UMyChart_Tooltip_Group_Tr';
116
- tbody.appendChild(trDom);
117
- rowItem.Tr=trDom;
118
-
119
- var tdDom=document.createElement("td");
120
- tdDom.className="UMyChart_Tooltip_Title_Td"; //标题
121
- trDom.appendChild(tdDom);
122
-
123
- var spanDom=document.createElement("span");
124
- spanDom.className='UMyChart_Tooltip_Title_Span';
125
- spanDom.innerText='标题';
126
- tdDom.appendChild(spanDom);
127
- rowItem.TitleSpan=spanDom;
128
-
129
- var tdDom=document.createElement("td");
130
- tdDom.className="UMyChart_Tooltip_Text_Td"; //数值
131
- trDom.appendChild(tdDom);
132
-
133
- var spanDom=document.createElement("span");
134
- spanDom.className='UMyChart_Tooltip_Text_Span';
135
- spanDom.innerText='数值';
136
- tdDom.appendChild(spanDom);
137
- rowItem.TextSpan=spanDom;
138
-
139
- this.AryData.push(rowItem);
119
+ for(var i=0;i<this.MaxRowCount;++i)
120
+ {
121
+ var rowItem={ Tr:null, TitleSpan:null, TextSpan:null, Tr2:null };
122
+
123
+ var trDom=document.createElement("tr");
124
+ trDom.className='UMyChart_Tooltip_Group_Tr';
125
+ tbody.appendChild(trDom);
126
+ rowItem.Tr=trDom;
127
+
128
+ var tdDom=document.createElement("td");
129
+ tdDom.className="UMyChart_Tooltip_Text_Sinlge_Td"; //标题
130
+ trDom.appendChild(tdDom);
131
+
132
+ var spanDom=document.createElement("span");
133
+ spanDom.className='UMyChart_Tooltip_Title_Left_Span';
134
+ spanDom.innerText='标题';
135
+ tdDom.appendChild(spanDom);
136
+ rowItem.TitleSpan=spanDom;
137
+
138
+ var trDom=document.createElement("tr");
139
+ trDom.className='UMyChart_Tooltip_Group_Tr';
140
+ tbody.appendChild(trDom);
141
+ rowItem.Tr2=trDom;
142
+
143
+ var tdDom=document.createElement("td");
144
+ tdDom.className="UMyChart_Tooltip_Text_Sinlge_Td"; //数值
145
+ trDom.appendChild(tdDom);
146
+
147
+ var spanDom=document.createElement("span");
148
+ spanDom.className='UMyChart_Tooltip_Text_Span';
149
+ spanDom.innerText='数值';
150
+ tdDom.appendChild(spanDom);
151
+ rowItem.TextSpan=spanDom;
152
+
153
+ this.AryData.push(rowItem);
154
+ }
155
+ }
156
+ else
157
+ {
158
+ for(var i=0;i<this.MaxRowCount;++i)
159
+ {
160
+ var rowItem={ Tr:null, TitleSpan:null, TextSpan:null };
161
+
162
+ var trDom=document.createElement("tr");
163
+ trDom.className='UMyChart_Tooltip_Group_Tr';
164
+ tbody.appendChild(trDom);
165
+ rowItem.Tr=trDom;
166
+
167
+ var tdDom=document.createElement("td");
168
+ tdDom.className="UMyChart_Tooltip_Title_Td"; //标题
169
+ trDom.appendChild(tdDom);
170
+
171
+ var spanDom=document.createElement("span");
172
+ spanDom.className='UMyChart_Tooltip_Title_Span';
173
+ spanDom.innerText='标题';
174
+ tdDom.appendChild(spanDom);
175
+ rowItem.TitleSpan=spanDom;
176
+
177
+ var tdDom=document.createElement("td");
178
+ tdDom.className="UMyChart_Tooltip_Text_Td"; //数值
179
+ trDom.appendChild(tdDom);
180
+
181
+ var spanDom=document.createElement("span");
182
+ spanDom.className='UMyChart_Tooltip_Text_Span';
183
+ spanDom.innerText='数值';
184
+ tdDom.appendChild(spanDom);
185
+ rowItem.TextSpan=spanDom;
186
+
187
+ this.AryData.push(rowItem);
188
+ }
140
189
  }
141
190
 
142
191
 
@@ -159,10 +208,23 @@ function JSDialogTooltip()
159
208
  if (this.HQChart.ClassName=='KLineChartContainer')
160
209
  {
161
210
  var strKItem=JSON.stringify(data.KItem);
211
+ var strLastValue=JSON.stringify(data.LastValue);
212
+ var bUpdata=false;
162
213
  if (this.KItemCacheID!=strKItem) //数据变动的才更新
163
214
  {
164
215
  this.KItemCache= JSON.parse(strKItem);
165
216
  this.KItemCacheID=strKItem;
217
+ bUpdata=true;
218
+ }
219
+ if (data.LastValue && data.LastValue.Y && IFrameSplitOperator.IsNumber(data.LastValue.Y.Value) && this.LastValueCacheID!=strLastValue)
220
+ {
221
+ this.LastValueCache=JSON.parse(strLastValue);
222
+ this.LastValueCacheID=strLastValue;
223
+ bUpdata=true;
224
+ }
225
+
226
+ if (bUpdata)
227
+ {
166
228
  this.UpdateTableDOM();
167
229
  }
168
230
  else
@@ -173,10 +235,23 @@ function JSDialogTooltip()
173
235
  else if (this.HQChart.ClassName=='MinuteChartContainer')
174
236
  {
175
237
  var strKItem=JSON.stringify(data.MinItem);
238
+ var strLastValue=JSON.stringify(data.LastValue);
239
+ var bUpdata=false;
176
240
  if (this.KItemCacheID!=strKItem) //数据变动的才更新
177
241
  {
178
242
  this.KItemCache= JSON.parse(strKItem);
179
243
  this.KItemCacheID=strKItem;
244
+ bUpdata=true;
245
+ }
246
+ if (data.LastValue && data.LastValue.Y && IFrameSplitOperator.IsNumber(data.LastValue.Y.Value) && this.LastValueCacheID!=strLastValue)
247
+ {
248
+ this.LastValueCache=JSON.parse(strLastValue);
249
+ this.LastValueCacheID=strLastValue;
250
+ bUpdata=true;
251
+ }
252
+
253
+ if (bUpdata)
254
+ {
180
255
  this.UpdateTableDOM();
181
256
  }
182
257
  }
@@ -213,12 +288,14 @@ function JSDialogTooltip()
213
288
  item.TextSpan.innerText=outItem.Text;
214
289
  item.TextSpan.style.color=outItem.Color;
215
290
  item.Tr.style.display="";
291
+ if (item.Tr2) item.Tr2.style.display="";
216
292
  }
217
293
 
218
294
  for( ; index<this.MaxRowCount; ++index)
219
295
  {
220
296
  var item=this.AryData[index];
221
297
  item.Tr.style.display="none";
298
+ if (item.Tr2) item.Tr2.style.display="none";
222
299
  }
223
300
  }
224
301
 
@@ -300,6 +377,9 @@ function JSDialogTooltip()
300
377
  {
301
378
  var defaultfloatPrecision=GetfloatPrecision(this.HQChart.Symbol);//价格小数位数
302
379
  var upperSymbol=this.HQChart.Symbol.toUpperCase();
380
+ var priceFormat=0;
381
+ if (this.Style==1) priceFormat=1;
382
+
303
383
  //日期
304
384
  var dateItem=this.ForamtDate(data.Date,"YYYY/MM/DD/W",'DialogTooltip-Date' );
305
385
 
@@ -310,18 +390,45 @@ function JSDialogTooltip()
310
390
  var yClose=data.YClose; //昨收价|昨结算价
311
391
  var aryText=
312
392
  [
313
- this.ForamtPrice(data.Open,yClose, defaultfloatPrecision,'DialogTooltip-Open'),
314
- this.ForamtPrice(data.High,yClose, defaultfloatPrecision,'DialogTooltip-High'),
315
- this.ForamtPrice(data.Low,yClose, defaultfloatPrecision,'DialogTooltip-Low'),
316
- this.ForamtPrice(data.Close,yClose, defaultfloatPrecision,'DialogTooltip-Close'),
393
+ this.ForamtPrice(data.Open,yClose, defaultfloatPrecision,'DialogTooltip-Open',priceFormat),
394
+ this.ForamtPrice(data.High,yClose, defaultfloatPrecision,'DialogTooltip-High',priceFormat),
395
+ this.ForamtPrice(data.Low,yClose, defaultfloatPrecision,'DialogTooltip-Low',priceFormat),
396
+ this.ForamtPrice(data.Close,yClose, defaultfloatPrecision,'DialogTooltip-Close',priceFormat),
317
397
  this.FormatVol(data.Vol,'DialogTooltip-Vol' ),
318
398
  this.FormatAmount(data.Amount,'DialogTooltip-Amount' ),
319
- this.FormatIncrease(data.Close,yClose,'DialogTooltip-Increase'),
320
- this.FormatAmplitude(data.High,data.Low,yClose,'DialogTooltip-Amplitude'),
399
+ this.FormatIncrease(data.Close,yClose,defaultfloatPrecision,'DialogTooltip-Increase',priceFormat),
400
+ this.FormatAmplitude(data.High,data.Low,yClose,defaultfloatPrecision,'DialogTooltip-Amplitude',priceFormat),
321
401
  ];
322
402
 
323
- if (timeItem) aryText.unshift(timeItem);
324
- aryText.unshift(dateItem);
403
+ if (this.LastValueCache && this.LastValueCache.Y)
404
+ {
405
+ var item=this.LastValueCache.Y;
406
+ var rowItem=null;
407
+ if (item.Extend.FrameID==0)
408
+ {
409
+ rowItem=this.ForamtPrice(item.Value,null, defaultfloatPrecision,'DialogTooltip-Value',2);
410
+ }
411
+ else
412
+ {
413
+ rowItem=this.ForamtValue(item.Value, 2,'DialogTooltip-Value');
414
+ }
415
+
416
+ if (rowItem) aryText.unshift(rowItem);
417
+ }
418
+
419
+ if (this.Style==1)
420
+ {
421
+ if (timeItem) aryText.unshift(timeItem);
422
+ var dateItem=this.ForamtDate(data.Date,"YYYY/MM/DD",'DialogTooltip-Date' );
423
+ aryText.unshift(dateItem);
424
+ }
425
+ else
426
+ {
427
+ if (timeItem) aryText.unshift(timeItem);
428
+ aryText.unshift(dateItem);
429
+ }
430
+
431
+
325
432
 
326
433
  //换手率
327
434
  if (MARKET_SUFFIX_NAME.IsSHSZStockA(upperSymbol) && data.FlowCapital>0)
@@ -349,7 +456,6 @@ function JSDialogTooltip()
349
456
  this.GetFormatMinuteTooltipText=function(data)
350
457
  {
351
458
  var defaultfloatPrecision=GetfloatPrecision(this.HQChart.Symbol);//价格小数位数
352
-
353
459
  var aryText=[];
354
460
  if (data.Type==0) //连续交易
355
461
  {
@@ -358,14 +464,31 @@ function JSDialogTooltip()
358
464
 
359
465
  aryText=
360
466
  [
361
- this.ForamtDate(item.Date,"YYYY/MM/DD/W",'DialogTooltip-Date' ),
467
+ this.ForamtDate(item.Date,this.Style==1?"MM/DD/W":"YYYY/MM/DD/W",'DialogTooltip-Date' ),
362
468
  this.FormatTime(item.Time, null, "HH:MM", 'DialogTooltip-Time'),
363
- this.ForamtPrice(item.Close,item.YClose, defaultfloatPrecision,'DialogTooltip-Price'),
469
+ this.ForamtPrice(item.Close,item.YClose, defaultfloatPrecision,'DialogTooltip-Price', 1),
470
+ this.ForamtPrice(item.AvPrice,item.YClose, defaultfloatPrecision,'DialogTooltip-AvPrice', 1),
364
471
  this.FormatRisefall(item.Close,item.YClose, defaultfloatPrecision,'DialogTooltip-Risefall'),
365
- this.FormatIncrease(item.Close,item.YClose,'DialogTooltip-Increase'),
472
+ this.FormatIncrease(item.Close,item.YClose,defaultfloatPrecision,'DialogTooltip-Increase', 1),
366
473
  this.FormatVol(item.Vol,'DialogTooltip-Vol' ),
367
474
  this.FormatAmount(item.Amount,'DialogTooltip-Amount' ),
368
475
  ];
476
+
477
+ if (this.LastValueCache && this.LastValueCache.Y)
478
+ {
479
+ var item=this.LastValueCache.Y;
480
+ var rowItem=null;
481
+ if (item.Extend.FrameID==0)
482
+ {
483
+ rowItem=this.ForamtPrice(item.Value,null, defaultfloatPrecision,'DialogTooltip-Value',2);
484
+ }
485
+ else
486
+ {
487
+ rowItem=this.ForamtValue(item.Value, 2,'DialogTooltip-Value');
488
+ }
489
+
490
+ if (rowItem) aryText.splice(2,0,rowItem);
491
+ }
369
492
  }
370
493
  else if (data.Type==1) //集合竞价
371
494
  {
@@ -376,10 +499,10 @@ function JSDialogTooltip()
376
499
  if (item.Ver===1) timeForamt="HH:MM"
377
500
  aryText=
378
501
  [
379
- this.ForamtDate(item.Date,"YYYY/MM/DD/W",'DialogTooltip-Date' ),
502
+ this.ForamtDate(item.Date,this.Style==1?"MM/DD/W":"YYYY/MM/DD/W",'DialogTooltip-Date' ),
380
503
  this.FormatTime(item.Time, null, timeForamt, 'DialogTooltip-Time'),
381
- this.ForamtPrice(item.Price,item.YClose, defaultfloatPrecision,'DialogTooltip-AC-Price'),
382
- this.FormatIncrease(item.Price,item.YClose,'DialogTooltip-AC-Increase'),
504
+ this.ForamtPrice(item.Price,item.YClose, defaultfloatPrecision,'DialogTooltip-AC-Price',1),
505
+ this.FormatIncrease(item.Price,item.YClose,defaultfloatPrecision,'DialogTooltip-AC-Increase',1),
383
506
  this.FormatVol(item.Vol[0],'DialogTooltip-AC-Vol' ),
384
507
  ];
385
508
  }
@@ -448,8 +571,8 @@ function JSDialogTooltip()
448
571
 
449
572
 
450
573
  /////////////////////////////////////////////////////////////////////////////////////////////
451
- //数据格式化
452
- this.ForamtPrice=function(price, yClose, defaultfloatPrecision, TitleID)
574
+ //数据格式化 format=0 点差+涨幅 1=涨幅
575
+ this.ForamtPrice=function(price, yClose, defaultfloatPrecision, TitleID, format)
453
576
  {
454
577
  var item=
455
578
  {
@@ -460,12 +583,44 @@ function JSDialogTooltip()
460
583
 
461
584
  if (!IFrameSplitOperator.IsNumber(price)) return item;
462
585
 
463
- item.Text=price.toFixed(defaultfloatPrecision);
586
+ if (format==2)
587
+ {
588
+ item.Text=price.toFixed(defaultfloatPrecision);
589
+ item.Color=this.TitleColor;
590
+ return item;
591
+ }
592
+
593
+ if (IFrameSplitOperator.IsNumber(yClose) && format!=1)
594
+ {
595
+ var value=(price-yClose)/yClose*100;
596
+ item.Text=`${price.toFixed(defaultfloatPrecision)}(${value.toFixed(2)}%)`;
597
+ }
598
+ else
599
+ {
600
+ item.Text=price.toFixed(defaultfloatPrecision);
601
+ }
602
+
603
+
464
604
  item.Color=this.GetColor(price, yClose);
465
605
 
466
606
  return item;
467
607
  }
468
608
 
609
+ this.ForamtValue=function(value, defaultfloatPrecision, TitleID)
610
+ {
611
+ var item=
612
+ {
613
+ Title:g_JSChartLocalization.GetText(TitleID,this.LanguageID),
614
+ Text:'--',
615
+ Color:this.TitleColor
616
+ };
617
+
618
+ if (!IFrameSplitOperator.IsNumber(value)) return item;
619
+
620
+ item.Text=IFrameSplitOperator.FormatValueStringV2(value,defaultfloatPrecision,2,this.LanguageID);
621
+ return item;
622
+ }
623
+
469
624
  this.FormatVol=function(vol, TitleID)
470
625
  {
471
626
  var item=
@@ -498,7 +653,7 @@ function JSDialogTooltip()
498
653
  return item;
499
654
  }
500
655
 
501
- this.FormatIncrease=function(price, yClose, TitleID)
656
+ this.FormatIncrease=function(price, yClose, defaultfloatPrecision, TitleID, fromat)
502
657
  {
503
658
  //涨幅
504
659
  var item=
@@ -510,8 +665,19 @@ function JSDialogTooltip()
510
665
 
511
666
  if (!IFrameSplitOperator.IsNumber(price) || !IFrameSplitOperator.IsNumber(yClose)) return item;
512
667
 
668
+
669
+
670
+ var diffValue=price-yClose;
513
671
  var value=(price-yClose)/yClose;
514
- item.Text=`${(value*100).toFixed(2)}%`;
672
+ if (fromat==1)
673
+ {
674
+ item.Text=`${(value*100).toFixed(2)}%`;
675
+ }
676
+ else
677
+ {
678
+ item.Text=`${diffValue.toFixed(defaultfloatPrecision)}(${(value*100).toFixed(2)}%)`;
679
+ }
680
+
515
681
  item.Color=this.GetColor(value,0);
516
682
 
517
683
  return item;
@@ -536,9 +702,9 @@ function JSDialogTooltip()
536
702
  return item;
537
703
  }
538
704
 
539
- this.FormatAmplitude=function(high, low, yClose, TitleID)
705
+ this.FormatAmplitude=function(high, low, yClose, defaultfloatPrecision, TitleID, fromat)
540
706
  {
541
- //涨幅
707
+ //振幅
542
708
  var item=
543
709
  {
544
710
  Title:g_JSChartLocalization.GetText(TitleID,this.LanguageID),
@@ -549,8 +715,10 @@ function JSDialogTooltip()
549
715
 
550
716
  if (!IFrameSplitOperator.IsNumber(high) || !IFrameSplitOperator.IsNumber(low) || !IFrameSplitOperator.IsNumber(yClose)) return item;
551
717
 
718
+ var diffValue=high-low;
552
719
  var value=(high-low)/yClose;
553
- item.Text=`${(value*100).toFixed(2)}%`;
720
+ if (fromat==1) item.Text=`${(value*100).toFixed(2)}%`;
721
+ else item.Text=`${diffValue.toFixed(defaultfloatPrecision)}(${(value*100).toFixed(2)}%)`;
554
722
  item.Color=this.GetColor(value,0);
555
723
 
556
724
  return item;