hqchart 1.1.13911 → 1.1.13915

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.
@@ -152,22 +152,41 @@ function JSDialogTooltip()
152
152
  this.Update=function(data)
153
153
  {
154
154
  if (!this.DivDialog || !this.TitleBox) return;
155
- if (!data.KItem || !data.IsShowCorss || data.ClientPos<0) return;
155
+ if ((!data.KItem && !data.MinItem) || !data.IsShowCorss || data.ClientPos<0) return;
156
156
 
157
157
  this.LanguageID=this.HQChart.LanguageID;
158
- this.TitleBox.DivName.innerText=data.Name;
159
-
160
- var strKItem=JSON.stringify(data.KItem);
161
- if (this.KItemCacheID!=strKItem) //数据变动的才更新
158
+
159
+ if (this.HQChart.ClassName=='KLineChartContainer')
160
+ {
161
+ var strKItem=JSON.stringify(data.KItem);
162
+ if (this.KItemCacheID!=strKItem) //数据变动的才更新
163
+ {
164
+ this.KItemCache= JSON.parse(strKItem);
165
+ this.KItemCacheID=strKItem;
166
+ this.UpdateTableDOM();
167
+ }
168
+ else
169
+ {
170
+ //JSConsole.Chart.Log(`[JSDialogTooltip::Update] save as KItemCache and KItem`);
171
+ }
172
+ }
173
+ else if (this.HQChart.ClassName=='MinuteChartContainer')
162
174
  {
163
- this.KItemCache= JSON.parse(strKItem);
164
- this.KItemCacheID=strKItem;
165
- this.UpdateTableDOM();
175
+ var strKItem=JSON.stringify(data.MinItem);
176
+ if (this.KItemCacheID!=strKItem) //数据变动的才更新
177
+ {
178
+ this.KItemCache= JSON.parse(strKItem);
179
+ this.KItemCacheID=strKItem;
180
+ this.UpdateTableDOM();
181
+ }
166
182
  }
167
183
  else
168
184
  {
169
- //JSConsole.Chart.Log(`[JSDialogTooltip::Update] save as KItemCache and KItem`);
185
+ return;
170
186
  }
187
+
188
+ this.TitleBox.DivName.innerText=data.Name;
189
+
171
190
 
172
191
  if (!this.IsShow()) this.Show();
173
192
  }
