2019-12-08 22:43:49 +01:00
|
|
|
/** @jsx React.DOM */
|
|
|
|
|
2022-10-08 20:37:38 +02:00
|
|
|
var Graph = createReactClass({
|
2019-12-08 22:43:49 +01:00
|
|
|
componentDidMount: function() {
|
|
|
|
var config = {
|
|
|
|
type: this.props.type,
|
|
|
|
data: this.props.data,
|
|
|
|
options: this.props.options || {},
|
|
|
|
};
|
|
|
|
this.chart_instance = new Chart(this.element, config);
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount: function() {
|
|
|
|
this.chart_instance.destroy();
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillReceiveProps: function(nextProps) {
|
|
|
|
const dataChanged = this.props.data !== nextProps.data;
|
|
|
|
const optionsChanged = this.props.options !== nextProps.options;
|
|
|
|
if (optionsChanged || dataChanged) {
|
|
|
|
this.chart_instance.destroy();
|
|
|
|
var config = {
|
|
|
|
type: this.props.type,
|
|
|
|
data: nextProps.data,
|
|
|
|
options: nextProps.options || {},
|
|
|
|
};
|
|
|
|
this.chart_instance = new Chart(this.element, config);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
ref: function(element) {
|
|
|
|
this.element = element;
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<canvas
|
|
|
|
ref={this.ref}
|
|
|
|
height={this.props.height}
|
|
|
|
width={this.props.width}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2022-10-08 20:37:38 +02:00
|
|
|
var LineGraph = createReactClass({
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<Graph
|
|
|
|
type="line"
|
|
|
|
data={this.props.data}
|
|
|
|
options={this.props.options}
|
|
|
|
width={this.props.width}
|
|
|
|
height={this.props.height}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-10-08 20:37:38 +02:00
|
|
|
var RadarGraph = createReactClass({
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<Graph
|
|
|
|
type="radar"
|
|
|
|
data={this.props.data}
|
|
|
|
options={this.props.options}
|
|
|
|
width={this.props.width}
|
|
|
|
height={this.props.height}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|