react-d3.js LineChart
react-d3.js LineChart example
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://fb.me/react-with-addons-15.0.1.js"></script>
<script src="https://fb.me/react-dom-15.0.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.js"></script>
<script src="https://npmcdn.com/[email protected]/build/public/js/react-d3.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
var LineChart = rd3.LineChart
var lineData = [
{
name: 'series1',
values: [ { x: 0, y: 20 }, { x: 1, y: 30 }, { x: 2, y: 10 }, { x: 3, y: 5 }, { x: 4, y: 8 }, { x: 5, y: 15 }, { x: 6, y: 10 } ],
strokeWidth: 3,
strokeDashArray: "5,5",
},
{
name: 'series2',
values : [ { x: 0, y: 8 }, { x: 1, y: 5 }, { x: 2, y: 20 }, { x: 3, y: 12 }, { x: 4, y: 4 }, { x: 5, y: 6 }, { x: 6, y: 2 } ]
},
{
name: 'series3',
values: [ { x: 0, y: 0 }, { x: 1, y: 5 }, { x: 2, y: 8 }, { x: 3, y: 2 }, { x: 4, y: 6 }, { x: 5, y: 4 }, { x: 6, y: 2 } ]
}
];
var Chart = React.createClass({
render: function() {
return (
<LineChart
legend={true}
data={lineData}
width='100%'
height={400}
viewBoxObject={{
x: 0,
y: 0,
width: 500,
height: 400
}}
title="Line Chart"
yAxisLabel="Altitude"
xAxisLabel="Elapsed Time (sec)"
domain={{x: [,6], y: [-10,]}}
gridHorizontal={true}
/>
)}
});
ReactDOM.render(
<Chart />,
document.getElementById('container')
);