Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(AreaChart): update markLine specification #123

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ader-h
Copy link
Contributor

@ader-h ader-h commented Jan 16, 2025

Summary by CodeRabbit

  • New Features

    • Added a new labelLineHeight configuration option for mark line labels across multiple themes
    • Enhanced label styling for mark lines by introducing line height customization
  • Refactor

    • Simplified mark line label styling by removing background and border-related properties
    • Standardized line height configuration across different theme configurations

Copy link

coderabbitai bot commented Jan 16, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/components/LineChart/handleSeries.js

Oops! Something went wrong! :(

ESLint: 8.56.0

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///eslint.config.js?mtime=1737019679289:1:15
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async onImport.tracePromise.proto (node:internal/modules/esm/loader:483:26)
at async loadFlatConfigFile (/node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/flat-eslint.js:299:21)
at async calculateConfigArray (/node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/flat-eslint.js:378:28)
at async FlatESLint.lintFiles (/node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/flat-eslint.js:741:25)
at async Object.execute (/node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js:421:23)
at async main (/node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js:152:22)

Walkthrough

The pull request introduces a new labelLineHeight configuration across multiple files related to token and chart configurations. This change standardizes the line height for mark line labels by adding a consistent labelLineHeight property to various theme and token-related functions. The modifications span different theme configurations (cloud, hdesign, ict) and update the mark line label styling in chart components, specifically simplifying the label's background and border properties while introducing a dedicated line height setting.

Changes

File Change Summary
src/components/LineChart/handleSeries.js Added lineHeight to mark line label configuration
src/feature/token/factory/getModelToken.js Introduced labelLineHeight in token generation
src/feature/token/theme/*/getAliasToken.js Added labelLineHeight with size5x value in cloud, hdesign, and ict themes
src/option/config/mark/index.js Removed label background/border properties, added lineHeight configuration

Possibly related PRs

Poem

🐰 Hop, hop, through the code's design,
Line heights now dance, perfectly fine!
Labels leap with newfound grace,
A rabbit's touch in every trace,
Configuration's sweet refrain! 📊✨

Finishing Touches

  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/components/LineChart/handleSeries.js (1)

Line range hint 82-117: Consider refactoring the isTopOrBottom function for better maintainability.

The function has grown to handle multiple responsibilities including position, labels, colors, and line styles. Consider breaking it down into smaller, focused functions:

-function isTopOrBottom(markLine, seriesUnit, flag) {
+function getMarkLinePosition(markLine, flag) {
   let position = '';
   let markLinePosition = '';
   let markLineLabel = '';
   let markLineColor = '';
   let markLinelLineStyle;
-  let markLineData = {};
+  
   if (flag === 'top') {
     position = markLine.top;
     markLinePosition = markLine.topPosition
     markLineLabel = markLine.topLabel;
     markLineColor = markLine.topColor;
     markLinelLineStyle = markLine.topLine
   } else {
     position = markLine.bottom;
     markLinePosition = markLine.bottomPosition
     markLineLabel = markLine.bottomLabel;
     markLineColor = markLine.bottomColor
     markLinelLineStyle = markLine.bottomLine
   }
+  return { position, markLinePosition, markLineLabel, markLineColor, markLinelLineStyle };
+}
+
+function createMarkLineData(position) {
+  if (isString(position)) {
+    return { type: position };
+  }
+  return { yAxis: position };
+}
+
+function configureMarkLineLabel(markLineData, markLinePosition, markLineLabel, markLineColor) {
   markLineData.label = { 
     show: false, 
     position: 'insideEndTop',
     lineHeight: Theme.config.markLineLabelLineHeight 
   };
   
   if (markLinePosition) {
     markLineData.label.position = markLinePosition;
   }
   
   if (markLineLabel) {
     markLineData.label.show = true;
     markLineData.label.color = 'inherit';
     markLineData.label.formatter = markLineLabel;
   }
   
   if (markLineColor === 'auto') {
     markLineColor = undefined;
   }
   
   if (markLineColor) {
     markLineData.label.color = markLineColor;
   }
+}
+
+function isTopOrBottom(markLine, seriesUnit, flag) {
+  const { 
+    position, 
+    markLinePosition, 
+    markLineLabel, 
+    markLineColor, 
+    markLinelLineStyle 
+  } = getMarkLinePosition(markLine, flag);
+  
+  const markLineData = createMarkLineData(position);
+  
+  configureMarkLineLabel(markLineData, markLinePosition, markLineLabel, markLineColor);
+  
   markLineData.lineStyle = {};
   
   if (!markLineColor) {
     setThresholdMarkLineLabel(markLineData);
   }
   
   if (markLineColor) {
     markLineData.lineStyle.color = markLineColor;
   }
   
   if (markLinelLineStyle === false) {
     markLineData.lineStyle.color = chartToken.color;
   }
   
   seriesUnit.markLine.data.push(markLineData);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50c4384 and 87c2b6a.

📒 Files selected for processing (6)
  • src/components/LineChart/handleSeries.js (1 hunks)
  • src/feature/token/factory/getModelToken.js (2 hunks)
  • src/feature/token/theme/cloud/getAliasToken.js (1 hunks)
  • src/feature/token/theme/hdesign/getAliasToken.js (1 hunks)
  • src/feature/token/theme/ict/getAliasToken.js (1 hunks)
  • src/option/config/mark/index.js (1 hunks)
🔇 Additional comments (6)
src/feature/token/theme/cloud/getAliasToken.js (1)

186-187: LGTM! Consistent theme token implementation.

The addition of labelLineHeight property with size5x value aligns with the theme configuration standards.

src/feature/token/theme/hdesign/getAliasToken.js (1)

190-191: LGTM! Consistent theme token implementation.

The addition of labelLineHeight property maintains consistency with other theme configurations.

src/feature/token/theme/ict/getAliasToken.js (1)

185-186: LGTM! Consistent theme token implementation.

The addition of labelLineHeight property completes the standardization across all theme configurations.

src/components/LineChart/handleSeries.js (1)

99-99: LGTM! Correct implementation of the line height configuration.

The addition of lineHeight property correctly utilizes the theme configuration.

src/feature/token/factory/getModelToken.js (1)

70-70: LGTM! Clean implementation of the line height configuration.

The addition of labelLineHeight and its usage in markLineLabelLineHeight follows the existing pattern and properly implements the line height configuration for mark lines.

Also applies to: 327-328

src/option/config/mark/index.js (1)

28-28: LGTM! Proper integration of line height configuration.

The addition of lineHeight property is consistent with the token changes and correctly references the theme configuration.

The AI summary indicates removal of several label properties (backgroundColor, borderColor, borderWidth, borderRadius, padding). Let's verify if these styles are now handled elsewhere:

✅ Verification successful

Verified: Style properties properly moved to theme system

The removed style properties (backgroundColor, borderColor, etc.) are now correctly handled through theme tokens in getModelToken.js and dynamic styling in handleSeries.js. This is an improvement in the architecture.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any alternative styling of mark line labels
rg -l "markLine.*label.*(\{|backgroundColor|borderColor|borderWidth|borderRadius|padding)" --type js

# Check for any theme configurations that might be handling these styles
rg -l "markLineLabelBg|markLineLabelBorder" --type js

Length of output: 242


Script:

#!/bin/bash
# Check mark line label styling in handleSeries.js
rg "markLine.*label.*\{" -A 10 src/components/LineChart/handleSeries.js

# Check theme token definitions in getModelToken.js
rg "markLine.*Label" -A 5 src/feature/token/factory/getModelToken.js

Length of output: 1061

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant