import React, { PropTypes } from 'react'; import { VictoryAxis, VictoryChart, VictoryLine } from 'victory'; import { formatBytes, formatNumber } from './../util'; import moment from 'moment'; import simplify from 'simplify-js'; import theme from './../theme'; const _formatIndependentAxis = tick => { return moment(tick).format('HH:mm:ss'); }; const _formatDependentAxis = (tick, format) => ( format === 'bytes' ? formatBytes(tick, 1) : formatNumber(tick, 1) ); // Uses simplifyJS to simplify the data from the backend (there can be up to // 8000 points so this step is necessary). Because of the format expectations // of simplifyJS, we need to convert x's to ints and back to moments. const _simplify = data => { if (data.length === 0) return []; return simplify( data.map(d => ({x: moment(d.x).valueOf(), y: d.y})) ).map(d => ({x: moment(d.x), y: d.y})); } const styles = { title: { fontSize: 22, fontWeight: 300, textAlign: 'center', margin: 0 } }; const LineChart = ({data, format, title}) => { return (