Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Location
    Parma Italy
    Posts
    88
    Rep Power
    0

    Default Why yAxis only display 3 decimals?

    I can't set more than 3 decimals on Y axis: this is my example code

    Java FX Code:
    package javafxapplication2;
    
    import javafx.application.Application;
    import javafx.scene.chart.CategoryAxis;
    import javafx.scene.chart.NumberAxis;
    import javafx.scene.chart.XYChart;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.chart.LineChart;
    
    public class JavaFXApplication2 extends Application {
    
        @Override
        public void start(Stage stage) {
           stage.setTitle("Lines plot");
           
           final CategoryAxis xAxis = new CategoryAxis();
           final NumberAxis yAxis = new NumberAxis(0.53000, 0.53910, 0.001);
                  
           final LineChart<String, Number>lineChart = new LineChart<String, Number>(xAxis, yAxis);
           
           //lineChart.setTitle("Stock quotes");
           lineChart.setCreateSymbols(false);
           lineChart.setAlternativeRowFillVisible(false);
                  
           XYChart.Series series1 = new XYChart.Series();
            //series1.setName("Stock 1");
            series1.getData().add(new XYChart.Data("Jan", 0.53185));
            series1.getData().add(new XYChart.Data("Feb", 0.532235));
            series1.getData().add(new XYChart.Data("Mar", 0.53234));
            series1.getData().add(new XYChart.Data("Apr", 0.538765));
            series1.getData().add(new XYChart.Data("May", 0.53442));
            series1.getData().add(new XYChart.Data("Jun", 0.534658));
            series1.getData().add(new XYChart.Data("Jul", 0.53023));
            series1.getData().add(new XYChart.Data("Aug", 0.53001));
            series1.getData().add(new XYChart.Data("Sep", 0.53589));
            series1.getData().add(new XYChart.Data("Oct", 0.53476));
            series1.getData().add(new XYChart.Data("Nov", 0.530123));
            series1.getData().add(new XYChart.Data("Dec", 0.53035));
    
    Scene scene = new Scene(lineChart, 800, 600);
            lineChart.getData().addAll(series1);
            
            stage.setScene(scene);
            scene.getStylesheets().add(this.getClass().getResource("linechart.css").toExternalForm());
            stage.show();
               
        }
        public static void main(String[] args) {
            launch(args);
    }
    }
    How to display on Y axis more than 3 decimals?

    Thanks

    Susie

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Why yAxis only display 3 decimals?

    Quote Originally Posted by susieferrari View Post
    I can't set more than 3 decimals on Y axis: this is my example code

    Java FX Code:
           final NumberAxis yAxis = new NumberAxis(0.53000, 0.53910, 0.001);
    How to display on Y axis more than 3 decimals?
    Java FX Code:
        yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis) {
    
          @Override
          public String toString(Number object) {
            return String.format("%6.4f", object);
          }
        });
    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Join Date
    Mar 2011
    Location
    Parma Italy
    Posts
    88
    Rep Power
    0

    Default Re: Why yAxis only display 3 decimals?

    Thank you very much DarrylBurke!

Similar Threads

  1. Help with decimals
    By sabarooni in forum New To Java
    Replies: 4
    Last Post: 11-02-2011, 02:07 AM
  2. Help with rounding decimals
    By university123 in forum New To Java
    Replies: 2
    Last Post: 10-04-2010, 10:28 PM
  3. BIG decimals
    By xael in forum New To Java
    Replies: 17
    Last Post: 10-04-2010, 10:14 AM
  4. Decimals in java help!!
    By Gold in forum New To Java
    Replies: 3
    Last Post: 12-09-2009, 11:25 PM
  5. get more decimals?!?! please help!
    By michcio in forum New To Java
    Replies: 7
    Last Post: 05-22-2008, 10:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •