import React from 'react'; import { Styles, CountBadge } from '../common'; import { CloseButton, Loader } from 'UI'; import { ResponsiveContainer, AreaChart, XAxis, YAxis, Area, Tooltip } from 'recharts'; import { numberWithCommas } from 'App/utils'; import cn from 'classnames'; import stl from './trendChart.css'; const loadChart = (data, loading, unit, syncId, compare, tooltipLael) => { const gradientDef = Styles.gradientDef(); return (
{gradientDef}
) } const countView = (avg, unit) => { if (unit === 'mb') { if (!avg) return 0; const count = Math.trunc(avg / 1024 / 1024); return numberWithCommas(count); } if (unit === 'min') { if (!avg) return 0; const count = Math.trunc(avg); return numberWithCommas(count > 1000 ? count +'k' : count); } return avg ? numberWithCommas(avg): 0; } function TrendChart({ loading = true, title, avg, progress, unit = false, subtext, data, handleRemove, compare = false, comparing = false, syncId = '', tooltipLael = '', textClass ='', prefix = '', canRemove = true }) { return (
{ canRemove && ( )}
{comparing &&
}
{ title }
{prefix} {/*
*/} {/*
*/} {/*
*/}
{ loadChart(data, loading, unit, syncId, compare, tooltipLael) }
) } export default TrendChart