forked from adamwight/ores-reference-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
prediction_graph.jsx
39 lines (35 loc) · 851 Bytes
/
prediction_graph.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { Component } from 'react';
import Chart from 'chart.js';
class PredictionGraph extends Component {
componentDidMount() {
let chartCanvas = this.refs.chart,
data = {
labels: Object.keys( this.props.score.probability ),
datasets: [
{
label: 'Revision ' + this.props.rev_id,
data: Object.values( this.props.score.probability ),
// TODO: pallete
backgroundColor: 'rgb(50, 50, 50)'
},
]
};
/* eslint-disable no-new */
new Chart( chartCanvas, {
type: 'bar',
data: data,
options: {
title: {
display: true,
text: this.props.model + ' prediction for revision ID ' + this.props.rev_id + ' on ' + this.props.wiki
}
}
} );
}
render() {
return (
<canvas ref={ 'chart' } height="400" width="600"></canvas>
);
}
}
export default PredictionGraph;