dugarab / jsplumb

Automatically exported from code.google.com/p/jsplumb
0 stars 0 forks source link

connector not showing, or connector line type ignored, when registerConnectionTypes() is used #336

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
broken, no line:
http://jsfiddle.net/JgkvP/1/

working, shows connector line:
http://jsfiddle.net/JgkvP/2/

only difference: comment line 40 in the javascript section.

this demo uses jsPlumb 1.3.16-all-min.js. i actually wanted to demonstrate a 
similar issue i'm having in my development with 1.4-snapshot, but could not 
find a linkable single js file online. all demos use the huge list of imports, 
like here: https://github.com/sporritt/jsPlumb/blob/master/demo/jquery/demo.html

the problem i detected with the 1.4 version is less bad, it does paint the 
line, but not the line type i wanted.

in the connect() function i passed in 
  connector:[ "StateMachine", { curviness:20 } ]

but this was ignored, the default Bezier was showing. only once i've added the 
"connector" config in the registerConnectionTypes() call then it would 
overwrite the default Bezier. as soon as i'm using registerConnectionTypes() 
(without "connector" config) then the "connector" given in connect() is ignored.

Original issue reported on code.google.com by fabian.k...@optimaize.com on 17 Apr 2013 at 4:32

GoogleCodeExporter commented 8 years ago
Same thing with the Label: when I pass this in to connect() then it's ignored 

overlays : [
    ["Label", {                                                                     
        cssClass:"foo",
        label : 'foo', 
        location:0.5,
    }]
]

as soon as I use (assign) types. In version 1.4 when I omit this
c.addType('someType')
it works, when I add it then the label is missing.

my registerConnectionTypes (called on my graph instance) doesn't include a 
label, but it includes an overlay:

registerConnectionTypes({
        "basic": {
            paintStyle:{lineWidth:2},
            hoverPaintStyle:{ lineWidth:7 },
            connector:[ "StateMachine", { curviness:20 } ],
            overlays: [
                [ "Arrow", { 
                    location: 0.9,
                    length:   14,
                    foldback: 0.8
                } ]
            ]
        },

it doesn't matter if i call registerConnectionTypes in version 1.4 or not. only 
calling addType() makes the difference.

Original comment by fabian.k...@optimaize.com on 17 Apr 2013 at 6:57

GoogleCodeExporter commented 8 years ago
So the workaround that works for me in 1.4 is this:

I register a type using registerConnectionTypes() and it has a label overlay:

["Label", {     
    id: 'label',
    label : 'temporary', 
    location:0.5,
}]

then, after connect() and addType():

var labelOverlay = c.getOverlay("label");
labelOverlay.setLabel( "myRelationSpecificLabel" );
labelOverlay.addClass( "myRelationSpecificCssClass" );

note that there is no setCssClass(), it's called addClass() (a bit inconsistent 
api).

Original comment by fabian.k...@optimaize.com on 17 Apr 2013 at 7:33

GoogleCodeExporter commented 8 years ago
the "huge list of imports" makes development easier and more maintainable.

when you need a single file before a version is released, you can build one, 
with the instructions from the wiki:

https://github.com/sporritt/jsPlumb/wiki/Build

addClass is called what it is because that is what it does.  it adds a class to 
the current classes on the label. it does not "set" the label's class.  

Original comment by simon.po...@gmail.com on 17 Apr 2013 at 10:36

GoogleCodeExporter commented 8 years ago
moved to github

https://github.com/sporritt/jsPlumb/issues/28

Original comment by simon.po...@gmail.com on 30 Apr 2013 at 11:39

GoogleCodeExporter commented 8 years ago
Issues have all moved to Github.  Google code is no longer in use for jsPlumb.

Original comment by simon.po...@gmail.com on 10 May 2013 at 11:37