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

feat(Bar): add bar totals #2525

Merged
merged 28 commits into from Mar 19, 2024

Conversation

joaopedromatias
Copy link
Contributor

This adds a totals layer to the bar chart component.

The goal is to provide the total value for each index of the chart.

In order to activate it, users have to add the layers prop having the totals value to the BarSvg or BarCanvas component, like following:

export const WithTotals = {
    return (
        <Bar
            {...props}
            layers={['grid', 'axes', 'bars', 'markers', 'legends', 'annotations', 'totals']}
        />
}

The issues #951 and #2020 are related to this feature.

Captura de Tela 2024-03-02 às 19 39 08

Copy link

vercel bot commented Mar 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nivo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 1:55am

Copy link

codesandbox-ci bot commented Mar 4, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 999ba05:

Sandbox Source
nivo Configuration

Copy link
Owner

@plouc plouc left a comment

Choose a reason for hiding this comment

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

Thank you for this, should be very useful as it's been requested quite often!

packages/bar/src/Bar.tsx Outdated Show resolved Hide resolved
packages/bar/src/Bar.tsx Outdated Show resolved Hide resolved
packages/bar/src/BarCanvas.tsx Outdated Show resolved Hide resolved
packages/bar/src/BarCanvas.tsx Outdated Show resolved Hide resolved
packages/bar/src/BarCanvas.tsx Outdated Show resolved Hide resolved
packages/bar/src/BarCanvas.tsx Outdated Show resolved Hide resolved
packages/bar/src/BarTotals.tsx Outdated Show resolved Hide resolved
packages/bar/src/BarTotals.tsx Outdated Show resolved Hide resolved
storybook/stories/bar/Bar.stories.tsx Show resolved Hide resolved
website/src/data/components/bar/meta.yml Outdated Show resolved Hide resolved
packages/bar/src/Bar.tsx Outdated Show resolved Hide resolved
packages/bar/src/Bar.tsx Outdated Show resolved Hide resolved
packages/bar/src/BarTotals.tsx Outdated Show resolved Hide resolved
packages/bar/src/props.ts Outdated Show resolved Hide resolved
packages/bar/src/props.ts Outdated Show resolved Hide resolved
packages/bar/src/Bar.tsx Outdated Show resolved Hide resolved
packages/bar/src/Bar.tsx Outdated Show resolved Hide resolved
packages/bar/src/Bar.tsx Outdated Show resolved Hide resolved
packages/bar/src/Bar.tsx Outdated Show resolved Hide resolved
packages/bar/src/BarCanvas.tsx Show resolved Hide resolved
website/src/data/components/bar/props.ts Show resolved Hide resolved
packages/bar/src/types.ts Outdated Show resolved Hide resolved
@plouc plouc added radial-bar 📊 bar @nivo/bar package and removed radial-bar labels Mar 8, 2024
Copy link
Owner

@plouc plouc left a comment

Choose a reason for hiding this comment

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

LGTM, just a small comment about keeping the value along with the formattedValue, good job! I tried the feature in the vercel preview, and it's really nice! I think we could allow the customization of the component (later).

This was referenced Mar 19, 2024
@plouc plouc merged commit d90a326 into plouc:master Mar 19, 2024
5 checks passed
@Maxim278
Copy link

@plouc is there an information about when this change is going to be released?

@dbuhon
Copy link
Contributor

dbuhon commented Apr 30, 2024

It works now on v0.86.0 with:

<ResponsiveBar 
  enableTotals
  layers={['bars', 'totals', ...]}
  ...
/>

@plouc
Copy link
Owner

plouc commented Apr 30, 2024

It works now on v0.86.0 with:

<ResponsiveBar 
  enableTotals
  layers={['bars', 'totals', ...]}
  ...
/>

Please note that you don't need to specify the layers as the totals layer is included by default, unless you want to change their order or add a custom layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📊 bar @nivo/bar package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants