Skip to content

Commit

Permalink
fix(xy): disable legend extra on ordinal (#2114)
Browse files Browse the repository at this point in the history
This commit disables the legend extra value when using an ordinal scale.
The major changes, visible also on the changes in the screenshot testing are
- no space left at the right of each legend item for ordinal x scale series
- no visible current value in the legend item when hovering over a chart with ordinal values

BREAKING CHANGE: when using the `ScaleType.Ordinal` for the X scale the legend extra value, representing the last and current hovered value, will not be shown.
  • Loading branch information
markov00 authored Aug 4, 2023
1 parent fd2bca4 commit 3ddfb18
Show file tree
Hide file tree
Showing 81 changed files with 12 additions and 2 deletions.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
* Side Public License, v 1.
*/

import { getComputedScalesSelector } from './get_computed_scales';
import { getTooltipInfoAndGeomsSelector } from './get_tooltip_values_highlighted_geoms';
import { LegendItemExtraValues } from '../../../../common/legend';
import { SeriesKey } from '../../../../common/series_id';
import { ScaleType } from '../../../../scales/constants';
import { createCustomCachedSelector } from '../../../../state/create_selector';
import { getLegendItemExtraValues } from '../../tooltip/tooltip';

const EMPTY_MAP = new Map();
/** @internal */
export const getLegendItemExtraValuesSelector = createCustomCachedSelector(
[getTooltipInfoAndGeomsSelector],
({ tooltip: { values } }): Map<SeriesKey, LegendItemExtraValues> => getLegendItemExtraValues(values),
[getTooltipInfoAndGeomsSelector, getComputedScalesSelector],
({ tooltip: { values } }, { xScale: { type } }): Map<SeriesKey, LegendItemExtraValues> =>
// See https://github.com/elastic/elastic-charts/issues/2050
type === ScaleType.Ordinal ? EMPTY_MAP : getLegendItemExtraValues(values),
);
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { LastValues } from './types';
import { SeriesKey } from '../../../../common/series_id';
import { ScaleType } from '../../../../scales/constants';
import { XDomain } from '../../domains/types';
import { isDatumFilled } from '../../rendering/utils';
import { DataSeries, getSeriesKey, XYChartSeriesIdentifier } from '../../utils/series';
Expand All @@ -19,6 +20,10 @@ import { StackMode } from '../../utils/specs';
* @param xDomain
*/
export function getLastValues(dataSeries: DataSeries[], xDomain: XDomain): Map<SeriesKey, LastValues> {
// See https://github.com/elastic/elastic-charts/issues/2050
if (xDomain.type === ScaleType.Ordinal) {
return new Map();
}
const lastValues = new Map<SeriesKey, LastValues>();

// we need to get the latest
Expand Down

0 comments on commit 3ddfb18

Please sign in to comment.