Skip to content

Feat/chart overlay stacked#224

Merged
ding113 merged 19 commits intoding113:feat/chart-overlay-stackedfrom
sususu98:feat/chart-overlay-stacked
Nov 28, 2025
Merged

Feat/chart overlay stacked#224
ding113 merged 19 commits intoding113:feat/chart-overlay-stackedfrom
sususu98:feat/chart-overlay-stacked

Conversation

@sususu98
Copy link
Contributor

@sususu98 sususu98 commented Nov 28, 2025

Summary

Add chart display mode toggle (Overlay/Stacked) for multi-user statistics visualization in the dashboard.

Problem

When viewing statistics for multiple users, the chart only supported stacked mode which made it difficult to directly compare individual user values since all data was cumulative.

Solution

Introduce a display mode toggle that allows switching between:

  1. Overlay (对比模式)

    • Focus: Individual differences ("who's stronger")
    • Logic: Independent rendering, baseline at 0 for all
    • Use case: Direct value comparison (e.g., User A vs User B)
  2. Stacked (堆叠模式)

    • Focus: Overall composition ("how's the total")
    • Logic: Cumulative rendering, each layer builds on previous
    • Use case: Total amount and proportion analysis (e.g., Total Spend composition)

Changes

  • Add chart mode state toggle (overlay/stacked) in UserStatisticsChart component
  • Implement dynamic stackId assignment based on selected mode
  • Add overlay mode rendering order optimization (larger values rendered first to prevent occlusion)
  • Add i18n translations for chart mode labels (en, ja, ru, zh-CN, zh-TW)
  • Update LiteLLM model prices with new Claude and other model entries
  • Bump version to 0.3.15 and update CHANGELOG.md

Testing

  • Manual testing performed
  • Multi-user chart display verified in both modes
  • No breaking changes

ding113 and others added 19 commits November 26, 2025 01:10
fix(ui): 修复供应商可用性监控页面排序顺序
fix: 故障转移后无条件更新 Session 绑定
Visual presentation modes:

1. Overlay (对比模式)
   - 关注点: 个体差异 ("谁更强")
   - 逻辑: 独立渲染,基准线均为 0
   - 用途: 数值直接对比 (e.g., User A vs User B)

2. Stacked (堆叠模式)
   - 关注点: 整体构成 ("整体怎样")
   - 逻辑: 累加渲染,后续层基于前一层
   - 用途: 总量及占比分析 (e.g., Total Spend composition)
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sususu98, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances data visualization capabilities by introducing 'Overlay' and 'Stacked' display modes for charts, allowing users to choose how multi-user statistics are presented. Alongside this new feature, the PR includes comprehensive updates to model pricing data and a significant update to the project's changelog and version number, reflecting a broad set of recent improvements and bug fixes.

Highlights

  • New Chart Display Modes: Introduces two new visual presentation modes for charts: 'Overlay' and 'Stacked'. Overlay mode focuses on individual differences with independent rendering, while Stacked mode emphasizes overall composition with cumulative rendering. A UI toggle has been added to switch between these modes when multiple users are displayed.
  • Multi-language Support for Chart Modes: Added translation keys for 'Display Mode', 'Overlay', and 'Stacked' in English, Japanese, Russian, Simplified Chinese, and Traditional Chinese dashboard message files to support internationalization of the new chart features.
  • Updated Model Pricing Data: Incorporated new model pricing configurations for a wide range of AI models, including Amazon Nova Canvas, Anthropic Claude Opus/Sonnet, Azure Claude models, Cohere embed-multilingual-light, Fireworks AI glm-4p6, Openrouter Anthropic Claude Opus, OpenAI text-embedding-ada-002-v2, and Watsonx Whisper.
  • Version Bump and Changelog Update: The project version has been updated from 0.3.9 to 0.3.15. The CHANGELOG.md file received a substantial update, documenting numerous additions, changes, and fixes across various features such as provider monitoring, API testing, performance improvements, and general bug resolutions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ding113
Copy link
Owner

ding113 commented Nov 28, 2025

🔒 Security Scan Results

No security vulnerabilities detected

