Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui-speedspacechart: speed limit tags enhancements #560

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Caracol3
Copy link

  • adding logic to make the tooltip follow the cursor move horizontally and vertically
  • sticking the tooltip to the chart when the cursor goes outside
  • adding logic to prevent text going outside its tag
    Signed-off-by: Mathieu [email protected]

@Caracol3 Caracol3 requested a review from a team as a code owner September 26, 2024 19:28
@Caracol3 Caracol3 added kind:bug Something isn't working enhancement New feature or request ui-speed-space-chart area:front labels Sep 26, 2024
- adding logic to make the tooltip follow the cursor move horizontally and vertically
- sticking the tooltip to the chart when the cursor goes outside
- adding logic to prevent text going outside its tag

Signed-off-by: Mathieu <[email protected]>
@Caracol3 Caracol3 force-pushed the mcy/speedspachechart-speed-limit-tags-linear-layer-enhancements branch from 2255b77 to 960c78a Compare September 27, 2024 08:21
Comment on lines 31 to +32
const TEXT_LEFT_PADDING = 4;
const TEXT_RIGHT_PADDING = 8;
const FIRST_TAG_LEFT_PADDING = 8;
const TEXT_RIGHT_PADDING = 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can merge:

  • TEXT_LEFT_PADDING and TEXT_RIGHT_PADDING to TEXT_PADDING
  • ICON_WIDTH and ICON_RIGHT to ICON_SIZE
  • ICON_BACKGROUND_WIDTH and ICON_BACKGROUND_HEIGHT to ICON_BACKGROUND_SIZE

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we talked about it but if i think it will be a problem with the logic then.
like here:

const textRectWidth = Math.min(
            actualTextWidth + TEXT_LEFT_PADDING + TEXT_RIGHT_PADDING,
            tagWidth
          );

Copy link
Contributor

@Yohh Yohh Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const textRectWidth = Math.min(
            actualTextWidth + TEXT_PADDING * 2,
            tagWidth
          );

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's more readable, no problem to change this. I thought it was clearer to understand by adding the two paddings, but indeed, apart from left and right, we don't have other options, so go for '*2'.

@@ -160,18 +136,62 @@ export const drawSpeedLimitTags = async ({
) {
tooltip = {
cursorX: cursor.x + MARGIN_LEFT,
cursorY: Y_POSITION,
cursorY: cursor.y,
text: 'Incompatible with the infrastructure',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: 'Incompatible with the infrastructure',
text: 'Incompatible with the infrastructure',

we should begin to add those texts in the user translations object prop, then keep this trad as a placeholder

tagWidth
);

ctx.save();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ctx.save();

seems useless

textRectWidth - TEXT_LEFT_PADDING
);

ctx.restore();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ctx.restore();

seems useless


ctx.strokeRect(x, Y_POSITION, tagWidth, RECT_HEIGHT);

if (tag === 'UU') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't use it anymore, is it still usefull?

Comment on lines -14 to +19
tag_name: 'UU',
color: '#D91C1C',
tag_name: 'MA100',
color: '#494641',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional to replace the UU tag with MA100 here? I noticed that you check the UU tag on line 188 in SpeedLimitTags, and it duplicates the MA100 tag at the same time.

Comment on lines +18 to +26
const constrainTooltipPosition = (cursorX: number, width: number, tooltipWidth: number) => {
if (cursorX - tooltipWidth / 2 < LEFT_MARGIN) {
return LEFT_MARGIN + tooltipWidth / 2;
}
if (cursorX + tooltipWidth / 2 > width - RIGHT_MARGIN) {
return width - RIGHT_MARGIN - tooltipWidth / 2;
}
return cursorX;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move this function to utils? It would also be great if you could add a unit test.

@Yohh
Copy link
Contributor

Yohh commented Sep 27, 2024

there is a strange white border next to the EVO or MA100 tag :
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front enhancement New feature or request kind:bug Something isn't working ui-speed-space-chart
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants