What is victory-chart?
Victory-chart is a composable charting library for React. It provides a set of modular charting components that can be combined to create complex data visualizations. The library is built on top of D3.js and offers a variety of chart types, including bar charts, line charts, pie charts, and more.
What are victory-chart's main functionalities?
Line Chart
This code demonstrates how to create a simple line chart using Victory-chart. The VictoryLine component is used to render the line chart within a VictoryChart container.
import React from 'react';
import { VictoryChart, VictoryLine } from 'victory';
const data = [
{ x: 1, y: 2 },
{ x: 2, y: 3 },
{ x: 3, y: 5 },
{ x: 4, y: 4 },
{ x: 5, y: 7 }
];
const LineChart = () => (
<VictoryChart>
<VictoryLine data={data} />
</VictoryChart>
);
export default LineChart;
Bar Chart
This code demonstrates how to create a bar chart using Victory-chart. The VictoryBar component is used to render the bar chart within a VictoryChart container.
import React from 'react';
import { VictoryChart, VictoryBar } from 'victory';
const data = [
{ x: 'A', y: 2 },
{ x: 'B', y: 3 },
{ x: 'C', y: 5 },
{ x: 'D', y: 4 },
{ x: 'E', y: 7 }
];
const BarChart = () => (
<VictoryChart>
<VictoryBar data={data} />
</VictoryChart>
);
export default BarChart;
Pie Chart
This code demonstrates how to create a pie chart using Victory-chart. The VictoryPie component is used to render the pie chart.
import React from 'react';
import { VictoryPie } from 'victory';
const data = [
{ x: 'Cats', y: 35 },
{ x: 'Dogs', y: 40 },
{ x: 'Birds', y: 25 }
];
const PieChart = () => (
<VictoryPie data={data} />
);
export default PieChart;
Other packages similar to victory-chart
recharts
Recharts is a composable charting library built on React components. It is similar to Victory-chart in that it provides a variety of chart types and is easy to use with React. However, Recharts has a different API and offers some unique features like animations and tooltips out of the box.
nivo
Nivo provides a rich set of dataviz components, built on top of D3 and React. It offers a wide range of chart types and is highly customizable. Compared to Victory-chart, Nivo provides more advanced features and customization options, but it may have a steeper learning curve.
react-chartjs-2
React-chartjs-2 is a React wrapper for Chart.js, a popular JavaScript charting library. It provides a simple way to integrate Chart.js charts into React applications. While it offers a wide range of chart types and customization options, it relies on Chart.js for rendering, which may not be as flexible as Victory-chart's approach.
##TODO: write an actual README!
These are the props
style: React.PropTypes.node,
data: React.PropTypes.oneOfType([ // maybe this should just be "node"
React.PropTypes.arrayOf(
React.PropTypes.shape({
x: React.PropTypes.any,
y: React.PropTypes.any
})
),
React.PropTypes.arrayOf(
React.PropTypes.arrayOf(
React.PropTypes.shape({
x: React.PropTypes.any,
y: React.PropTypes.any
})
)
)
]),
dataAttributes: React.PropTypes.oneOfType([
React.PropTypes.object,
React.PropTypes.arrayOf(React.PropTypes.object)
]),
x: React.PropTypes.array,
y: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.func
]),
yAttributes: React.PropTypes.oneOfType([
React.PropTypes.object,
React.PropTypes.arrayOf(React.PropTypes.object)
]),
domain: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.shape({
x: React.PropTypes.array,
y: React.PropTypes.array
})
]),
range: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.shape({
x: React.PropTypes.arrayOf(React.PropTypes.number),
y: React.PropTypes.arrayOf(React.PropTypes.number)
})
]),
scale: React.PropTypes.oneOfType([
React.PropTypes.func,
React.PropTypes.shape({
x: React.PropTypes.func,
y: React.PropTypes.func
})
]),
samples: React.PropTypes.number,
interpolation: React.PropTypes.oneOf([
"linear",
"linear-closed",
"step",
"step-before",
"step-after",
"basis",
"basis-open",
"basis-closed",
"bundle",
"cardinal",
"cardinal-open",
"cardinal-closed",
"monotone"
]),
axisOrientation: React.PropTypes.shape({
x: React.PropTypes.oneOf(["top", "bottom"]),
y: React.PropTypes.oneOf(["left", "right"])
}),
showGridLines: React.PropTypes.shape({
x: React.PropTypes.bool,
y: React.PropTypes.bool
}),
tickValues: React.PropTypes.shape({
x: React.PropTypes.arrayOf(React.PropTypes.any),
y: React.PropTypes.arrayOf(React.PropTypes.any)
}),
tickFormat: React.PropTypes.shape({
x: React.PropTypes.func,
y: React.PropTypes.func
}),
tickCount: React.PropTypes.shape({
x: React.PropTypes.number,
y: React.PropTypes.number
}),
axisStyle: React.PropTypes.shape({
x: React.PropTypes.node,
y: React.PropTypes.node
}),
tickStyle: React.PropTypes.shape({
x: React.PropTypes.node,
y: React.PropTypes.node
}),
gridStyle: React.PropTypes.shape({
x: React.PropTypes.node,
y: React.PropTypes.node
}),
animate: React.PropTypes.oneOfType([
React.PropTypes.bool,
React.PropTypes.shape({
line: React.PropTypes.bool,
scatter: React.PropTypes.bool,
axis: React.PropTypes.bool
})
]),
containerElement: React.PropTypes.oneOf(["svg", "g"])
Victory Chart
Development
Please see DEVELOPMENT
Contributing
Please see CONTRIBUTING