koishi-plugin-chat-analyse 1.4.11 → 1.4.12

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 (2) hide show
  1. package/lib/index.js +12 -7
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1715,24 +1715,29 @@ var Renderer = class {
1715
1715
  const points = s.data.map((value, index) => `${getX(index)},${getY(value)}`).join(" ");
1716
1716
  svgElements += `<polyline points="${points}" fill="none" stroke="${color}" stroke-width="2"/>`;
1717
1717
  });
1718
- let legendHeight = 0;
1718
+ const chartAreaHeight = 280;
1719
+ const legendTopMargin = 15;
1720
+ const legendBottomMargin = 15;
1721
+ let legendBlockHeight = 0;
1719
1722
  if (series.length > 1) {
1720
1723
  const legendRows = Math.ceil(series.length / 3);
1721
- legendHeight = 15 + legendRows * 20;
1722
- const LEGEND_START_Y = 300;
1724
+ const legendRowHeight = 20;
1725
+ const legendInternalPadding = 5;
1726
+ legendBlockHeight = legendRows * legendRowHeight + legendInternalPadding;
1727
+ const LEGEND_START_Y = chartAreaHeight + legendTopMargin;
1723
1728
  const columnWidth = 560 / 3;
1724
1729
  series.forEach((s, seriesIndex) => {
1725
1730
  const rowIndex = Math.floor(seriesIndex / 3);
1726
1731
  const colIndex = seriesIndex % 3;
1727
1732
  const legendX = 40 + colIndex * columnWidth;
1728
- const legendY = LEGEND_START_Y + rowIndex * 20;
1733
+ const legendY = LEGEND_START_Y + rowIndex * legendRowHeight;
1729
1734
  const color = seriesColors[seriesIndex % seriesColors.length];
1730
1735
  svgElements += `<rect x="${legendX}" y="${legendY - 8}" width="12" height="8" fill="${color}" rx="2"/>`;
1731
1736
  svgElements += `<text x="${legendX + 18}" y="${legendY}" font-size="12" fill="var(--text-color)">${s.name}</text>`;
1732
1737
  });
1733
1738
  }
1734
- const totalLegendSpace = legendHeight > 0 ? legendHeight + 15 : 0;
1735
- const svgHeight = 280 + totalLegendSpace;
1739
+ const totalLegendSpace = legendBlockHeight > 0 ? legendTopMargin + legendBlockHeight + legendBottomMargin : 0;
1740
+ const svgHeight = chartAreaHeight + totalLegendSpace;
1736
1741
  const totalMessages = series.reduce((sum, s) => sum + s.data.reduce((a, b) => a + b, 0), 0);
1737
1742
  const cardHtml = `
1738
1743
  <div class="container" style="width: 600px;">
@@ -1768,7 +1773,7 @@ var Renderer = class {
1768
1773
  const maxWeight = Math.max(...weights, 1);
1769
1774
  const minWeight = Math.min(...weights);
1770
1775
  const wordCount = words.length;
1771
- const maxFontSize = Math.max(20, Math.round(512 / Math.log1p(wordCount)));
1776
+ const maxFontSize = Math.max(20, Math.round(600 / Math.log1p(wordCount)));
1772
1777
  const minFontSize = Math.max(6, Math.round(maxFontSize / 10));
1773
1778
  const cardHtml = `
1774
1779
  <div class="container" style="width: 600px;">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-chat-analyse",
3
3
  "description": "强大而全面的聊天数据分析插件。支持多维度统计(命令、发言、消息类型、活跃度),可生成发言排行、词云图,并提供完善的数据管理。",
4
- "version": "1.4.11",
4
+ "version": "1.4.12",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],