I want to implement content scrolling inside of a PositionPanel. It works for positive values like go.Point(100, 100), but when I position an object using negative values like go.Point(-100, -100) the object will stick to go.Point(0, 0). How to allow objects to be positioned using negative values?
new go.Group("Position", {
resizable: true,
width: 400,
height: 100,
background: "lightblue",
}).add(
new go.Panel("Graduated", {
graduatedMin: 0,
graduatedMax: 100,
graduatedTickUnit: 10,
background: "lightgreen",
position: new go.Point(-100, -100), // the panel sticks to go.Point(0, 0)
name: "timescale",
}).add(
new go.Shape({ geometryString: "M0 0 H800" }),
new go.Shape({ geometryString: "M0 0 V10" }),
new go.TextBlock({ segmentOffset: new go.Point(0, 12) })
)
);
Yes, you can have elements of a “Position” Panel at negative GraphObject.positions. If you examine that “Graduated” Panel in the debugger, does it not have (-100, -100) as its position? (Unless you have set it in some code; it doesn’t have a Binding.)
This is also shown in the second sample at: Panels | GoJS Note how one element is at (-50, 50). The origin (0, 0) is near the middle of the panel.
Maybe you don’t want to use a “Position” Panel to arrange your “Graduated” Panel relative to other elements?
If you add a second element to that “Position” Panel and specify its position, you will see that that “Graduated” Panel that you positioned at (-100, 0) does in fact extend towards the left of the origin position.
For example, let’s say I add this Shape to your “Position” Panel:
new go.Shape("Circle", { position: new go.Point(0, 10), width: 3, height: 3, fill: "red", strokeWidth: 0 })
(Note that the red circle is positioned at y==10 so that is isn’t obscured by the main path of the “Graduated” Panel. But its position.x is zero.)
The position of an element in a “Position” Panel is in that panel’s coordinate system. Those positions don’t mean anything outside of that panel, because each panel has its own coordinate system.
For top-level GraphObjects, which must always be Parts, there is no such containing Panel, so the coordinate system is the document coordinate system. Coordinate Systems | GoJS
Ok, so what I want to achieve is that the graduated panel should get cropped when it is positioned below (0, 0) so in this case I expect to only see the part after the red dot. 0 and 10 should be hidden/cropped. I should only be able to see 20, 30 and so on when the position is set to (-100, -100).