cats-charts 0.0.81 → 0.0.83

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.
@@ -0,0 +1,3 @@
1
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M2.5 6H9.5M6 9.5L9.5 6L6 2.5" stroke="#434A51" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -1324,39 +1324,38 @@ class Charts {
1324
1324
  }
1325
1325
  return Math.max(...levelMap.values());
1326
1326
  }
1327
- sankeyTooltipFormatter(params) {
1327
+ sankeyTooltipFormatter(params, config) {
1328
1328
  if (params.dataType === 'edge') {
1329
- const { source, target, sourceDesc, targetDesc } = params.data;
1329
+ const { source, target, value, tooltip } = params.data;
1330
+ const escape = (item) => String(item ?? '').replace(/[&<>"']/g, char => ({
1331
+ '&': '&amp;',
1332
+ '<': '&lt;',
1333
+ '>': '&gt;',
1334
+ '"': '&quot;',
1335
+ "'": '&#39;',
1336
+ })[char] ?? char);
1337
+ const formatKey = (key) => key ? key.charAt(0).toUpperCase() + key.slice(1) : key;
1338
+ const tooltipRows = tooltip && typeof tooltip === 'object'
1339
+ ? Object.entries(tooltip)
1340
+ .map(([key, item]) => {
1341
+ const value = Array.isArray(item) ? item.map(escape).join(', ') : escape(item);
1342
+ return `<div style="font-size:12px;font-weight:600">${escape(formatKey(key))}: <span style="font-size:12px;font-weight:400">${value}</span></div>`;
1343
+ })
1344
+ .join('')
1345
+ : '';
1330
1346
  return `
1331
- <div style="
1332
- background: #fff;
1333
- padding: 12px 14px;
1334
- border-radius: 10px;
1335
- box-shadow: 0 4px 14px rgba(0,0,0,0.15);
1336
- min-width: 220px;
1337
- font-family: sans-serif;
1338
- ">
1339
- <div style="margin-bottom:10px;">
1340
- <div style="font-size:12px; color:#777;">Source:
1341
- <span style="font-weight:600; color:#000">${source}</span>
1342
- </div>
1343
- ${sourceDesc
1344
- ? `<div style="font-size:11px; color:#aaa;">
1345
- ${sourceDesc}
1346
- </div>`
1347
- : ''}
1348
- </div>
1349
-
1350
- <div>
1351
- <div style="font-size:12px; color:#777;">Destination:
1352
- <span style="font-weight:600; color:#000">${target}</span>
1353
- </div>
1354
- ${targetDesc
1355
- ? `<div style="font-size:11px; color:#aaa;">
1356
- ${targetDesc}
1357
- </div>`
1358
- : ''}
1359
- </div>
1347
+ <div style="background:#FFFFFF;padding:12px;border:1px solid #d9e1ea;border-radius:8px;min-width:150px;">
1348
+ <div style="display:flex;align-items:center;gap:6px;font-size:12px;font-weight:600;">
1349
+ <span>${escape(source)}</span>
1350
+ <img
1351
+ src="images/arrow-right.svg"
1352
+ alt=""
1353
+ style="width:14px;height:14px;display:block;"
1354
+ />
1355
+ <span>${escape(target)}</span>
1356
+ </div>
1357
+ <div style="font-size:12px;font-weight:600"">${formatKey(config?.activeMetric) || 'Value'}: <span style="font-size:12px;font-weight:400">${escape(value)}</span></div>
1358
+ ${tooltipRows}
1360
1359
  </div>
1361
1360
  `;
1362
1361
  }
@@ -3712,6 +3711,12 @@ class CustomChartComponent {
3712
3711
  const tooltipCategories = this.config.tooltipCategories;
3713
3712
  if (tooltipCategories?.length && !tooltipCategories.includes(params.data?.category))
3714
3713
  return '';
3714
+ if (this.config.tooltipFormatter) {
3715
+ const formattedString = this.config.tooltipFormatter(params, this.config);
3716
+ if (this.config.darkTooltip)
3717
+ return `<div style="background-color: #111827; color: #fff; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-family: inherit; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); white-space: nowrap;">${formattedString}</div>`;
3718
+ return formattedString;
3719
+ }
3715
3720
  return this.chartService.timelineChartTooltipFormatter(params);
3716
3721
  },
3717
3722
  ...this.config.tooltip,
@@ -3895,7 +3900,7 @@ class SankeyChart {
3895
3900
  extraCssText: 'box-shadow:none;', // remove default shadow
3896
3901
  formatter: (params) => this.config.tooltipFormatter
3897
3902
  ? this.config.tooltipFormatter(params)
3898
- : this.chartService.sankeyTooltipFormatter(params),
3903
+ : this.chartService.sankeyTooltipFormatter(params, this.config),
3899
3904
  },
3900
3905
  series: [
3901
3906
  {
@@ -3905,8 +3910,16 @@ class SankeyChart {
3905
3910
  bottom: legendEnabled && legendConfig?.position === 'bottom' ? 32 : 16,
3906
3911
  ...this.config.seriesOption,
3907
3912
  type: 'sankey',
3908
- nodeWidth: this.clamp(styling?.node?.thickness ?? this.config.seriesOption?.nodeWidth, 1, 50),
3909
- nodeGap: this.clamp(styling?.node?.padding ?? this.config.seriesOption?.nodeGap, 0, 100),
3913
+ ...(styling?.node?.thickness ?? this.config.seriesOption?.nodeWidth
3914
+ ? {
3915
+ nodeWidth: this.clamp(styling?.node?.thickness ?? this.config.seriesOption?.nodeWidth, 1, 50)
3916
+ }
3917
+ : {}),
3918
+ ...(styling?.node?.padding ?? this.config.seriesOption?.nodeGap
3919
+ ? {
3920
+ nodeGap: this.clamp(styling?.node?.padding ?? this.config.seriesOption?.nodeGap, 0, 100)
3921
+ }
3922
+ : {}),
3910
3923
  data: visibleNodes.map((n, index) => {
3911
3924
  const nodeStyle = this.resolveSingleNodeStyle(n.name);
3912
3925
  return {
@@ -5248,8 +5261,10 @@ class GaugeChart {
5248
5261
  },
5249
5262
  pointer: {
5250
5263
  show: true,
5251
- width: 3,
5252
- length: '72%',
5264
+ icon: 'rect',
5265
+ width: 6,
5266
+ length: '18%',
5267
+ offsetCenter: [0, '-91%'],
5253
5268
  itemStyle: {
5254
5269
  color: '#374151',
5255
5270
  },