onesight-charts 1.4.5 → 1.4.7

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.
Files changed (30) hide show
  1. package/dist/onesight-charts.min.js +1 -1
  2. package/es/components/common-bar/index.js +1 -1
  3. package/es/components/custom-line/index.js +16 -13
  4. package/es/components/custom-line/tooltipConfig.js +8 -3
  5. package/es/components/line/index.js +15 -12
  6. package/es/components/line/tooltipConfig.js +8 -3
  7. package/es/components/one-table/index.js +1 -1
  8. package/es/components/pie/legend/index.js +2 -2
  9. package/es/components/stacked-bar/index.js +4 -4
  10. package/es/components/standard-custom-line/index.js +15 -5
  11. package/es/components/standard-custom-line/tooltipConfig.js +8 -3
  12. package/es/components/standard-line/index.js +16 -13
  13. package/es/components/standard-line/tooltipConfig.js +8 -3
  14. package/es/components/vertical-stacked-bar/index.js +2 -2
  15. package/es/utils/chartUtils.js +79 -1
  16. package/lib/components/common-bar/index.js +6 -1
  17. package/lib/components/custom-line/index.js +16 -13
  18. package/lib/components/custom-line/tooltipConfig.js +11 -2
  19. package/lib/components/line/index.js +15 -12
  20. package/lib/components/line/tooltipConfig.js +11 -2
  21. package/lib/components/one-table/index.js +1 -1
  22. package/lib/components/pie/legend/index.js +2 -2
  23. package/lib/components/stacked-bar/index.js +4 -4
  24. package/lib/components/standard-custom-line/index.js +19 -5
  25. package/lib/components/standard-custom-line/tooltipConfig.js +11 -2
  26. package/lib/components/standard-line/index.js +16 -13
  27. package/lib/components/standard-line/tooltipConfig.js +11 -2
  28. package/lib/components/vertical-stacked-bar/index.js +2 -2
  29. package/lib/utils/chartUtils.js +71 -0
  30. package/package.json +1 -1
@@ -60,8 +60,12 @@ function CustomLine(props) {
60
60
  xType,
61
61
  rightSpacing,
62
62
  legendDropdownRight = -98,
63
- showAllLegends = false
63
+ showAllLegends = false,
64
64
  // 是否显示所有图例
65
+ legendNameMaxWidth = 120,
66
+ // legend 名称最大宽度(像素值),用于文本截断
67
+ tooltipNameMaxWidth = 140
68
+ // tooltip 名称最大宽度(像素值),用于文本截断
65
69
  } = props;
66
70
  const chartRef = (0, import_react.useRef)(null);
67
71
  const prevDepsRef = (0, import_react.useRef)(null);
@@ -240,8 +244,10 @@ function CustomLine(props) {
240
244
  isTotalShow,
241
245
  xAxis,
242
246
  // 传入原始 xAxis 数据
243
- tooltipYOffset
247
+ tooltipYOffset,
244
248
  // y 方向偏移量
249
+ tooltipNameMaxWidth
250
+ // tooltip 名称最大宽度
245
251
  });
