Skip to content

Conversation

@LucyChyzhova
Copy link
Contributor

@LucyChyzhova LucyChyzhova commented Nov 27, 2025

…arts

Screenshot 2025-11-28 at 09 37 25

Summary by CodeRabbit

Release Notes

  • New Features
    • Bar charts in landscape orientation now support optional column titles display. Toggle the column titles setting to customize how information appears above chart bars.

✏️ Tip: You can customize this high-level summary in your review settings.

Review:

  • Commits are atomic
  • Commits have the correct type for the changes made
  • Commits with breaking changes are marked as such

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

  • Chrome
  • Edge
  • Firefox

Linux:

  • Chrome
  • Firefox

macOS:

  • Chrome
  • Firefox
  • Safari

Mobile:

  • Chrome on Android
  • iOS

@coderabbitai
Copy link

coderabbitai bot commented Nov 27, 2025

📝 Walkthrough

Walkthrough

The changes introduce a column titles feature for landscape-oriented bar charts in the Chart component. A new showColumnTitles property enables conditional rendering of column headers. Supporting styling updates add positioning context and title truncation. An example component and updated bar chart example demonstrate the feature with interactive controls.

Changes

Cohort / File(s) Change Summary
Chart component core implementation
src/components/chart/chart.tsx, src/components/chart/chart.scss, src/components/chart/partial-styles/_bar-gantt-dot.scss
Added public showColumnTitles property (defaults to false); renamed renderTooltip method to renderItemLabel with conditional logic to render column title elements for landscape bar charts; added .column-title class with truncation and absolute positioning; updated .item rule to include position: relative for positioning context.
Example components
src/components/chart/examples/chart-column-titles.tsx, src/components/chart/examples/chart-type-bar.tsx
Created new ChartColumnTitlesExample component with toggle control for showColumnTitles state; updated ChartTypeBarExample to include showColumnTitles prop on the chart component.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • chart.tsx: Verify the conditional rendering logic in renderItemLabel correctly applies only to landscape bar charts and that method rename is complete
  • Styling changes: Confirm .column-title positioning aligns with chart layout and that position: relative on .item doesn't affect existing bar/dot chart layouts
  • Examples: Validate that the toggle behavior works as expected and the new example properly demonstrates the feature

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main feature: adding an option to display column titles for landscape bar charts, which is the primary objective of all changes across the files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chart-column-title-for-bar-chart

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-3742/

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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/chart/chart.tsx (1)

333-366: Avoid returning an array from renderItemLabel (and fix the key warning)

renderItemLabel currently returns an array of JSX elements when showColumnTitles is enabled; this is what triggers the “missing key” warnings from static analysis. In Stencil, it’s preferable to avoid array literals here rather than adding React‑style key props.

You can return a single wrapper element containing both the column title and the tooltip instead:

     const tooltip = (
         <limel-tooltip
             {...tooltipProps}
             openDirection={
                 this.orientation === 'portrait' ? 'right' : 'top'
             }
         />
     );
 
-    if (
-        this.showColumnTitles &&
-        this.orientation === 'landscape' &&
-        this.type === 'bar'
-    ) {
-        return [<div class="column-title">{text}</div>, tooltip];
-    }
-
-    return tooltip;
+    const showColumnTitle =
+        this.showColumnTitles &&
+        this.orientation === 'landscape' &&
+        this.type === 'bar';
+
+    if (showColumnTitle) {
+        return (
+            <div>
+                <div class="column-title">{text}</div>
+                {tooltip}
+            </div>
+        );
+    }
+
+    return tooltip;

This keeps the DOM structure simple, removes the array literal, and should satisfy the lint checks without introducing key props.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 834cf99 and bf536b3.

📒 Files selected for processing (5)
  • src/components/chart/chart.scss (1 hunks)
  • src/components/chart/chart.tsx (5 hunks)
  • src/components/chart/examples/chart-column-titles.tsx (1 hunks)
  • src/components/chart/examples/chart-type-bar.tsx (1 hunks)
  • src/components/chart/partial-styles/_bar-gantt-dot.scss (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
src/components/**/*.scss

📄 CodeRabbit inference engine (.cursor/rules/css-class-names-in-components-using-shadow-dom.mdc)

Do not use BEM-style class names in CSS for components, as components use shadow-DOM.

Files:

  • src/components/chart/partial-styles/_bar-gantt-dot.scss
  • src/components/chart/chart.scss
**/*.{tsx,scss}

⚙️ CodeRabbit configuration file

**/*.{tsx,scss}: Almost all our components use shadow-DOM. Therefore, we have no need of BEM-style class names in our CSS.

Files:

  • src/components/chart/partial-styles/_bar-gantt-dot.scss
  • src/components/chart/examples/chart-type-bar.tsx
  • src/components/chart/chart.scss
  • src/components/chart/examples/chart-column-titles.tsx
  • src/components/chart/chart.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/wrap-multiple-jsx-elements-in-host-not-in-array.mdc)

When returning multiple JSX elements from the render method, never wrap them in an array literal. Instead, always wrap them in the special <Host> element. When there is already a single top-level element, it does not have to be wrapped in <Host>.

