Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1848,8 +1848,8 @@ export type LegendItemValue = {

// @public (undocumented)
export interface LegendLabelOptions {
maxLines?: number;
widthLimit?: number;
maxLines: number;
widthLimit: number;
}

// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe('Computed chart dimensions', () => {
margin: 0,
labelOptions: {
maxLines: 1,
widthLimit: 250,
},
};
const defaultTheme = LIGHT_THEME;
Expand Down
6 changes: 3 additions & 3 deletions packages/charts/src/components/legend/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function Label({
[onToggle],
);

const title = options.maxLines ?? 1 > 0 ? label : ''; // full text already visible
const title = Math.abs(options.maxLines) > 0 ? label : ''; // full text already visible

return isToggleable ? (
// This div is required to allow multiline text truncation, all ARIA requirements are still met
Expand Down Expand Up @@ -135,8 +135,8 @@ function getSharedProps(
isToggleable?: boolean,
truncationMode: TruncationMode = 'line',
) {
const maxLines = Math.abs(options.maxLines ?? 1);
const widthLimit = Math.abs(options.widthLimit ?? 250);
const maxLines = Math.abs(options.maxLines);
const widthLimit = Math.abs(options.widthLimit);
const className = classNames('echLegendItem__label', {
'echLegendItem__label--clickable': Boolean(isToggleable),
'echLegendItem__label--singleline': maxLines === 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/charts/src/state/selectors/get_legend_size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const getLegendSizeSelector = createCustomCachedSelector(
: bbox.height * 2 + 24;
} else {
// This section is related to the list layout
const widthLimit = Math.abs(theme.legend.labelOptions.widthLimit ?? 250);
const widthLimit = Math.abs(theme.legend.labelOptions.widthLimit);
const { isSingleLine, isMoreThanTwoLines } = withTextMeasure((textMeasure) =>
computeHorizontalLegendRowCount({
items,
Expand Down
3 changes: 2 additions & 1 deletion packages/charts/src/utils/themes/amsterdam_dark_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export const AMSTERDAM_DARK_THEME: Theme = {
margin: 0,
labelOptions: {
maxLines: 1,
widthLimit: 250,
},
},
crosshair: {
Expand Down Expand Up @@ -434,7 +435,7 @@ export const AMSTERDAM_DARK_THEME: Theme = {
emptyBackground: Colors.Transparent.keyword,
nonFiniteText: 'N/A',
minHeight: 64,
titleWeight: 'bold',
titleWeight: 500,
},
bulletGraph: {
textColor: '#E0E5EE',
Expand Down
3 changes: 2 additions & 1 deletion packages/charts/src/utils/themes/amsterdam_light_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export const AMSTERDAM_LIGHT_THEME: Theme = {
margin: 0,
labelOptions: {
maxLines: 1,
widthLimit: 250,
},
},
crosshair: {
Expand Down Expand Up @@ -434,7 +435,7 @@ export const AMSTERDAM_LIGHT_THEME: Theme = {
emptyBackground: Colors.Transparent.keyword,
nonFiniteText: 'N/A',
minHeight: 64,
titleWeight: 'bold',
titleWeight: 500,
},
bulletGraph: {
textColor: '#343741',
Expand Down
3 changes: 2 additions & 1 deletion packages/charts/src/utils/themes/dark_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export const DARK_THEME: Theme = {
margin: 0,
labelOptions: {
maxLines: 1,
widthLimit: 250,
},
},
crosshair: {
Expand Down Expand Up @@ -457,7 +458,7 @@ export const DARK_THEME: Theme = {
emptyBackground: Colors.Transparent.keyword,
nonFiniteText: 'N/A',
minHeight: 64,
titleWeight: 'bold',
titleWeight: 500,
},
bulletGraph: DARK_THEME_BULLET_STYLE,
tooltip: {
Expand Down
3 changes: 2 additions & 1 deletion packages/charts/src/utils/themes/legacy_dark_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export const LEGACY_DARK_THEME: Theme = {
margin: 0,
labelOptions: {
maxLines: 1,
widthLimit: 250,
},
},
crosshair: {
Expand Down Expand Up @@ -438,7 +439,7 @@ export const LEGACY_DARK_THEME: Theme = {
emptyBackground: Colors.Transparent.keyword,
nonFiniteText: 'N/A',
minHeight: 64,
titleWeight: 'bold',
titleWeight: 500,
},
bulletGraph: DARK_THEME_BULLET_STYLE,
tooltip: {
Expand Down
3 changes: 2 additions & 1 deletion packages/charts/src/utils/themes/legacy_light_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export const LEGACY_LIGHT_THEME: Theme = {
margin: 0,
labelOptions: {
maxLines: 1,
widthLimit: 250,
},
},
crosshair: {
Expand Down Expand Up @@ -437,7 +438,7 @@ export const LEGACY_LIGHT_THEME: Theme = {
emptyBackground: Colors.Transparent.keyword,
nonFiniteText: 'N/A',
minHeight: 64,
titleWeight: 'bold',
titleWeight: 500,
},
bulletGraph: LIGHT_THEME_BULLET_STYLE,
tooltip: {
Expand Down
3 changes: 2 additions & 1 deletion packages/charts/src/utils/themes/light_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export const LIGHT_THEME: Theme = {
margin: 0,
labelOptions: {
maxLines: 1,
widthLimit: 250,
},
},
crosshair: {
Expand Down Expand Up @@ -456,7 +457,7 @@ export const LIGHT_THEME: Theme = {
emptyBackground: Colors.Transparent.keyword,
nonFiniteText: 'N/A',
minHeight: 64,
titleWeight: 'bold',
titleWeight: 500,
},
bulletGraph: LIGHT_THEME_BULLET_STYLE,
tooltip: {
Expand Down
8 changes: 2 additions & 6 deletions packages/charts/src/utils/themes/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,19 +400,15 @@ export interface LegendLabelOptions {
* Sets maxlines allowable before truncating
*
* Setting value to `0` will _never_ truncate the text
*
* @defaultValue 1
*/
maxLines?: number;
maxLines: number;
/**
* Sets widthLimit allowable before truncating (unit: px)
* Only applicable if the list layout is chosen for the top and bottom positions
*
* Setting value to `0` will _never_ truncate the text
*
* @defaultValue 250
*/
widthLimit?: number;
widthLimit: number;
}

/** @public */
Expand Down
1 change: 1 addition & 0 deletions storybook/stories/legend/11_legend_actions.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const getLabelOptionKnobs = (): LegendLabelOptions => {

return {
maxLines: number('max label lines', 1, { min: 0, step: 1 }, group),
widthLimit: 250,
};
};

Expand Down
1 change: 1 addition & 0 deletions storybook/stories/legend/17_tabular_data.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const getLabelOptionKnobs = (): LegendLabelOptions => {

return {
maxLines: number('max label lines', 1, { min: 0, step: 1 }, group),
widthLimit: 250,
};
};

Expand Down
2 changes: 2 additions & 0 deletions storybook/stories/legend/2_legend_layout.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ const getLabelOptionKnobs = (isLineLimit: boolean): LegendLabelOptions => {
return isLineLimit
? {
maxLines: number('max label lines', 1, { min: 0, step: 1 }, group),
widthLimit: 250,
}
: {
maxLines: 1,
widthLimit: number('width limit', 250, { min: 0, step: 1 }, group),
};
};
Expand Down