import React from 'react'; import { SvgWrapper, ResponsiveWrapper } from 'app/shared/modules/chart/core'; import percentagePipe from 'app/shared/pipes/percent.pipe'; const PROGRESS_BAR_COLORS = [ '#B5E0F4', '#0073AB', '#4DB5AB', '#D6EAE9', ]; export const SUB_PROGRESS_COLOR = '#E69C56'; export const getProgressBarColor = (index: number) => { return PROGRESS_BAR_COLORS[index % PROGRESS_BAR_COLORS.length]; }; const defaultHeight = 16; const defaultFontSize = 12; const sum = (previousValue, currentValue) => previousValue + currentValue; const scaleValues = (values: number[], scale: number) => { const maxValue = values.reduce(sum, 0); return values.map(value => (value * scale) / maxValue); }; const getPercentages = (values: number[], subValues?: number[]) => { const maxValue = values.reduce(sum, 0); return values.map((value, index) => ({ value: percentagePipe.format(value * 100 / maxValue), position: values.slice(0, index).reduce(sum, 0) + value / 2, subValue: subValues && subValues[index] ? percentagePipe.format(subValues[index]) : undefined, })); }; export interface Props { values: number[]; barKey: string; subProgress?: number[]; } export const ProgressBar = ({ values, barKey, subProgress }: Props) => { return