This repository was archived by the owner on Jul 19, 2019. It is now read-only.
File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ var MyComponent = React.createClass({
37
37
* all other parameters will be passed through to the ``` canvas ``` element
38
38
39
39
40
+ Chart References
41
+ ----------------
42
+ The ``` canvas ``` element can be retrieved using ``` getCanvass ``` and the ``` chartjs object ``` can be retrieved using ``` getChart ``` .
43
+
44
+
40
45
### Other React projects that may interest you
41
46
42
47
* [ jhudson8/react-mixin-manager] ( https://github.com/jhudson8/react-mixin-manager )
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ module.exports = {
4
4
displayName : chartType + 'Chart' ,
5
5
getInitialState : function ( ) { return { } ; } ,
6
6
render : function ( ) {
7
- var _props = { } ;
7
+ var _props = {
8
+ ref : 'canvass'
9
+ } ;
8
10
for ( var name in this . props ) {
9
11
if ( this . props . hasOwnProperty ( name ) ) {
10
12
if ( name !== 'data' && name !== 'options' ) {
@@ -46,6 +48,16 @@ module.exports = {
46
48
this . state . chart = chart ;
47
49
} ;
48
50
51
+ // return the chartjs instance
52
+ classData . getChart = function ( ) {
53
+ return this . state . chart ;
54
+ } ;
55
+
56
+ // return the canvass element that contains the chart
57
+ classData . getCanvass = function ( ) {
58
+ return this . refs . canvass . getDOMNode ( ) ;
59
+ } ;
60
+
49
61
var i ;
50
62
for ( i = 0 ; i < extras . length ; i ++ ) {
51
63
extra ( extras [ i ] ) ;
You can’t perform that action at this time.
0 commit comments