Gathering detailed insights and metrics for @visx/axis
Gathering detailed insights and metrics for @visx/axis
Gathering detailed insights and metrics for @visx/axis
Gathering detailed insights and metrics for @visx/axis
npm install @visx/axis
90.7
Supply Chain
73.5
Quality
87.7
Maintenance
100
Vulnerability
98.9
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
19,545 Stars
3,250 Commits
719 Forks
139 Watching
26 Branches
160 Contributors
Updated on 27 Nov 2024
TypeScript (97.44%)
CSS (1.3%)
JavaScript (1.26%)
Cumulative downloads
Total Downloads
Last day
2.2%
85,051
Compared to previous day
Last week
15.8%
455,846
Compared to previous week
Last month
10.1%
1,759,880
Compared to previous month
Last year
70.6%
21,286,492
Compared to previous year
1
visx is a collection of reusable low-level visualization components. visx combines the power of d3 to generate your visualization with the benefits of react for updating the DOM.
Docs • Gallery • Blog • Discussions • Changelog • Getting started tutorial
Let's make a simple bar graph.
First we'll install the relevant packages:
1npm install --save @visx/mock-data @visx/group @visx/shape @visx/scale
1import React from 'react'; 2import { letterFrequency } from '@visx/mock-data'; 3import { Group } from '@visx/group'; 4import { Bar } from '@visx/shape'; 5import { scaleLinear, scaleBand } from '@visx/scale'; 6 7// We'll use some mock data from `@visx/mock-data` for this. 8const data = letterFrequency; 9 10// Define the graph dimensions and margins 11const width = 500; 12const height = 500; 13const margin = { top: 20, bottom: 20, left: 20, right: 20 }; 14 15// Then we'll create some bounds 16const xMax = width - margin.left - margin.right; 17const yMax = height - margin.top - margin.bottom; 18 19// We'll make some helpers to get at the data we want 20const x = d => d.letter; 21const y = d => +d.frequency * 100; 22 23// And then scale the graph by our data 24const xScale = scaleBand({ 25 range: [0, xMax], 26 round: true, 27 domain: data.map(x), 28 padding: 0.4, 29}); 30const yScale = scaleLinear({ 31 range: [yMax, 0], 32 round: true, 33 domain: [0, Math.max(...data.map(y))], 34}); 35 36// Compose together the scale and accessor functions to get point functions 37const compose = (scale, accessor) => data => scale(accessor(data)); 38const xPoint = compose(xScale, x); 39const yPoint = compose(yScale, y); 40 41// Finally we'll embed it all in an SVG 42function BarGraph(props) { 43 return ( 44 <svg width={width} height={height}> 45 {data.map((d, i) => { 46 const barHeight = yMax - yPoint(d); 47 return ( 48 <Group key={`bar-${i}`}> 49 <Bar 50 x={xPoint(d)} 51 y={yMax - barHeight} 52 height={barHeight} 53 width={xScale.bandwidth()} 54 fill="#fc2e1c" 55 /> 56 </Group> 57 ); 58 })} 59 </svg> 60 ); 61} 62 63// ... somewhere else, render it ... 64// <BarGraph />
For more examples using visx
, check out the gallery.
Goal
The goal is to create a library of components you can use to make both your own reusable chart library or your slick custom one-off chart. visx is largely unopinionated and is meant to be built upon. Keep your bundle sizes down and use only the packages you need.
How?
Under the hood, visx is using d3 for the calculations and math. If you're creating your own awesome chart library on top of visx, it's easy to create a component api that hides d3 entirely. Meaning your team could create charts as easily as using reusable react components.
But why?
Mixing two mental models for updating the DOM is never a good time. Copy and pasting d3 code into
componentDidMount()
is just that. This collection of components lets you easily build your own
reusable visualization charts or library without having to learn d3. No more selections or
enter()
/exit()
/update()
.
react-move
by
@techniq (Demo)
(Radial demo)
(More info)react-spring
by
@drcmda (Demo)vx
, earlier version of visx
. (Demo)Have a project that's using visx
? Open a pull request and we'll add it to the list.
What does visx
stand for?
visx stands for visualization components.
Do you plan on supporting animation/transitions?
A common criticism of visx is it doesn't have animation baked in, but this was a conscious choice. It's a powerful feature to not bake it in.
Imagine your app already bundles
react-motion
, adding a hypothetical@visx/animation
is bloat. Since visx is react, it already supports all react animation libs.Charting libraries are like style guides. Each org or app will eventually want full control over their own implementation.
visx makes this easier for everyone. No need to reinvent the wheel each time.
more info: https://github.com/airbnb/visx/issues/6
examples:
- Collapsible tree with
react-move
by @techniq (Demo) (Radial demo)- Animation with
react-spring
by @drcmda (Demo)
Do I have to use every package to make a chart?
nope! pick and choose the packages you need.
Can I use this to create my own library of charts for my team?
Please do.
Does visx work with preact?
yup! need to alias
react
+react-dom
and usepreact-compat
.
I like using d3.
Me too.
Please see CONTRIBUTING.md
:v:
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
4 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 5
Reason
Found 7/30 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
78 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More