Code Monkey home page Code Monkey logo

Comments (6)

kumilingus avatar kumilingus commented on May 26, 2024

I'm sorry, what exactly are we supposed to be looking at?
What is the problem? The paper does not have to originate at 0x0 for multiple reasons.
What would be the expected result?
How to reproduce it? Providing a code to see the issue always helps.

from joint.

ROYopedia avatar ROYopedia commented on May 26, 2024

Sorry for the ambiguity.
SVG tag is positioned from (0,0) in viewport but g tag is positioned way too right. I am not able to figure out what is the root cause of being g tag with classname = "joint-layers" positioned this way instead of (0,0).
Can we force manipulate the position of g tag??
You talked about multiple reason for this. Can you highlight some of them?

It would have been better with a small code demo but I cant share code as it is confidential one.

from joint.

kumilingus avatar kumilingus commented on May 26, 2024

What is graph.getBBox()? The top left corner of the bounding box is most likely in negative coordinates. So for the paper to display the entire graph, it must change its origin to negative coordinates as well.

But I think you don't like the space around the paper. Not the transformation of the paper (the transformation attribute does not change the position of the <g> tag within the paper scroller). The space around the paper within the paper scroller is controlled by the padding and borderless options. I suggest reading the PaperScroller documentation first.

from joint.

ROYopedia avatar ROYopedia commented on May 26, 2024

In this case the graph.getBBox is -> Rect {x: 55, y: 140, width: 4840, height: 2440}.

Yeah! Space around the paper is not needed.
Let me re-phrase my desired outcome.
Steps:
step1:
Created Paper

const graph = new dia.Graph({}, { cellNamespace });
  const paper = new dia.Paper({
    model: graph,
    async: true,
    preventContextMenu: true,
    sorting: dia.Paper.sorting.APPROX,
    //interactive: true,
    snapLabels: true,
    interactive: {
      labelMove: true,
    },
    cellViewNamespace: cellNamespace,
    background: { color: "transparent" },
    defaultConnectionPoint: { name: "boundary", args: { offset: 3 } },
    defaultConnector: {
      name: "jumpover",
      args: { jump: "arc" }, //other values arc / cubic
    },
    defaultRouter: function (_vertices, _opt, linkView: any) {
      const link = linkView.model;
      const source = link.getSourceCell();
      const target = link.getTargetCell();
      if (
        (source && isCellHidden(source)) ||
        (target && isCellHidden(target))
      ) {
        //use straight line if either source or target is hidden
        return [];
      }

      return routers.normal([], { margin: 100 }, linkView);
    },
    defaultAnchor: multiLinkAnchor,
    viewport: function (view: any) {
      return !isCellHidden(view.model);
    },
    // viewport: (view: dia.CellView) => !isCellHidden(view.model),
  });

Step2:
I created paperscroller the way it is mentioned in doc.

const paperScroller = new ui.PaperScroller({
      paper,
     // padding: { top: 0, left: 0 },
      autoResizePaper: true,
      // contentOptions: function (paperScroller) {
      //   var visibleArea = paperScroller.getVisibleArea();
      //   return {
      //     padding: {
      //       bottom: visibleArea.height / 2,
      //       top: visibleArea.height / 2,
      //       left: visibleArea.width / 2,
      //       right: visibleArea.width / 2,
      //     },
      //     allowNewOrigin: "any",
      //   };
      // },
      
    });

The outcome in browser is:
Screenshot1:
Paperscroller position:
Screenshot from 2023-09-21 11-34-09
Paperscroller position is perfect as per division of layout.

but,
Screenshot2:

Screenshot from 2023-09-21 11-43-39

The div.jointpaper is positioned somewhere in middle with some calculated left and top.How are these positioned calculated???? I want this div.jointpaper to be positioned at top:0,left:0 so that it is aligned with paperscroller.

Desired output:

Screenshot from 2023-09-21 11-58-41

from joint.

kumilingus avatar kumilingus commented on May 26, 2024

Perhaps calling paperScroller.positionContent('top-left', { padding: 50, useModelGeometry: true }) will do the job?
There are many methods to modify the position of the paper inside the paper scroller (e.g. scroll(), center()).

from joint.

github-actions avatar github-actions commented on May 26, 2024

This issue is stale because it has been open 60 days with no activity. Please remove stale label or comment or this will be closed in 14 days.

from joint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.