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

Replace react-vis with Recharts #2242

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MarkPollmann
Copy link

Which problem is this PR solving?

Description of the changes

How was this change tested?

Checklist

@MarkPollmann
Copy link
Author

Tests in ScatterPlot are failing because the behavior of the plot changed, see screenshots. I'm new to jaeger so I don't know how how much I should change this behavior to resemble the old one. What do you think?

This is the new recharts version:
local

This is the version from docker-all-in-one:
docker

@yurishkuro
Copy link
Member

Please make sure your new commits are signed. See CONTRIBUTING.

Signed-off-by: Mark Pollmann <markpollmann@web.de>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

the behavior of the plot changed

What specific changes are you not sure about? The new chart looks good. Could use a bit smaller font. I like that the axis labels are now outside. But it's not possible to tell if the dynamic behavior changed, like the crosshair, point data tooltip, etc.

Suggestion: change y-axis to "Trace Duration", to be explicit.

@@ -130,8 +130,10 @@ const calcDisplayTimeUnit = (serviceLatencies: ServiceMetricsObject | ServiceMet
};

// export for tests
export const yAxisTickFormat = (timeInMS: number, displayTimeUnit: string) =>
convertToTimeUnit(timeInMS * 1000, displayTimeUnit);
export const yAxisTickFormat = (timeInMS: number, displayTimeUnit: string) => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export const yAxisTickFormat = (timeInMS: number, displayTimeUnit: string) => {
export const yAxisTickFormat = (timeInMS: number, displayTimeUnit: string): string => {

?

export const yAxisTickFormat = (timeInMS: number, displayTimeUnit: string) =>
convertToTimeUnit(timeInMS * 1000, displayTimeUnit);
export const yAxisTickFormat = (timeInMS: number, displayTimeUnit: string) => {
const formattedValue = convertToTimeUnit(timeInMS * 1000, displayTimeUnit);
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
const formattedValue = convertToTimeUnit(timeInMS * 1000, displayTimeUnit);
const scaledValue = convertToTimeUnit(timeInMS * 1000, displayTimeUnit);

@@ -20,23 +20,13 @@ exports[`<OperationsGraph> Graph rendered successfully 1`] = `
<div
className="ops-container"
>
<XYPlot
className=""
<ForwardRef
Copy link
Member

Choose a reason for hiding this comment

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

ideally we should get rid of snapshot testing here, such large snapshot is useless and highly dependent on implementation details of the lib

Comment on lines +68 to +69
<Area type="monotone" dataKey="y" stroke={color} fill={color} {...dynProps} />
<Line type="monotone" dataKey="y" stroke={color} {...dynProps} />
Copy link
Member

Choose a reason for hiding this comment

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

would be nice to comment what these two lines do

});

it('Crosshair map test', () => {
it('Tooltip test', () => {
Copy link
Member

Choose a reason for hiding this comment

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

This changes what the test was looking for. Is the crosshair pointer not available? Or we can't test for it? I assume it's just part of the style.

Comment on lines +148 to +150
`label: ${exampleEntry.payload.label * 100}`,
`x: ${formattedLabel}`,
`Y: ${exampleEntry.payload.y}`,
Copy link
Member

Choose a reason for hiding this comment

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

nit: this is testing production code with production code (akin to assert f(x) == f(x)). I would rather have precise strings in the expected dict - makes for a simpler and easier to read test, which is not tautological.

expect(markSeries.length).toEqual(1);

const circle = wrapper.find('.rv-xy-plot__series--mark circle:first-child');
const circle = wrapper.find(Tooltip);
Copy link
Member

Choose a reason for hiding this comment

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

why is this equivalent test?

expect(circle.length).toEqual(1);

circle.simulate('mouseOver');
const hint = wrapper.find(Hint);
const hint = wrapper.find(Tooltip);
Copy link
Member

Choose a reason for hiding this comment

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

why is this equivalent test?

@@ -191,7 +191,7 @@ export class UnconnectedSearchResults extends React.PureComponent<SearchResultsP
x: t.startTime,
y: t.duration,
traceID: t.traceID,
size: t.spans.length,
size: t.spans.length * 30,
Copy link
Member

Choose a reason for hiding this comment

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

what is the motivation for *30?

@MarkPollmann
Copy link
Author

Thanks for the review, @yurishkuro! Will try to finish it by Friday.

the behavior of the plot changed

What specific changes are you not sure about? The new chart looks good. Could use a bit smaller font. I like that the axis labels are now outside. But it's not possible to tell if the dynamic behavior changed, like the crosshair, point data tooltip, etc.

Mostly that the x-axis is no longer uniform in time. If you look at the screenshot of the docker version, every tick is around 17 minutes. In the recharts version the first tick is 2min, the next one is 45min. It scales automatically to 'un-bunch' the circles (pretty cool, actually).

@yurishkuro
Copy link
Member

Mostly that the x-axis is no longer uniform in time.

oh, wow, that's terrible. It only makes sense to do if it displayed some visual indicator of timeline tear, kind of like what GitHub is doing:
image

Can we set some option to use linear scale?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace react-vis library for drawing charts
2 participants