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 #2558

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

navaneeth-dev
Copy link

@navaneeth-dev navaneeth-dev commented Jan 6, 2025

Which problem is this PR solving?

Description of the changes

Still work in progress, copying all the changes from previous PR #2242 and implementing the needed tests.

How was this change tested?

  • npm run start
  • npm run build
  • npm run test

Checklist

@navaneeth-dev
Copy link
Author

navaneeth-dev commented Jan 7, 2025

@yurishkuro My first step is replacing the search page and get the tests working, then move on to other pages.

Changes made that are different from the original PR:

  1. Fixes non-uniform time: Max 4 ticks, interval evenly calculated from start and end in generateTicks()
  2. Made Y Axis label "Trace duration"

image

image

Which should we use? Should the cells clip at the edge like the second one?

TODO: Working on making cell size similar to the current behavior.

Thanks in advance.

@yurishkuro
Copy link
Member

Aside from color scheme the chart looks ok to me. Just make sure all existing behaviors are supported, like hover.

I would add more x-axis ticks. How does grafana do it?

@navaneeth-dev
Copy link
Author

navaneeth-dev commented Jan 7, 2025

Yes hover is already working.

Grafana does intervals according to scrape_interval in Prometheus (default 15 seconds).

image

@yurishkuro
Copy link
Member

Grafana does intervals according to scrape_interval in Prometheus

but what if I select a larger time range? Doing ticks at scrape intervals would cause labels to overlap.

@yurishkuro
Copy link
Member

please make sure you work off up to date main branch, you already have merge conflicts

@navaneeth-dev
Copy link
Author

but what if I select a larger time range? Doing ticks at scrape intervals would cause labels to overlap.

Just checked Grafana, for 2 days they do 2 hours intervals and even when resizing they reduce the tick count.

Do you want Grafana like behavior?

@yurishkuro
Copy link
Member

Do you want Grafana like behavior?

I don't care about it being specifically Grafana-like, just that the ticks need to adjust depending on the time range of the query, but also the screen size. E.g. in your screenshot you can easily go from 4 to 8 ticks, which will increase readability, but if I start reducing the screen width the 8 ticks might start overlapping, so what is the solution to that?

@navaneeth-dev navaneeth-dev force-pushed the replace-react-vis branch 2 times, most recently from 84a5b73 to 5a4e614 Compare January 7, 2025 17:54
@navaneeth-dev
Copy link
Author

Fixed merge conflicts. Do you recommend rebasing every day before starting work on a feature?

We can make it responsive by calculating number of ticks based on containerWidth variable using some math functions with fixed size of date tick size. Meaning, check how many of ticks fits inside containerWidth.

For intervals, it might be a bit more complicated.
For example, Grafana sets interval to 12 hours for 90 day query and returns only those data. Do we have a similar system here? I already hang if I try to get large data like 50 results.

We can calculate the interval like end-start and some if conditions based on the value.

I will try to implement code tomorrow.

@navaneeth-dev
Copy link
Author

I tried the interval={equidistantPreserveStart} option, but it is NOT equidistant in the middle.

image

There is an issue open but no timeline: recharts/recharts#3305

I think for now we have to manually calculate it.

@yurishkuro
Copy link
Member

@navaneeth-dev lmk when ready for review

@navaneeth-dev
Copy link
Author

Will do, working on migrating tests from emyze to react-testing-library.

Have you thought about adding .editorconfig?

@yurishkuro
Copy link
Member

working on migrating tests from emyze to react-testing-library.

is there a lot of tests? Perhaps we can merge them in a separate PR before merging this one.

Have you thought about adding .editorconfig?

I don't know what that is, sounds like specific to an IDE that you are using.

@navaneeth-dev
Copy link
Author

No just started work on ScatterPlot.test.js, was busy yesterday. So do you want me to finish ScatterPlot component fully with tests and let know know for this PR?


"Editorconfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs":

So formatter (prettier) usually comes after saving, but EditorConfig sets up the editor's: space, indent size correctly etc...
I highly recommend it and many CNCF projects use it. Currently, I have it git excluded with Neovim.
https://editorconfig.org/

@yurishkuro
Copy link
Member

my point was that changing tests to react-testing-library is a task on its own, it's good to do it before making changes to the code, such that we can then actually just the later code changes based on whether the tests are passing.

@navaneeth-dev
Copy link
Author

Understood, will migrate the remaining files and let you know:

./packages/jaeger-ui/src/components/Monitor/ServicesView/serviceGraph.tsx
./packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/opsGraph.tsx

@navaneeth-dev
Copy link
Author

@navaneeth-dev
Copy link
Author

@yurishkuro

Service Graph latency, error, request rate graphs finished. Is the tooltip fine?

output.mp4

Bottom graphs seem to have some bug, will be fixing that.
image

@navaneeth-dev
Copy link
Author

navaneeth-dev commented Jan 25, 2025

Fixed opsGraph, this PR is now ready.

I have two questions:

  1. Error rate data point's y value IS 0, so I set minimum value to 0.1 for every opsGraph so it displays a red line.
  2. Do we need sharp steps like below OR like my previous video which is linear? When the service is down, there is no data so there is a gap.

