Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Making a smooth LineChart

900726Nov 17 2011 — edited Nov 18 2011
Hey all,
I'm new to JavaFX and this problem has been bugging me for some time. Any help would be really appreciated.

I have the following code. What I want from it is to have a smooth curve instead of having individual points shown in the graph. I tried looking up the documentations but could not find any way to do it( unless I missed it ). If it's possible can anyone tell me how to do it or point me in the right direction?

Also, I would like to know if it's possible, and if possible, how to paint a portion of the area beneath the chart. What I want to do is listen for a mouse click beneath the curve and paint the area under the curve from that point to the origin.
protected LineChart<Number, Number> createChart() {
        NumberAxis xAxis = new NumberAxis();
        NumberAxis yAxis = new NumberAxis();
        LineChart<Number,Number> ac = new LineChart<Number,Number>(xAxis,yAxis);
        // setup chart
        ac.setTitle("Test Graph");
        xAxis.setLabel("X Axis");
        yAxis.setLabel("Y Axis");

        
        // add starting data
            XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
            series.setName("NoProb");
            int x = 0;
            while (x < 10) {                
                series.getData().add(new XYChart.Data<Number,Number>(x,x*x));
                x++;
            }
            ac.getData().add(series);
            return ac;
    }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 16 2011
Added on Nov 17 2011
1 comment
1,175 views