NOTE: This repository is now under new management. Please reach out to the new administrators if you have any questions.
A collection of react components to render common data visualization charts, such as line/area/bar charts, heat maps, scatterplots, contour plots, hexagon heatmaps, pie and donut charts, sunbursts, radar charts, parallel coordinates, and tree maps.
Some notable features:
- Simplicity.
react-vis
doesn't require any deep knowledge of data visualization libraries to start building your first visualizations. - Flexibility.
react-vis
provides a set of basic building blocks for different charts. For instance, separate X and Y axis components. This provides a high level of control of chart layout for applications that need it. - Ease of use. The library provides a set of defaults which can be overridden by the custom user's settings.
- Integration with React.
react-vis
supports the React's lifecycle and doesn't create unnecessary nodes.
Install react-vis via npm.
npm install react-vis --save
Include the built main CSS file in your HTML page or via SASS:
@import "~react-vis/dist/style";
You can also select only the styles you want to use. This helps minimize the size of the outputted CSS. Here's an example of importing only the legends styles:
@import "~react-vis/dist/styles/legends";
Import the necessary components from the library...
import {XYPlot, XAxis, YAxis, HorizontalGridLines, LineSeries} from 'react-vis';
… and add the following code to your render
function:
<XYPlot
width={300}
height={300}>
<HorizontalGridLines />
<LineSeries
data={[
{x: 1, y: 10},
{x: 2, y: 5},
{x: 3, y: 15}
]}/>
<XAxis />
<YAxis />
</XYPlot>
If you're working in a non-node environment, you can also directly include the bundle and compiled style using basic html tags.
<link rel="stylesheet" href="https://unpkg.com/react-vis/dist/style.css">
<script type="text/javascript" src="https://unpkg.com/react-vis/dist/dist.min.js"></script>
The global reactVis
object will now be available for you to play around.
You can checkout these example CodePens: #1, #2, #3 or #4
Take a look at the folder with examples or check out some docs:
- Common concepts:
- Scales and Data about how the attributes can be adjusted.
- Animations about how to tweak animations in the library.
- Components:
- XYPlot about orthogonal charts.
- RadialChart about radial charts.
- Treemap about making tree maps.
- Sankey about making sankey diagrams.
- Radar Chart about making radar charts.
- Parallel Coordinates about making parallel coordinate charts.
- Sunbursts about making sunburst diagrams.
- Legends about the legends.
Make sure you are using the correct version of node
and yarn
. To do so, check package.json
and find the entry "volta", e.g.
"volta": {
"node": "14.18.0",
"yarn": "1.22.4"
}
It's recommanded to install volta to manage node and yarn.
To develop on react-vis, navigate to packages/react-vis
, and install the dependencies and then build and watch the static files:
yarn && yarn start
Once complete, you can view the component's example in your browser (will open automatically). Any changes you make to the example code will run the compiler to build the files again.
To run the tests, and create code coverage reports:
yarn cover
react-vis makes use of ES6 array methods such as Array.prototype.find
. If you make use of react-vis, in an environment without these methods, you'll see errors like TypeError: Server rendering error: Object x,y,radius,angle,color,fill,stroke,opacity,size has no method 'find'
. You can use babel-polyfill
to polyfill these methods.
react-vis's People
Forkers
wumengqiang revskill10 graemeworthy herlenadita danielstclair cganey joshvar88 adhbh porterjamesj gitvfd sam-silv koulmomo mcnuttandrew gwulfs dmtsui defvol haydn perfettiful cuulee caohy1988 leoipreo mayblue9 rakesh-mohanta duanshuaimin btford musofan timfpark ibbd faisal-w manassra ranjithnori mwang27 ifrit jordanstarkey95 yinghaochan fastfrwrd hellocrunch nfort nauhc limitlessv2 orlowang hangy233 dmitry-zaets geyang ebertmi hiddenloop absenteerealitycheck ejhack nkahnfr ebottabi jameskraus summerstorm imjerrybao yubozhao akindr brendansudol modulexcite chrisirhc teczgirish keshavnandan donaldfoss amilajack huokedu defjosiah akre54 gwokae alexxnica kryndex salzhrani jason88888 billx1975 robgev doquoctoan danhipke gghildya jpaulynice mathandpencil dtp45 tigertian ergestnako safr0 hycript yoks sibstephen jan-auer imbcmdth jparklev phoenox7 satryacode thanaporn-sk ericshape kolliparachandra saigonthink cloudhubke firenze11 river0510 andrewrocco danvc charliemartell handtrixreact-vis's Issues
Missing stacked charts example
Support dropoffs in sankey diagram
In order to visualize the lost data/money/visitors, we should be able to show "dropoffs" on the sankey diagram (Google Analytics has a great example). Current d3-sankey
does not support this behavior. Most likely we'll have to fork/adjust it.
This task should be implemented after #34.
Add the ability to show labels on the chart (e.g. label series)
Add Labels in Scatter/Bubble Plot
Label field on bubble chart - now you can make cool bubble charts, but you are not able to understand what this specific bubble stands for without clicking on it
API to use chart components directly?
Hello, great work on this library.
I'm wondering if it is possible, or if you would like to add, some kind of API for using components such as LineSeries
etc directly, rather than making them part of some explicit plot wrapper. The use case for this is if a user (such as myself) would like to draw them onto an existing SVG or combine them with custom SVG components that are not part of this library. For example I work on a chart-making tool and we'd like to add custom elements such as labels to the chart, but currently react-vis takes responsibility for the entire SVG.
Perhaps this API is there already, and can e.g. be used by passing all of these props to each series type, only that they are not documented as part of propTypes
?
_getClonedChildComponents() {
const {animation} = this.props;
const {scaleMixins, data} = this.state;
const dimensions = getInnerDimensions(this.props);
const children = React.Children.toArray(this.props.children);
const seriesProps = getSeriesPropsFromChildren(children);
return children.map((child, index) => {
const dataProps = data[index] ? {data: data[index]} : null;
return React.cloneElement(child, {
...dimensions,
animation,
...seriesProps[index],
...scaleMixins,
...child.props,
...dataProps
});
});
}
Otherwise, I'd be happy to look at submitting a PR to make this possible
Greater than five data series wraps data
When trying to plot more than five line series i find that each additional series greater than five doesn't render. This appears to be because react-vis is wrapping the data so that given six line series, what you would expect would be:
<lineseries data=data_1>
<lineseries data=data_2>
<lineseries data=data_3>
<lineseries data=data_4>
<lineseries data=data_5>
<lineseries data=data_6>
But instead i find that last one gets the firsts data, that is:
<lineseries data=data_1>
<lineseries data=data_2>
<lineseries data=data_3>
<lineseries data=data_4>
<lineseries data=data_5>
<lineseries data=data_1>
I think that this is connected to #62.
Bars are 0-height when y-values are the same
When data of the series has same y values, the height of bars are calculated as 0. It also happens when there is only one bar in data.
Is there some graph map with edges?
Let's say we start with one node, attach a click listener in which it will fetch some data, then we will expand that "graph map" with more edges connected with these other nodes that we get from our new data.
Add ability to customize bar width on bar series
Support clicks for the series objects
Clicks are not currently implemented
Pie chart gives fails to render opacity correctly
When I set opacity to any value for the pie chart I get a console error:
Cannot use data defined opacity for this seriestype. Using fallback value instead.
[Question] Is it possible convert a data point to a styled circle when user hovers over it?
What is the recommended approach to accomplish this?
Best regards,
Alex
react-vis 0.3.1 XYPlot fails on nested child array
Tried to upgrade from 0.1.1 to 0.3.1 but had to revert.
Got a crash in collectSeriesTypesInfo when it tried to process my application's nested array of XYPlot children.
Perhaps some higher level code is not first calling getSeriesChildren?
Add sankey diagrams to the library
Currently we have a big need to show the flow of step by step changes. Sankey Diagram is a good way to visualize it.
I think, we should use d3-sankey
for this purpose, but before that we should upgrade to [email protected] (see #29 for detail).
Adding yType of 'log' to graph throws d3.js errors
Example issues
I'd like to do some exercises of react-vis, but some issues happened.
1.The LineSeries doesn't look like same as 'http://uber.github.io/react-vis/' provided. Just like as the attachment image.
2.The VerticalBarSeries doesn't display normally, It only has coordinate like as the attachment image.
Other series and radial work fine. All the example codes come from the 'src/example' file directory.
Some suggestions: Could you provide the example codes for each chart in 'http://uber.github.io/react-vis/' or build online editors in jsfiddle?
Examples do not render as shown
I tried out the example provided at https://github.com/uber-common/react-vis/blob/master/src/example/plot/line-chart.js
It renders as https://i.imgur.com/efmrQBg.png when I try it out.
Does any one know whats up ?
Assign the series event listeners using react (e.g. not using d3)
Currently the components' event listeners are assigned via d3 either at componentDidMount
or at componentDidUpdate
. The usage of d3 definitely helps: the event handler automatically gets the values associated with the DOM node, but these event listeners are not testable.
Thus, we should move the components' event listeners to the render
function.
XYPlot appears to require a consistant number of children
For both area and line charts it appears that there is a render issue such that react-vis requries a consitant number of elements. For instance, say we were render three line series:
<XYPlot> <series 1> <series 2> <series 3> </XYPlot>
and then add grid lines
<XYPlot> <grid> <grid> <series 1> <series 2> <series 3> </XYPlot>
More likely than not series 3 would not appear
Y axis issues when data is constant
The y-axis lacks a tickmark when data is constant. I'd expect the line series to be vertically in the xyplot with 1 tickmark & gridline at the value specified.
<XYPlot
width={600}
height={300}>
<HorizontalGridLines />
<LineMarkSeries
color='blue'
data={[ {x: 1,y:10}, {x: 2, y:10}]}/>
<XAxis />
<YAxis />
</XYPlot>
Add hints for radial chart
Bar charts aren't rendering correctly when using ordinal scale
broken from #104 .
Add the example of donut charts to the example page
The functionality exists, but not shown anywhere besides docs. It'll be great to have it on the page.
Add better documentation on how to use scales in react-vis
Please provide an example of how to use fill scale and innerRadius scale. Here's how I tried to do it. It didn't work as expected. I couldn't find any examples about the same.
<RadialChart
radiusDomain={[0,20]}
innerRadiusDomain={[5,9]}
data={[
{angle: 2, fill: '#1a3141', radius: 10, innerRadius: 7},
{angle: 7, fill: '#ff6f00', radius: 10, innerRadius: 7},
{angle: 5, fill: '#1a3242', radius: 10, innerRadius: 7}
]}
width={300}
height={300} />
static displayName getter interferes with livereactreload
livereactreload overwrites displayName while it proxies React components. This fails since react-vis uses a static getter to define the displayName attribute. As alternative to static get displayName()
it would be great if we could either rely on auto deduction of displayName
s or just assign them after the class declaration:
class Component extends React.Component {
...
}
Component.displayName = 'Component';
Upgrade to d3 4.0
Upgrade to d3 4.0 will help us to make our codebase smaller and more extensible.
Ordinal scale breaks the bar chart with only one data point
Add the checks for most frequent user's errors
There are several most frequent errors made by users that should be checked:
null
s orundefined
s in the data properties;- mismatching
x
properties for stacked charts; - negative or zero values for
log
scales.
Peer Dependencies Error
It looks like recent versions of react-addons-shallow-compare
(15.x.x) cause peer dependency problems:
npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants react@^15.0.2
npm ERR! peerinvalid Peer [email protected] wants react@^0.14.8
npm ERR! peerinvalid Peer [email protected] wants react@^0.14.8
Dropping back to 0.14.8 works fine.
"Animated" treemap doesn't seem to be animated
There's either some misconfiguration of the animated treemap or too fast animation for the cells: the animation is not visible for on the example page.
x and y axes don't get a specific class
they get rendered as a rv-xy-plot__axis g element.
Bars have 0 height
The bars have the 0 height in following case
<XYPlot, {
width: 900,
height: 250,
yDomain: [0, 9367]
}>
<VerticalBarSeries, {
data: [{x: 0, y: 9367}, {x: 1, y: 184}]
} />
<XAxis />
<YAxis />
</XYPlot>
Pie chart gives console error when changing number of segments is animated
The pie chart yields a bunch of console errors like this
d3.js:8756 Error: Invalid value for <path> attribute d="M109.35191368826634,412.2430898706445A426.5,426.5 0 0.000006912,1 -225.26700899816143,362.14965805466653L-144.9842766002235,233.08532321974673Z"
when animation is on and the number of segments is increasing or decreasing. This doesn't appear to affect the functionality of the chart, but is a little worrisome.
Typo in title of scatterplot example
Typo in the title of:
react-vis/src/example/plot/scatteplot.js
scale-utils mutates the domain array passed to react-vis
offsetLeft/offsetTop's behavior is unexpected in bottom and right hint alignment
Using offsetLeft
actually offsets the hint in the opposite direction (pushing it more towards left as it's increased) when the tip is positioned with topright
because it's added to the css right
property.
We can either also accept offsetRight
or offsetBottom
(which would be less ambiguous and offer more control, or subtract instead of add offsetLeft
and offsetTop
in the case of right and bottom orientations.
/cc @chrisirhc
getStackedData causes an error if XY-Plot maps data into series children
var data = child.props.data;
on line 109 of series-utils.js
will fail if the XY-Plot maps data into children such as this case:
{dataSets.map((set, index) => {
return (
<LineSeries
key={index}
data={set.points}
onNearestX={this.onNearestX.bind(null, set.name)}
color={colorMap[set.name]} />
);
})}
which will send an array of children to the getStackedData
function, and child.props
will be undefined, causing this error: Uncaught TypeError: Cannot read property 'data' of undefined
Implement stacking for XYPlot
Consider removing custom fonts from the library
Custom fonts are quite heavy, they are loaded from the external place (this doesn't seem right). We should remove this from main.scss and place them into the examples.
Add the ability to align axis in the center/top/right
There’s an obvious way to use charts when the axes are intersecting in the center of the visualization (instead of bottom and left sides). It might be very helpful for some statistical data.
Charting XY
Quick question I was going through some of the source and examples, when charting line series and the like does you data keys need to be in the format x/y?
data={[
{x: '..', y: '..'},
...
]}
Change the margin property to a set of four properties for each of the sides
Current way to organize margin enforces the user to pass all four margins (left
, right
, top
and bottom
) in the single margin
property. It's better to have marginLeft
, marginRight
, marginTop
and marginBottom
properties instead.
E. g. instead of having
<XYPlot margin={{left: 20, right: 20, top: 10, bottom: 10}} />
we should have this (in case if we want to override just one of them)
<XYPlot marginLeft={20} />
Provide an example with Time as the Y-Axis.
Right now I try to make a graph with X part of the dataset to be js Date objects. The graph renders horribly in that case. An example for xScale='time' would be very useful.
Legends for charts with multiple series
I've been pondering this for the last couple days, working out a means of building a legend with interactivity hooks into the existing XY chart series.
Perhaps something like this could work as a starter - wrapping a higher order component around the series components. This component would essentially be an interface rendering a 'default legend' and include event handlers to do things like filtering on selection of a specific series.
<XYPlot
width={300}
height={300}>
<HorizontalGridLines />
<Legend onSelection={this.onSelection} style={style}>
<LineSeries
color='red'
data={[
{x: 1, y: 10},
{x: 2, y: 5},
{x: 3, y: 15}
]}/>
<LineSeries
color='blue'
data={[
{x: 1, y: 10},
{x: 2, y: 5},
{x: 3, y: 15}
]}/>
</Legend>
<XAxis />
<YAxis />
</XYPlot>
An alternative would be just to have a standalone <Legend/>
component that is fed information about series the chart from the XYPlot
- potentially less complexity there, I guess.
Would appreciate thoughts (or alternative approaches!) on this, and happy to help with PR to get it landed.
react-vis brings the latest version of React when no react-addons-shallow-compare is installed
Originally reported by @harishkraman
pass style objects / class names to series
I'd like to be able to have complete style control on the series. two ways that could be done:
passing a style argument to the series, with an object that d3 could just assign to the style.
also, I'd like to be able to pass specific classes to series. I'm thinking we can just pass a string with a class name to add to begin with, and if needs be be more specific. But being able to have full, css-like access to each individual series would be really nice.
Add more complex tests for the components
Currently only basic functionality of components is checked. We need better tests for the components.
Add tests for scale transformations
Ability to supply class prefix?
It'd be cool to be able to isolate the CSS classes with a prefix of our choosing.
Is this something you'd be interested in incorporating if we submit a PR?
Bar widths incorrectly calculated for bar charts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.