Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dbb92d6
use React Node ref instead of dom-node
mrvicadai Mar 9, 2016
703529f
add style property to React type-checking
mrvicadai Mar 9, 2016
cc74524
Merge pull request #35 from mrvicadai/master
fraserxu Mar 11, 2016
0aa5b44
Update to React 15
joshgerdes Apr 8, 2016
09edab9
Bump version
joshgerdes Apr 8, 2016
a1b7e1a
Merge pull request #36 from joshgerdes/master
fraserxu Apr 11, 2016
2dce37e
update peer dependencies
fraserxu Apr 12, 2016
0ebbf39
This is a Bar, not a Pie.
lawrencekgrant Jul 29, 2016
eae6b90
feat(package): chartist 0.10 as peer dependency
julien-f Nov 15, 2016
55d1882
chore(package): merge devDependencies
julien-f Nov 15, 2016
6815527
Merge pull request #44 from julien-f/patch-1
fraserxu Nov 15, 2016
f6d116c
bump babel to v6.18.0
fraserxu Nov 15, 2016
1c981fb
0.11.0
fraserxu Nov 15, 2016
419dd3f
Enforce valid chart types in propTypes
cmmartin Dec 12, 2016
2c2dd42
Merge pull request #39 from lawrencekgrant/patch-1
fraserxu Dec 12, 2016
f1c717c
Merge pull request #45 from cmmartin/patch-1
fraserxu Dec 12, 2016
7696267
Allow children and give them access to all graph props
Jan 26, 2017
6f74b94
Use spread
Jan 26, 2017
5b6e893
only pass down data and type to avoid conflicts
Jan 27, 2017
6ffe055
revert to original style
Jan 27, 2017
75da26a
Only try to render children of they exist
Jan 27, 2017
07210bc
Merge branch 'master' of github.com:theslip/react-chartist
Jan 27, 2017
ccd8d63
Update index.js
Jan 27, 2017
f89d97c
Clone props to all children.
Jan 29, 2017
853418c
Merge pull request #49 from theslip/master
fraserxu Jan 30, 2017
715071a
bump to v0.12.0
fraserxu Jan 30, 2017
19181d2
Replace React.PropTypes with the new standalone PropTypes
robinsoncol Apr 20, 2017
314b774
Update react version to match prop-types's react version requirements
robinsoncol Apr 21, 2017
69563e4
Merge pull request #50 from robinsoncol/standalone-prop-types
fraserxu Apr 25, 2017
52e3e30
0.13.0
fraserxu Apr 25, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import ChartistGraph from '../index';

class Pie extends React.Component {
class Bar extends React.Component {
render() {

var data = {
Expand Down Expand Up @@ -33,4 +33,4 @@ class Pie extends React.Component {
}
}

ReactDOM.render(<Pie />, document.getElementById('react-chart'))
ReactDOM.render(<Bar />, document.getElementById('react-chart'))
36 changes: 21 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

import React, {Component} from 'react';
import {findDOMNode} from 'react-dom';
import React, { Component, cloneElement, Children } from 'react';
import PropTypes from 'prop-types'

class ChartistGraph extends Component {

Expand Down Expand Up @@ -36,7 +34,7 @@ class ChartistGraph extends Component {
if (this.chartist) {
this.chartist.update(data, options, responsiveOptions);
} else {
this.chartist = new Chartist[type](findDOMNode(this), data, options, responsiveOptions);
this.chartist = new Chartist[type](this.refs.chart, data, options, responsiveOptions);

if (config.listener) {
for (event in config.listener) {
Expand All @@ -45,26 +43,34 @@ class ChartistGraph extends Component {
}
}
}

}

return this.chartist;
}

render() {
const className = this.props.className ? ' ' + this.props.className : ''
const style = this.props.style ? this.props.style : {};
return (<div className={'ct-chart' + className} style={style} />)
const { className, style, children, data, type } = this.props;
const childrenWithProps = children && Children.map(children, (child) => (
cloneElement(child, {
type,
data
})
));
return (
<div className={`ct-chart ${className || ''}`} ref='chart' style={style}>
{childrenWithProps}
</div>
)
}

}

ChartistGraph.propTypes = {
type: React.PropTypes.string.isRequired,
data: React.PropTypes.object.isRequired,
className: React.PropTypes.string,
options: React.PropTypes.object,
responsiveOptions: React.PropTypes.array
type: PropTypes.oneOf(['Line', 'Bar', 'Pie']).isRequired,
data: PropTypes.object.isRequired,
className: PropTypes.string,
options: PropTypes.object,
responsiveOptions: PropTypes.array,
style: PropTypes.object
}

export default ChartistGraph;
29 changes: 18 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-chartist",
"version": "0.10.1",
"version": "0.13.0",
"description": "React component for Chartist.js",
"main": "dist/index.js",
"repository": {
Expand All @@ -19,25 +19,32 @@
"email": "xvfeng123@gmail.com",
"url": "https://fraserxu.me"
},
"babel": {
"presets": [
"react",
"es2015",
"stage-0"
]
},
"license": "MIT",
"bugs": {
"url": "https://github.com/fraserxu/react-chartist/issues"
},
"homepage": "https://github.com/fraserxu/react-chartist",
"peerDependencies": {
"react": "^0.14.0",
"react-dom": "^0.14.0"
},
"dependencies": {
"chartist": "^0.9.4"
"chartist": "^0.10.1",
"react": "^0.14.9 || ^15.3.0"
},
"scripts": {
"build": "mkdir -p dist && babel index.js > dist/index.js"
"build": "mkdir -p dist && babel index.js -o dist/index.js"
},
"devDependencies": {
"babel": "^5.1.8",
"babelify": "^5.0.3",
"browserify": "^8.1.0",
"watchify": "^2.2.1"
"babel-cli": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0"
},
"dependencies": {
"prop-types": "^15.5.8"
}
}