Socket
Socket
Sign inDemoInstall

@vx/shape

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vx/shape

vx shape


Version published
Maintainers
1
Created

What is @vx/shape?

@vx/shape is a part of the vx library, which is a collection of reusable low-level visualization components. The @vx/shape package provides a set of components for creating various shapes and paths in SVG, which can be used to build complex visualizations like charts and graphs.

What are @vx/shape's main functionalities?

Bar

The Bar component allows you to create bar charts. The code sample demonstrates how to create a simple bar chart using SVG rectangles.

const Bar = ({ data }) => (
  <svg width={500} height={500}>
    {data.map((d, i) => (
      <rect
        key={i}
        x={i * 30}
        y={500 - d}
        width={25}
        height={d}
        fill="teal"
      />
    ))}
  </svg>
);

LinePath

The LinePath component is used to create line charts. The code sample shows how to create a simple line chart using an SVG path element.

const LinePath = ({ data }) => (
  <svg width={500} height={500}>
    <path
      d={`M ${data.map((d, i) => `${i * 30},${500 - d}`).join(' L ')}`}
      fill="none"
      stroke="blue"
    />
  </svg>
);

Pie

The Pie component is used to create pie charts. The code sample demonstrates how to create a simple pie chart using SVG path elements.

const Pie = ({ data }) => (
  <svg width={500} height={500}>
    {data.map((d, i) => (
      <path
        key={i}
        d={`M250,250 L${250 + 200 * Math.cos(2 * Math.PI * i / data.length)},${250 + 200 * Math.sin(2 * Math.PI * i / data.length)} A200,200 0 0,1 ${250 + 200 * Math.cos(2 * Math.PI * (i + 1) / data.length)},${250 + 200 * Math.sin(2 * Math.PI * (i + 1) / data.length)} Z`}
        fill={d.color}
      />
    ))}
  </svg>
);

Other packages similar to @vx/shape

Keywords

FAQs

Package last updated on 01 Nov 2017

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