import React, { FC } from 'react'; import { UncontrolledTooltip } from 'reactstrap'; import { Histogram } from '../../types/types'; import { bucketRangeString } from './DataTable'; const HistogramChart: FC<{ histogram: Histogram; index: number }> = ({ index, histogram }) => { const { buckets } = histogram; const rangeMax = buckets ? parseFloat(buckets[buckets.length - 1][2]) : 0; const countMax = buckets ? buckets.map((b) => parseFloat(b[3])).reduce((a, b) => Math.max(a, b)) : 0; const formatter = Intl.NumberFormat('en', { notation: 'compact' }); return (
{[1, 0.75, 0.5, 0.25].map((i) => (
{formatter.format(countMax * i)}
))}
0
{[0, 0.25, 0.5, 0.75, 1].map((i) => (
))} {buckets?.map((b, bIdx) => (
range: {bucketRangeString(b)}
count: {b[3]}
))}
0
{[0.25, 0.5, 0.75, 1].map((i) => (
{formatter.format(rangeMax * i)}
))}
); }; export default HistogramChart;