Open ogallagher opened 2 years ago
Change of plan! It should be much easier to just change the initial transform on the graph canvas to fit the content rather than transforming the content to fit the canvas. If I can implement this way, I’ll update the issue title accordingly.
So far I’ve implemented basic scaling, but haven’t fixed translation. Scaling the canvas invalidates the calculated translation, and recalculating translation doesn't account for the scaling either, unfortunately.
Also, in order to flip the y axis I need to be able to set the y-scale to -1 in the canvas, which is not possible with the current PannableCanvas
class, and I believe would also mess up graph node mouse interaction.
In a cartesian graph, between the data coordinates for a point (raw x,y) and the viewport coordinates (camera pan, zoom), there should be a transform for display coordinates, given the desired viewport space versus the data space. For example, this transform could optionally flip the y axis and scale the data to fit in the initial viewport (pan=0,0 zoom=1) when displayed.
Use the
FitToContentLayout
class for this, and make a difference in the placement of a point between the point’s coordinates and the displayed location (CartesianPoint.getGraphic
).