import React from 'react'; import { getNumberRangeLabel, getSortedSampleInfo, } from 'pages/patientView/timeline/TimelineWrapperUtils'; import { getTextWidth } from 'cbioportal-frontend-commons'; import _ from 'lodash'; const SampleMarker: React.FunctionComponent<{ color: string; label: string; y: number; }> = function({ color, label, y }) { return ( {label} ); }; export const MultipleSampleMarker: React.FunctionComponent<{ colors: string[]; // same length as labels labels: string[]; y: number; }> = function({ colors, labels, y }) { const sortedSampleInfo = getSortedSampleInfo(colors, labels); const label = getNumberRangeLabel(sortedSampleInfo.map(p => p.label)); const labelWidth = Math.ceil(getTextWidth(label, 'Arial', '10px')); const rectPadding = 4; const rectWidth = labelWidth + 2 * rectPadding; const rectHeight = 14; const clipPathId = `clipPath_${Math.random()}`; const uniqueColors = _.uniq(sortedSampleInfo.map(p => p.color)); const colorRectWidth = rectWidth / uniqueColors.length; return ( {uniqueColors.map((color, index) => ( ))} {label} ); }; export default SampleMarker;