Skip to content

Commit

Permalink
fix(label): null value for series mark (#5099)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed May 26, 2023
1 parent 6de9e33 commit a1db7aa
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion __tests__/plots/interaction/unemployment-choropleth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ unemploymentChoropleth.steps = ({ canvas }) => {
const { document } = canvas;
const elements = document.getElementsByClassName(ELEMENT_CLASS_NAME);
const e = elements.find((d) => d.__data__.title === 6071);
console.log(e.__data__);
return [step(e, 'pointerover')];
};
18 changes: 18 additions & 0 deletions __tests__/plots/static/basic-line-null-label.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { G2Spec } from '../../../src';

export async function basicLineNullLabel(): Promise<G2Spec> {
return {
type: 'line',
data: [
{ name: 'MODIFY', value: 138, washaway: 0.21014492753623193 },
{ name: 'PRERELEASE', value: 109, washaway: 0.5596330275229358 },
{ name: 'RELEASING', value: 48, washaway: 0 },
{ name: 'XXX', value: null, washaway: 0 },
],
encode: {
x: 'name',
y: 'value',
},
labels: [{ text: 'name' }],
};
}
1 change: 1 addition & 0 deletions __tests__/plots/static/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,4 @@ export { aaplIntervalDateEncodeX } from './aapl-interval-date-encode-x';
export { athletesRectBinLegendStyle } from './athletes-rect-bin-legend-style';
export { HeatmapHeatmapBasic } from './heatmap-heatmap-basic';
export { DiamondHeatmapDensity } from './diamond-heatmap-density';
export { basicLineNullLabel } from './basic-line-null-label';
18 changes: 10 additions & 8 deletions src/runtime/plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1024,14 +1024,16 @@ function getLabels(
];
}
const selector = normalizeLabelSelector(label);
const F = SI.map((index: number, i: number) => ({
...label,
key: `${seriesKey[i]}-${labelIndex}`,
bounds: [points[i]],
index,
points,
dependentElement: element,
}));
const F = SI.filter((_, i) => points[i].every(defined)).map(
(index: number, i: number) => ({
...label,
key: `${seriesKey[i]}-${labelIndex}`,
bounds: [points[i]],
index,
points,
dependentElement: element,
}),
);
return selector ? selector(F) : F;
}

Expand Down

0 comments on commit a1db7aa

Please sign in to comment.