Socket
Socket
Sign inDemoInstall

@visx/axis

Package Overview
Dependencies
39
Maintainers
4
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @visx/axis

visx axis


Version published
Maintainers
4
Install size
5.48 MB
Created

Package description

What is @visx/axis?

@visx/axis is a part of the VisX library, which provides a collection of low-level visualization components for building custom visualizations in React. The @visx/axis package specifically focuses on rendering axes for charts, including both horizontal and vertical axes, with customizable ticks, labels, and styles.

What are @visx/axis's main functionalities?

Rendering a Basic Axis

This code demonstrates how to render a basic bottom axis using the @visx/axis package. The `AxisBottom` component is used along with a linear scale to create an axis at the bottom of the SVG.

import { AxisBottom } from '@visx/axis';
import { scaleLinear } from '@visx/scale';

const xScale = scaleLinear({ domain: [0, 100], range: [0, 400] });

<svg width={500} height={100}>
  <AxisBottom scale={xScale} top={50} />
</svg>;

Customizing Axis Ticks

This code shows how to customize the ticks of a left axis. The `tickLength` property is used to set the length of the ticks, and the `tickFormat` function is used to format the tick labels.

import { AxisLeft } from '@visx/axis';
import { scaleLinear } from '@visx/scale';

const yScale = scaleLinear({ domain: [0, 100], range: [400, 0] });

<svg width={100} height={500}>
  <AxisLeft
    scale={yScale}
    left={50}
    tickLength={10}
    tickFormat={(value) => `${value}%`}
  />
</svg>;

Styling Axis Components

This example demonstrates how to style the axis components. The `stroke` and `tickStroke` properties are used to set the color of the axis line and ticks, respectively. The `tickLabelProps` function is used to customize the properties of the tick labels.

import { AxisTop } from '@visx/axis';
import { scaleLinear } from '@visx/scale';

const xScale = scaleLinear({ domain: [0, 100], range: [0, 400] });

<svg width={500} height={100}>
  <AxisTop
    scale={xScale}
    top={50}
    stroke='#1b1a1e'
    tickStroke='#1b1a1e'
    tickLabelProps={() => ({
      fill: '#1b1a1e',
      fontSize: 11,
      textAnchor: 'middle',
    })}
  />
</svg>;

Other packages similar to @visx/axis

Changelog

Source

v1.12.0 (2021-06-03)

:rocket: Enhancements
  • new(shape): support dynamic fill directly in Pie #1225
:trophy: Contributors

Readme

Source

@visx/axis

An axis component consists of a line with ticks, tick labels, and an axis label that helps viewers interpret your graph.

You can use one of the 4 pre-made axes, or you can create your own based on the <Axis /> element. Note that the @visx/react-spring package exports an AnimatedAxis variant with animated ticks.

Installation

npm install --save @visx/axis

Keywords

FAQs

Last updated on 03 Jun 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc