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

ability to disable vertical alignment for condition symbol #115

Closed
bertrandmartel opened this issue Aug 27, 2017 · 6 comments
Closed

ability to disable vertical alignment for condition symbol #115

bertrandmartel opened this issue Aug 27, 2017 · 6 comments

Comments

@bertrandmartel
Copy link
Contributor

I've noticed that when multiple elements are aligned the upper condition element is aligning to the left of the bottom right hand element. For example, I have this configuration

vertical-align-issue

You can reproduce with

st=>start: Start
current=>operation: program = current program
last=>operation: program = last program
op11=>operation: somethin
op1=>operation: Get current program
op2=>end: startover = ad after program start
op3=>end: startover = ad after SharpStart
op4=>end: startover = ad after last program end
fail=>end: startover = EPG program start
cond1=>condition: program exists ?
cond2=>condition: SharpStart after 
program start ?
cond3=>condition: Ad existing after 
program start ?
cond4=>condition: SharpStart 
before program ?
cond5=>condition: Ad after previous 
SharpStart ?
cond6=>condition: Ad after 
last program ?

st->op1->cond1
cond1(yes)->current
current->cond2

cond1(no)->cond6
cond6(no)->last
cond6(yes)->op4
last->cond2
cond2(yes)->cond3
cond2(no)->cond4
cond3(no)->cond4
cond3(yes)->op2
cond4(no)->fail
cond4(yes,right)->cond5
cond5(yes,right)->op3
cond5(no)->fail

I've forked and modified the library to add ability to put parameters for symbol declaration such as

element(param1=value1,param2=value2)=>start: Start

This is done using

var symbol = {
  key: parts[0].replace(/\(.*\)/, ''),
  symbolType: parts[1],
  params: {},
  text: null,
  link: null,
  target: null,
  lineStyle: {},
  flowstate: null
};

//parse parameters
var params = parts[0].match(/\((.*)\)/);
if (params && params.length > 1){
  var entries = params[1].split(',');
  for(var i = 0; i < entries.length; i++) {
    var entry = entries[0].split('=');
    if (entry.length == 2){
      symbol.params[entry[0]] = entry[1];
    }
  }
}

In flowchart.symbol.condition I identified the code responsible for identifying if an element is under this one : here

After applying the new configuration which indicates not to vertical align the next element

cond1(align-next=no)=>condition: program exists ?
cond6(align-next=no)=>condition: Ad after 

It gives

vertical-align-fix

What do you think about this ?

@adrai
Copy link
Owner

adrai commented Aug 27, 2017

Nice work... as soon I get my hands back to my macbook I will look at your PRs...
PS. I did not check... did you describe it a bit in the readme?

@adrai
Copy link
Owner

adrai commented Aug 27, 2017

@bertrandmartel ok, as soon you describe the new functionalities in the readme and in the gh-page with an example (https://github.com/adrai/flowchart.js/blob/gh-pages/index.html) or at least a proposal... ;-) I will merge the PRs
Well done! 👍

@bertrandmartel
Copy link
Contributor Author

I've added in the readme

'cond=>condition: Yes \n' + // use cond(align-next=no) to disable vertical align of symbols below

I've updated gh-pages locsize demo with more aligned conditions. Is that ok or you prefer to setup a new demo ?

@bertrandmartel
Copy link
Contributor Author

@adrai Also do you want me to commit the release folder ?

@adrai
Copy link
Owner

adrai commented Aug 27, 2017

It's ok, I will do the rest... 😉

adrai pushed a commit that referenced this issue Aug 27, 2017
#116)

* add parameter to disable vertical alignment of condition symbol (#115)

* add note about disabling vertical-alignment in readme
@vic-t
Copy link

vic-t commented May 24, 2021

I came across this PR and the issue it solves today by chance through a post on StackOverflow. I'm just curious, why not make this the default for diagrams created with flowchart.js? It seems to me that flowcharts look a lot better when parallel items are not scattered all over the place but kept in one column.

cdfmlr added a commit to cdfmlr/pyflowchart that referenced this issue Feb 13, 2022
Implement ConditionNode alignment support (#14).
This comment follows bertrandmartel's steps (adrai/flowchart.js#115 (comment)):

1. add ability to put parameters for Node declaration such as:
        element(param1=value1,param2=value2)=>start: Start
    * add Node.params field, a dict for params;
    * add Node.set_param() method to set params;
    * modify Node.fc_definition to write params into generated flowchart.
2. add ability to set `align-next=no` param for ConditionNode:
    * add ConditionNode.no_align_next() to set the param.
    * ConditionNode.__init__() support passing a `align_next=False` to set it.

Closes #14
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

No branches or pull requests

3 participants