React Base Fiddle (JSX) - JSFiddle
Starting point for creating JSFiddles with React. This uses React with Addons.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/react-with-addons.min.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/react-dom.min.js"></script>
<script src="https://npmcdn.com/prop-types/prop-types.min.js"></script>
<script src="https://npmcdn.com/recharts/umd/Recharts.min.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>
CSS
body {
margin: 0;
}
#container {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
width: 800px;
height: 800px;
background-color: #fff;
}
JavaScript 1.7
const {PropTypes} = React;
const {BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend} = Recharts;
const data = [
{name: 'Page A', a: 400, b: 240, c: 240},
{name: 'Page B', a: 300, b: 139, c: 221},
{name: 'Page C', a: -200, b: -980, c: 229},
{name: 'Page D', a: 278, b: 390, c: 200},
{name: 'Page E', a: 189, b: 480, c: 218},
{name: 'Page F', a: 239, b: -380, c: 250},
{name: 'Page G', a: 349, b: 430, c: 210}
];
const CandyBar = (props) => {
const {
x: oX,
y: oY,
width: oWidth,
height: oHeight,
value,
fill
} = props;
let x = oX;
let y = oHeight < 0 ? oY + oHeight : oY;
let width = oWidth;
let height = Math.abs(oHeight);
return (
<rect fill={fill}
mask='url(#mask-stripe)'
x={x}
y={y}
width={width}
height={height} />
);
};
const CustomShapeBarChart = React.createClass({
render () {
return (
<div>
<BarChart width={700} height={300} data={data}
margin={{top: 20, right: 30, left: 20, bottom: 5}}>
<pattern id="pattern-stripe"
width="8" height="8"
patternUnits="userSpaceOnUse"
patternTransform="rotate(45)">
<rect width="4" height="8" transform="translate(0,0)" fill="white"></rect>
</pattern>
<mask id="mask-stripe">
<rect x="0" y="0" width="100%" height="100%" fill="url(#pattern-stripe)" />
</mask>
<XAxis dataKey="name"/>
<YAxis/>
<CartesianGrid strokeDasharray="3 3"/>
<Bar dataKey="a" fill="green" isAnimationActive={false} shape={<CandyBar />} />
<Bar dataKey="b" isAnimationActive={false} fill="red" />
<Bar dataKey="c" isAnimationActive={false} shape={<CandyBar fill="#8884d8" />} />
</BarChart>
</div>
);
}
})
ReactDOM.render(
<CustomShapeBarChart />,
document.getElementById('container')
);