Skip to content

Commit

Permalink
fix: filter highlighted y values
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Oct 6, 2020
1 parent 219f9dd commit 11ecc8e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
7 changes: 6 additions & 1 deletion .playground/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ export const SWIM_LANE_DATA = [
export class Playground extends React.Component<any, { highlightedData?: HeatmapSpec['highlightedData'] }> {
constructor(props: any) {
super(props);
this.state = {};
this.state = {
highlightedData: {
x: [1572874200000, 1572897600000],
y: ['Overall', 'test'],
},
};
}

onBrushEnd: HeatmapConfig['onBrushEnd'] = (e) => {
Expand Down
22 changes: 12 additions & 10 deletions src/chart_types/heatmap/layout/viewmodel/viewmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,18 @@ export function shapeViewModel(
const width = endFromScale - startFromScale + (isOutOfRange ? cellWidth : 0);

// resolve Y coordinated making sure the order is correct
const { y: yStart, totalHeight } = y.reduce(
(acc, current, i) => {
if (i === 0) {
acc.y = yScale(current) || 0;
}
acc.totalHeight += cellHeight;
return acc;
},
{ y: 0, totalHeight: 0 },
);
const { y: yStart, totalHeight } = y
.filter((v) => yValues.includes(v))
.reduce(
(acc, current, i) => {
if (i === 0) {
acc.y = yScale(current) || 0;
}
acc.totalHeight += cellHeight;
return acc;
},
{ y: 0, totalHeight: 0 },
);

return {
x: xStart,
Expand Down

0 comments on commit 11ecc8e

Please sign in to comment.