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

AreaChart use only XYChart<String, Number> #10

Open
dpozimski opened this issue Mar 13, 2017 · 4 comments
Open

AreaChart use only XYChart<String, Number> #10

dpozimski opened this issue Mar 13, 2017 · 4 comments

Comments

@dpozimski
Copy link

Hello!

I would like to make a ticket with this issue:

When i try to build a new Tile with series of type XYChart<Number, Number> to use it for dynamic visualization i am getting:

Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at javafx.scene.chart.CategoryAxis.toNumericValue(CategoryAxis.java:67)
at javafx.scene.chart.AreaChart.updateAxisRange(AreaChart.java:175)
at javafx.scene.chart.XYChart.layoutChartChildren(XYChart.java:660)
at javafx.scene.chart.Chart$1.layoutChildren(Chart.java:94)
at javafx.scene.Parent.layout(Parent.java:1087)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Scene.doLayoutPass(Scene.java:552)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2397)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$30(Toolkit.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:354)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:381)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$404(QuantumToolkit.java:319)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)

To reproduce problem use snippet and put it into Main code:

    private void init(Stage primaryStage) {
        //-- Chart Series
        Series series = new XYChart.Series<Number, Number>();
        series.setName("Temperature");

        Tile sc = TileBuilder.create()
                .prefSize(800, 240)
                .skinType(Tile.SkinType.AREA_CHART)
                .series(series)
                .animated(true)
                .build();

        for(int i=0;i<100;i++)
              series.getData().add(new XYChart.Data(i, i+1));;

        primaryStage.setScene(new Scene(sc));
        primaryStage.setWidth(800);
        primaryStage.setHeight(240);
        primaryStage.show();
    }
@negste
Copy link
Contributor

negste commented Oct 16, 2017

Maybe I'm late but I was having a look at this and I found that it already works: you only have to provide the Axis. So it will work if you change your code like this:

        Series series = new XYChart.Series<Number, Number>();
        series.setName("Temperature");

        Axis<Number> vXAxis = new NumberAxis();
        
        Tile sc = TileBuilder.create()
                .prefSize(800, 240)
                .skinType(Tile.SkinType.AREA_CHART)
                .xAxis(vXAxis)
                .series(series)
                .animated(true)
                .build();

@dpozimski
Copy link
Author

Thank you for your feedback very well, but I resolved this issue in the past by replacing the AreaChart with standard Chart from jdk.
I am really happy that i have got a response after a long time :)

@negste
Copy link
Contributor

negste commented Oct 16, 2017

You're welcome. Maybe this issue should be closed now?

@dpozimski
Copy link
Author

Yes of course, but I can propose to add programmer friendly exception for that case (missmath between series generic types and xAxis or something like that)

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

2 participants