Paperwidth / height always from 0 to value - JointJs not rappid

92 views
Skip to first unread message

Mat Jackson

unread,
Jun 16, 2021, 7:09:16 PM6/16/21
to JointJS
Is there anyway to make paper width and paper height range from two values instead of being from 0 to set value. So paper width/height from (-1000,1000). I can extend the paper past the given width / height with 

paper.fitToContent({
padding: 20,
minWidth: 2000,
minHeight: 2000,
maxHeight: 5000,
maxWidth: 5000,
allowNewOrigin: 'negative'
});
and save the new paper width / height in mongo but when reloading that paper width and height are 5000 but the cells dragged to the left or up are cut off because they do not fall within the 0-5000 it seems to me that paper 0,0 starts top left and goes to the right and downward. If I set a new origin on the graph to 1000,1000(center) it does not set the paper width / height to that origin they always go from 0,0 top left to right and bottom. Any recommendations would be great and my boss is not willing to pay for rappid given we are a small company not even in production yet so rappid is not an option, I know that rappid has a good way of doing this but sadly cant use it.  

Thank you 

Roman Bruckner

unread,
Jun 17, 2021, 3:16:00 AM6/17/21
to joi...@googlegroups.com
Hi,

The default origin in fitToContent() is always 0,0 and currently can not be changed (apply to default, negative, positive allowNewOrigin). It would be a nice new option though.

What you can do right now, is to use the `allowNewOrigin: 'any'` together with a custom `contentArea` rectangle.

paper.el.style.border = '1px solid red';

paper.on('render:done', () => {

    const origin = new g.Point(-100, -100);
    const bbox = graph.getBBox().union(origin);
    // make sure the bbox.x / bbox.y / bbox.width / bbox.height are not out of limits here

    paper.fitToContent({
        contentArea: bbox,
        allowNewOrigin: 'any',
        allowNegativeBottomRight: true,
        gridWidth: 100,
        gridHeight: 100,
        // maxWidth: 5000,
        // maxHeight: 5000,
        // minWidth: 2000,
        // minHeight: 2000
    });
});


Best,
Roman

--

---
You received this message because you are subscribed to the Google Groups "JointJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jointjs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jointjs/ffe2ef1d-91f8-4191-953d-a2e162c05854n%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages