Sha256: 3deeca2c56af44909b4961c63c7dad5df4a099f1d955b2a79986cfcb17d1d323
Contents?: true
Size: 1.14 KB
Versions: 8
Compression:
Stored size: 1.14 KB
Contents
Rev.registerComponent 'PieChart', propTypes: data: React.PropTypes.array.isRequired options: React.PropTypes.object width: React.PropTypes.number height: React.PropTypes.number title: React.PropTypes.string getDefaultProps: -> title: "Pie Chart" width: 300 height: 300 componentDidMount: -> ctx = @refs.canvas.getDOMNode().getContext('2d') @_chart = @renderChart(ctx) componentWillUnmount: -> @_chart.destroy() renderChart: (ctx) -> new Chart(ctx).Pie(@props.data, @getDefaultOptions()) getDefaultOptions: -> defaultOptions = segmentShowStroke : true segmentStrokeColor : "#fff" segmentStrokeWidth : 2 percentageInnerCutout : 0 animationSteps : 100 animationEasing : "easeOutBounce" animateRotate : true animateScale : false defaultOptions = Object.assign(defaultOptions, @props.options) render: -> <div> <h3 className="ChartTitle">{ @props.title }</h3> <canvas ref="canvas" width={ @props.width } height={ @props.height } /> <button onClick={@clearChart}>Clear Chart</button> </div>
Version data entries
8 entries across 8 versions & 1 rubygems