Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

Commit

Permalink
add chart and canvass accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
jhudson8 committed Feb 23, 2015
1 parent c4593a4 commit e255385
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ var MyComponent = React.createClass({
* all other parameters will be passed through to the ```canvas``` element


Chart References
----------------
The ```canvas``` element can be retrieved using ```getCanvass``` and the ```chartjs object``` can be retrieved using ```getChart```.


### Other React projects that may interest you

* [jhudson8/react-mixin-manager](https://github.com/jhudson8/react-mixin-manager)
Expand Down
14 changes: 13 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module.exports = {
displayName: chartType + 'Chart',
getInitialState: function() { return {}; },
render: function() {
var _props = {};
var _props = {
ref: 'canvass'
};
for (var name in this.props) {
if (this.props.hasOwnProperty(name)) {
if (name !== 'data' && name !== 'options') {
Expand Down Expand Up @@ -46,6 +48,16 @@ module.exports = {
this.state.chart = chart;
};

// return the chartjs instance
classData.getChart = function() {
return this.state.chart;
};

// return the canvass element that contains the chart
classData.getCanvass = function() {
return this.refs.canvass.getDOMNode();
};

var i;
for (i=0; i<extras.length; i++) {
extra(extras[i]);
Expand Down

0 comments on commit e255385

Please sign in to comment.