koishi-plugin-chat-analyse 1.4.5 → 1.4.6

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 +10 -0
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1783,6 +1783,11 @@ var Renderer = class {
1783
1783
  if (!words?.length) return;
1784
1784
  const wordsJson = JSON.stringify(words);
1785
1785
  const selectedPalette = this.COLOR_PALETTES[Math.floor(Math.random() * this.COLOR_PALETTES.length)];
1786
+ const weights = words.map((w) => w[1]);
1787
+ const maxWeight = Math.max(...weights, 1);
1788
+ const minWeight = Math.min(...weights);
1789
+ const MAX_FONT_SIZE = 64;
1790
+ const MIN_FONT_SIZE = 4;
1786
1791
  const cardHtml = `
1787
1792
  <div class="container">
1788
1793
  <div class="header">
@@ -1796,6 +1801,11 @@ var Renderer = class {
1796
1801
  const palette = ${JSON.stringify(selectedPalette)};
1797
1802
  WordCloud(document.getElementById('wordcloud-container'), {
1798
1803
  fontFamily: '"Noto Sans CJK SC", "Arial", sans-serif',
1804
+ weightFactor: (size) => {
1805
+ if (${maxWeight} === ${minWeight}) return (${MIN_FONT_SIZE} + ${MAX_FONT_SIZE}) / 2;
1806
+ const normalizedWeight = (size - ${minWeight}) / (${maxWeight} - ${minWeight});
1807
+ return ${MIN_FONT_SIZE} + normalizedWeight * (${MAX_FONT_SIZE} - ${MIN_FONT_SIZE});
1808
+ },
1799
1809
  color: (word, weight, fontSize, distance, theta) => {
1800
1810
  return palette[Math.floor(Math.random() * palette.length)];
1801
1811
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-chat-analyse",
3
3
  "description": "强大而全面的聊天数据分析插件。支持多维度统计(命令、发言、消息类型、活跃度),可生成发言排行、词云图,并提供完善的数据管理。",
4
- "version": "1.4.5",
4
+ "version": "1.4.6",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],