Skip to content

Commit

Permalink
fix(MicroBarChart): Add ellipsis and tooltip (#289)
Browse files Browse the repository at this point in the history
* fix(MicroBarChart): Add ellipsis to value on overflow, add title to label + value
  • Loading branch information
Lukas742 authored and MarcusNotheis committed Jan 23, 2020
1 parent c4568b9 commit 41f6971
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ exports[`Micro Bar Chart Renders with data 1`] = `
>
<span
class="MicroBarChart--label-"
title="Bar Number One"
>
Bar Number One
</span>
<span
class="MicroBarChart--text-"
style="font-size:12px"
title="10"
>
10
</span>
Expand All @@ -38,12 +40,14 @@ exports[`Micro Bar Chart Renders with data 1`] = `
>
<span
class="MicroBarChart--label-"
title="Bar Number Two"
>
Bar Number Two
</span>
<span
class="MicroBarChart--text-"
style="font-size:12px"
title="100"
>
100
</span>
Expand Down Expand Up @@ -73,12 +77,14 @@ exports[`Micro Bar Chart custom colors 1`] = `
>
<span
class="MicroBarChart--label-"
title="Bar Number One"
>
Bar Number One
</span>
<span
class="MicroBarChart--text-"
style="font-size:12px"
title="10"
>
10
</span>
Expand All @@ -101,12 +107,14 @@ exports[`Micro Bar Chart custom colors 1`] = `
>
<span
class="MicroBarChart--label-"
title="Bar Number Two"
>
Bar Number Two
</span>
<span
class="MicroBarChart--text-"
style="font-size:12px"
title="100"
>
100
</span>
Expand Down Expand Up @@ -136,12 +144,14 @@ exports[`Micro Bar Chart element selection 1`] = `
>
<span
class="MicroBarChart--label-"
title="Bar Number One"
>
Bar Number One
</span>
<span
class="MicroBarChart--text-"
style="font-size:12px"
title="10"
>
10
</span>
Expand Down Expand Up @@ -172,12 +182,14 @@ exports[`Micro Bar Chart maxWidth selection 1`] = `
>
<span
class="MicroBarChart--label-"
title="Bar Number One"
>
Bar Number One
</span>
<span
class="MicroBarChart--text-"
style="font-size:12px"
title="10"
>
10
</span>
Expand All @@ -200,12 +212,14 @@ exports[`Micro Bar Chart maxWidth selection 1`] = `
>
<span
class="MicroBarChart--label-"
title="Bar Number Two"
>
Bar Number Two
</span>
<span
class="MicroBarChart--text-"
style="font-size:12px"
title="100"
>
100
</span>
Expand Down
20 changes: 14 additions & 6 deletions packages/charts/src/components/MicroBarChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { resolveColors } from '../../util/populateData';
const BarStyles = {
container: {
display: 'flex',
flexDirection: 'column'
flexDirection: 'column',
overflow: 'hidden'
},
labelContainer: {
display: 'flex',
Expand All @@ -29,17 +30,21 @@ const BarStyles = {
fontWeight: 'normal',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
fontSize: '12px'
fontSize: '12px',
maxWidth: '70%'
},
text: {
paddingLeft: '6px',
display: 'inline-block',
overflow: 'hidden',
fontSize: '14px',
wordWrap: 'break-word',
boxSizing: 'border-box',
fontFamily: "'72', Arial, Helvetica, sans-serif",
fontWeight: 'normal',
whiteSpace: 'pre-line',
color: '#333333'
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
color: '#333333',
textAlign: 'right'
}
};

Expand Down Expand Up @@ -79,12 +84,15 @@ const MicroBarChart: FC<MicroBarChartPropTypes> = forwardRef(
return (
<div key={item.label}>
<div className={classes.labelContainer}>
<span className={classes.label}>{labelFormatter(item.label)}</span>
<span className={classes.label} title={`${labelFormatter(item.label)}`}>
{labelFormatter(item.label)}
</span>
<span
className={classes.text}
style={{
fontSize: '12px'
}}
title={`${valueFormatter(item.value)}`}
>
{valueFormatter(item.value)}
</span>
Expand Down

0 comments on commit 41f6971

Please sign in to comment.