Skip to content

Commit 92dfb1e

Browse files
committed
speedspacechart: rewrite steps and reticle management
- Gather steps rectangle, lines and title together - Hidden if the layer is disabled - Match style with mock-up (color, size, opacity) - Step snapping matches the mock-up - Add vetical and horizontal lines from crosshair to axis - Multiple small fixes Signed-off-by: Florian Amsallem <[email protected]>
1 parent 635c39d commit 92dfb1e

File tree

12 files changed

+323
-413
lines changed

12 files changed

+323
-413
lines changed

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui-speedspacechart/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@osrd-project/ui-core": "0.0.1-dev",
4141
"@osrd-project/ui-icons": "0.0.1-dev",
4242
"@types/d3": "^7.4.3",
43+
"chroma-js": "^3.1.1",
4344
"classnames": "^2.5.1",
4445
"d3": "^7.9.0",
4546
"tailwindcss": "^3.4.1"

ui-speedspacechart/src/components/SpeedSpaceChart.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ import SettingsPanel from './common/SettingsPanel';
55
import { LINEAR_LAYERS_HEIGHTS, MARGINS } from './const';
66
import { resetZoom } from './helpers/layersManager';
77
import {
8-
AxisLayerX,
8+
StepsLayer,
9+
AxisLayerY,
910
CurveLayer,
1011
DeclivityLayer,
1112
ElectricalProfileLayer,
1213
FrontInteractivityLayer,
1314
PowerRestrictionsLayer,
1415
ReticleLayer,
1516
SpeedLimitTagsLayer,
16-
StepLayer,
1717
TickLayerX,
18-
AxisLayerY,
1918
TickLayerYRight,
2019
} from './layers/index';
2120
import { getAdaptiveHeight, getGraphOffsets, getLinearLayerMarginTop } from './utils';
@@ -182,9 +181,8 @@ const SpeedSpaceChart = ({
182181
<DeclivityLayer width={WIDTH_OFFSET} height={HEIGHT_OFFSET} store={store} />
183182
)}
184183
<CurveLayer width={WIDTH_OFFSET} height={HEIGHT_OFFSET} store={store} />
185-
<AxisLayerX width={adjustedWidthRightAxis} height={height} store={store} />
186184
{store.layersDisplay.steps && (
187-
<StepLayer width={WIDTH_OFFSET} height={HEIGHT_OFFSET} store={store} />
185+
<StepsLayer width={adjustedWidthRightAxis} height={height} store={store} />
188186
)}
189187
<AxisLayerY width={width} height={height} store={store} />
190188
{store.layersDisplay.electricalProfiles && (

ui-speedspacechart/src/components/common/DetailsBox.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const DetailsBox = ({
3636
previousGradientText,
3737
modeText,
3838
}: DetailsBoxProps) => {
39-
const { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT } = MARGINS;
39+
const { MARGIN_BOTTOM, MARGIN_RIGHT } = MARGINS;
4040
const { energySource, tractionStatus, declivities, electricalProfiles, powerRestrictions } =
4141
store.detailsBoxDisplay;
4242

@@ -46,12 +46,12 @@ const DetailsBox = ({
4646
const adaptedOffset = store.isSettingsPanelOpened ? 641 : 115;
4747

4848
// find out if the box is going out off the right side of the canvas
49-
if (curveX + MARGIN_LEFT + adaptedOffset > width - MARGIN_RIGHT - 10) rightOffset = 127;
49+
if (curveX + adaptedOffset > width - MARGIN_RIGHT - 10) rightOffset = 127;
5050
// find out if the box is going out off the bottom side of the canvas
51-
if (curveY + MARGIN_TOP + 180 > height - MARGIN_BOTTOM - 10) bottomOffset = 192;
51+
if (curveY + 180 > height - MARGIN_BOTTOM - 10) bottomOffset = 192;
5252

53-
const boxX = curveX + MARGIN_LEFT + 6 - rightOffset;
54-
const boxY = curveY + MARGIN_TOP + 6 - bottomOffset;
53+
const boxX = curveX + 6 - rightOffset;
54+
const boxY = curveY + 6 - bottomOffset;
5555

5656
const speedDifference = Number(speedText) - Number(ecoSpeedText);
5757
const speedDifferenceText =

ui-speedspacechart/src/components/const.ts

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import chroma from 'chroma-js';
2+
13
import { type ColorDictionary, type Store } from '../types/chartTypes';
24

35
export const SLOPE_FILL_COLOR = '#CFDDCE';
@@ -23,6 +25,8 @@ export const MARGINS = {
2325
OFFSET_RIGHT_AXIS: 42,
2426
};
2527

28+
export const CURSOR_SNAP_DISTANCE = 6;
29+
2630
export const LINEAR_LAYERS_HEIGHTS = {
2731
ELECTRICAL_PROFILES_HEIGHT: 56,
2832
POWER_RESTRICTIONS_HEIGHT: 40,
@@ -63,6 +67,13 @@ export const LAYERS_SELECTION: Array<keyof Store['layersDisplay']> = [
6367
'speedLimitTags',
6468
];
6569

70+
// Colors
71+
72+
export const BLACK = chroma(0, 0, 0);
73+
export const GREY_50 = chroma(121, 118, 113);
74+
export const GREY_80 = chroma(49, 46, 43);
75+
export const LIGHT_BLUE = chroma(33, 112, 185);
76+
6677
/**
6778
* COLOR_DICTIONARY maps specific colors to their corresponding secondary colors used for speed limit tags.
6879
*/

ui-speedspacechart/src/components/helpers/drawElements/gridX.ts

-71
This file was deleted.

0 commit comments

Comments
 (0)