This PR has been scanned against OWASP Top 10, CWE Top 25, and common security anti-patterns. No security issues were identified in the code changes.

📋 Changes Analyzed

File Type Security Impact
CHANGELOG.md Documentation None
VERSION Version bump None
messages/*/dashboard.json (5 files) i18n translations None - static strings
public/seed/litellm-prices.json Static pricing data None - read-only config
src/app/.../chart.tsx React component None - UI presentation only

🔍 Scanned Categories

  • Injection attacks (SQL, NoSQL, Command, LDAP, etc.) - No database queries or command execution
  • Authentication and session management - No auth logic modified
  • Sensitive data exposure - No sensitive data handling
  • Access control and authorization - No authorization logic modified
  • Security misconfiguration - No configuration changes
  • Cross-site scripting (XSS) - React JSX with proper escaping, no dangerouslySetInnerHTML
  • Insecure deserialization - No deserialization of untrusted data
  • SSRF and path traversal - No URL fetching or file operations
  • Cryptographic weaknesses - No crypto operations

📝 Notes

The code changes are primarily:

  1. UI enhancements - Adding chart display mode toggle (overlay/stacked)
  2. i18n additions - New translation keys for the chart mode feature
  3. Static data updates - Model pricing information

All React component changes use proper JSX escaping and do not introduce any attack surface. The component receives data via props and renders it using standard React patterns.


🤖 Automated security scan by Claude AI - OWASP Top 10 & CWE coverage

@ding113 ding113 added enhancement New feature or request size/M Medium PR (< 500 lines) labels Nov 28, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 PR 实现了图表的“对比”和“堆叠”模式切换功能,整体实现得非常出色。代码逻辑清晰,并且考虑到了“对比”模式下图形遮挡的视觉优化问题。

主要亮点:

  • 动态切换: 通过 chartMode state 和对 Area 组件 stackId 的动态赋值,实现了两种模式的无缝切换。
  • 视觉优化: 在“对比”模式下,通过对数据系列进行降序排序渲染,确保了数值较大的区域不会遮挡数值较小的区域,提升了图表的可读性。
  • 坐标轴优化: 为 Y 轴添加了 domain={[0, "dataMax"]},保证了图表基线从 0 开始,使得数据对比更加直观和准确。

代码质量很高,我只在 chart.tsx 中发现一个可以优化的点,以提高性能和代码结构。详细信息请见具体评论。

此外,这个 PR 还包含了大量的 CHANGELOG.mdlitellm-prices.json 的更新,以及版本号的提升,看起来像一个集合了多个功能的发布版本。

Comment on lines +495 to +506
{(chartMode === "overlay"
? [...visibleUsers].sort((a, b) => {
const totalA = userTotals[a.dataKey];
const totalB = userTotals[b.dataKey];
if (!totalA || !totalB) return 0;
if (activeChart === "cost") {
return totalB.cost.comparedTo(totalA.cost);
}
return totalB.calls - totalA.calls;
})
: visibleUsers
).map((user) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了提升性能和代码可读性,建议将此排序逻辑提取到 React.useMemo 中。当前实现在每次组件渲染时都会重新创建数组并进行排序,当用户数量较多时可能会产生不必要的性能开销。

通过 useMemo 缓存排序结果,可以确保只有在相关依赖(如 chartMode, visibleUsers, userTotals, activeChart)变化时才重新计算。

示例:

const sortedVisibleUsers = React.useMemo(() => {
  if (chartMode !== "overlay") {
    return visibleUsers;
  }
  // Overlay 模式下按数值降序渲染,大的在底层,小的在顶层避免遮挡
  return [...visibleUsers].sort((a, b) => {
    const totalA = userTotals[a.dataKey];
    const totalB = userTotals[b.dataKey];
    if (!totalA || !totalB) return 0;
    if (activeChart === "cost") {
      return totalB.cost.comparedTo(totalA.cost);
    }
    return totalB.calls - totalA.calls;
  });
}, [chartMode, visibleUsers, userTotals, activeChart]);

// ... 在 JSX 中使用 ...
{sortedVisibleUsers.map((user) => {
  // ...
})}

Copy link
Owner

@ding113 ding113 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Code Review Summary

This PR adds a chart display mode toggle (Overlay vs Stacked) to the statistics dashboard, allowing users to switch between comparing individual values and viewing cumulative totals. The implementation is clean, well-structured, and includes complete i18n support for all 5 locales.

🔍 Issues Found

  • Critical (🔴): 0 issues
  • High (🟠): 0 issues
  • Medium (🟡): 0 issues
  • Low (🟢): 0 issues

🎯 Priority Actions

No issues requiring action were identified.

💡 General Observations

  • The chart mode state management using React useState is appropriate for this use case
  • The sorting logic for overlay mode (rendering larger values first/behind) is a good UX decision to prevent visual occlusion
  • The stackId conditional (chartMode === "stacked" ? "a" : undefined) correctly toggles between stacked and overlay rendering
  • The Y-axis domain constraint [0, "dataMax"] ensures consistent axis scaling across both modes
  • All locale files (en, ja, ru, zh-CN, zh-TW) have been updated with the new chartMode translations

The additional CHANGELOG, VERSION, and litellm-prices.json changes appear to be bundled release updates and are outside the core feature scope.


🤖 Automated review by Claude AI - focused on identifying issues for improvement

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Missing Feature Documentation: PR feature not documented in CHANGELOG

Problem: This PR adds a new chart display mode feature (Overlay vs Stacked modes) for the statistics dashboard, but this feature is NOT documented in the CHANGELOG. The CHANGELOG updates only include changes from other merged PRs (#199, #207, #210, #216, #219, #220) but omit the actual feature being added in PR #224.

Impact: Users will not know about this new feature when reviewing release notes. The CHANGELOG should accurately reflect what this specific PR adds.

Suggested Fix:
Add an entry under ### Added for this PR's feature:

### Added

- Add chart display mode toggle (Overlay/Stacked) for statistics dashboard with optimized rendering order (#224) @ding113

Or under ### Changed if you prefer:

### Changed

- Add Overlay and Stacked display modes to statistics charts for better multi-user data visualization (#224) @ding113

Copy link
Owner

@ding113 ding113 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Documentation Review

📊 Issues Summary

  • Critical (🔴): 0 - No critical issues
  • High (🟠): 1 - Should fix before merge
  • Medium (🟡): 0 - No medium issues
  • Low (🟢): 0 - No low issues

⚡ Priority Fixes

  1. Missing Feature Documentation: The main feature of this PR (chart Overlay/Stacked display modes) is not documented in CHANGELOG.md. The CHANGELOG updates only consolidate entries from previously merged PRs (#199, #207, #210, #216, #219, #220) but miss the actual feature being added in PR #224.

📋 Review Coverage

  • Technical accuracy - 0 issues
  • Completeness - 1 issue (missing feature documentation)
  • Code examples - N/A (no code examples in docs)
  • Links and references - 0 issues (all PR references verified as valid)
  • Clarity and organization - 0 issues

💡 General Observations

  • All referenced PR numbers (#173, #171, #178, #179, #181, #183, #184, #193, #199, #207, #210, #216, #219, #220) are valid and point to merged PRs
  • Translation files (messages/*.json) are complete across all 5 locales (en, ja, ru, zh-CN, zh-TW)
  • The pricing data file (litellm-prices.json) additions appear to be valid model configurations
  • The VERSION bump from 0.3.9 to 0.3.15 is a significant jump - consider if all intermediate version changes are documented

📝 Recommendation

Add a CHANGELOG entry for the chart display mode feature before merging:

### Added
- Add chart display mode toggle (Overlay/Stacked) for statistics dashboard with optimized multi-user rendering (#224) @ding113

🤖 Automated docs review by Claude AI

@ding113
Copy link
Owner

ding113 commented Nov 28, 2025

咦,你的 base 分支是从 main 拉出来的吗,这样可能会导致后续合并冲突

可否从 dev 拉一个分支,把你的提交 cherry-pick 过来

@ding113 ding113 changed the base branch from dev to feat/chart-overlay-stacked November 28, 2025 04:09
@ding113 ding113 merged commit 50cbb19 into ding113:feat/chart-overlay-stacked Nov 28, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size/M Medium PR (< 500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants