Add more reports
This commit is contained in:
@ -7,17 +7,17 @@ module.exports = React.createClass({
|
||||
render: function() {
|
||||
/* Expects 'this.props.data' to be in the form:
|
||||
* var data = [
|
||||
* {'label': 'foo', 'value': 1.4},
|
||||
* {'label': 'bar', 'value': 8}
|
||||
* {'Label': 'foo', 'Value': 1.4},
|
||||
* {'Label': 'bar', 'Value': 8}
|
||||
* ];
|
||||
*/
|
||||
if (this.props.data.length < 1)
|
||||
return (<div />);
|
||||
|
||||
var max = parseFloat(this.props.data[0].value);
|
||||
var min = parseFloat(this.props.data[0].value);
|
||||
var max = parseFloat(this.props.data[0].Value);
|
||||
var min = parseFloat(this.props.data[0].Value);
|
||||
for (var i = 0; i < this.props.data.length; i++) {
|
||||
var cur = parseFloat(this.props.data[i].value);
|
||||
var cur = parseFloat(this.props.data[i].Value);
|
||||
if (cur > max)
|
||||
max = cur;
|
||||
if (cur < min)
|
||||
@ -30,12 +30,12 @@ module.exports = React.createClass({
|
||||
if ((max - min) == 0.0)
|
||||
var percent = 100;
|
||||
else if (min < 0)
|
||||
var percent = 100*(parseFloat(rowData.value)-min)/(max-min);
|
||||
var percent = 100*(parseFloat(rowData.Value)-min)/(max-min);
|
||||
else
|
||||
var percent = 100*parseFloat(rowData.value)/max;
|
||||
var percent = 100*parseFloat(rowData.Value)/max;
|
||||
rows.push((
|
||||
<tr key={i}>
|
||||
<td style={{'width': '20%'}}>{rowData.label + " (" + rowData.value + ")"}</td>
|
||||
<td style={{'width': '20%'}}>{rowData.Label + " (" + rowData.Value + ")"}</td>
|
||||
<td style={{'width': '80%'}}><div style={{'width': percent + "%", 'backgroundColor': 'steelblue'}}> </div></td>
|
||||
</tr>
|
||||
));
|
||||
|
Reference in New Issue
Block a user