Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving XYCharts to a new scene causes improper scaling between the axis and series/gridlines #595

Closed
itsmaxymoo opened this issue Aug 7, 2023 · 4 comments

Comments

@itsmaxymoo
Copy link

Describe the bug

I am developing an application that must display and save several graphs. To do this, I have XYCharts in a GridContainer. The container is displayed normally in the interface. When a screenshot is necessary, the container is moved to a new blank scene that is not displayed, and a snapshot is taken of that scene. This is done because the screenshots must be higher resolution than the interface (or computer monitor, for that matter).

The screenshot produced shows that the graph axes scaled to the proper visual size, but everything else is wrong. The axes values are completely wrong, and the series and grid lines maintain the same size as before the scene switch. I have tried the workarounds mentioned in #533 with no success. Upon "returning" the GridContainer node to the main interface, the graphs look proper again.

before -
after

To Reproduce

  1. Display a XYChart
  2. Move that chart to a new invisible scene of a forced larger size
  3. Take a screenshot of that scene.

Environment:

  • OS: Windows 10
  • Java version: 17.0.7
  • JavaFx version: 17.0.7
  • ChartFx version: 11.2.7
@wirew0rm
Copy link
Member

wirew0rm commented Aug 7, 2023

possible duplicate of #410
This should hopefully be resolved by #579 and #592, which I'm in the process of merging. This should be merged at latest tomorrow and be released at latest next week.
If you can't wait for that, there are some workarounds in the first issue that might help.

@itsmaxymoo
Copy link
Author

Sadly the workarounds mentioned in #410 do not work. I have found a workaround that works although it is quite janky; to momentarily create and display a stage so that the graphs can properly adjust, and then closing the temporary stage.

@ennerf
Copy link
Collaborator

ennerf commented Aug 7, 2023

You can create SnapshotParameters that scale the node to a higher resolution. Here is some code I'm using:

    public static Image snapshot(Node node, double pixelScale) {
        SnapshotParameters snapParams = new SnapshotParameters();
        Transform snapshotScale = Transform.scale(pixelScale, pixelScale);
        snapParams.setTransform(snapshotScale);
        if (Platform.isSupported(ConditionalFeature.SCENE3D)) {
            snapParams.setDepthBuffer(true);
        }
        return node.snapshot(snapParams, null);
    }

@wirew0rm
Copy link
Member

Glad you found a workaround that is working for you and thanks for sharing 👍

Since 11.3.0 with the new layout code is now released which should solve these kind of problems at the root it would be interesting to confirm that the problem is gone now.

As this errors are on the old release and the relevant parts of the code have been fundamentally changed I'll close this issue, feel free to reopen if the issue persists in the 11.3.0 release (which I think it shouldn't).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants