tvcharts 0.7.60 → 0.7.61

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/dist/echarts.js CHANGED
@@ -222,7 +222,7 @@ __export(util_exports, {
222
222
 
223
223
  // node_modules/tvrender/src/core/platform.ts
224
224
  var DEFAULT_FONT_SIZE = 12;
225
- var DEFAULT_FONT_FAMILY = "sans-serif";
225
+ var DEFAULT_FONT_FAMILY = `-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif`;
226
226
  var DEFAULT_FONT = `${DEFAULT_FONT_SIZE}px ${DEFAULT_FONT_FAMILY}`;
227
227
  var OFFSET = 20;
228
228
  var SCALE = 100;
@@ -7238,7 +7238,7 @@ function getElementSSRData(el) {
7238
7238
  function registerSSRDataGetter(getter) {
7239
7239
  ssrDataGetter = getter;
7240
7240
  }
7241
- var version = "5.6.76";
7241
+ var version = "5.6.78";
7242
7242
 
7243
7243
  // src/util/number.ts
7244
7244
  var RADIAN_EPSILON = 1e-4;
@@ -11393,7 +11393,7 @@ var ZRText = class extends Displayable_default {
11393
11393
  style.fontStyle,
11394
11394
  style.fontWeight,
11395
11395
  parseFontSize(style.fontSize),
11396
- style.fontFamily || "sans-serif"
11396
+ style.fontFamily || DEFAULT_FONT_FAMILY
11397
11397
  ].join(" ");
11398
11398
  }
11399
11399
  return font && trim(font) || style.textFont || style.font;
@@ -72753,6 +72753,31 @@ function getLeftTextX(x, text, textStyle, ecModel) {
72753
72753
  const paddings = normalizeCssArray2(textStyle.padding || 0);
72754
72754
  return x - textRect.width - paddings[1] - paddings[3] - (textStyle.borderWidth || 0) - 1;
72755
72755
  }
72756
+ var SECONDS_PER_HOUR = 3600;
72757
+ var SECONDS_PER_DAY = 86400;
72758
+ var SECONDS_PER_MONTH = 30 * SECONDS_PER_DAY;
72759
+ function formatSeconds(seconds2) {
72760
+ if (seconds2 >= SECONDS_PER_DAY) {
72761
+ const months = Math.floor(seconds2 / SECONDS_PER_MONTH);
72762
+ let remaining = seconds2 % SECONDS_PER_MONTH;
72763
+ const days = Math.floor(remaining / SECONDS_PER_DAY);
72764
+ remaining %= SECONDS_PER_DAY;
72765
+ const hours2 = Math.floor(remaining / SECONDS_PER_HOUR);
72766
+ return [
72767
+ months > 0 ? `${months}m` : null,
72768
+ days > 0 ? `${days}d` : null,
72769
+ hours2 > 0 ? `${hours2}h` : null
72770
+ ].filter(Boolean).join(" ");
72771
+ } else {
72772
+ const hours2 = Math.floor(seconds2 / SECONDS_PER_HOUR);
72773
+ const minutes2 = Math.floor(seconds2 % SECONDS_PER_HOUR / 60);
72774
+ const secs = seconds2 % 60;
72775
+ return hours2 > 0 ? `${pad2(hours2)}:${pad2(minutes2)}:${pad2(secs)}` : `${pad2(minutes2)}:${pad2(secs)}`;
72776
+ }
72777
+ }
72778
+ function pad2(num) {
72779
+ return num.toString().padStart(2, "0");
72780
+ }
72756
72781
 
72757
72782
  // src/util/color.ts
72758
72783
  function parseColor(color2) {
@@ -75328,6 +75353,7 @@ var MarkLabelModal2 = class extends Component_default {
75328
75353
  dataMap[key] = this.option.data[key] = merge(item, defaultDataOption);
75329
75354
  } else {
75330
75355
  dataMap[key] = merge(this.option.data[key], item, true);
75356
+ console.log("%c [ item ]-178", "font-size:13px; background:pink; color:#bf2c9f;", item);
75331
75357
  }
75332
75358
  if (item.$action === "remove") {
75333
75359
  this.option.data[key] = void 0;
@@ -75400,7 +75426,7 @@ var markerTypeCalculator2 = {
75400
75426
  return {
75401
75427
  value: seriesData.getByRawIndex(item.valueDim, lastIndex),
75402
75428
  labelTextStyle: {
75403
- fill: fill ? contrastColor2(fill) : "#fff",
75429
+ fill: fill ? contrastColor2(fill) : "#ffffff",
75404
75430
  backgroundColor: fill ? removeTransparency(fill) : DefaultColor,
75405
75431
  borderWidth: 0
75406
75432
  }
@@ -75455,6 +75481,7 @@ var MarkLabelView2 = class extends Component_default2 {
75455
75481
  }
75456
75482
  init() {
75457
75483
  this.markerGroupMapBySeries = createHashMap();
75484
+ this._timerMap = createHashMap();
75458
75485
  this._graphicLabelElMap = createHashMap();
75459
75486
  this._graphLabelGroup = new Group_default();
75460
75487
  this.group.add(this._graphLabelGroup);
@@ -75470,12 +75497,11 @@ var MarkLabelView2 = class extends Component_default2 {
75470
75497
  if (isUpdateGraphic) {
75471
75498
  this.graphicLabelsResize(ecModel);
75472
75499
  }
75473
- if (isAvoidOverlap) {
75474
- this.avoidOverlap();
75475
- }
75500
+ this.avoidOverlap(isAvoidOverlap);
75476
75501
  }
75477
75502
  updateMarkLabels(markerModel, ecModel) {
75478
75503
  const markerGroupMapBySeries = this.markerGroupMapBySeries;
75504
+ const timerMap = this._timerMap;
75479
75505
  const labelMap = markerModel.labelMap;
75480
75506
  const updatedSeriesByName = {};
75481
75507
  ecModel.eachSeries((seriesModel) => {
@@ -75549,6 +75575,13 @@ var MarkLabelView2 = class extends Component_default2 {
75549
75575
  markerGroupMap.set(item.name, el);
75550
75576
  this.group.add(el);
75551
75577
  }
75578
+ if (item.countDown && item.countDown.show && item.countDown.value) {
75579
+ const key = seriesName + item.name;
75580
+ if (!timerMap.get(key)) {
75581
+ const countDownTextEl = el.childAt(3);
75582
+ this._labelCountDown(item, countDownTextEl, key);
75583
+ }
75584
+ }
75552
75585
  inner21(el).yAxisIndex = yAxisModel.index;
75553
75586
  inner21(el).isSort = item.showName;
75554
75587
  });
@@ -75572,6 +75605,11 @@ var MarkLabelView2 = class extends Component_default2 {
75572
75605
  return;
75573
75606
  }
75574
75607
  markerGroupMap.removeKey(item.name);
75608
+ const downKey = seriesName + item.name;
75609
+ if (timerMap.get(downKey)) {
75610
+ clearTimeout(timerMap.get(downKey));
75611
+ timerMap.removeKey(downKey);
75612
+ }
75575
75613
  this.group.remove(el);
75576
75614
  });
75577
75615
  markerGroupMapBySeries.removeKey(seriesName);
@@ -75684,7 +75722,22 @@ var MarkLabelView2 = class extends Component_default2 {
75684
75722
  graphicLabelElMap.removeKey(option.id);
75685
75723
  });
75686
75724
  }
75687
- avoidOverlap() {
75725
+ _labelCountDown(item, el, key) {
75726
+ const timerMap = this._timerMap;
75727
+ const timer = setTimeout(() => {
75728
+ item.countDown.value = item.countDown.value - 1;
75729
+ const text = formatSeconds(item.countDown.value);
75730
+ el.attr("style", {text});
75731
+ if (item.countDown.value && item.countDown.show) {
75732
+ this._labelCountDown(item, el, key);
75733
+ } else {
75734
+ el.ignore = true;
75735
+ timerMap.removeKey(key);
75736
+ }
75737
+ }, 1e3);
75738
+ timerMap.set(key, timer);
75739
+ }
75740
+ avoidOverlap(isAvoidOverlap) {
75688
75741
  const labelsByYAxisId = {};
75689
75742
  const markerGroupMapBySeries = this.markerGroupMapBySeries;
75690
75743
  markerGroupMapBySeries.each((markerGroupMap) => {
@@ -75710,24 +75763,28 @@ var MarkLabelView2 = class extends Component_default2 {
75710
75763
  labelsByYAxisId[yAxisId] = labels;
75711
75764
  });
75712
75765
  each(labelsByYAxisId, (labels) => {
75713
- labelAvoidOverlap(labels);
75766
+ labelAvoidOverlap(labels, isAvoidOverlap);
75714
75767
  });
75715
75768
  }
75716
75769
  };
75717
75770
  var MarkLabelView = MarkLabelView2;
75718
75771
  MarkLabelView.type = "markLabel";
75719
- function textYChange(label, y) {
75772
+ function textYChange(label, y, height) {
75720
75773
  if (label.type === "text") {
75721
75774
  label.y = y;
75722
75775
  } else {
75723
75776
  each(label.children(), (item) => {
75724
75777
  if (item.type === "text") {
75778
+ if (inner21(item).labelType === "countDown") {
75779
+ item.y = y + inner21(item).parentHeight;
75780
+ return;
75781
+ }
75725
75782
  item.y = y;
75726
75783
  }
75727
75784
  });
75728
75785
  }
75729
75786
  }
75730
- function labelAvoidOverlap(labels, marginTop = 0) {
75787
+ function labelAvoidOverlap(labels, isAvoidOverlap, marginTop = 0) {
75731
75788
  if (labels.length === 0) {
75732
75789
  return;
75733
75790
  }
@@ -75738,18 +75795,18 @@ function labelAvoidOverlap(labels, marginTop = 0) {
75738
75795
  for (let i = 0; i < labels.length; i++) {
75739
75796
  const currentLabel = labels[i];
75740
75797
  let currentLabelY = inner21(currentLabel).y;
75741
- if (i === 0) {
75742
- textYChange(currentLabel, currentLabelY - offestY);
75798
+ if (i === 0 || !isAvoidOverlap) {
75799
+ textYChange(currentLabel, currentLabelY - offestY, height);
75743
75800
  continue;
75744
75801
  }
75745
75802
  const prevLabel = labels[i - 1];
75746
75803
  const prevLabelY = sortYbyId[prevLabel.id] ?? inner21(prevLabel).y;
75747
- const prevHeight = height + marginTop;
75804
+ const prevHeight = inner21(prevLabel).showCountDown ? height * 2 + marginTop - 1 : height + marginTop;
75748
75805
  if (prevLabelY > currentLabelY || Math.abs(currentLabelY - prevLabelY) < prevHeight) {
75749
75806
  currentLabelY = prevLabelY + prevHeight;
75750
75807
  }
75751
75808
  sortYbyId[currentLabel.id] = currentLabelY;
75752
- textYChange(currentLabel, currentLabelY - offestY);
75809
+ textYChange(currentLabel, currentLabelY - offestY, height);
75753
75810
  }
75754
75811
  }
75755
75812
  function getPaddingByStyle(fontsize, borderWidth = 0) {
@@ -75786,7 +75843,7 @@ function updateText({option, gridRect, position: position2, ecModel, el, y, offs
75786
75843
  }
75787
75844
  function createLabel({x, y, labelData, markerModel, gridRect, position: position2, labelTextStyle = {}, fontSize}) {
75788
75845
  const {zlevel} = markerModel.option;
75789
- const {lineStyle, showLine, showName, showTitle, title} = labelData;
75846
+ const {lineStyle, showLine, showName, showTitle, title, countDown} = labelData;
75790
75847
  const textStyle = Object.assign(labelData.textStyle ?? {}, {fontSize, padding: getPaddingByStyle(fontSize, labelTextStyle.borderWidth)}, labelTextStyle);
75791
75848
  const text = labelData.text;
75792
75849
  const labelTitle = title || labelData.name;
@@ -75794,10 +75851,17 @@ function createLabel({x, y, labelData, markerModel, gridRect, position: position
75794
75851
  const group = new Group_default();
75795
75852
  const labelY = y;
75796
75853
  const borderWidth = textStyle.borderWidth ?? 0;
75854
+ const font = getFont(textStyle, markerModel.ecModel);
75855
+ const countDownText = countDown && countDown.show && formatSeconds(countDown.value) || "";
75856
+ const renderText = countDownText.length > text.length ? countDownText : text;
75857
+ const textRect = getBoundingRect(renderText, font);
75858
+ const paddings = normalizeCssArray2(textStyle.padding || 0);
75859
+ const textElWidth = textRect.width + paddings[1] + paddings[3];
75860
+ const textElx = isLeft ? x - textElWidth - borderWidth - 1 : x + borderWidth;
75797
75861
  const textEl = new Text_default({
75798
- x: isLeft ? getLeftTextX(x, text, textStyle, markerModel.ecModel) : x,
75862
+ x: textElx,
75799
75863
  y: labelY,
75800
- style: Object.assign({text}, textStyle),
75864
+ style: Object.assign({text, width: textRect.width}, textStyle),
75801
75865
  z: 101,
75802
75866
  zlevel,
75803
75867
  ignore: !showName
@@ -75829,16 +75893,41 @@ function createLabel({x, y, labelData, markerModel, gridRect, position: position
75829
75893
  group.add(lineEl);
75830
75894
  group.add(textEl);
75831
75895
  group.add(textNameEl);
75896
+ if (countDown) {
75897
+ const show = countDown.show && !!countDown.value;
75898
+ const offsetY = showName && show ? textRect.height + paddings[0] + paddings[2] - 1 : 0;
75899
+ const fill = textStyle.fill === "#ffffff" ? "rgba(255,255,255,0.9)" : "rgba(0,0,0,0.9)";
75900
+ const countDownEl = new Text_default({
75901
+ x: textElx,
75902
+ y: labelY + offsetY,
75903
+ style: Object.assign({text: countDownText, width: textRect.width}, textStyle, {fill}),
75904
+ z: 101,
75905
+ zlevel,
75906
+ ignore: !show
75907
+ });
75908
+ inner21(group).showCountDown = show;
75909
+ inner21(countDownEl).labelType = "countDown";
75910
+ inner21(countDownEl).parentHeight = offsetY;
75911
+ group.add(countDownEl);
75912
+ }
75832
75913
  return group;
75833
75914
  }
75834
75915
  function updateLabel({x, y, labelData, markerModel, gridRect, position: position2, el, labelTextStyle = {}, fontSize}) {
75835
- const {lineStyle, showLine, showName, showTitle, title} = labelData;
75916
+ const {lineStyle, showLine, showName, showTitle, title, countDown} = labelData;
75836
75917
  const textStyle = Object.assign(labelData.textStyle ?? {}, {fontSize, padding: getPaddingByStyle(fontSize, labelTextStyle.borderWidth)}, labelTextStyle);
75837
75918
  const borderWidth = textStyle.borderWidth ?? 0;
75838
75919
  const isLeft = position2 === "left";
75839
75920
  if (el.ignore) {
75840
75921
  el.ignore = false;
75841
75922
  }
75923
+ const text = labelData.text;
75924
+ const countDownText = countDown && countDown.show && formatSeconds(countDown.value) || "";
75925
+ const renderText = countDownText.length > text.length ? countDownText : text;
75926
+ const font = getFont(textStyle, markerModel.ecModel);
75927
+ const textRect = getBoundingRect(renderText, font);
75928
+ const paddings = normalizeCssArray2(textStyle.padding || 0);
75929
+ const textElWidth = textRect.width + paddings[1] + paddings[3];
75930
+ const textElx = isLeft ? x - textElWidth - borderWidth - 1 : x + borderWidth;
75842
75931
  const labelY = y;
75843
75932
  inner21(el).y = labelY;
75844
75933
  each(el.children(), (element) => {
@@ -75867,10 +75956,9 @@ function updateLabel({x, y, labelData, markerModel, gridRect, position: position
75867
75956
  return;
75868
75957
  }
75869
75958
  const textLabel = labelData.text;
75870
- const labelX = isLeft ? getLeftTextX(x, textLabel, textStyle, markerModel.ecModel) - borderWidth : x + borderWidth;
75871
- element.x = labelX;
75959
+ element.x = textElx;
75872
75960
  element.y = labelY;
75873
- element.attr("style", Object.assign({text: textLabel}, textStyle));
75961
+ element.attr("style", Object.assign({text: textLabel, width: textRect.width}, textStyle));
75874
75962
  element.ignore = false;
75875
75963
  break;
75876
75964
  case "nameLabel":
@@ -75885,6 +75973,22 @@ function updateLabel({x, y, labelData, markerModel, gridRect, position: position
75885
75973
  element.attr("style", Object.assign({text: labelTitle}, textStyle));
75886
75974
  element.ignore = false;
75887
75975
  break;
75976
+ case "countDown":
75977
+ if (!countDown.show || !countDown.value) {
75978
+ element.ignore = true;
75979
+ inner21(el).showCountDown = false;
75980
+ inner21(element).parentHeight = 0;
75981
+ return;
75982
+ }
75983
+ const offsetY = showName ? textRect.height + paddings[0] + paddings[2] - 1 : 0;
75984
+ inner21(el).showCountDown = true;
75985
+ inner21(element).parentHeight = offsetY;
75986
+ const fill = textStyle.fill === "#ffffff" ? "rgba(255,255,255,0.9)" : "rgba(0,0,0,0.9)";
75987
+ element.x = textElx;
75988
+ element.y = labelY + offsetY;
75989
+ element.attr("style", Object.assign({text: countDownText, width: textRect.width}, textStyle, {fill}));
75990
+ element.ignore = false;
75991
+ break;
75888
75992
  }
75889
75993
  });
75890
75994
  }