Installations
npm install @visx/tooltip
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
16.14.0
NPM Version
lerna/7.0.2/node@v16.14.0+x64 (linux)
Statistics
19,546 Stars
3,250 Commits
719 Forks
139 Watching
26 Branches
160 Contributors
Updated on 28 Nov 2024
Bundle Size
12.34 kB
Minified
4.25 kB
Minified + Gzipped
Languages
TypeScript (97.44%)
CSS (1.3%)
JavaScript (1.26%)
Total Downloads
Cumulative downloads
Total Downloads
38,851,012
Last day
4.1%
79,417
Compared to previous day
Last week
14.4%
412,541
Compared to previous week
Last month
11%
1,613,614
Compared to previous month
Last year
64.2%
19,308,970
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
1
visx
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
Usage
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.
Motivation
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()
.
In the wild
- williaster/data-ui (Demo)
- dylanmoz/trello (Demo) (How to Make Beautiful Graphs With vx and React-Motion)
- gkunthara/Crypto-Chart (Tutorial)
- Collapsible tree with
react-move
by @techniq (Demo) (Radial demo) (More info) - Bitcoin 30-day price by @hshoff (Github) (YouTube)
- Ethereum candlestick chart by @hshoff (Github)
- Song data visualization through spotify by @bother7 (Github)
- Investment Calculator (website)
- Animation with
react-spring
by @drcmda (Demo) - Code Coverage Dashboard by @ezy (Github)
- Ethereum Portfolio Toolkit by @JayWelsh (Demo) (Github)
- Family tree by @vkallore (Github)
- South African Coronavirus Data Visuals by @JayWelsh (Demo) (Github)
- CNN: Tracking America's Recovery
- Wall Street Journal: Americans Familiarize Themselves with the Word ‘Forbearance’ by @rayshan (Demo)
- Dollar to food emoji caculator by @gmlwo530 (Demo) (Github)
- [zh-TW] Taiwan Real-time Air Quality Index by @ArvinH(Demo)(Tutorial)
- tokenized BTC on ethereum stacked chart with brush by @sakulstra
- Escape From Tarkov Ammo Chart by @codenomial
- Pry Finance for Founders (dashboard by @valtism)
- Data 2 the People Donation Efficacy Analysis for Downballot Races (Demo) (Github)
- Augora Display information of french deputies (Demo)(Github)
- WHO Coronavirus (COVID-19) Dashboard is built on top of
vx
, earlier version ofvisx
. (Demo) - Fig Stats - Figma community plugin & widget analytics
- Physician.FYI - Explore physicians' disciplinary history
- Index by Superstardle, Salaries by Superstardle, & Pack'Em by Superstardle - Explore professional sports teams and superstars in the world of underdogs, salaries, and playoff performances.
- Ridgeline chart visualizing shuffling probabilities by @jmssnr (Demo) (Github)
Have a project that's using visx
? Open a pull request and we'll add it to the list.
FAQ
-
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)
- Collapsible tree with
-
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.
Development
Please see CONTRIBUTING.md
:v:
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no binaries found in the repo
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/airbnb/.github/SECURITY.md:1
- Info: Found linked content: github.com/airbnb/.github/SECURITY.md:1
- Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy
- Info: Found text in security policy: github.com/airbnb/.github/SECURITY.md:1
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
- Warn: no topLevel permission defined: .github/workflows/pull_request.yml:1
- Warn: no topLevel permission defined: .github/workflows/push.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pull_request.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/airbnb/visx/pull_request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pull_request.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/airbnb/visx/pull_request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pull_request.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/airbnb/visx/pull_request.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/pull_request.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/airbnb/visx/pull_request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/push.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/airbnb/visx/push.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/push.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/airbnb/visx/push.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/push.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/airbnb/visx/push.yml/master?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 8 are checked with a SAST tool
Reason
78 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-8hc4-vh64-cxmj
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-36jr-mh4h-2g58
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-8cf7-32gw-wr33
- Warn: Project is vulnerable to: GHSA-hjrf-2m68-5959
- Warn: Project is vulnerable to: GHSA-qwph-4952-7xr6
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-fmvm-x8mv-47mj
- Warn: Project is vulnerable to: GHSA-c59h-r6p8-q9wc
- Warn: Project is vulnerable to: GHSA-g77x-44xx-532m
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3
- Warn: Project is vulnerable to: GHSA-wvhm-4hhf-97x9
- Warn: Project is vulnerable to: GHSA-h4hr-7fg3-h35w
- Warn: Project is vulnerable to: GHSA-gj77-59wh-66hg
- Warn: Project is vulnerable to: GHSA-hqhp-5p83-hx96
- Warn: Project is vulnerable to: GHSA-3949-f494-cm99
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-662x-fhqg-9p8v
- Warn: Project is vulnerable to: GHSA-394c-5j6w-4xmx
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
3.7
/10
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