Convert Figma logo to code with AI

uber logoreact-vis

Data Visualization Components

8,716
833
8,716
343

Top Related Projects

19,308

🐯 visx | visualization components

23,653

Redefined chart library built with React and D3

10,956

A collection of composable React components for building interactive data visualizations

13,066

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries

📊 Interactive JavaScript Charts built on SVG

64,334

Simple HTML5 Charts using the <canvas> tag

Quick Overview

React-vis is a data visualization library for React applications, developed by Uber. It provides a collection of composable and customizable components for creating various types of charts and graphs, making it easy to integrate data visualizations into React projects.

Pros

  • Easy to use and integrate with existing React applications
  • Offers a wide range of chart types and customization options
  • Supports both SVG and Canvas rendering for performance optimization
  • Provides smooth animations and interactions out of the box

Cons

  • Documentation can be incomplete or outdated in some areas
  • Limited community support compared to more popular charting libraries
  • Some advanced features may require additional configuration or custom implementations
  • Not actively maintained, with the last major update in 2019

Code Examples

  1. Creating a simple line chart:
import {XYPlot, LineSeries, XAxis, YAxis} from 'react-vis';

const MyLineChart = () => (
  <XYPlot width={300} height={300}>
    <XAxis />
    <YAxis />
    <LineSeries data={[{x: 1, y: 10}, {x: 2, y: 5}, {x: 3, y: 15}]} />
  </XYPlot>
);
  1. Creating a bar chart with custom styling:
import {XYPlot, VerticalBarSeries, XAxis, YAxis} from 'react-vis';

const MyBarChart = () => (
  <XYPlot width={300} height={300}>
    <XAxis />
    <YAxis />
    <VerticalBarSeries
      data={[{x: 1, y: 10}, {x: 2, y: 5}, {x: 3, y: 15}]}
      color="#1E88E5"
      style={{stroke: 'white', strokeWidth: 2}}
    />
  </XYPlot>
);
  1. Creating an interactive scatter plot:
import {XYPlot, MarkSeries, Hint} from 'react-vis';

const MyScatterPlot = () => {
  const [hintValue, setHintValue] = useState(null);

  return (
    <XYPlot width={300} height={300}>
      <MarkSeries
        data={[{x: 1, y: 10}, {x: 2, y: 5}, {x: 3, y: 15}]}
        onValueMouseOver={(datapoint) => setHintValue(datapoint)}
        onValueMouseOut={() => setHintValue(null)}
      />
      {hintValue && <Hint value={hintValue} />}
    </XYPlot>
  );
};

Getting Started

To use react-vis in your React project:

  1. Install the package:

    npm install react-vis
    
  2. Import the necessary components and styles in your React component:

    import {XYPlot, LineSeries} from 'react-vis';
    import 'react-vis/dist/style.css';
    
  3. Use the components to create your chart:

    const MyChart = () => (
      <XYPlot width={300} height={300}>
        <LineSeries data={[{x: 1, y: 10}, {x: 2, y: 5}, {x: 3, y: 15}]} />
      </XYPlot>
    );
    

Competitor Comparisons

19,308

🐯 visx | visualization components

Pros of visx

  • More flexible and customizable, allowing for greater control over chart elements
  • Modular architecture, enabling developers to use only the components they need
  • Better TypeScript support and more comprehensive documentation

Cons of visx

  • Steeper learning curve due to its low-level nature and flexibility
  • Requires more code to create basic charts compared to react-vis
  • Less out-of-the-box functionality for common chart types

Code Comparison

react-vis example:

<XYPlot width={300} height={300}>
  <VerticalBarSeries data={data} />
  <XAxis />
  <YAxis />
</XYPlot>

visx example:

<svg width={300} height={300}>
  <Group top={20} left={20}>
    <BarGroup data={data} {...scaleProps}>
      {(barGroups) => barGroups.map((bar) => (
        <Bar key={`bar-${bar.index}`} {...bar} />
      ))}
    </BarGroup>
    <AxisBottom scale={xScale} top={yMax} />
    <AxisLeft scale={yScale} />
  </Group>
</svg>

The code comparison illustrates that visx requires more setup and configuration, but offers greater control over individual chart elements. react-vis provides a more straightforward API for creating common chart types with less code.

23,653

Redefined chart library built with React and D3

Pros of Recharts

  • More active development and maintenance
  • Better performance with large datasets
  • Wider variety of chart types and customization options

Cons of Recharts

  • Steeper learning curve for complex customizations
  • Less extensive documentation compared to React-vis

Code Comparison

React-vis:

