Skip to content

Commit

Permalink
consider single point visibility on auto
Browse files Browse the repository at this point in the history
  • Loading branch information
markov00 committed Dec 4, 2024
1 parent 0d381a3 commit e2caae9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export function renderPoints(
pointsDistanceVisibilityThreshold: number,
hasConnectingLine: boolean,
) {
// seriesMinPointDistance could be Infinity if we don't have points, or we just have a single point per series.
// In this case the point should be visible if the visibility style is set to `auto`
const isHiddenOnAuto = pointStyle.visible === 'auto' && seriesMinPointDistance < pointsDistanceVisibilityThreshold;
const hideDataPoints = pointStyle.visible === 'never' || isHiddenOnAuto;
const hideIsolatedDataPoints = hasConnectingLine && hideDataPoints;
Expand Down
4 changes: 2 additions & 2 deletions packages/charts/src/chart_types/xy_chart/state/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ function renderGeometries(
bubblePoints: 0,
};
const barsPadding = enableHistogramMode ? chartTheme.scales.histogramPadding : chartTheme.scales.barsPadding;
// This var remains Infinity if we don't have points, or we just have a single point per series.
// In this case the point should be visible if the visibility style is set to `auto`
let globalMinPointsDistance = Infinity;
dataSeries.forEach((ds) => {
const spec = getSpecsById<BasicSeriesSpec>(seriesSpecs, ds.specId);
Expand Down Expand Up @@ -491,8 +493,6 @@ function renderGeometries(
}
});

globalMinPointsDistance = isFiniteNumber(globalMinPointsDistance) ? globalMinPointsDistance : 0;

return {
geometries: {
bars,
Expand Down

0 comments on commit e2caae9

Please sign in to comment.