tvcharts 0.6.38 → 0.6.40

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
@@ -894,7 +894,12 @@ function hexToRgba(hex) {
894
894
  function parseRgbaString(rgba) {
895
895
  const match = rgba.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*([\d.]+)\s*)?\)/);
896
896
  if (!match) {
897
- throw new Error("Invalid RGBA string format.");
897
+ return {
898
+ r: 0,
899
+ g: 0,
900
+ b: 0,
901
+ a: 0
902
+ };
898
903
  }
899
904
  const a = match[5] !== void 0 ? parseFloat(match[5]) : 1;
900
905
  return {
@@ -904,7 +909,7 @@ function parseRgbaString(rgba) {
904
909
  a
905
910
  };
906
911
  }
907
- function colorToRgba(color2) {
912
+ function colorToRgba(color2 = "") {
908
913
  if (colorCache.get(color2)) {
909
914
  return colorCache.get(color2);
910
915
  }
@@ -914,7 +919,12 @@ function colorToRgba(color2) {
914
919
  } else if (color2.startsWith("rgb")) {
915
920
  rgbaColor = parseRgbaString(color2);
916
921
  } else {
917
- throw new Error("Unsupported color format.");
922
+ rgbaColor = {
923
+ r: 0,
924
+ g: 0,
925
+ b: 0,
926
+ a: 0
927
+ };
918
928
  }
919
929
  colorCache.put(color2, rgbaColor);
920
930
  return rgbaColor;
@@ -7185,7 +7195,7 @@ function getElementSSRData(el) {
7185
7195
  function registerSSRDataGetter(getter) {
7186
7196
  ssrDataGetter = getter;
7187
7197
  }
7188
- var version = "5.6.5";
7198
+ var version = "5.6.6";
7189
7199
 
7190
7200
  // src/util/number.ts
7191
7201
  var RADIAN_EPSILON = 1e-4;
@@ -55255,7 +55265,10 @@ var linesPlotLayout = {
55255
55265
  return;
55256
55266
  }
55257
55267
  const dataModal = lineData.getItemModel(index);
55258
- const symbolColor = dataModal.get("itemStyle")?.color || defaultColor;
55268
+ const symbolColor = dataModal.get("itemStyle")?.color;
55269
+ if (!symbolColor) {
55270
+ return;
55271
+ }
55259
55272
  const symbol = dataModal.get("symbol");
55260
55273
  const symbolKey = `${symbol}`;
55261
55274
  const symbolData = symbolPointsByColor[symbolKey] || [];
@@ -68077,7 +68090,7 @@ TableModel.type = "table";
68077
68090
  TableModel.defaultOption = {
68078
68091
  z: 6,
68079
68092
  tables: [],
68080
- paddings: 8
68093
+ paddings: 10
68081
68094
  };
68082
68095
  var TableModel_default = TableModel;
68083
68096
 
@@ -68175,20 +68188,35 @@ var TableView2 = class extends Component_default2 {
68175
68188
  each(tables, function(item, index) {
68176
68189
  const columnWidthByIndex = [];
68177
68190
  const rowHeightByIndex = [];
68191
+ const margeCellByKey = {};
68192
+ item.merge_cells?.forEach((item2) => {
68193
+ margeCellByKey[item2.start_row + ":" + item2.start_column] = item2;
68194
+ });
68178
68195
  each(item.cell, function(cell) {
68179
68196
  each(cell, function(cellItem) {
68180
68197
  if (!cellItem) {
68181
68198
  return;
68182
68199
  }
68183
68200
  const {column, row, text, width: width2, height: height2, text_size, text_font_family} = cellItem;
68201
+ const mergeCell = margeCellByKey[row + ":" + column];
68184
68202
  const fontSize = getSymbolLabelFontSize(text_size);
68185
68203
  const font = getFont({
68186
68204
  fontSize,
68187
68205
  fontFamily: text_font_family
68188
68206
  }, ecModel);
68189
- const textRect = getBoundingRect(text, font);
68207
+ const textRect = new Text_default({
68208
+ style: {
68209
+ text,
68210
+ font
68211
+ }
68212
+ }).getBoundingRect();
68190
68213
  const textHight = height2 ? height2 / 100 * rect.height : textRect.height;
68191
68214
  const textWidth = width2 ? width2 / 100 * rect.width : textRect.width + 2;
68215
+ if (mergeCell) {
68216
+ columnWidthByIndex[column] = Math.floor(Math.max(0, columnWidthByIndex[column] || 0));
68217
+ rowHeightByIndex[row] = Math.floor(Math.max(textHight, rowHeightByIndex[row] || 0));
68218
+ return;
68219
+ }
68192
68220
  columnWidthByIndex[column] = Math.floor(Math.max(textWidth, columnWidthByIndex[column] || 0));
68193
68221
  rowHeightByIndex[row] = Math.floor(Math.max(textHight, rowHeightByIndex[row] || 0));
68194
68222
  });
@@ -68198,6 +68226,7 @@ var TableView2 = class extends Component_default2 {
68198
68226
  for (let index2 = 0; index2 < columnWidthByIndex.length; index2++) {
68199
68227
  const columnWidth = columnWidthByIndex[index2];
68200
68228
  if (!columnWidth) {
68229
+ columnObjByIndex[index2] = {x: width, width: 0};
68201
68230
  continue;
68202
68231
  }
68203
68232
  const last = index2 === columnWidthByIndex.length - 1;
@@ -68209,6 +68238,7 @@ var TableView2 = class extends Component_default2 {
68209
68238
  for (let index2 = 0; index2 < rowHeightByIndex.length; index2++) {
68210
68239
  const rowHeight = rowHeightByIndex[index2];
68211
68240
  if (!rowHeight) {
68241
+ rowObjByIndex[index2] = {y: height, height: 0};
68212
68242
  continue;
68213
68243
  }
68214
68244
  const last = index2 === rowHeightByIndex.length - 1;
@@ -68228,19 +68258,55 @@ var TableView2 = class extends Component_default2 {
68228
68258
  const group = this.group;
68229
68259
  each(tables, function(item, index) {
68230
68260
  const {x, y, columnObjByIndex, rowObjByIndex, width, height} = tableAttrByIndex[index];
68231
- const {bgcolor, frame_color, frame_width = 0, border_width = 0, border_color} = item;
68261
+ const {bgcolor, frame_color, frame_width = 0, border_width = 0, border_color, columns} = item;
68232
68262
  const tableGroup = new Group_default({x, y});
68263
+ const margeCellByKey = {};
68264
+ item.merge_cells?.forEach((item2) => {
68265
+ margeCellByKey[item2.start_row + ":" + item2.start_column] = item2;
68266
+ });
68233
68267
  each(item.cell, function(cell) {
68234
68268
  each(cell, function(cellItem) {
68235
68269
  if (!cellItem) {
68236
68270
  return;
68237
68271
  }
68238
- const {column, row, text, text_size, text_font_family, text_halign, text_color, bgcolor: bgcolor2, text_valign} = cellItem;
68272
+ const {
68273
+ column,
68274
+ row,
68275
+ text,
68276
+ text_size,
68277
+ text_font_family,
68278
+ text_halign,
68279
+ text_color,
68280
+ bgcolor: bgcolor2,
68281
+ text_valign
68282
+ } = cellItem;
68239
68283
  const fontSize = getSymbolLabelFontSize(text_size);
68240
- const {width: width2, x: x2} = columnObjByIndex[column];
68241
- const {height: height2, y: y2} = rowObjByIndex[row];
68284
+ const {x: x2} = columnObjByIndex[column];
68285
+ let width2 = columnObjByIndex[column].width;
68286
+ const {y: y2} = rowObjByIndex[row];
68287
+ let height2 = rowObjByIndex[row].height;
68242
68288
  const align = getAlign(text_halign);
68243
68289
  const verticalAlign = getVerticalAlign(text_valign);
68290
+ const mergeCell = margeCellByKey[row + ":" + column];
68291
+ if (mergeCell) {
68292
+ const {end_column, end_row} = mergeCell;
68293
+ const mergeColumnIndex = end_column;
68294
+ for (let i = column + 1; i <= mergeColumnIndex; i++) {
68295
+ const w = columnObjByIndex[i]?.width;
68296
+ if (w) {
68297
+ width2 = width2 + w + paddings + item.border_width;
68298
+ }
68299
+ }
68300
+ ;
68301
+ const mergeRowIndex = end_row;
68302
+ for (let i = row + 1; i <= mergeRowIndex; i++) {
68303
+ const h = rowObjByIndex[i]?.height;
68304
+ if (h) {
68305
+ height2 = height2 + h + paddings + item.border_width;
68306
+ }
68307
+ }
68308
+ ;
68309
+ }
68244
68310
  const textEl = new Text_default({
68245
68311
  style: {
68246
68312
  text,
@@ -68261,54 +68327,43 @@ var TableView2 = class extends Component_default2 {
68261
68327
  z2: 10
68262
68328
  });
68263
68329
  tableGroup.add(textEl);
68330
+ if (border_width && border_color) {
68331
+ const cellColumn = mergeCell ? mergeCell.end_column : column;
68332
+ const isLastColumn = cellColumn === columns - 1;
68333
+ const startPoint = [x2, y2 - border_width / 2];
68334
+ const midPoint = [
68335
+ x2 + width2 + paddings + (isLastColumn ? 0 : border_width / 2),
68336
+ y2 - (row ? border_width / 2 : 0)
68337
+ ];
68338
+ const endPoint = [
68339
+ x2 + width2 + paddings + border_width / 2,
68340
+ y2 + height2 + paddings
68341
+ ];
68342
+ const points4 = [midPoint];
68343
+ if (row) {
68344
+ points4.unshift(startPoint);
68345
+ }
68346
+ if (!isLastColumn) {
68347
+ points4.push(endPoint);
68348
+ }
68349
+ if (points4.length < 2) {
68350
+ return;
68351
+ }
68352
+ const lineEl = new Polyline_default({
68353
+ shape: {
68354
+ points: points4
68355
+ },
68356
+ style: {
68357
+ stroke: border_color,
68358
+ lineWidth: border_width
68359
+ },
68360
+ z,
68361
+ z2: 11
68362
+ });
68363
+ tableGroup.add(lineEl);
68364
+ }
68264
68365
  });
68265
68366
  });
68266
- if (border_width && border_color) {
68267
- for (let index2 = 0; index2 < columnObjByIndex.length; index2++) {
68268
- const obj = columnObjByIndex[index2];
68269
- const hide = index2 === 0 || !obj;
68270
- if (hide) {
68271
- continue;
68272
- }
68273
- const lineEl = new Line_default({
68274
- shape: {
68275
- x1: obj.x - border_width / 2,
68276
- y1: 0,
68277
- x2: obj.x - border_width / 2,
68278
- y2: height
68279
- },
68280
- style: {
68281
- stroke: border_color,
68282
- lineWidth: border_width
68283
- },
68284
- z,
68285
- z2: 11
68286
- });
68287
- tableGroup.add(lineEl);
68288
- }
68289
- for (let index2 = 0; index2 < rowObjByIndex.length; index2++) {
68290
- const obj = rowObjByIndex[index2];
68291
- const hide = index2 === 0 || !obj;
68292
- if (hide) {
68293
- continue;
68294
- }
68295
- const lineEl = new Line_default({
68296
- shape: {
68297
- x1: 0,
68298
- y1: obj.y - border_width / 2,
68299
- x2: width,
68300
- y2: obj.y - border_width / 2
68301
- },
68302
- style: {
68303
- stroke: border_color,
68304
- lineWidth: border_width
68305
- },
68306
- z,
68307
- z2: 11
68308
- });
68309
- tableGroup.add(lineEl);
68310
- }
68311
- }
68312
68367
  if (bgcolor) {
68313
68368
  const rectEl = new Rect_default({
68314
68369
  shape: {
@@ -70357,6 +70412,42 @@ MarkLabelModal.defaultOption = {
70357
70412
  };
70358
70413
  var MarkLabelModal_default = MarkLabelModal;
70359
70414
 
70415
+ // src/util/color.ts
70416
+ function parseColor(color2) {
70417
+ if (color2.startsWith("#")) {
70418
+ color2 = color2.slice(1);
70419
+ if (color2.length === 3) {
70420
+ color2 = color2.split("").map((c) => c + c).join("");
70421
+ }
70422
+ if (color2.length !== 6 || !/^[0-9A-Fa-f]{6}$/.test(color2)) {
70423
+ return [0, 0, 0];
70424
+ }
70425
+ return [
70426
+ parseInt(color2.slice(0, 2), 16),
70427
+ parseInt(color2.slice(2, 4), 16),
70428
+ parseInt(color2.slice(4, 6), 16)
70429
+ ];
70430
+ }
70431
+ const match = color2.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*[\d.]+)?\s*\)/);
70432
+ if (!match) {
70433
+ return [0, 0, 0];
70434
+ }
70435
+ return [
70436
+ parseInt(match[1], 10),
70437
+ parseInt(match[2], 10),
70438
+ parseInt(match[3], 10)
70439
+ ];
70440
+ }
70441
+ function contrastColor2(color2) {
70442
+ const [r, g, b] = parseColor(color2);
70443
+ const brightness = (r * 299 + g * 587 + b * 114) / 1e3;
70444
+ return brightness >= 128 ? "#000000" : "#ffffff";
70445
+ }
70446
+ function removeTransparency(color2) {
70447
+ const [r, g, b] = parseColor(color2);
70448
+ return `rgb(${r}, ${g}, ${b})`;
70449
+ }
70450
+
70360
70451
  // src/component/marker/MarkLabelView.ts
70361
70452
  var markerTypeCalculator2 = {
70362
70453
  dataMin: (item, seriesModel) => {
@@ -70401,8 +70492,8 @@ var markerTypeCalculator2 = {
70401
70492
  return {
70402
70493
  value: seriesData.getByRawIndex(item.valueDim, lastIndex),
70403
70494
  labelTextStyle: {
70404
- fill: "#fff",
70405
- backgroundColor: fill,
70495
+ fill: contrastColor2(fill),
70496
+ backgroundColor: removeTransparency(fill),
70406
70497
  borderWidth: 0
70407
70498
  }
70408
70499
  };