summaryrefslogtreecommitdiffstats
path: root/web/react/components/admin_console/line_chart.jsx
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-10-27 11:40:49 -0700
committerCorey Hulen <corey@hulen.com>2015-10-27 11:40:49 -0700
commite0f69060fa462390779dd7b4cf6b67a12c3974ba (patch)
treeb1ea3f745c2607a0f12eaa0af18db3c4c846ab63 /web/react/components/admin_console/line_chart.jsx
parent4dbde3e1d8f6c6a7087c6af1407140a7b250c8d0 (diff)
parent399e9c6f4bbed7f9eac0a75242ec75e4b0d2bb59 (diff)
downloadchat-e0f69060fa462390779dd7b4cf6b67a12c3974ba.tar.gz
chat-e0f69060fa462390779dd7b4cf6b67a12c3974ba.tar.bz2
chat-e0f69060fa462390779dd7b4cf6b67a12c3974ba.zip
Merge pull request #1190 from mattermost/PLT-25
PLT-25 adding stats to admin console
Diffstat (limited to 'web/react/components/admin_console/line_chart.jsx')
-rw-r--r--web/react/components/admin_console/line_chart.jsx50
1 files changed, 50 insertions, 0 deletions
diff --git a/web/react/components/admin_console/line_chart.jsx b/web/react/components/admin_console/line_chart.jsx
new file mode 100644
index 000000000..7e2f95c84
--- /dev/null
+++ b/web/react/components/admin_console/line_chart.jsx
@@ -0,0 +1,50 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+export default class LineChart extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.initChart = this.initChart.bind(this);
+ this.chart = null;
+ }
+
+ componentDidMount() {
+ this.initChart(this.props);
+ }
+
+ componentWillReceiveProps(nextProps) {
+ if (this.chart) {
+ this.chart.destroy();
+ this.initChart(nextProps);
+ }
+ }
+
+ componentWillUnmount() {
+ if (this.chart) {
+ this.chart.destroy();
+ }
+ }
+
+ initChart(props) {
+ var el = ReactDOM.findDOMNode(this);
+ var ctx = el.getContext('2d');
+ this.chart = new Chart(ctx).Line(props.data, props.options || {}); //eslint-disable-line new-cap
+ }
+
+ render() {
+ return (
+ <canvas
+ width={this.props.width}
+ height={this.props.height}
+ />
+ );
+ }
+}
+
+LineChart.propTypes = {
+ width: React.PropTypes.string,
+ height: React.PropTypes.string,
+ data: React.PropTypes.object,
+ options: React.PropTypes.object
+};