Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nivo/bar

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nivo/bar

  • 0.88.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @nivo/bar?

@nivo/bar is a powerful and flexible library for creating bar charts in React applications. It provides a wide range of customization options and is built on top of D3.js, making it suitable for creating complex and interactive data visualizations.

What are @nivo/bar's main functionalities?

Basic Bar Chart

This code demonstrates how to create a basic bar chart using the @nivo/bar package. The chart displays values for different countries with customizable margins, padding, and axis labels.

import { ResponsiveBar } from '@nivo/bar';

const data = [
  { country: 'USA', value: 100 },
  { country: 'China', value: 200 },
  { country: 'Japan', value: 150 }
];

const MyBarChart = () => (
  <ResponsiveBar
    data={data}
    keys={['value']}
    indexBy='country'
    margin={{ top: 50, right: 130, bottom: 50, left: 60 }}
    padding={0.3}
    colors={{ scheme: 'nivo' }}
    axisBottom={{
      tickSize: 5,
      tickPadding: 5,
      tickRotation: 0,
      legend: 'Country',
      legendPosition: 'middle',
      legendOffset: 32
    }}
    axisLeft={{
      tickSize: 5,
      tickPadding: 5,
      tickRotation: 0,
      legend: 'Value',
      legendPosition: 'middle',
      legendOffset: -40
    }}
  />
);

Grouped Bar Chart

This code demonstrates how to create a grouped bar chart using the @nivo/bar package. The chart displays multiple values for each country, grouped side by side.

import { ResponsiveBar } from '@nivo/bar';

const data = [
  { country: 'USA', valueA: 100, valueB: 80 },
  { country: 'China', valueA: 200, valueB: 150 },
  { country: 'Japan', valueA: 150, valueB: 120 }
];

const MyGroupedBarChart = () => (
  <ResponsiveBar
    data={data}
    keys={['valueA', 'valueB']}
    indexBy='country'
    margin={{ top: 50, right: 130, bottom: 50, left: 60 }}
    padding={0.3}
    groupMode='grouped'
    colors={{ scheme: 'nivo' }}
    axisBottom={{
      tickSize: 5,
      tickPadding: 5,
      tickRotation: 0,
      legend: 'Country',
      legendPosition: 'middle',
      legendOffset: 32
    }}
    axisLeft={{
      tickSize: 5,
      tickPadding: 5,
      tickRotation: 0,
      legend: 'Value',
      legendPosition: 'middle',
      legendOffset: -40
    }}
  />
);

Stacked Bar Chart

This code demonstrates how to create a stacked bar chart using the @nivo/bar package. The chart displays multiple values for each country, stacked on top of each other.

import { ResponsiveBar } from '@nivo/bar';

const data = [
  { country: 'USA', valueA: 100, valueB: 80 },
  { country: 'China', valueA: 200, valueB: 150 },
  { country: 'Japan', valueA: 150, valueB: 120 }
];

const MyStackedBarChart = () => (
  <ResponsiveBar
    data={data}
    keys={['valueA', 'valueB']}
    indexBy='country'
    margin={{ top: 50, right: 130, bottom: 50, left: 60 }}
    padding={0.3}
    groupMode='stacked'
    colors={{ scheme: 'nivo' }}
    axisBottom={{
      tickSize: 5,
      tickPadding: 5,
      tickRotation: 0,
      legend: 'Country',
      legendPosition: 'middle',
      legendOffset: 32
    }}
    axisLeft={{
      tickSize: 5,
      tickPadding: 5,
      tickRotation: 0,
      legend: 'Value',
      legendPosition: 'middle',
      legendOffset: -40
    }}
  />
);

Other packages similar to @nivo/bar

Keywords

FAQs

Package last updated on 11 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc