Skip to content

Commit

Permalink
Add truncation of timeline label (#4990)
Browse files Browse the repository at this point in the history
* Add ellipse for long label in Timeline chart with a tooltip when too truncated. Also add padding between end of label and arrow.

* fix: limit width of left bar
  • Loading branch information
jCHENEBY authored Jan 16, 2025
1 parent 6908c32 commit b1d675f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 3 additions & 6 deletions packages/cbioportal-clinical-timeline/src/TrackHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import { TICK_AXIS_HEIGHT } from './TickAxis';
import { CustomTrackSpecification } from './CustomTrack';
import { TimelineStore } from './TimelineStore';
import { useObserver } from 'mobx-react-lite';
import { TruncatedText } from 'cbioportal-frontend-commons';
import { EllipsisTextTooltip } from 'cbioportal-frontend-commons';
import { isTrackVisible } from './lib/helpers';
import LineChartAxis, {
LINE_CHART_AXIS_SVG_WIDTH,
LINE_CHART_AXIS_TICK_WIDTH,
} from './LineChartAxis';
import LineChartAxis, { LINE_CHART_AXIS_SVG_WIDTH } from './LineChartAxis';
import ReactDOM from 'react-dom';

interface ITrackHeaderProps {
Expand Down Expand Up @@ -50,7 +47,7 @@ const TrackHeader: React.FunctionComponent<ITrackHeaderProps> = function({
onMouseLeave={handleTrackHover}
>
<span>
<TruncatedText text={getTrackLabel(track)} maxLength={20} />
<EllipsisTextTooltip text={getTrackLabel(track)} />
</span>
{isLineChartTrack && (
<div
Expand Down
8 changes: 6 additions & 2 deletions packages/cbioportal-clinical-timeline/src/timeline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,20 @@ $tl-fontsize: 12px;
}

.tl-timeline-leftbar {
max-width: 150px;
.tl-timeline-tracklabels {
overflow: hidden;
display: flex;
flex-direction: column;
font-size: $tl-fontsize;
font-size: 12.5px; // The first tooltip does not show up if the font-size is too small (<12px)
> div {
white-space: nowrap;
border-bottom: 1px dashed #eee;
padding-right: 10px;
padding-right: 15px;
padding-top: 2px;
overflow: hidden;
text-overflow: ellipsis;
//max-width: 100%;
}
}
}
Expand Down

0 comments on commit b1d675f

Please sign in to comment.