@@ -176,7 +195,12 @@ function JSDialogTooltip()
176
195
  {
177
196
  if (!this.KItemCache) return;
178
197
 
179
- this.AryText=this.GetFormatKlineTooltipText(this.KItemCache);
198
+ if (this.HQChart.ClassName=='KLineChartContainer')
199
+ this.AryText=this.GetFormatKlineTooltipText(this.KItemCache);
200
+ else if (this.HQChart.ClassName=='MinuteChartContainer')
201
+ this.AryText=this.GetFormatMinuteTooltipText(this.KItemCache);
202
+ else
203
+ return;
180
204
 
181
205
  var index=0;
182
206
  for(index=0;index<this.AryText.length && index<this.MaxRowCount;++index)
@@ -277,92 +301,22 @@ function JSDialogTooltip()
277
301
  var defaultfloatPrecision=GetfloatPrecision(this.HQChart.Symbol);//价格小数位数
278
302
 
279
303
  //日期
280
- var dateItem=
281
- {
282
- Title:g_JSChartLocalization.GetText('DialogTooltip-Date',this.LanguageID),
283
- Text:IFrameSplitOperator.FormatDateString(data.Date,"YYYY/MM/DD/W"),
284
- Color:this.DateTimeColor
285
- }
304
+ var dateItem=this.ForamtDate(data.Date,"YYYY/MM/DD/W",'DialogTooltip-Date' );
286
305
 
287
306
  //时间
288
307
  var timeItem=null;
289
- var timeFormat=null;
290
- if (ChartData.IsMinutePeriod(this.HQChart.Period,true)) timeFormat='HH:MM'; // 分钟周期
291
- else if (ChartData.IsSecondPeriod(this.HQChart.Period)) timeFormat='HH:MM:SS';
292
- else if (ChartData.IsMilliSecondPeriod(this.HQChart.Period)) timeFormat='HH:MM:SS.fff';
293
-
294
- if (timeFormat)
295
- {
296
- timeItem=
297
- {
298
- Title:g_JSChartLocalization.GetText('DialogTooltip-Time',this.LanguageID),
299
- Text:IFrameSplitOperator.FormatTimeString(data.Time,timeFormat),
300
- Color:this.DateTimeColor
301
- }
302
- }
303
-
304
- //涨幅
305
- var increaseItem=
306
- {
307
- Title:g_JSChartLocalization.GetText('DialogTooltip-Increase',this.LanguageID),
308
- Text:"--.--",
309
- Color:this.TitleColor
310
- };
311
- if (IFrameSplitOperator.IsNumber(data.YClose) && IFrameSplitOperator.IsNumber(data.Close))
312
- {
313
- var value=(data.Close-data.YClose)/data.YClose;
314
- increaseItem.Text=`${(value*100).toFixed(2)}%`;
315
- increaseItem.Color=this.GetColor(value,0);
316
- }
317
-
318
- //涨幅
319
- var amplitudeItem=
320
- {
321
- Title:g_JSChartLocalization.GetText('DialogTooltip-Amplitude',this.LanguageID),
322
- Text:"--.--",
323
- Color:this.TitleColor
324
- }
325
- if (IFrameSplitOperator.IsNumber(data.YClose) && IFrameSplitOperator.IsNumber(data.High) && IFrameSplitOperator.IsNumber(data.Low))
326
- {
327
- var value=(data.High-data.Low)/data.YClose;
328
- amplitudeItem.Text=`${(value*100).toFixed(2)}%`;
329
- amplitudeItem.Color=this.GetColor(value,0);
330
- }
331
-
308
+ if (IFrameSplitOperator.IsNumber(data.Time)) timeItem=this.FormatTime(data.Time, this.HQChart.Period, null, 'DialogTooltip-Time');
309
+
332
310
  var aryText=
333
311
  [
334
- {
335
- Title:g_JSChartLocalization.GetText('DialogTooltip-Open',this.LanguageID),
336
- Text:IFrameSplitOperator.IsNumber(data.Open)? data.Open.toFixed(defaultfloatPrecision):'--',
337
- Color:this.GetPriceColor(data.Open,data.YClose),
338
- },
339
- {
340
- Title:g_JSChartLocalization.GetText('DialogTooltip-High',this.LanguageID),
341
- Text:IFrameSplitOperator.IsNumber(data.High)? data.High.toFixed(defaultfloatPrecision):'--',
342
- Color:this.GetPriceColor(data.High,data.YClose)
343
- },
344
- {
345
- Title:g_JSChartLocalization.GetText('DialogTooltip-Low',this.LanguageID),
346
- Text:IFrameSplitOperator.IsNumber(data.Low)? data.Low.toFixed(defaultfloatPrecision):'--',
347
- Color:this.GetPriceColor(data.Low,data.YClose)
348
- },
349
- {
350
- Title:g_JSChartLocalization.GetText('DialogTooltip-Close',this.LanguageID),
351
- Text:IFrameSplitOperator.IsNumber(data.Close)? data.Close.toFixed(defaultfloatPrecision):'--',
352
- Color:this.GetPriceColor(data.Close,data.YClose)
353
- },
354
- {
355
- Title:g_JSChartLocalization.GetText('DialogTooltip-Vol',this.LanguageID),
356
- Text:IFrameSplitOperator.IsNumber(data.Vol)? IFrameSplitOperator.FormatValueString(data.Vol,2,this.LanguageID):'--',
357
- Color:this.VolColor
358
- },
359
- {
360
- Title:g_JSChartLocalization.GetText('DialogTooltip-Amount',this.LanguageID),
361
- Text:IFrameSplitOperator.IsNumber(data.Amount)? IFrameSplitOperator.FormatValueString(data.Amount,2,this.LanguageID):'--',
362
- Color:this.AmountColor
363
- },
364
- increaseItem,
365
- amplitudeItem
312
+ this.ForamtPrice(data.Open,data.YClose, defaultfloatPrecision,'DialogTooltip-Open'),
313
+ this.ForamtPrice(data.High,data.YClose, defaultfloatPrecision,'DialogTooltip-High'),
314
+ this.ForamtPrice(data.Low,data.YClose, defaultfloatPrecision,'DialogTooltip-Low'),
315
+ this.ForamtPrice(data.Close,data.YClose, defaultfloatPrecision,'DialogTooltip-Close'),
316
+ this.FormatVol(data.Vol,'DialogTooltip-Vol' ),
317
+ this.FormatAmount(data.Amount,'DialogTooltip-Amount' ),
318
+ this.FormatIncrease(data.Close,data.YClose,'DialogTooltip-Increase'),
319
+ this.FormatAmplitude(data.High,data.Low,data.YClose,'DialogTooltip-Amplitude'),
366
320
  ];
367
321
 
368
322
  if (timeItem) aryText.unshift(timeItem);
@@ -371,6 +325,50 @@ function JSDialogTooltip()
371
325
  return aryText;
372
326
  },
373
327
 
328
+ this.GetFormatMinuteTooltipText=function(data)
329
+ {
330
+ var defaultfloatPrecision=GetfloatPrecision(this.HQChart.Symbol);//价格小数位数
331
+
332
+ if (data.Type==0) //连续交易
333
+ {
334
+ var item=data.Data;
335
+ if (!item) item={ };
336
+
337
+ var aryText=
338
+ [
339
+ this.ForamtDate(item.Date,"YYYY/MM/DD/W",'DialogTooltip-Date' ),
340
+ this.FormatTime(item.Time, null, "HH:MM", 'DialogTooltip-Time'),
341
+ this.ForamtPrice(item.Close,item.YClose, defaultfloatPrecision,'DialogTooltip-Price'),
342
+ this.FormatRisefall(item.Close,item.YClose, defaultfloatPrecision,'DialogTooltip-Risefall'),
343
+ this.FormatIncrease(item.Close,item.YClose,'DialogTooltip-Increase'),
344
+ this.FormatVol(item.Vol,'DialogTooltip-Vol' ),
345
+ this.FormatAmount(item.Amount,'DialogTooltip-Amount' ),
346
+ ];
347
+
348
+ return aryText;
349
+ }
350
+ else if (data.Type==1) //集合竞价
351
+ {
352
+ var item=data.Data.Data;
353
+ if (!item) item={ Vol:[] };
354
+
355
+ var timeForamt="HH:MM:SS";
356
+ if (item.Ver===1) timeForamt="HH:MM"
357
+ var aryText=
358
+ [
359
+ this.ForamtDate(item.Date,"YYYY/MM/DD/W",'DialogTooltip-Date' ),
360
+ this.FormatTime(item.Time, null, timeForamt, 'DialogTooltip-Time'),
361
+ this.ForamtPrice(item.Price,item.YClose, defaultfloatPrecision,'DialogTooltip-AC-Price'),
362
+ this.FormatIncrease(item.Price,item.YClose,'DialogTooltip-AC-Increase'),
363
+ this.FormatVol(item.Vol[0],'DialogTooltip-AC-Vol' ),
364
+ ];
365
+
366
+ return aryText;
367
+ }
368
+
369
+ return [];
370
+ }
371
+
374
372
  this.GetColor=function(price,yClose)