image

EDIT: I fixed the order of time to behave like current main one.
EDIT2: I still don't know the purpose of LineSeries.

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.

please resolve conflicts and update branch up to date

} = {};

if (yDomain) {
dynProps.yDomain = yDomain;
dynProps.domain = yDomain;
Copy link
Member

Choose a reason for hiding this comment

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

please avoid unnecessary changes, I want to focus my review on the main changes, not be distracted by these ^^^

Copy link
Author

Choose a reason for hiding this comment

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

This is a necessary change, <YAxis hide={true} {...dynProps} /> YAxis takes domain prop not yDomain like react-vis.

How would you want me to proceed?

Copy link
Member

Choose a reason for hiding this comment

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

do you need this const and if at all? Could it not be just inlined where needed?

Signed-off-by: Navaneeth Rao <[email protected]>
- Equal interval
- Proper Label position

Signed-off-by: Navaneeth Rao <[email protected]>
Signed-off-by: Navaneeth Rao <[email protected]>
Signed-off-by: Navaneeth Rao <[email protected]>
Signed-off-by: Navaneeth Rao <[email protected]>
Copy link
Author

@navaneeth-dev navaneeth-dev left a comment

Choose a reason for hiding this comment

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

Fixed all merge conflicts and updated to main.

@navaneeth-dev navaneeth-dev marked this pull request as ready for review January 26, 2025 05:08
@navaneeth-dev navaneeth-dev requested a review from a team as a code owner January 26, 2025 05:08
@navaneeth-dev navaneeth-dev requested review from pavolloffay and removed request for a team January 26, 2025 05:08
@@ -82,6 +82,7 @@
"react-vis-force": "^0.3.1",
Copy link
Member

Choose a reason for hiding this comment

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

is react-vis still needed after this change?

Copy link
Author

Choose a reason for hiding this comment

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

No, I will remove it

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.

I ran monitor example. The Search screen did not show scatterplot at all

image

The Monitor page showed charts, but their time axis doesn't make sense, when I switched to 24hrs view:

image

@navaneeth-dev
Copy link
Author

react-vis-force is different from react-vis. Once we migrate the tests we can remove react-vis.

rg react-vis                                     
package.json
49:    "prettier": "prettier --write '{.,scripts}/*.{js,jsx,json,md,ts,tsx,mts}' 'packages/*/{src,demo/src}/**/!(layout.worker.bundled|react-vis).{css,js,jsx,json,md,ts,tsx}' 'packages/*/*.{css,js,jsx,json,md,ts,tsx,mts}'",
50:    "prettier-lint": "prettier --list-different '{.,scripts}/*.{js,jsx,json,md,ts,tsx,mts}' 'packages/*/{src,demo/src}/**/!(layout.worker.bundled|react-vis).{css,js,jsx,json,md,ts,tsx}' 'packages/*/*.{css,js,jsx,json,md,ts,tsx,mts}' || (echo '*** PLEASE RUN npm run prettier AND RESUBMIT ***' && false)",

packages/jaeger-ui/package.json
81:    "react-vis": "1.11.12",
82:    "react-vis-force": "^0.3.1",

packages/jaeger-ui/typings/custom.d.ts
43:declare module 'react-vis-force';

package-lock.json
16602:    "node_modules/react-vis": {
16604:      "resolved": "https://registry.npmjs.org/react-vis/-/react-vis-1.11.12.tgz",
16635:    "node_modules/react-vis-force": {
16637:      "resolved": "https://registry.npmjs.org/react-vis-force/-/react-vis-force-0.3.1.tgz",
16651:    "node_modules/react-vis/node_modules/d3-color": {
16657:    "node_modules/react-vis/node_modules/d3-interpolate": {
16666:    "node_modules/react-vis/node_modules/deep-equal": {
20264:        "react-vis": "1.11.12",
20265:        "react-vis-force": "^0.3.1",

packages/jaeger-ui/src/components/DependencyGraph/ForceGraphArrowLink.tsx
22:import { ForceGraphLink } from 'react-vis-force';

packages/jaeger-ui/src/components/DependencyGraph/DependencyForceGraph.test.js
17:import { InteractiveForceGraph, ForceGraphNode } from 'react-vis-force';

packages/jaeger-ui/src/components/DependencyGraph/DependencyForceGraph.jsx
16:import { InteractiveForceGraph, ForceGraphNode } from 'react-vis-force';

packages/jaeger-ui/src/components/SearchTracePage/SearchResults/ScatterPlot.test.js
17:import { XAxis, XYPlot, YAxis, MarkSeries, Hint } from 'react-vis';

@navaneeth-dev
Copy link
Author

I think there is a bug with the size of ScatterPlot circles will test and let you know. I ran monitor docker compose example too but it shows for me 🤔 .

As for Monitor I used default recharts xaxis so interval isn't uniform. I will try to make it like Grafana and let you know.

@yurishkuro
Copy link
Member

react-vis-force is different from react-vis.

I know, I was referring to react-vis only.

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