246
252
  let option = {
247
253
  legend: {
@@ -257,15 +263,12 @@ function CustomLine(props) {
257
263
  itemGap: 8,
258
264
  formatter: function(name) {
259
265
  const value = legendValue ? (0, import_chartUtils.numberFormatMust)(seriesTotal[name] || 0) : 0;
260
- let showName = name;
261
- if (dealData.length >= 4) {
262
- const strLen = 15;
263
- if (name.length > strLen) {
264
- showName = name.substring(0, strLen) + "...";
265
- }
266
- }
267
- return legendValue ? `{labelName|${showName}}
268
- {labelMark|${value}}` : `{labelName|${showName}}`;
266
+ const ellipsisName = (0, import_chartUtils.canvasEllipsisMiddle)(name, legendNameMaxWidth, {
267
+ fontSize: 12,
268
+ fontWeight: 500
269
+ });
270
+ return legendValue ? `{labelName|${ellipsisName}}
271
+ {labelMark|${value}}` : `{labelName|${ellipsisName}}`;
269
272
  },
270
273
  textStyle: {
271
274
  fontWeight: 500,
@@ -281,7 +284,7 @@ function CustomLine(props) {
281
284
  },
282
285
  // 给labelMark添加样式
283
286
  labelMark: {
284
- color: "#7A8283",
287
+ // color: '#7A8283',
285
288
  fontSize: 12,
286
289
  padding: [30, 0, 0, 0]
287
290
  }
@@ -540,7 +543,7 @@ function CustomLine(props) {
540
543
  const total = legendTotals[name] ?? 0;
541
544
  item.innerHTML = `
542
545
  <div class="l">
543
- <span class="onesight-legend-chip" style="display:inline-block;width:14px;vertical-align:middle;height:14px;background-color:${colorObj[name]};border-radius:4px;margin-bottom:2px;margin-right:6px"></span>
546
+ <span class="onesight-legend-chip" style="display:inline-block;width:16px;vertical-align:middle;height:4px;background-color:${colorObj[name]};margin-bottom:2px;margin-right:6px"></span>
544
547
  <span>${name}</span>
545
548
  </div>
546
549
  <div class="r" style="padding-left:6px;">
@@ -58,8 +58,10 @@ var createCustomTooltip = ({
58
58
  isTotalShow,
59
59
  xAxis,
60
60
  // 新增:原始的 xAxis 数据
61
- tooltipYOffset = -4
61
+ tooltipYOffset = -4,
62
62
  // y 方向偏移量,默认 14px
63
+ tooltipNameMaxWidth = 140
64
+ // tooltip 名称最大宽度(像素值),用于文本截断
63
65
  }) => ({
64
66
  className: `onesight-line-tooltip ${tooltipClassName}`,
65
67
  trigger: "axis",
@@ -151,7 +153,14 @@ var createCustomTooltip = ({
151
153
  <div class='l'>
152
154
  <span class='l-color' style="background-color:${item.color}"></span>
153
155
  <span>
154
- ${item.seriesName}
156
+ ${(0, import_chartUtils.canvasEllipsisMiddle)(
157
+ item.seriesName,
158
+ tooltipNameMaxWidth,
159
+ {
160
+ fontSize: 14,
161
+ fontWeight: 400
162
+ }
163
+ )}
155
164
  </span>
156
165
  </div>
157
166
  <div class='r'>
@@ -63,8 +63,12 @@ function Line(props) {
63
63
  sumData = 0,
64
64
  yAxisScale = true,
65
65
  // Y轴是否不从0开始,根据数据范围自动调整
66
- showAllLegends = false
66
+ showAllLegends = false,
67
67
  // 是否显示所有图例(line组件默认显示所有,此参数用于触发动态调整grid.bottom)
68
+ legendNameMaxWidth = 120,
69
+ // legend 名称最大宽度(像素值),用于文本截断
70
+ tooltipNameMaxWidth = 140
71
+ // tooltip 名称最大宽度(像素值),用于文本截断
68
72
  } = props;
69
73
  const chartRef = (0, import_react.useRef)(null);
70
74
  const prevDepsRef = (0, import_react.useRef)(null);
@@ -205,8 +209,10 @@ function Line(props) {
205
209
  isTotalShow,
206
210
  xAxis,
207
211
  // 传入原始 xAxis 数据
208
- tooltipYOffset
212
+ tooltipYOffset,
209
213
  // y 方向偏移量
214
+ tooltipNameMaxWidth
215
+ // tooltip 名称最大宽度
210
216
  });
211
217
  const series = (0, import_chartUtils.convertSeriesData)(seriesData);
212
218
  const legendData = Object.keys(seriesData).map((item) => ({
@@ -227,18 +233,15 @@ function Line(props) {
227
233
  itemGap: 8,
228
234
  formatter: function(name) {
229
235
  let value = legendValue ? (0, import_chartUtils.numberFormatMust)(seriesTotal[name] || 0) : 0;
230
- let showName = name;
231
- if (seriesData.length >= 4) {
232
- const strLen = 15;
233
- if (name.length > strLen) {
234
- showName = name.substring(0, strLen) + "...";
235
- }
236
- }
237
236
  if (sumData) {
238
237
  value = (0, import_chartUtils.numberFormatMust)(sumData);
239
238
  }
240
- return legendValue ? `{labelName|${showName}}
241
- {labelMark|${value}}` : `{labelName|${showName}}`;
239
+ const ellipsisName = (0, import_chartUtils.canvasEllipsisMiddle)(name, legendNameMaxWidth, {
240
+ fontSize: 12,
241
+ fontWeight: 500
242
+ });
243
+ return legendValue ? `{labelName|${ellipsisName}}
244
+ {labelMark|${value}}` : `{labelName|${ellipsisName}}`;
242
245
  },
243
246
  textStyle: {
244
247
  fontWeight: 500,
@@ -254,7 +257,7 @@ function Line(props) {
254
257
  },
255
258
  // 给labelMark添加样式
256
259
  labelMark: {
257
- color: "#7A8283",
260
+ // color: '#7A8283',
258
261
  fontSize: 12,
259
262
  padding: [30, 0, 0, 0]
260
263
  }
@@ -59,8 +59,10 @@ var createCustomTooltip = ({
59
59
  isTotalShow,
60
60
  xAxis,
61
61
  // 新增:原始的 xAxis 数据
62
- tooltipYOffset = -4
62
+ tooltipYOffset = -4,
63
63
  // y 方向偏移量,默认 14px
64
+ tooltipNameMaxWidth = 140
65
+ // tooltip 名称最大宽度(像素值),用于文本截断
64
66
  }) => ({
65
67
  className: `onesight-line-tooltip ${tooltipClassName} ${id}`,
66
68
  trigger: "axis",
@@ -154,7 +156,14 @@ var createCustomTooltip = ({
154
156
  <div class='l'>
155
157
  <span class='l-color' style="background-color:${item.color}"></span>
156
158
  <span>
157
- ${item.seriesName}
159
+ ${(0, import_chartUtils.canvasEllipsisMiddle)(
160
+ item.seriesName,
161
+ tooltipNameMaxWidth,
162
+ {
163
+ fontSize: 14,
164
+ fontWeight: 400
165
+ }
166
+ )}
158
167
  </span>
159
168
  </div>
160
169
  <div class='r'>
@@ -81,7 +81,7 @@ var LineChart = ({ data }) => {
81
81
  },
82
82
  // 给labelMark添加样式
83
83
  labelMark: {
84
- color: "#7A8283",
84
+ // color: '#7A8283',
85
85
  fontSize: 12,
86
86
  padding: [30, 0, 0, 0]
87
87
  }
@@ -156,8 +156,8 @@ function Legend(props) {
156
156
  {
157
157
  src: platformIconMap[item.name],
158
158
  style: {
159
- width: "13px",
160
- height: "13px",
159
+ width: "16px",
160
+ height: "16px",
161
161
  marginRight: "6px",
162
162
  flexShrink: 0,
163
163
  verticalAlign: "middle"
@@ -136,7 +136,7 @@ function StackedBar(props) {
136
136
  }, [onChartClick]);
137
137
  const chartColor = color || import_colors.defaultChartColors;
138
138
  const legendDataForCheck = series.map((s) => s.name);
139
- const ICON_SIZE = 18;
139
+ const ICON_SIZE = 16;
140
140
  const ICON_GAP = 0;
141
141
  const MAX_LABEL_WIDTH = 188;
142
142
  function makeYAxisRich(rows, maxLabelWidth = 188) {
@@ -497,7 +497,7 @@ function StackedBar(props) {
497
497
  icon: "roundRect",
498
498
  itemWidth: 14,
499
499
  itemHeight: 14,
500
- itemGap: 24,
500
+ itemGap: 8,
501
501
  data: visibleLegends,
502
502
  formatter: function(name) {
503
503
  const rawTotal = seriesTotalMap[name] || 0;
@@ -519,7 +519,7 @@ function StackedBar(props) {
519
519
  },
520
520
  // 给labelMark添加样式
521
521
  labelMark: {
522
- color: "#7A8283",
522
+ // color: '#7A8283',
523
523
  fontSize: 12,
524
524
  padding: [30, 0, 0, 0]
525
525
  }
@@ -739,7 +739,7 @@ function StackedBar(props) {
739
739
  const total = seriesTotalMap[name] ?? 0;
740
740
  item.innerHTML = `
741
741
  <div class="l">
742
- <span class="onesight-legend-chip" style="display:inline-block;width:14px;vertical-align:middle;height:14px;background-color:${colorObj[name]};border-radius:4px;margin-right:6px;flex-shrink:0;"></span>
742
+ <span class="onesight-legend-chip" style="display:inline-block;width:16px;vertical-align:middle;height:4px;background-color:${colorObj[name]};margin-right:6px;flex-shrink:0;"></span>
743
743
  <span style="flex:1;min-width:0;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">${name}</span>
744
744
  </div>
745
745
  <div class="r">
@@ -63,8 +63,12 @@ function StandardCustomLine(props) {
63
63
  yAxisScale = true,
64
64
  // Y轴是否不从0开始,根据数据范围自动调整
65
65
  legendDropdownRight = -98,
66
- showAllLegends = false
66
+ showAllLegends = false,
67
67
  // 是否显示所有图例
68
+ legendNameMaxWidth = 120,
69
+ // legend 名称最大宽度(像素值),用于文本截断
70
+ tooltipNameMaxWidth = 140
71
+ // tooltip 名称最大宽度(像素值),用于文本截断
68
72
  } = props;
69
73
  const chartRef = (0, import_react.useRef)(null);
70
74
  const prevDepsRef = (0, import_react.useRef)(null);
@@ -288,8 +292,10 @@ function StandardCustomLine(props) {
288
292
  // 传入映射,使 tooltip 显示原始 name
289
293
  xAxis,
290
294
  // 传入原始 xAxis 数据
291
- tooltipYOffset
295
+ tooltipYOffset,
292
296
  // y 方向偏移量
297
+ tooltipNameMaxWidth
298
+ // tooltip 名称最大宽度
293
299
  });
294
300
  const nameToIndexMap = {};
295
301
  legendData.forEach((item, index) => {
@@ -304,7 +310,7 @@ function StandardCustomLine(props) {
304
310
  },
305
311
  // 给labelMark添加样式
306
312
  labelMark: {
307
- color: "#7A8283",
313
+ // color: '#7A8283',
308
314
  fontSize: 12,
309
315
  padding: [30, 0, 0, 0]
310
316
  }
@@ -360,8 +366,16 @@ function StandardCustomLine(props) {
360
366
  const index = nameToIndexMap[name];
361
367
  const iconKey = platformIcon && index !== void 0 ? `icon${index}` : "";
362
368
  const iconPrefix = iconKey ? `{${iconKey}|} ` : "";
363
- return legendValue ? `${iconPrefix}{labelName|${showName}}
364
- {labelMark|${value}}` : `${iconPrefix}{labelName|${showName}}`;
369
+ const ellipsisName = (0, import_chartUtils.canvasEllipsisMiddle)(
370
+ showName,
371
+ legendNameMaxWidth,
372
+ {
373
+ fontSize: 12,
374
+ fontWeight: 500
375
+ }
376
+ );
377
+ return legendValue ? `${iconPrefix}{labelName|${ellipsisName}}
378
+ {labelMark|${value}}` : `${iconPrefix}{labelName|${ellipsisName}}`;
365
379
  },
366
380
  textStyle: {
367
381
  fontWeight: 500,
@@ -60,8 +60,10 @@ var createCustomTooltip = ({
60
60
  // 新增:uniqueKey 到原始 name 的映射
61
61
  xAxis,
62
62
  // 新增:原始的 xAxis 数据
63
- tooltipYOffset = -4
63
+ tooltipYOffset = -4,
64
64
  // y 方向偏移量,默认 14px
65
+ tooltipNameMaxWidth = 140
66
+ // tooltip 名称最大宽度(像素值),用于文本截断
65
67
  }) => ({
66
68
  className: `onesight-line-tooltip ${tooltipClassName}`,
67
69
  trigger: "axis",
@@ -158,7 +160,14 @@ var createCustomTooltip = ({
158
160
  <div class='l'>
159
161
  <span class='l-color' style="background-color:${item.color}"></span>
160
162
  <span>
161
- ${item.seriesName}
163
+ ${(0, import_chartUtils.canvasEllipsisMiddle)(
164
+ item.seriesName,
165
+ tooltipNameMaxWidth,
166
+ {
167
+ fontSize: 14,
168
+ fontWeight: 400
169
+ }
170
+ )}
162
171
  </span>
163
172
  </div>
164
173
  <div class='r'>
@@ -63,8 +63,12 @@ function StandardLine(props) {
63
63
  yAxisScale = true,
64
64
  // Y轴是否不从0开始,根据数据范围自动调整
65
65
  legendDropdownRight = -98,
66
- showAllLegends = false
66
+ showAllLegends = false,
67
67
  // 是否显示所有图例
68
+ legendNameMaxWidth = 120,
69
+ // legend 名称最大宽度(像素值),用于文本截断
70
+ tooltipNameMaxWidth = 140
71
+ // tooltip 名称最大宽度(像素值),用于文本截断
68
72
  } = props;
69
73
  const chartRef = (0, import_react.useRef)(null);
70
74
  const legendMoreBtnRef = (0, import_react.useRef)(null);
@@ -249,8 +253,10 @@ function StandardLine(props) {
249
253
  isTotalShow,
250
254
  xAxis,
251
255
  // 传入原始 xAxis 数据
252
- tooltipYOffset
256
+ tooltipYOffset,
253
257
  // y 方向偏移量
258
+ tooltipNameMaxWidth
259
+ // tooltip 名称最大宽度
254
260
  });
255
261
  let option = {
256
262
  legend: {
@@ -271,15 +277,12 @@ function StandardLine(props) {
271
277
  } else if (sumData) {
272
278
  value = (0, import_chartUtils.numberFormatMust)(sumData);
273
279
  }
274
- let showName = name;
275
- if (dealData.length >= 4) {
276
- const strLen = 15;
277
- if (showName.length > strLen) {
278
- showName = showName.substring(0, strLen) + "...";
279
- }
280
- }
281
- return legendValue ? `{labelName|${showName}}
282
- {labelMark|${value}}` : `{labelName|${showName}}`;
280
+ const ellipsisName = (0, import_chartUtils.canvasEllipsisMiddle)(name, legendNameMaxWidth, {
281
+ fontSize: 12,
282
+ fontWeight: 500
283
+ });
284
+ return legendValue ? `{labelName|${ellipsisName}}
285
+ {labelMark|${value}}` : `{labelName|${ellipsisName}}`;
283
286
  },
284
287
  textStyle: {
285
288
  fontWeight: 500,
@@ -295,7 +298,7 @@ function StandardLine(props) {
295
298
  },
296
299
  // 给labelMark添加样式
297
300
  labelMark: {
298
- color: "#7A8283",
301
+ // color: '#7A8283',
299
302
  fontSize: 12,
300
303
  padding: [30, 0, 0, 0]
301
304
  }
@@ -566,7 +569,7 @@ function StandardLine(props) {
566
569
  total = sumData;
567
570
  }
568
571
  item.innerHTML = `
569
- <span class="onesight-legend-chip" style="display:inline-block;width:14px;height:14px;background-color:${colorObj[name]};border-radius:4px;flex-shrink:0;margin-right:6px"></span>
572
+ <span class="onesight-legend-chip" style="display:inline-block;width:16px;height:4px;background-color:${colorObj[name]};flex-shrink:0;margin-right:6px"></span>
570
573
  <span class="onesight-legend-name" style="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${name}</span>
571
574
  <span class="onesight-legend-num" style="flex-shrink:0;padding-left:6px">${(0, import_chartUtils.numberFormatMust)(
572
575
  total
@@ -58,8 +58,10 @@ var createCustomTooltip = ({
58
58
  isTotalShow,
59
59
  xAxis,
60
60
  // 新增:原始的 xAxis 数据
61
- tooltipYOffset = -4
61
+ tooltipYOffset = -4,
62
62
  // y 方向偏移量,默认 14px
63
+ tooltipNameMaxWidth = 140
64
+ // tooltip 名称最大宽度(像素值),用于文本截断
63
65
  }) => ({
64
66
  className: `onesight-line-tooltip ${tooltipClassName}`,
65
67
  trigger: "axis",
@@ -152,7 +154,14 @@ var createCustomTooltip = ({
152
154
  <div class='l'>
153
155
  <span class='l-color' style="background-color:${item.color}"></span>
154
156
  <span>
155
- ${item.seriesName}
157
+ ${(0, import_chartUtils.canvasEllipsisMiddle)(
158
+ item.seriesName,
159
+ tooltipNameMaxWidth,
160
+ {
161
+ fontSize: 14,
162
+ fontWeight: 400
163
+ }
164
+ )}
156
165
  </span>
157
166
  </div>
158
167
  <div class='r'>
@@ -545,7 +545,7 @@ function VerticalStackedBar(props) {
545
545
  icon: "roundRect",
546
546
  itemWidth: 14,
547
547
  itemHeight: 14,
548
- itemGap: 24,
548
+ itemGap: 8,
549
549
  formatter: function(name) {
550
550
  const originalName = keyToNameMap && keyToNameMap[name] ? keyToNameMap[name] : name;
551
551
  let showName = originalName;
@@ -742,7 +742,7 @@ function VerticalStackedBar(props) {
742
742
  const iconHtml = platformIcon ? `<img src="${platformIcon}" style="width:13px;height:13px;margin-right:6px;flex-shrink:0;vertical-align:middle;" alt="" />` : "";
743
743
  item.innerHTML = `
744
744
  <div class="l">
745
- <span class="onesight-legend-chip" style="display:inline-block;width:14px;vertical-align:middle;height:14px;background-color:${colorObj[uniqueKey]};border-radius:4px;margin-right:6px;flex-shrink:0;"></span>
745
+ <span class="onesight-legend-chip" style="display:inline-block;width:16px;vertical-align:middle;height:4px;background-color:${colorObj[uniqueKey]};margin-right:6px;flex-shrink:0;"></span>
746
746
  ${iconHtml}
747
747
  <span style="flex:1;min-width:0;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">${originalName}</span>
748
748
  </div>
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var chartUtils_exports = {};
21
21
  __export(chartUtils_exports, {
22
22
  calculateSeriesTotal: () => calculateSeriesTotal,
23
+ canvasEllipsisMiddle: () => canvasEllipsisMiddle,
23
24
  changeDataTypeEn: () => changeDataTypeEn,
24
25
  computeFloat: () => computeFloat,
25
26
  computeFloatNull: () => computeFloatNull,
@@ -2239,9 +2240,79 @@ var mapEchartsDict = {
2239
2240
  function numberFormat(num, fixedNum = 1) {
2240
2241
  return numberFormatMust(num, fixedNum);
2241
2242
  }
2243
+ function canvasGetTextWidth(str, style = {}) {
2244
+ if (!str)
2245
+ return 0;
2246
+ const { fontSize = 12, fontWeight = 500, fontFamily = "sans-serif" } = style;
2247
+ const canvas = document.createElement("canvas");
2248
+ const ctx = canvas.getContext("2d");
2249
+ ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
2250
+ return Math.ceil(ctx.measureText(str).width);
2251
+ }
2252
+ function canvasEllipsisMiddle(str, maxWidth, style = {}) {
2253
+ if (!str)
2254
+ return "";
2255
+ if (canvasGetTextWidth(str, style) <= maxWidth)
2256
+ return str;
2257
+ const ellipsis = "...";
2258
+ let left = 1;
2259
+ let testWidth = 0;
2260
+ let arr = [];
2261
+ while (testWidth < maxWidth) {
2262
+ const leftPart = str.slice(0, left);
2263
+ const rightPart = str.slice(-left);
2264
+ const testStr = leftPart + ellipsis + rightPart;
2265
+ testWidth = canvasGetTextWidth(testStr, style);
2266
+ arr.push({
2267
+ left,
2268
+ testWidth
2269
+ });
2270
+ left++;
2271
+ }
2272
+ let T = 0;
2273
+ for (let i = arr.length - 1; i >= 0; i--) {
2274
+ if (arr[i].testWidth < maxWidth) {
2275
+ T = arr[i].left;
2276
+ break;
2277
+ }
2278
+ }
2279
+ if (T) {
2280
+ return `${str.slice(0, T)}${ellipsis}${str.slice(-T)}`;
2281
+ } else {
2282
+ return "";
2283
+ }
2284
+ }
2285
+ var TextMeasure = (() => {
2286
+ const span = document.createElement("span");
2287
+ span.style.position = "fixed";
2288
+ span.style.visibility = "hidden";
2289
+ span.style.whiteSpace = "nowrap";
2290
+ span.style.pointerEvents = "none";
2291
+ span.style.left = "-9999px";
2292
+ document.body.appendChild(span);
2293
+ function getWidth(str, style = {}) {
2294
+ if (!str)
2295
+ return 0;
2296
+ const {
2297
+ fontSize = 14,
2298
+ fontWeight = "normal",
2299
+ // fontFamily = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",
2300
+ fontFamily = '"PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
2301
+ letterSpacing = 0
2302
+ } = style;
2303
+ span.style.fontSize = fontSize + "px";
2304
+ span.style.fontWeight = fontWeight;
2305
+ span.style.letterSpacing = letterSpacing + "px";
2306
+ span.style.fontFamily = fontFamily;
2307
+ span.textContent = str;
2308
+ return Math.ceil(span.offsetWidth) + 2;
2309
+ }
2310
+ return { getWidth };
2311
+ })();
2242
2312
  // Annotate the CommonJS export names for ESM import in node:
2243
2313
  0 && (module.exports = {
2244
2314
  calculateSeriesTotal,
2315
+ canvasEllipsisMiddle,
2245
2316
  changeDataTypeEn,
2246
2317
  computeFloat,
2247
2318
  computeFloatNull,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onesight-charts",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
4
4
  "private": false,
5
5
  "description": "OneSight前端图表公共组件库",
6
6
  "license": "MIT",