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

Legend Displays Empty Labels When Adding Empty Bars to Adjust Bar Width in ngx-charts-bar-vertical #1985

Open
M-Muddasir opened this issue Jan 6, 2025 · 0 comments
Labels

Comments

@M-Muddasir
Copy link

Bug Description
I need to reduce the width of individual bars in a single bar chart using ngx-charts-bar-vertical. Since there is no direct property to adjust bar width, I added empty bars to the dataset as a workaround (#692 (comment)). However, this causes an issue with the legend, as it displays colors for all bars, including the empty ones, along with empty labels.

Steps to Reproduce the Issue

  1. Use the ngx-charts-bar-vertical component.
  2. Add empty bars to the dataset to reduce the width of the existing bars. For example:
    if (data.chart_data?.length < 10) {
        const empty = '  ';
        for (let i = 0; i < 10 - data.chart_data.length; i++) {
            this.data.push({
                name: empty.repeat(i + 1),
                value: 0
            });
        }
    }
  3. Save the changes and observe the issue with the legend.

Expected Behavior
Provide a property or configuration to exclude empty-value legends, ensuring the chart looks clean and the legend only reflects meaningful data.

Screenshots
image

ngx-charts Version
@swimlane/ngx-charts: ^20.4.1

@M-Muddasir M-Muddasir added the Bug label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant