tvcharts 0.7.40 → 0.7.42

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
@@ -8459,13 +8459,13 @@ function parseRichText(text, style) {
8459
8459
  for (let j = 0; j < line2.tokens.length; j++) {
8460
8460
  const token = line2.tokens[j];
8461
8461
  const tokenStyle = token.styleName && style.rich[token.styleName] || {};
8462
- const textPadding = token.textPadding = tokenStyle.padding;
8463
- const paddingH = textPadding ? textPadding[1] + textPadding[3] : 0;
8462
+ const textPadding2 = token.textPadding = tokenStyle.padding;
8463
+ const paddingH = textPadding2 ? textPadding2[1] + textPadding2[3] : 0;
8464
8464
  const font = token.font = tokenStyle.font || style.font;
8465
8465
  token.contentHeight = getLineHeight(font);
8466
8466
  let tokenHeight = retrieve2(tokenStyle.height, token.contentHeight);
8467
8467
  token.innerHeight = tokenHeight;
8468
- textPadding && (tokenHeight += textPadding[0] + textPadding[2]);
8468
+ textPadding2 && (tokenHeight += textPadding2[0] + textPadding2[2]);
8469
8469
  token.height = tokenHeight;
8470
8470
  token.lineHeight = retrieve3(tokenStyle.lineHeight, style.lineHeight, tokenHeight);
8471
8471
  token.align = tokenStyle && tokenStyle.align || style.align;
@@ -11108,7 +11108,7 @@ var ZRText = class extends Displayable_default {
11108
11108
  _updatePlainTexts() {
11109
11109
  const style = this.style;
11110
11110
  const textFont = style.font || DEFAULT_FONT;
11111
- const textPadding = style.padding;
11111
+ const textPadding2 = style.padding;
11112
11112
  const text = getStyleText(style);
11113
11113
  const contentBlock = parsePlainText(text, style);
11114
11114
  const needDrawBg = needDrawBackground(style);
@@ -11125,18 +11125,18 @@ var ZRText = class extends Displayable_default {
11125
11125
  const verticalAlign = style.verticalAlign || defaultStyle.verticalAlign || "top";
11126
11126
  let textX = baseX;
11127
11127
  let textY = adjustTextY2(baseY, contentBlock.contentHeight, verticalAlign);
11128
- if (needDrawBg || textPadding) {
11128
+ if (needDrawBg || textPadding2) {
11129
11129
  const boxX = adjustTextX(baseX, outerWidth, textAlign);
11130
11130
  const boxY = adjustTextY2(baseY, outerHeight, verticalAlign);
11131
11131
  needDrawBg && this._renderBackground(style, style, boxX, boxY, outerWidth, outerHeight);
11132
11132
  }
11133
11133
  textY += lineHeight / 2;
11134
- if (textPadding) {
11135
- textX = getTextXForPadding(baseX, textAlign, textPadding);
11134
+ if (textPadding2) {
11135
+ textX = getTextXForPadding(baseX, textAlign, textPadding2);
11136
11136
  if (verticalAlign === "top") {
11137
- textY += textPadding[0];
11137
+ textY += textPadding2[0];
11138
11138
  } else if (verticalAlign === "bottom") {
11139
- textY -= textPadding[2];
11139
+ textY -= textPadding2[2];
11140
11140
  }
11141
11141
  }
11142
11142
  let defaultLineWidth = 0;
@@ -11187,7 +11187,7 @@ var ZRText = class extends Displayable_default {
11187
11187
  const contentWidth = contentBlock.width;
11188
11188
  const outerWidth = contentBlock.outerWidth;
11189
11189
  const outerHeight = contentBlock.outerHeight;
11190
- const textPadding = style.padding;
11190
+ const textPadding2 = style.padding;
11191
11191
  const baseX = style.x || 0;
11192
11192
  const baseY = style.y || 0;
11193
11193
  const defaultStyle = this._defaultStyle;
@@ -11197,9 +11197,9 @@ var ZRText = class extends Displayable_default {
11197
11197
  const boxY = adjustTextY2(baseY, outerHeight, verticalAlign);
11198
11198
  let xLeft = boxX;
11199
11199
  let lineTop = boxY;
11200
- if (textPadding) {
11201
- xLeft += textPadding[3];
11202
- lineTop += textPadding[0];
11200
+ if (textPadding2) {
11201
+ xLeft += textPadding2[3];
11202
+ lineTop += textPadding2[0];
11203
11203
  }
11204
11204
  let xRight = xLeft + contentWidth;
11205
11205
  if (needDrawBackground(style)) {
@@ -11252,10 +11252,10 @@ var ZRText = class extends Displayable_default {
11252
11252
  const needDrawBg = !token.isLineHolder && needDrawBackground(tokenStyle);
11253
11253
  needDrawBg && this._renderBackground(tokenStyle, style, textAlign === "right" ? x - token.width : textAlign === "center" ? x - token.width / 2 : x, y - token.height / 2, token.width, token.height);
11254
11254
  const bgColorDrawn = !!tokenStyle.backgroundColor;
11255
- const textPadding = token.textPadding;
11256
- if (textPadding) {
11257
- x = getTextXForPadding(x, textAlign, textPadding);
11258
- y -= token.height / 2 - textPadding[0] - token.innerHeight / 2;
11255
+ const textPadding2 = token.textPadding;
11256
+ if (textPadding2) {
11257
+ x = getTextXForPadding(x, textAlign, textPadding2);
11258
+ y -= token.height / 2 - textPadding2[0] - token.innerHeight / 2;
11259
11259
  }
11260
11260
  const el = this._getOrCreateChild(TSpan_default);
11261
11261
  const subElStyle = el.createStyle();
@@ -11402,8 +11402,8 @@ function normalizeStyle(style) {
11402
11402
  let verticalAlign = style.verticalAlign;
11403
11403
  verticalAlign === "center" && (verticalAlign = "middle");
11404
11404
  style.verticalAlign = verticalAlign == null || VALID_TEXT_VERTICAL_ALIGN[verticalAlign] ? verticalAlign : "top";
11405
- const textPadding = style.padding;
11406
- if (textPadding) {
11405
+ const textPadding2 = style.padding;
11406
+ if (textPadding2) {
11407
11407
  style.padding = normalizeCssArray(style.padding);
11408
11408
  }
11409
11409
  }
@@ -11414,8 +11414,8 @@ function getStroke(stroke, lineWidth) {
11414
11414
  function getFill(fill) {
11415
11415
  return fill == null || fill === "none" ? null : fill.image || fill.colorStops ? "#000" : fill;
11416
11416
  }
11417
- function getTextXForPadding(x, textAlign, textPadding) {
11418
- return textAlign === "right" ? x - textPadding[1] : textAlign === "center" ? x + textPadding[3] / 2 - textPadding[1] / 2 : x + textPadding[3];
11417
+ function getTextXForPadding(x, textAlign, textPadding2) {
11418
+ return textAlign === "right" ? x - textPadding2[1] : textAlign === "center" ? x + textPadding2[3] / 2 - textPadding2[1] / 2 : x + textPadding2[3];
11419
11419
  }
11420
11420
  function getStyleText(style) {
11421
11421
  let text = style.text;
@@ -24452,6 +24452,18 @@ var ECharts = class extends Eventful_default {
24452
24452
  }, this);
24453
24453
  return !!result;
24454
24454
  }
24455
+ getGridRect(index = 0) {
24456
+ if (this._disposed) {
24457
+ disposedWarning(this.id);
24458
+ return;
24459
+ }
24460
+ const ecModel = this._model;
24461
+ const gird = ecModel.getComponent("grid", index);
24462
+ if (gird && gird.coordinateSystem) {
24463
+ return gird.coordinateSystem.getRect();
24464
+ }
24465
+ return;
24466
+ }
24455
24467
  getVisual(finder, visualType) {
24456
24468
  const ecModel = this._model;
24457
24469
  const parsedFinder = parseFinder(ecModel, finder, {
@@ -46597,7 +46609,7 @@ function renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimat
46597
46609
  return;
46598
46610
  }
46599
46611
  const textStyle = textEl.style;
46600
- const textPadding = normalizeCssArray(textStyle.padding || 0);
46612
+ const textPadding2 = normalizeCssArray(textStyle.padding || 0);
46601
46613
  if (upperLabelRect) {
46602
46614
  rectEl.setTextConfig({
46603
46615
  layoutRect: upperLabelRect
@@ -46605,8 +46617,8 @@ function renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimat
46605
46617
  textEl.disableLabelLayout = true;
46606
46618
  }
46607
46619
  textEl.beforeUpdate = function() {
46608
- const width = Math.max((upperLabelRect ? upperLabelRect.width : rectEl.shape.width) - textPadding[1] - textPadding[3], 0);
46609
- const height = Math.max((upperLabelRect ? upperLabelRect.height : rectEl.shape.height) - textPadding[0] - textPadding[2], 0);
46620
+ const width = Math.max((upperLabelRect ? upperLabelRect.width : rectEl.shape.width) - textPadding2[1] - textPadding2[3], 0);
46621
+ const height = Math.max((upperLabelRect ? upperLabelRect.height : rectEl.shape.height) - textPadding2[0] - textPadding2[2], 0);
46610
46622
  if (textStyle.width !== width || textStyle.height !== height) {
46611
46623
  textEl.setStyle({
46612
46624
  width,
@@ -57228,10 +57240,10 @@ var MinePolyLinesLayout = {
57228
57240
  for (let i = params.start; i < params.end; i++) {
57229
57241
  const itemModel = data.getItemModel(i);
57230
57242
  const {width, color: color2 = "none", lineStyle, fill = "none", closed = false, curved = false} = itemModel.get("itemStyle");
57231
- if (!color2 && fill === "none") {
57243
+ if (!color2 && !fill) {
57232
57244
  continue;
57233
57245
  }
57234
- const key = `${color2 || "none"}:${width}:${lineStyle}:${fill}:${closed}:${curved}`;
57246
+ const key = `${color2 || "none"}:${width}:${lineStyle}:${fill || "none"}:${closed}:${curved}`;
57235
57247
  const points4 = itemModel.get("points");
57236
57248
  const itemPoints = [];
57237
57249
  each(points4, function(item) {
@@ -57596,7 +57608,7 @@ var BoxesView2 = class extends Chart_default {
57596
57608
  style: {
57597
57609
  ...textStyle
57598
57610
  },
57599
- x: item.align === "center" ? item.x : item.x + 4,
57611
+ x: item.x,
57600
57612
  y: item.y + 2
57601
57613
  });
57602
57614
  if (item.v_align === "middle") {
@@ -57695,14 +57707,14 @@ var BoxesSeries_default = BoxesSeriesModel;
57695
57707
  // src/chart/boxes/util.ts
57696
57708
  var canvas = document.createElement("canvas");
57697
57709
  var ctx = canvas.getContext("2d");
57698
- function findFontSize(text, maxWidth, font = DefaultFamily, minSize = 2, maxSize = 50, tolerance = 8) {
57710
+ function findFontSize(text, maxWidth, font = DefaultFamily, tolerance = 8, minSize = 2, maxSize = 50) {
57699
57711
  let low = minSize;
57700
57712
  let high = maxSize;
57701
57713
  while (low <= high) {
57702
57714
  const size = Math.floor((low + high) / 2);
57703
57715
  ctx.font = `${size}px ${font}`;
57704
57716
  const width = ctx.measureText(text).width;
57705
- if (Math.abs(width - maxWidth) <= tolerance) {
57717
+ if (maxWidth > width && maxWidth - width <= tolerance) {
57706
57718
  return size;
57707
57719
  } else if (width < maxWidth) {
57708
57720
  low = size + 1;
@@ -57717,10 +57729,10 @@ var boxFontSizeMapping = {
57717
57729
  large: 18,
57718
57730
  normal: 14,
57719
57731
  small: 10,
57720
- tiny: 6
57732
+ tiny: 8
57721
57733
  };
57722
57734
  function getFontSize(size, text, maxWidth, font) {
57723
- return boxFontSizeMapping[size] || findFontSize(text, maxWidth, font);
57735
+ return boxFontSizeMapping[size] || findFontSize(text, maxWidth, font, 2);
57724
57736
  }
57725
57737
 
57726
57738
  // src/chart/boxes/BoxesLayout.ts
@@ -57735,23 +57747,28 @@ function optimizePoint3(point1, point2, lineWidth) {
57735
57747
  point2[1] = Math.floor(point2[1]) + 0.5;
57736
57748
  }
57737
57749
  }
57750
+ var textPadding = 4;
57738
57751
  function getBoxPoint(startPoint, endPoint, text_halign, text_valign) {
57739
- let x = startPoint[0];
57740
- let y = startPoint[1];
57752
+ const leftX = Math.min(startPoint[0], endPoint[0]);
57753
+ const rightX = Math.max(startPoint[0], endPoint[0]);
57754
+ const topY = Math.min(startPoint[1], endPoint[1]);
57755
+ const bottomY = Math.max(startPoint[1], endPoint[1]);
57756
+ let x = leftX + textPadding;
57757
+ let y = topY;
57741
57758
  let align = "left";
57742
57759
  let v_align = "top";
57743
57760
  if (text_halign === "align_center") {
57744
57761
  x = (startPoint[0] + endPoint[0]) / 2;
57745
57762
  align = "center";
57746
57763
  } else if (text_halign === "align_right") {
57747
- x = endPoint[0];
57764
+ x = rightX - textPadding;
57748
57765
  align = "right";
57749
57766
  }
57750
57767
  if (text_valign === "align_center") {
57751
57768
  y = (startPoint[1] + endPoint[1]) / 2;
57752
57769
  v_align = "middle";
57753
57770
  } else if (text_valign === "align_bottom") {
57754
- y = endPoint[1];
57771
+ y = bottomY;
57755
57772
  v_align = "bottom";
57756
57773
  }
57757
57774
  return {x, y, align, v_align};
@@ -57829,24 +57846,30 @@ var BoxesLayout = {
57829
57846
  const points4 = linesPointById[key] || [];
57830
57847
  optimizePoint3(startPoint, endPoint, border_width);
57831
57848
  const [left, right] = getHExtend(startPoint[0], endPoint[0], extend2);
57832
- points4.push(left, right, startPoint[1], endPoint[1]);
57833
- linesPointById[key] = points4;
57834
57849
  if (text) {
57835
- const width2 = endPoint[0] - startPoint[0];
57850
+ const width2 = Math.abs(endPoint[0] - startPoint[0]);
57851
+ const height = Math.abs(endPoint[1] - startPoint[1]);
57852
+ const minBoxSize = Math.min(width2, height);
57853
+ if (!minBoxSize) {
57854
+ continue;
57855
+ }
57836
57856
  const {x, y, align, v_align} = getBoxPoint(startPoint, endPoint, text_halign, text_valign);
57857
+ const padding = Math.min(minBoxSize / 2, 8);
57837
57858
  textList.push({
57838
57859
  text,
57839
57860
  text_color,
57840
57861
  text_wrap,
57841
- text_size: getFontSize(text_size, text, width2 - 10, font),
57862
+ text_size: getFontSize(text_size, text, minBoxSize - padding, font),
57842
57863
  align,
57843
57864
  v_align,
57844
57865
  width: width2,
57845
- height: Math.abs(endPoint[1] - startPoint[1]),
57866
+ height,
57846
57867
  x,
57847
57868
  y
57848
57869
  });
57849
57870
  }
57871
+ points4.push(left, right, startPoint[1], endPoint[1]);
57872
+ linesPointById[key] = points4;
57850
57873
  }
57851
57874
  data.setLayout({
57852
57875
  linesPointById,
@@ -59318,11 +59341,11 @@ var labelFontSizeMapping = {
59318
59341
  large: 18,
59319
59342
  normal: 14,
59320
59343
  small: 10,
59321
- tiny: 6
59344
+ tiny: 8
59322
59345
  };
59323
59346
  function getSymbolLabelFontSize(size, width) {
59324
59347
  if (size === "auto" && width) {
59325
- return Math.max(6, width / 2);
59348
+ return Math.max(8, width / 2);
59326
59349
  }
59327
59350
  return labelFontSizeMapping[size] ?? 12;
59328
59351
  }
@@ -74556,7 +74579,7 @@ var MarkLabelView2 = class extends Component_default2 {
74556
74579
  this.removeGraphicLabels(label);
74557
74580
  return;
74558
74581
  }
74559
- if (!item.labelVisible) {
74582
+ if (!label || !item.labelVisible) {
74560
74583
  return;
74561
74584
  }
74562
74585
  const seriesId = item.seriesId || defaultSeries.id;