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

Do not alter paths data when loading through d3js #7026

Merged
merged 3 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cypress/integration/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ describe('Paths', () => {

cy.get('[data-attr=paths-viz]').should('exist')
})

it('can save paths', () => {
cy.get('[data-attr="insight-edit-button"]').should('not.exist')
cy.get('[data-attr="insight-save-button"]').click()
cy.get('[data-attr="insight-edit-button"]').should('exist')
})
})
5 changes: 4 additions & 1 deletion frontend/src/scenes/paths/NewPaths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ export function NewPaths({ dashboardItemId = null, color = 'white' }: PathsProps

const svg = createCanvas(width, height)
const sankey = createSankey(width, height)
const { nodes, links } = sankey(paths)
const { nodes, links } = sankey({
nodes: paths.nodes.map((d) => ({ ...d })),
Copy link
Contributor

Choose a reason for hiding this comment

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

non-blocking

Should we add in ...paths as well to ensure that any other attributes that were considered and part of paths are also considered by sankey. I have no idea if that's a likely scenario

Copy link
Member Author

Choose a reason for hiding this comment

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

Reading the code in d3-sankey I'm pretty sure it's only node and links that are used by sankey

(We also explode paths the same way in the Old Paths.tsx)

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

links: paths.links.map((d) => ({ ...d })),
})

setPathItemCards(
nodes.map((node: PathNodeData) => ({ ...node, visible: node.y1 - node.y0 > HIDE_PATH_CARD_HEIGHT }))
Expand Down