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

Flowchart Orientation #2251

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

Flowchart Orientation #2251

wants to merge 17 commits into from

Conversation

rashidakanchwala
Copy link
Contributor

@rashidakanchwala rashidakanchwala commented Jan 28, 2025

Description

Resolves #2159

Development notes

For first PR review, pls QA it and look through the code. I will add dev notes when i am back from PTO

QA notes

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

Signed-off-by: rashidakanchwala <[email protected]>
@rashidakanchwala rashidakanchwala changed the base branch from new-flowchart-rtl to main January 28, 2025 11:49
Signed-off-by: rashidakanchwala <[email protected]>
Signed-off-by: rashidakanchwala <[email protected]>
Signed-off-by: rashidakanchwala <[email protected]>
Signed-off-by: rashidakanchwala <[email protected]>
Signed-off-by: rashidakanchwala <[email protected]>
Signed-off-by: rashidakanchwala <[email protected]>
Signed-off-by: rashidakanchwala <[email protected]>
Signed-off-by: rashidakanchwala <[email protected]>
@rashidakanchwala rashidakanchwala marked this pull request as ready for review February 5, 2025 17:12
Copy link
Member

@astrojuanlu astrojuanlu left a comment

Choose a reason for hiding this comment

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

I gave this a quick run using the demo project and looks like it works! 😄

Copy link
Contributor

@SajidAlamQB SajidAlamQB left a comment

Choose a reason for hiding this comment

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

Awesome work @rashidakanchwala, tested it manually and looks great!

ariaLabel="Change flowchart orientation"
className={'pipeline-menu-button--orientation'}
dataTest={'sidebar-flowchart-orientation-btn'}
icon={orientation === 'vertical' ? TopBottomIcon : LeftRightIcon}
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be opposite ? Like when vertical we show LeftRightIcon to change, similar to expand/collapse pipelines ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a very good point. i am not sure; once @stephkaiser is back; let's ask her.

Signed-off-by: rashidakanchwala <[email protected]>
;

Signed-off-by: rashidakanchwala <[email protected]>
@@ -9,26 +9,22 @@
import { Constraint, Operator, Strength } from 'kiwi.js';

/**
* Layout constraint in Y for separating rows
* Layout constraint in for separating rows
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
* Layout constraint in for separating rows
* Layout constraint for separating rows

Strength.required
),
};

/**
* Layout constraint in Y for separating layers
* Layout constraint in for separating layers
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
* Layout constraint in for separating layers
* Layout constraint for separating layers

@@ -39,16 +35,15 @@ export const layerConstraint = {
};

/**
* Layout constraint in X for minimising distance from source to target for straight edges
* Layout constraint in for minimising distance from source to target for straight edges
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
* Layout constraint in for minimising distance from source to target for straight edges
* Layout constraint for minimising distance from source to target for straight edges

@@ -61,37 +56,39 @@ export const parallelConstraint = {
};

/**
* Crossing constraint in X for minimising edge crossings
* Crossing constraint in for minimising edge crossings
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
* Crossing constraint in for minimising edge crossings
* Crossing constraint for minimising edge crossings

},
};

/**
* Layout constraint in X for minimum node separation
* Layout constraint in for minimum node separation
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
* Layout constraint in for minimum node separation
* Layout constraint for minimum node separation

node.x = 0;
node.y = 0;
node[coordPrimary] = 0;
node[coordSecondary] = 0;
}

// Constants used by constraints
const constants = {
Copy link
Contributor

Choose a reason for hiding this comment

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

[Nit] Though not introduced in this PR, constants variable name does not feel proper. Something like constraintDefaults ?

};

/**
* Creates row constraints for the given edges.
* @param {Array} edges The input edges
* @returns {Array} The constraints
*/
const createRowConstraints = (edges) =>
const createRowConstraints = (edges, constants) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add some comments on what does Creates row constraints for the given edges. means ?

@@ -106,14 +107,24 @@ export const routing = ({

const offsetX = Math.min(spaceX, nodeGap * 0.5);

let sourceX, sourceY, targetX, targetY;

//TODO: Need to do this for horizontal orientation as well.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -57,20 +57,22 @@ export const solveStrict = (constraints, constants) => {
};

for (const constraint of constraints) {
addVariable(constraint.a, constraint.base.property);
addVariable(constraint.b, constraint.base.property);
const property = constraint.property || constraint.base.property;
Copy link
Contributor

Choose a reason for hiding this comment

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

I do see constraint has property everywhere. Is there a place where we have property on base and not constraint ?
Also, in simple terms what is a constraint , base, property ?

@ravi-kumar-pilla
Copy link
Contributor

Hi @rashidakanchwala ,

I did another pass at the PR and left few comments. The code looks good and seems quite complex. It would be great if you can add some comments/context (mostly related to graph constraints rows, layers, edges, cross constraints). I could understand most parts but the code at src/utils/graph/* needs another pass :)

Thank you

const { chartSize, layers, orientation } = this.props;

const layerNamePosition =
orientation === 'vertical' ? chartSize.sidebarWidth || 0 : 100 || 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
orientation === 'vertical' ? chartSize.sidebarWidth || 0 : 100 || 0;
orientation === 'vertical' ? chartSize.sidebarWidth || 0 : 100;

@jitu5
Copy link
Contributor

jitu5 commented Feb 17, 2025

@rashidakanchwala When I was testing it locally I observed,

  • In horizontal orientation pipeline slicing is not working
  • After selecting horizontal orientation and if I reload the page, right now its not retaining the horizontal orientation.

Is it expected for this PR ?

@rashidakanchwala
Copy link
Contributor Author

@rashidakanchwala When I was testing it locally I observed,

  • In horizontal orientation pipeline slicing is not working
  • After selecting horizontal orientation and if I reload the page, right now its not retaining the horizontal orientation.

Is it expected for this PR ?

  • Good catch, let me investgatee
  • Yes, i am not storing it in localStorage. let me add that now. thanks for pointing.

@jitu5
Copy link
Contributor

jitu5 commented Feb 18, 2025

  • In horizontal orientation pipeline slicing is not working

@rashidakanchwala Pipeline slicing is working as expected.

Signed-off-by: rashidakanchwala <[email protected]>
@stephkaiser
Copy link

Awesome work @rashidakanchwala! some design QA notes below:

  1. Button tooltip - lowercase 'O' for 'Orientation' - should be: 'Change orientation'
Screenshot 2025-02-18 at 15 42 32
  1. Reset view button doesn't show the full flowchart in both horizontal and landscape orientation (its currently broken on demo site as well)
Screenshot 2025-02-18 at 15 46 36
  1. Order of the orientation button in the actions bar -
Screenshot 2025-02-19 at 10 48 25
  1. Transition animation of the layers labels in horizontal orientation looks odd (see the 'intermediate' text overlaps with 'primary')
    LTR 1

  2. Layers highlights on hover are slightly off and not aligned with the layer labels
    LTR 2 1

  3. In regards to @ravi-kumar-pilla's comment on button icon behaviour, lets keep it for now. It is inconsistent with the expand/collapse button but they are different also - Expand/collapse changes to a different button, while orientation button indicates which is the current orientation. Both make sense to me even though they are not consistent with each other. I'll review and discuss this with other designers to see what they think but for now I think we can keep it as it is.

  4. Lines are looking really weird, can we improve this?

Screenshot 2025-02-18 at 15 41 47

Thank you!!

@rashidakanchwala
Copy link
Contributor Author

rashidakanchwala commented Feb 19, 2025

  1. Will do.
  2. I attempted to fix this, but as you noticed, it affects both horizontal and vertical orientations. This has been an existing issue for a long time. A trade-off was made here, as the best fit sometimes results in a very wide and short visual. We should address this as a separate issue since it’s not specific to horizontal orientation—it has existed since the Kedro-Viz flowchart algorithm was written.
  3. Will do.
  4. I'll look into this fix.
  5. I tried fixing this issue and time-boxed it, but I wasn’t able to get it working. I can spend some more time on it.
  6. Makes sense.
  7. This trade-off was made for optimisation. The lines (that go over multiple layers) behave unpredictably in vertical orientation as well. I had raised this issue in the last PS, and we had decided to revisit this later since it took me a long time to get it to this stage, and further improvements would require a lot of time.

@stephkaiser , pls see my responses below.
cc - @astrojuanlu

@stephkaiser
Copy link

stephkaiser commented Feb 19, 2025

  1. sounds good, lets tackle in a separate issue

7 . understood, lets revisit this in the future then

thank you @rashidakanchwala !!

Signed-off-by: rashidakanchwala <[email protected]>
@rashidakanchwala
Copy link
Contributor Author

@stephkaiser

I've fixed points 1, 3, and 5. I also attempted to address the transition issue (point 4) , but I'd like to understand from you how the transitions should behave since they affect both horizontal and vertical orientations.

This seems to be an existing issue, so we can also tackle it in a separate PR if needed. I tried removing transitions, but it didn’t fully resolve the problem. Let me know your thoughts!

@stephkaiser
Copy link

@stephkaiser

I've fixed points 1, 3, and 5. I also attempted to address the transition issue (point 4) , but I'd like to understand from you how the transitions should behave since they affect both horizontal and vertical orientations.

This seems to be an existing issue, so we can also tackle it in a separate PR if needed. I tried removing transitions, but it didn’t fully resolve the problem. Let me know your thoughts!

It looks to me like there is a delay when the layer labels change, would shortening the animation of the layer labels solve this? we can jump on a quick call tomorrow if thats useful

Signed-off-by: rashidakanchwala <[email protected]>
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.

Implementing Left-to-Right Orientation for Kedro-Viz
6 participants