joyent-portal/legacy/spikes/graphs-matrix/nvd3/client/chart.js
Sérgio Ramos 8295bd6882 chore: initial lerna setup
this shall be a progressive process
2017-05-25 10:56:50 +01:00

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'
/>
);
};