Visualizzazione dei risultati da 1 a 2 su 2

Discussione: JFreechart e date

  1. #1

    JFreechart e date

    ciao a tutti! ho un grafico fatto con JFreeChart, l'asse delle X è il tempo, io adesso lo visualizzo in secondi ma vorrei cambiarlo in HH:mm:ss è possibile?
    vi lascio il codice

    codice:
    /**
         * Plots settigns angles
         * @return 
         */
        public JPanel PlotAngles(){
            DefaultXYDataset DS_Heel = new DefaultXYDataset();
            DS_Heel.addSeries("\u03D5", new double[][] {Time, this.Heel});
            DefaultXYDataset DS_Trim = new DefaultXYDataset();
            DS_Trim.addSeries("\u03B8", new double[][] {Time, this.Trim});
            DefaultXYDataset DS_Tm = new DefaultXYDataset();
            DS_Tm.addSeries("Tm",     new double[][] {Time, this.Tm});
            DefaultXYDataset DS_GM = new DefaultXYDataset();
            DS_GM.addSeries("GM",     new double[][] {Time, this.GM});      
            
            this.Plot_Settings = ChartFactory.createXYLineChart(
                    language.getString("SINKING_EVOLUTION"), // chart title
                    "t [s]", // x axis label
                    "", // y axis label
                    null, // data
                    PlotOrientation.VERTICAL,
                    true, // include legend
                    true, // tooltips
                    false // urls
            );
            XYPlot plot = Plot_Settings.getXYPlot();
            
            
            plot.setDataset(0, DS_Heel);
            plot.setDataset(1, DS_Trim);
            plot.setDataset(2, DS_Tm);
            plot.setDataset(3, DS_GM);
            
            
            plot.mapDatasetToRangeAxis(0, 0);
            plot.mapDatasetToRangeAxis(1, 1);
            plot.mapDatasetToRangeAxis(2, 2);
            plot.mapDatasetToRangeAxis(3, 3);
            plot.mapDatasetToRangeAxis(4, 0);
            //--- Heel
            NumberAxis N_Heel = new NumberAxis("\u03D5; [°]");
            NumberAxis N_Trim = new NumberAxis("\u03B8 [°]");
            NumberAxis N_Tm   = new NumberAxis("Tm [m]");
            NumberAxis N_GM   = new NumberAxis("GM [m]");
            plot.setRangeAxis(0,N_Heel);
            plot.setRangeAxisLocation(0,AxisLocation.BOTTOM_OR_LEFT);
            plot.setRangeAxis(1,N_Trim);
            plot.setRangeAxisLocation(1,AxisLocation.BOTTOM_OR_LEFT);
            plot.setRangeAxis(2,N_Tm);
            plot.setRangeAxisLocation(2,AxisLocation.BOTTOM_OR_RIGHT);
            plot.setRangeAxis(3,N_GM);
            plot.setRangeAxisLocation(3,AxisLocation.BOTTOM_OR_RIGHT);
            
            XYItemRenderer IR_A = new StandardXYItemRenderer();
            IR_A.setSeriesPaint(0, Color.RED);
            XYItemRenderer IR_B = new StandardXYItemRenderer();
            IR_B.setSeriesPaint(0, Color.BLUE);
            XYItemRenderer IR_C = new StandardXYItemRenderer();
            IR_C.setSeriesPaint(0, new Color(0,100,0));
            XYItemRenderer IR_D = new StandardXYItemRenderer();
            IR_D.setSeriesPaint(0, Color.ORANGE);
            XYItemRenderer IR_E = new StandardXYItemRenderer();
            IR_E.setSeriesPaint(0, Color.BLACK);
            IR_E.setSeriesStroke(0, new BasicStroke(
                                    1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                                    1.0f, new float[] {6.0f, 6.0f}, 0.0f
                                ));
            
            
            plot.setRenderer(0,IR_A);
            plot.setRenderer(1,IR_B);
            plot.setRenderer(2,IR_C);
            plot.setRenderer(3,IR_D);
            plot.setRenderer(4,IR_E);
            
            DefaultXYDataset DS_MAXSC = new DefaultXYDataset();
            if(SC_MaxT!=-1){
                double Min = N_Heel.getRange().getLowerBound();
                double Max = N_Heel.getRange().getUpperBound();
                DS_MAXSC.addSeries(language.getString("MAX_TIME_TO_LAUNCH_SC"), new double[][]{{SC_MaxT,SC_MaxT},{Min,Max}});
                plot.setDataset(4,DS_MAXSC);
            }  
            
            PlotStaticData.PlotDecorate(plot);
            return PlotStaticData.PlotToJPanel(Plot_Settings);
        }

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Non sono un esperto di JFreeChart, per cui ti linko solo un risultato di una ricerca in internet che spero sia adattabile al tuo caso:

    http://stackoverflow.com/questions/1...-on-the-y-axis
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.