tvcharts 0.9.26 → 0.9.27

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.
@@ -181,7 +181,7 @@ var BoxesLayout = {
181
181
  text: text,
182
182
  text_color: text_color,
183
183
  text_wrap: text_wrap,
184
- text_size: getFontSize(text_size, text, width_1 - Math.floor(width_1 / 5), font, height - Math.min(minBoxSize / 2, 10)),
184
+ text_size: getFontSize(text_size, text, width_1 - Math.floor(width_1 / 10), font, height - Math.min(minBoxSize / 2, 10)),
185
185
  align: align,
186
186
  v_align: v_align,
187
187
  width: width_1,
@@ -57,6 +57,14 @@ function getLineDashByLineStyle(lineStyle) {
57
57
  }
58
58
  return 'solid';
59
59
  }
60
+ function getTextOffset(text, fontSize) {
61
+ var hasChinese = /[\u4e00-\u9fa5]/.test(text);
62
+ if (hasChinese) {
63
+ return fontSize * 0.09; // 中文需要较多下移
64
+ }
65
+ // 纯英文/数字通常只需要极小位移或不位移
66
+ return 0;
67
+ }
60
68
  var BoxesView = /** @class */function (_super) {
61
69
  __extends(BoxesView, _super);
62
70
  function BoxesView() {
@@ -142,7 +150,7 @@ var BoxesView = /** @class */function (_super) {
142
150
  y: item.y + 2
143
151
  });
144
152
  if (item.v_align === 'middle') {
145
- el.y = item.y - Math.min(el.getBoundingRect().height, item.height) / 2;
153
+ el.y = item.y - Math.min(el.getBoundingRect().height, item.height) / 2 + getTextOffset(item.text, item.text_size);
146
154
  } else if (item.v_align === 'bottom') {
147
155
  el.y = item.y - Math.min(el.getBoundingRect().height, item.height) - 2;
148
156
  }
@@ -35,7 +35,7 @@ function findFontSize(text, maxWidth, font, tolerance, maxHeight) {
35
35
  tolerance = 8;
36
36
  }
37
37
  var low = 2;
38
- var high = 50;
38
+ var high = 1000;
39
39
  var lines = text.split('\n');
40
40
  var linesLength = lines.length;
41
41
  var maxLengthText = lines[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tvcharts",
3
- "version": "0.9.26",
3
+ "version": "0.9.27",
4
4
  "main": "dist/echarts.js",
5
5
  "module": "index.js",
6
6
  "jsdelivr": "dist/echarts.min.js",