<XYPlot width={300} height={300}>
  <VerticalBarSeries data={[{x: 1, y: 10}, {x: 2, y: 5}, {x: 3, y: 15}]} />
  <XAxis />
  <YAxis />
</XYPlot>

Recharts:

<BarChart width={300} height={300} data={[{x: 1, y: 10}, {x: 2, y: 5}, {x: 3, y: 15}]}>
  <Bar dataKey="y" />
  <XAxis dataKey="x" />
  <YAxis />
</BarChart>

Both libraries offer declarative approaches to creating charts, but Recharts provides a more intuitive API for common chart types. React-vis offers more flexibility for custom visualizations, while Recharts excels in creating standard charts with less code. Recharts also provides better responsiveness out of the box, making it easier to create mobile-friendly charts.

10,956

A collection of composable React components for building interactive data visualizations

Pros of Victory

  • More extensive and flexible API, allowing for greater customization of charts
  • Better documentation and examples, making it easier for developers to get started
  • Active development and regular updates, ensuring compatibility with latest React versions

Cons of Victory

  • Steeper learning curve due to its more complex API
  • Larger bundle size, which may impact performance for smaller projects
  • Less opinionated design, requiring more configuration for basic charts

Code Comparison

Victory:

<VictoryChart>
  <VictoryBar data={data} x="quarter" y="earnings" />
</VictoryChart>

React-vis:

<XYPlot width={300} height={300}>
  <VerticalBarSeries data={data} />
</XYPlot>

Victory requires more explicit configuration but offers greater flexibility, while React-vis provides a simpler API for basic charts. Victory's approach allows for more granular control over chart elements, but React-vis may be quicker to implement for straightforward visualizations.

Both libraries have their strengths, and the choice between them depends on project requirements, desired customization level, and developer preferences. Victory is better suited for complex, highly customized charts, while React-vis excels in simplicity and ease of use for basic visualizations.

13,066

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries

Pros of nivo

  • More extensive chart types and customization options
  • Better documentation and examples
  • Active development and frequent updates

Cons of nivo

  • Steeper learning curve due to more complex API
  • Larger bundle size, which may impact performance

Code Comparison

nivo:

<ResponsiveLine
  data={data}
  margin={{ top: 50, right: 110, bottom: 50, left: 60 }}
  xScale={{ type: 'point' }}
  yScale={{ type: 'linear', min: 'auto', max: 'auto', stacked: true, reverse: false }}
  axisTop={null}
  axisRight={null}
  axisBottom={{
    orient: 'bottom',
    tickSize: 5,
    tickPadding: 5,
    tickRotation: 0,
    legend: 'transportation',
    legendOffset: 36,
    legendPosition: 'middle'
  }}
  axisLeft={{
    orient: 'left',
    tickSize: 5,
    tickPadding: 5,
    tickRotation: 0,
    legend: 'count',
    legendOffset: -40,
    legendPosition: 'middle'
  }}
  pointSize={10}
  pointColor={{ theme: 'background' }}
  pointBorderWidth={2}
  pointBorderColor={{ from: 'serieColor' }}
  pointLabelYOffset={-12}
  useMesh={true}
  legends={[
    {
      anchor: 'bottom-right',
      direction: 'column',
      justify: false,
      translateX: 100,
      translateY: 0,
      itemsSpacing: 0,
      itemDirection: 'left-to-right',
      itemWidth: 80,
      itemHeight: 20,
      itemOpacity: 0.75,
      symbolSize: 12,
      symbolShape: 'circle',
      symbolBorderColor: 'rgba(0, 0, 0, .5)',
      effects: [
        {
          on: 'hover',
          style: {
            itemBackground: 'rgba(0, 0, 0, .03)',
            itemOpacity: 1
          }
        }
      ]
    }
  ]}
/>

react-vis:

<XYPlot width={300} height={300}>
  <VerticalGridLines />
  <HorizontalGridLines />
  <XAxis />
  <YAxis />
  <LineSeries data={data} />
</XYPlot>

📊 Interactive JavaScript Charts built on SVG

Pros of ApexCharts.js

  • More extensive chart types and customization options
  • Better documentation and examples
  • Active development and frequent updates

Cons of ApexCharts.js

  • Larger bundle size
  • Steeper learning curve for complex configurations

Code Comparison

ApexCharts.js:

var options = {
  chart: { type: 'line' },
  series: [{ data: [30, 40, 35, 50, 49, 60, 70] }],
  xaxis: { categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997] }
};
var chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render();

React-vis:

import { XYPlot, LineSeries } from 'react-vis';

const MyChart = () => (
  <XYPlot width={300} height={300}>
    <LineSeries data={[{x: 1, y: 10}, {x: 2, y: 5}, {x: 3, y: 15}]} />
  </XYPlot>
);

ApexCharts.js offers more built-in features and customization options, making it suitable for complex visualizations. However, this comes at the cost of a larger bundle size and potentially more complex configuration. React-vis, being more lightweight and React-specific, may be easier to integrate into existing React projects but offers fewer out-of-the-box features.

64,334

Simple HTML5 Charts using the <canvas> tag

Pros of Chart.js

  • More extensive documentation and larger community support
  • Wider range of chart types and customization options
  • Lighter weight and better performance for large datasets

Cons of Chart.js

  • Less seamless integration with React applications
  • Steeper learning curve for developers familiar with React ecosystem
  • Limited built-in support for responsive design

Code Comparison

React-vis example:

<XYPlot width={300} height={300}>
  <VerticalBarSeries data={[{x: 1, y: 10}, {x: 2, y: 5}, {x: 3, y: 15}]} />
  <XAxis />
  <YAxis />
</XYPlot>

Chart.js example:

new Chart(ctx, {
  type: 'bar',
  data: {
    labels: ['1', '2', '3'],
    datasets: [{data: [10, 5, 15]}]
  }
});

Both libraries offer declarative ways to create charts, but React-vis uses a more React-centric approach with components, while Chart.js uses a configuration object. React-vis integrates more naturally with React applications, while Chart.js provides a more traditional JavaScript charting solution that can be used in various environments.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

deprecated version build build downloads

react-vis | Demos | Docs

A COMPOSABLE VISUALIZATION SYSTEM

demo

NOTE: This repository is now under new management. Please reach out to the new administrators if you have any questions.

Overview

A collection of react components to render common data visualization charts, such as line/area/bar charts, heat maps, scatterplots, contour plots, hexagon heatmaps, pie and donut charts, sunbursts, radar charts, parallel coordinates, and tree maps.

Some notable features:

  • Simplicity. react-vis doesn't require any deep knowledge of data visualization libraries to start building your first visualizations.
  • Flexibility. react-vis provides a set of basic building blocks for different charts. For instance, separate X and Y axis components. This provides a high level of control of chart layout for applications that need it.
  • Ease of use. The library provides a set of defaults which can be overridden by the custom user's settings.
  • Integration with React. react-vis supports the React's lifecycle and doesn't create unnecessary nodes.

Usage

Install react-vis via npm.

npm install react-vis --save

Include the built main CSS file in your HTML page or via SASS:

@import "~react-vis/dist/style";

You can also select only the styles you want to use. This helps minimize the size of the outputted CSS. Here's an example of importing only the legends styles:

@import "~react-vis/dist/styles/legends";

Import the necessary components from the library...

import {XYPlot, XAxis, YAxis, HorizontalGridLines, LineSeries} from 'react-vis';

… and add the following code to your render function:

<XYPlot
  width={300}
  height={300}>
  <HorizontalGridLines />
  <LineSeries
    data={[
      {x: 1, y: 10},
      {x: 2, y: 5},
      {x: 3, y: 15}
    ]}/>
  <XAxis />
  <YAxis />
</XYPlot>

If you're working in a non-node environment, you can also directly include the bundle and compiled style using basic html tags.

<link rel="stylesheet" href="https://unpkg.com/react-vis/dist/style.css">
<script type="text/javascript" src="https://unpkg.com/react-vis/dist/dist.min.js"></script>

The global reactVis object will now be available for you to play around.

You can checkout these example CodePens: #1, #2, #3 or #4

More information

Take a look at the folder with examples or check out some docs:

Development

Make sure you are using the correct version of node and yarn. To do so, check package.json and find the entry "volta", e.g.

"volta": {
  "node": "14.18.0",
  "yarn": "1.22.4"
}

It's recommanded to install volta to manage node and yarn.

To develop on react-vis, navigate to packages/react-vis, and install the dependencies and then build and watch the static files:

yarn && yarn start

Once complete, you can view the component's example in your browser (will open automatically). Any changes you make to the example code will run the compiler to build the files again.

To run the tests, and create code coverage reports:

yarn cover

Requirements

react-vis makes use of ES6 array methods such as Array.prototype.find. If you make use of react-vis, in an environment without these methods, you'll see errors like TypeError: Server rendering error: Object x,y,radius,angle,color,fill,stroke,opacity,size has no method 'find'. You can use babel-polyfill to polyfill these methods.

NPM DownloadsLast 30 Days