Skip to content

Commit fb3b3bd

Browse files
committed
ui-spacetimechart: fix spacetimechart scaling
When the first waypoint or first x waypoints were hidden, the space time chart wouldn't display the corresponding curve in linear mode Signed-off-by: SharglutDev <[email protected]>
1 parent 16a2060 commit fb3b3bd

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

ui-manchette-with-spacetimechart/src/__tests__/helpers.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ describe('getScales', () => {
221221
yZoom: 1,
222222
});
223223

224-
expect(result).toHaveLength(1);
224+
expect(result).toHaveLength(2);
225225
expect(result[0].size).toBeDefined();
226226
expect(result[0].coefficient).not.toBeDefined();
227227
});

ui-spacetimechart/src/components/SpaceTimeChart.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const SpaceTimeChart = (props: SpaceTimeChartProps) => {
107107
}
108108

109109
const getTimePixel = getTimeToPixel(timeOrigin, timePixelOffset, timeScale);
110-
const getSpacePixel = getSpaceToPixel(spaceOrigin, spacePixelOffset, spaceScaleTree);
110+
const getSpacePixel = getSpaceToPixel(spacePixelOffset, spaceScaleTree);
111111
const getPoint = getDataToPoint(getTimePixel, getSpacePixel, timeAxis, spaceAxis);
112112
const getTime = getPixelToTime(timeOrigin, timePixelOffset, timeScale);
113113
const getSpace = getPixelToSpace(spaceOrigin, spacePixelOffset, spaceScaleTree);

ui-spacetimechart/src/utils/scales.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,11 @@ export function getPixelToTime(
153153
}
154154

155155
export function getSpaceToPixel(
156-
spaceOrigin: number,
157156
pixelOffset: number,
158157
binaryTree: NormalizedScaleTree
159158
): SpaceToPixel {
160159
return (position: number) => {
161-
const { from, pixelFrom, coefficient } = getNormalizedScaleAtPosition(
162-
position - spaceOrigin,
163-
binaryTree
164-
);
160+
const { from, pixelFrom, coefficient } = getNormalizedScaleAtPosition(position, binaryTree);
165161
return pixelOffset + pixelFrom + (position - from) / coefficient;
166162
};
167163
}

0 commit comments

Comments
 (0)