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
@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.

@Maxim278
Copy link

Maxim278 commented Jul 7, 2024

is it possible to format totals value?

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.

4 participants