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

@visx/xychart

Package Overview
Dependencies
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visx/xychart

Composable cartesian coordinate chart built with visx primitives

  • 1.6.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
165K
increased by6.32%
Maintainers
4
Weekly downloads
 
Created

What is @visx/xychart?

@visx/xychart is a powerful and flexible library for creating complex and customizable charts in React applications. It leverages D3 for calculations and rendering, providing a declarative API for building various types of XY charts.

What are @visx/xychart's main functionalities?

Line Chart

This code demonstrates how to create a simple line chart using @visx/xychart. It includes animated axes, grid, and a line series with a tooltip.

import { XYChart, AnimatedAxis, AnimatedGrid, AnimatedLineSeries, Tooltip } from '@visx/xychart';

const data = [
  { x: 0, y: 50 },
  { x: 1, y: 10 },
  { x: 2, y: 20 },
  { x: 3, y: 30 },
  { x: 4, y: 40 },
];

const accessors = {
  xAccessor: d => d.x,
  yAccessor: d => d.y,
};

function LineChart() {
  return (
    <XYChart height={300} width={500} xScale={{ type: 'linear' }} yScale={{ type: 'linear' }}>
      <AnimatedAxis orientation="bottom" />
      <AnimatedAxis orientation="left" />
      <AnimatedGrid columns={false} numTicks={4} />
      <AnimatedLineSeries dataKey="Line Series" data={data} {...accessors} />
      <Tooltip />
    </XYChart>
  );
}

Bar Chart

This code demonstrates how to create a bar chart using @visx/xychart. It includes animated axes, grid, and a bar series with a tooltip.

import { XYChart, AnimatedAxis, AnimatedGrid, AnimatedBarSeries, Tooltip } from '@visx/xychart';

const data = [
  { x: 'A', y: 30 },
  { x: 'B', y: 80 },
  { x: 'C', y: 45 },
  { x: 'D', y: 60 },
  { x: 'E', y: 20 },
];

const accessors = {
  xAccessor: d => d.x,
  yAccessor: d => d.y,
};

function BarChart() {
  return (
    <XYChart height={300} width={500} xScale={{ type: 'band' }} yScale={{ type: 'linear' }}>
      <AnimatedAxis orientation="bottom" />
      <AnimatedAxis orientation="left" />
      <AnimatedGrid columns={false} numTicks={4} />
      <AnimatedBarSeries dataKey="Bar Series" data={data} {...accessors} />
      <Tooltip />
    </XYChart>
  );
}

Scatter Plot

This code demonstrates how to create a scatter plot using @visx/xychart. It includes animated axes, grid, and a point series with a tooltip.

import { XYChart, AnimatedAxis, AnimatedGrid, AnimatedPointSeries, Tooltip } from '@visx/xychart';

const data = [
  { x: 10, y: 20 },
  { x: 20, y: 30 },
  { x: 30, y: 40 },
  { x: 40, y: 50 },
  { x: 50, y: 60 },
];

const accessors = {
  xAccessor: d => d.x,
  yAccessor: d => d.y,
};

function ScatterPlot() {
  return (
    <XYChart height={300} width={500} xScale={{ type: 'linear' }} yScale={{ type: 'linear' }}>
      <AnimatedAxis orientation="bottom" />
      <AnimatedAxis orientation="left" />
      <AnimatedGrid columns={false} numTicks={4} />
      <AnimatedPointSeries dataKey="Point Series" data={data} {...accessors} />
      <Tooltip />
    </XYChart>
  );
}

Other packages similar to @visx/xychart

Keywords

FAQs

Package last updated on 08 Mar 2021

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