mirror of
https://github.com/yldio/copilot.git
synced 2024-11-14 15:20:06 +02:00
41 lines
628 B
JavaScript
41 lines
628 B
JavaScript
|
const NVD3Chart = require('react-nvd3');
|
||
|
const React = require('react');
|
||
|
|
||
|
module.exports = ({
|
||
|
data
|
||
|
}) => {
|
||
|
const datum = [{
|
||
|
key: 'test',
|
||
|
values: (data || []).map((v, i) => ({
|
||
|
label: `${i}`,
|
||
|
value: v.cpu
|
||
|
}))
|
||
|
}];
|
||
|
|
||
|
const context = {
|
||
|
getColor: (i) => {
|
||
|
if (i.value > 50) {
|
||
|
return 'red';
|
||
|
}
|
||
|
|
||
|
return 'green';
|
||
|
}
|
||
|
};
|
||
|
|
||
|
const color = {
|
||
|
name: 'getColor',
|
||
|
type: 'function'
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<NVD3Chart
|
||
|
duration={0}
|
||
|
context={context}
|
||
|
color={color}
|
||
|
type='discreteBarChart'
|
||
|
datum={datum}
|
||
|
x='label'
|
||
|
y='value'
|
||
|
/>
|
||
|
);
|
||
|
};
|