Files:

  • src/components/chart/examples/chart-type-bar.tsx
  • src/components/chart/examples/chart-column-titles.tsx
  • src/components/chart/chart.tsx

⚙️ CodeRabbit configuration file

**/*.tsx: Our .tsx files are typically using StencilJS, not React. When a developer wants to return multiple top-level JSX elements from the render method, they will sometimes wrap them in an array literal. In these cases, rather than recommending they add key properties to the elements, recommend removing the hardcoded array literal. Recommend wrapping the elements in StencilJS's special <Host> element.

Files:

  • src/components/chart/examples/chart-type-bar.tsx
  • src/components/chart/examples/chart-column-titles.tsx
  • src/components/chart/chart.tsx
**/*.{ts,tsx}

⚙️ CodeRabbit configuration file

**/*.{ts,tsx}: Imports from other files in the same module (lime-elements) must use relative paths. Using absolute paths for imports will cause the production build to fail.

Files:

  • src/components/chart/examples/chart-type-bar.tsx
  • src/components/chart/examples/chart-column-titles.tsx
  • src/components/chart/chart.tsx
src/components/**/examples/**/*.{ts,tsx}

⚙️ CodeRabbit configuration file

src/components/**/examples/**/*.{ts,tsx}: These files are an exception to the rule that all imports should use relative paths. When these example files import something that is publicly exported by lime-elements, the import should be made from @limetech/lime-elements. If they import something from another file inside the example folder, the import should use a relative path.

Files:

  • src/components/chart/examples/chart-type-bar.tsx
  • src/components/chart/examples/chart-column-titles.tsx
src/components/**/*.tsx

⚙️ CodeRabbit configuration file

src/components/**/*.tsx: When contributors add new props to existing components in the lime-elements repository, they should always add documentation examples that demonstrate the new prop's usage and explain how it works. This helps with user adoption, feature discoverability, and maintains comprehensive documentation.

Files:

  • src/components/chart/examples/chart-type-bar.tsx
  • src/components/chart/examples/chart-column-titles.tsx
  • src/components/chart/chart.tsx
🧠 Learnings (2)
📚 Learning: 2025-04-25T13:32:56.396Z
Learnt from: adrianschmidt
Repo: Lundalogik/lime-elements PR: 3529
File: src/components/lime-ai-avatar/lime-ai-avatar.tsx:30-38
Timestamp: 2025-04-25T13:32:56.396Z
Learning: For StencilJS components in lime-elements, prefer using the `<Host>` element to wrap child elements in the render method instead of returning an array of elements, which eliminates the need for key attributes and follows StencilJS best practices.

Applied to files:

  • src/components/chart/examples/chart-column-titles.tsx
📚 Learning: 2025-03-04T14:27:29.714Z
Learnt from: adrianschmidt
Repo: Lundalogik/lime-elements PR: 3464
File: src/components/text-editor/prosemirror-adapter/plugins/image/inserter.ts:1-11
Timestamp: 2025-03-04T14:27:29.714Z
Learning: In example components (typically found in `src/components/*/examples/`), imports of lime-elements exports should use `limetech/lime-elements` instead of relative paths. This is because example components aren't included in type declarations and are used in documentation to show developers how to properly use lime-elements components.

Applied to files:

  • src/components/chart/chart.tsx
🧬 Code graph analysis (1)
src/components/chart/chart.tsx (1)
src/components/chart/chart.types.ts (1)
  • ChartItem (7-38)
🪛 Biome (2.1.2)
src/components/chart/chart.tsx

[error] 362-362: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🪛 GitHub Check: SonarCloud Code Analysis
src/components/chart/examples/chart-column-titles.tsx

[warning] 46-46: Member 'handleToggleChange' is never reassigned; mark it as readonly.

See more on https://sonarcloud.io/project/issues?id=Lundalogik_lime-elements&issues=AZrF8hs_7q8XMp_X1pHR&open=AZrF8hs_7q8XMp_X1pHR&pullRequest=3742

src/components/chart/chart.tsx

[warning] 362-362: Missing "key" prop for element in array

See more on https://sonarcloud.io/project/issues?id=Lundalogik_lime-elements&issues=AZrF8hvs7q8XMp_X1pHS&open=AZrF8hvs7q8XMp_X1pHS&pullRequest=3742

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Docs / Publish Docs
  • GitHub Check: Test
  • GitHub Check: Build
🔇 Additional comments (6)
src/components/chart/examples/chart-type-bar.tsx (1)

48-54: Correct wiring of showColumnTitles in bar chart example

Using the new showColumnTitles prop here is consistent with the core chart API and works correctly with the orientation state.

src/components/chart/chart.scss (1)

62-67: Scoped styling for .column-title looks good

Truncation and absolute positioning are minimal and appropriate, and the class name follows the non‑BEM guideline for shadow‑DOM components.

src/components/chart/partial-styles/_bar-gantt-dot.scss (1)

7-14: position: relative on .item is appropriate