375
373
  {
376
374
  if(price>yClose) return this.UpColor;
@@ -417,6 +415,157 @@ function JSDialogTooltip()
417
415
  if (this.TitleBGColor) this.TitleBox.DivTitle.style['background-color']=this.TitleBGColor;
418
416
 
419
417
  this.UpdateTableDOM();
418
+ },
419
+
420
+
421
+ /////////////////////////////////////////////////////////////////////////////////////////////
422
+ //数据格式化
423
+ this.ForamtPrice=function(price, yClose, defaultfloatPrecision, TitleID)
424
+ {
425
+ var item=
426
+ {
427
+ Title:g_JSChartLocalization.GetText(TitleID, this.LanguageID),
428
+ Text:"--.--",
429
+ Color:this.TitleColor
430
+ };
431
+
432
+ if (!IFrameSplitOperator.IsNumber(price)) return item;
433
+
434
+ item.Text=price.toFixed(defaultfloatPrecision);
435
+ item.Color=this.GetColor(price, yClose);
436
+
437
+ return item;
438
+ }
439
+
440
+ this.FormatVol=function(vol, TitleID)
441
+ {
442
+ var item=
443
+ {
444
+ Title:g_JSChartLocalization.GetText(TitleID,this.LanguageID),
445
+ Text:'--',
446
+ Color:this.VolColor
447
+ };
448
+
449
+ if (!IFrameSplitOperator.IsNumber(vol)) return item;
450
+
451
+ item.Text=IFrameSplitOperator.FormatValueString(vol,2,this.LanguageID);
452
+
453
+ return item;
454
+ }
455
+
456
+ this.FormatAmount=function(amount, TitleID)
457
+ {
458
+ var item=
459
+ {
460
+ Title:g_JSChartLocalization.GetText(TitleID,this.LanguageID),
461
+ Text:'--',
462
+ Color:this.AmountColor
463
+ };
464
+
465
+ if (!IFrameSplitOperator.IsNumber(amount)) return item;
466
+
467
+ item.Text=IFrameSplitOperator.FormatValueString(amount,2,this.LanguageID);
468
+
469
+ return item;
470
+ }
471
+
472
+ this.FormatIncrease=function(price, yClose, TitleID)
473
+ {
474
+ //涨幅
475
+ var item=
476
+ {
477
+ Title:g_JSChartLocalization.GetText(TitleID,this.LanguageID),
478
+ Text:"--.--",
479
+ Color:this.TitleColor
480
+ };
481
+
482
+ if (!IFrameSplitOperator.IsNumber(price) || !IFrameSplitOperator.IsNumber(yClose)) return item;
483
+
484
+ var value=(price-yClose)/yClose;
485
+ item.Text=`${(value*100).toFixed(2)}%`;
486
+ item.Color=this.GetColor(value,0);
487
+
488
+ return item;
489
+ }
490
+
491
+ this.FormatRisefall=function(price, yClose, defaultfloatPrecision, TitleID)
492
+ {
493
+ //涨跌
494
+ var item=
495
+ {
496
+ Title:g_JSChartLocalization.GetText(TitleID,this.LanguageID),
497
+ Text:"--.--",
498
+ Color:this.TitleColor
499
+ };
500
+
501
+ if (!IFrameSplitOperator.IsNumber(price) || !IFrameSplitOperator.IsNumber(yClose)) return item;
502
+
503
+ var value=price-yClose;
504
+ item.Text=`${value.toFixed(defaultfloatPrecision)}`;
505
+ item.Color=this.GetColor(value,0);
506
+
507
+ return item;
508
+ }
509
+
510
+ this.FormatAmplitude=function(high, low, yClose, TitleID)
511
+ {
512
+ //涨幅
513
+ var item=
514
+ {
515
+ Title:g_JSChartLocalization.GetText(TitleID,this.LanguageID),
516
+ Text:"--.--",
517
+ Color:this.TitleColor
518
+ };
519
+
520
+
521
+ if (!IFrameSplitOperator.IsNumber(high) || !IFrameSplitOperator.IsNumber(low) || !IFrameSplitOperator.IsNumber(yClose)) return item;
522
+
523
+ var value=(high-low)/yClose;
524
+ item.Text=`${(value*100).toFixed(2)}%`;
525
+ item.Color=this.GetColor(value,0);
526
+
527
+ return item;
528
+ }
529
+
530
+ this.ForamtDate=function(date, format, TitleID)
531
+ {
532
+ //日期
533
+ var item=
534
+ {
535
+ Title:g_JSChartLocalization.GetText('DialogTooltip-Date',this.LanguageID),
536
+ Text:"----/--/--",
537
+ Color:this.DateTimeColor
538
+ }
539
+
540
+ if (!IFrameSplitOperator.IsNumber(date)) return item;
541
+
542
+ item.Text=IFrameSplitOperator.FormatDateString(date,format);
543
+
544
+ return item;
545
+ }
546
+
547
+ this.FormatTime=function(time, period, format, TitleID)
548
+ {
549
+ //时间
550
+ var item=
551
+ {
552
+ Title:g_JSChartLocalization.GetText(TitleID,this.LanguageID),
553
+ Text:'--:--',
554
+ Color:this.DateTimeColor
555
+ };
556
+
557
+ if (!IFrameSplitOperator.IsNumber(time)) return item;
558
+ if (!format)
559
+ {
560
+ format="HH:MM";
561
+ if (ChartData.IsMinutePeriod(period,true)) timeFormat='HH:MM'; // 分钟周期
562
+ else if (ChartData.IsSecondPeriod(period)) timeFormat='HH:MM:SS';
563
+ else if (ChartData.IsMilliSecondPeriod(period)) timeFormat='HH:MM:SS.fff';
564
+ }
565
+
566
+ item.Text=IFrameSplitOperator.FormatTimeString(time,format);
567
+
568
+ return item;
420
569
  }
421
570
 
422
571
  }
@@ -55982,7 +55982,7 @@ HQData.RequestMinuteRealtimeData=function(data,callback)
55982
55982
 
55983
55983
  //生成随机测试数据
55984
55984
  var price=kItem[5];
55985
- var value=Math.ceil(Math.random()*10)/10000*price;
55985
+ var value=Math.ceil(Math.random()*10)/5000*price;
55986
55986
  var bUp=Math.ceil(Math.random()*10)>=5;
55987
55987
 
55988
55988
  if (bUp) price+=value;
@@ -20889,6 +20889,7 @@ function ScriptIndex(name,script,args,option)
20889
20889
  if (varItem.UpColor) chart.UpColor=varItem.UpColor;
20890
20890
  if (varItem.DownColor) chart.DownColor=varItem.DownColor;
20891
20891
  if (IFrameSplitOperator.IsNumber(varItem.StickType)) chart.BarType=varItem.StickType;
20892
+ if (IFrameSplitOperator.IsNumber(varItem.BarColorType)) chart.BarColorType=varItem.BarColorType;
20892
20893
  if (varItem.LineWidth)
20893
20894
  {
20894
20895
  let width=parseInt(varItem.LineWidth.replace("LINETHICK",""));
@@ -20900,9 +20901,21 @@ function ScriptIndex(name,script,args,option)
20900
20901
  chart.HistoryData=hisData;
20901
20902
  this.ReloadChartResource(hqChart,windowIndex,chart);
20902
20903
 
20903
- var titleData=new DynamicTitleData(chart.Data,varItem.Name,chart.Color);
20904
- hqChart.TitlePaint[titleIndex].Data[id]=titleData;
20905
- this.SetTitleData(titleData,chart);
20904
+ if (varItem.IsShowTitle===false) //NOTEXT 不绘制标题
20905
+ {
20906
+
20907
+ }
20908
+ else if (IFrameSplitOperator.IsString(varItem.Name) && varItem.Name.indexOf("NOTEXT")==0) //标题中包含NOTEXT不绘制标题
20909
+ {
20910
+
20911
+ }
20912
+ else
20913
+ {
20914
+ var titleData=new DynamicTitleData(chart.Data,varItem.Name,chart.Color);
20915
+ hqChart.TitlePaint[titleIndex].Data[id]=titleData;
20916
+ this.SetTitleData(titleData,chart);
20917
+ }
20918
+
20906
20919
  this.SetChartIndexName(chart);
20907
20920
  hqChart.ChartPaint.push(chart);
20908
20921
  }
@@ -22848,6 +22861,7 @@ function OverlayScriptIndex(name,script,args,option)
22848
22861
  if (varItem.UpColor) chart.UpColor=varItem.UpColor;
22849
22862
  if (varItem.DownColor) chart.DownColor=varItem.DownColor;
22850
22863
  if (IFrameSplitOperator.IsNumber(varItem.StickType)) chart.BarType=varItem.StickType;
22864
+ if (IFrameSplitOperator.IsNumber(varItem.BarColorType)) chart.BarColorType=varItem.BarColorType;
22851
22865
  if (varItem.LineWidth)
22852
22866
  {
22853
22867
  let width=parseInt(varItem.LineWidth.replace("LINETHICK",""));
@@ -24276,6 +24290,8 @@ function APIScriptIndex(name,script,args,option, isOverlay)
24276
24290
  if (IFrameSplitOperator.IsBool(item.isDotLine)) outVarItem.IsDotLine = item.isDotLine;
24277
24291
  if (IFrameSplitOperator.IsNonEmptyArray(item.lineDash)) outVarItem.LineDash=item.lineDash;
24278
24292
  if (IFrameSplitOperator.IsBool(item.isSingleLine)) outVarItem.IsSingleLine=item.isSingleLine;
24293
+ if (IFrameSplitOperator.IsNumber(item.StickType)) outVarItem.StickType=item.StickType;
24294
+ if (IFrameSplitOperator.IsNumber(item.BarColorType)) outVarItem.BarColorType=item.BarColorType;
24279
24295
 
24280
24296
  result.push(outVarItem);
24281
24297
  }