This establishes a consistent positioning context for both the new .column-title and existing absolute pseudo‑elements on dot charts, without conflicting with the surrounding layout rules.

src/components/chart/chart.tsx (2)

15-36: New example reference keeps documentation in sync

Adding @exampleComponent limel-example-chart-column-titles correctly exposes the new example in the chart docs.


221-249: Item label rendering hook is correctly integrated

Switching the row rendering to use renderItemLabel instead of an inline tooltip keeps the per‑item markup centralized and makes it easier to evolve the label/tooltip behavior.

src/components/chart/examples/chart-column-titles.tsx (1)

4-44: Example cleanly demonstrates showColumnTitles behavior

The example correctly fixes orientation to landscape, wires showColumnTitles to local state, and uses <Host> as the render root, which matches the Stencil guidelines.

Comment on lines +115 to +120
/**
* When set to `true`, displays column titles for bar charts.
* By default, column titles are not rendered.
*/
@Prop({ reflect: true })
public showColumnTitles: boolean = false;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Clarify that showColumnTitles applies to landscape bar charts

The implementation only shows column titles when type === 'bar' and orientation === 'landscape', but the doc comment currently mentions only “bar charts”. Consider making that explicit so consumers understand why nothing changes for portrait bar charts.

For example:

/**
 * When set to `true`, displays column titles for bar charts
 * in landscape orientation. By default, column titles are not rendered.
 */
@Prop({ reflect: true })
public showColumnTitles: boolean = false;
🤖 Prompt for AI Agents
In src/components/chart/chart.tsx around lines 115 to 120, the Prop doc comment
for showColumnTitles is misleading because it implies it applies to all bar
charts but the implementation only renders column titles when type === 'bar' and
orientation === 'landscape'; update the JSDoc to explicitly state that the flag
controls column titles for bar charts in landscape orientation (and that
portrait bar charts are unaffected) so consumers understand the scope of the
prop.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually a red flag. Let's think a bit more about how we should solve this 🤔

  1. We shouldn't have a prop that only sometimes works. Preferably, we should cover most of the types if possible. Can we somehow display it for others too?
  2. If this is only for bar chart, then
  • it should work for both landscape and portrait modes.
  • the name of the prop should be more descriptive

Comment on lines +46 to +48
private handleToggleChange = (event: CustomEvent<boolean>) => {
this.showColumnTitles = event.detail;
};
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Mark handleToggleChange as readonly

The member is never reassigned and is used as an event handler; marking it readonly matches the pattern used in chart.tsx and satisfies the static analysis suggestion.

-export class ChartColumnTitlesExample {
+export class ChartColumnTitlesExample {
@@
-    private handleToggleChange = (event: CustomEvent<boolean>) => {
+    private readonly handleToggleChange = (event: CustomEvent<boolean>) => {
         this.showColumnTitles = event.detail;
     };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private handleToggleChange = (event: CustomEvent<boolean>) => {
this.showColumnTitles = event.detail;
};
private readonly handleToggleChange = (event: CustomEvent<boolean>) => {
this.showColumnTitles = event.detail;
};
🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 46-46: Member 'handleToggleChange' is never reassigned; mark it as readonly.

See more on https://sonarcloud.io/project/issues?id=Lundalogik_lime-elements&issues=AZrF8hs_7q8XMp_X1pHR&open=AZrF8hs_7q8XMp_X1pHR&pullRequest=3742

🤖 Prompt for AI Agents
In src/components/chart/examples/chart-column-titles.tsx around lines 46 to 48,
the event handler handleToggleChange is never reassigned but is defined as a
mutable class field; change its declaration to a readonly class field (e.g. add
the readonly modifier to "private readonly handleToggleChange = ...") so it
matches the pattern used in chart.tsx and satisfies the static analysis
suggestion while keeping the same arrow-function/event-handler behavior.

@LucyChyzhova LucyChyzhova self-assigned this Nov 27, 2025
@LucyChyzhova LucyChyzhova requested a review from Kiarokh November 28, 2025 08:10
@Kiarokh Kiarokh self-assigned this Dec 1, 2025
Comment on lines +122 to +126
/**
* Label for the horizontal axis (X-axis).
*/
@Prop({ reflect: true })
public xAxisLabel?: string;
Copy link
Contributor

@Kiarokh Kiarokh Dec 1, 2025

Choose a reason for hiding this comment

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

This one is a new separate feature. It should not be committed together with the other one 😊

It also has the same problem like the previous one. The chart component has various modes or types. Since all of them are 2D, the x-axis is applicable to all. Basically, all of them have an x-axis. But in some, like the circular ones, the meaning of x-axis would be really strange.

Further down, the this prop is implemented in a way where it will always show up. Even under a pie or doughnut chart.

Additionally, there is already a prop called accessibleItemsLabel which is basically what you are trying to do.

    /**
     * Helps users of assistive technologies to understand
     * what the items in the chart represent.
     */
    @Prop({ reflect: true })
    public accessibleItemsLabel?: string;

Further,
On landscape orientation, the x-axis is below. But on it can be on the left side on the portrait mode. So this name becomes confusing

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.

3 participants