Example usage for org.jfree.chart.axis DateAxis setDateFormatOverride

List of usage examples for org.jfree.chart.axis DateAxis setDateFormatOverride

Introduction

In this page you can find the example usage for org.jfree.chart.axis DateAxis setDateFormatOverride.

Prototype

public void setDateFormatOverride(DateFormat formatter) 

Source Link

Document

Sets the date format override and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

private void setDateAxisStyles(DateAxis axis, UIAxis comp) {
    UIDataSeries data = ((UIChart) comp.getParent()).getDataSeries();
    if (!(data instanceof UITimeSeries))
        return;/*from w  w  w . ja v  a 2s  . c  o  m*/
    UITimeSeries ts = (UITimeSeries) data;

    axis.setInverted(comp.isInverted());

    Object lowerBound = comp.getLowerBound();
    Object upperBound = comp.getUpperBound();
    Double lowerMargin = comp.getLowerMargin();
    Double upperMargin = comp.getUpperMargin();

    if (lowerBound != null)
        axis.setLowerBound(getTimePeriodValue(ts, lowerBound));
    if (upperBound != null)
        axis.setUpperBound(getTimePeriodValue(ts, upperBound));
    if (lowerMargin != null)
        axis.setLowerMargin(lowerMargin);
    if (upperMargin != null)
        axis.setUpperMargin(upperMargin);

    Double tickStep = comp.getTickStep();
    String tickFormat = comp.getTickLabelFormat();
    int dateTickUnit = 0;
    int dateTickStep = 0;

    if (tickStep != null) {
        dateTickStep = tickStep.intValue();

        TimePeriodType tp = comp.getTickUnit();
        if (tp == null) {
            tp = ts.getTimePeriod();
        }
        switch (tp) {
        case Year:
            dateTickUnit = DateTickUnit.YEAR;
            break;
        case Quarter:
            dateTickUnit = DateTickUnit.MONTH;
            dateTickStep *= 4;
            break;
        case Month:
            dateTickUnit = DateTickUnit.MONTH;
            break;
        case Week:
            dateTickUnit = DateTickUnit.DAY;
            dateTickStep *= 7;
            break;
        case Day:
            dateTickUnit = DateTickUnit.DAY;
            break;
        case Hour:
            dateTickUnit = DateTickUnit.HOUR;
            break;
        case Minute:
            dateTickUnit = DateTickUnit.MINUTE;
            break;
        case Second:
            dateTickUnit = DateTickUnit.SECOND;
            break;
        case Millisecond:
            dateTickUnit = DateTickUnit.MILLISECOND;
            break;
        default:
            throw new AssertionError();
        }
    }

    if ((tickStep != null && tickStep > 0) || tickFormat != null) {
        if (tickFormat == null) {
            axis.setTickUnit(new DateTickUnit(dateTickUnit, dateTickStep));
        } else if (tickStep == null) {
            DateFormat format = new SimpleDateFormat(tickFormat);
            axis.setDateFormatOverride(format);
        } else {
            DateFormat format = new SimpleDateFormat(tickFormat);
            axis.setTickUnit(new DateTickUnit(dateTickUnit, dateTickStep, format));
        }
    }
}

From source file:interfaces.InterfazPrincipal.java

private void botonGenerarReporteClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGenerarReporteClienteActionPerformed
    // TODO add your handling code here:
    try {/*from   w  w  w  . j  av a 2  s .  com*/
        if (clienteReporteClienteFechaFinal.getSelectedDate().getTime()
                .compareTo(clienteReporteClienteFechaInicial.getSelectedDate().getTime()) < 0) {
            JOptionPane.showMessageDialog(this, "La fecha final debe ser posterior al dia de inicio");
        } else {
            final ArrayList<Integer> listaIDFlujos = new ArrayList<>();
            final JDialog dialogoEditar = new JDialog();
            dialogoEditar.setTitle("Reporte cliente");
            dialogoEditar.setSize(350, 610);
            dialogoEditar.setResizable(false);

            JPanel panelDialogo = new JPanel();
            panelDialogo.setLayout(new GridBagLayout());

            GridBagConstraints c = new GridBagConstraints();
            //c.fill = GridBagConstraints.HORIZONTAL;

            JLabel ediitarTextoPrincipalDialogo = new JLabel("Informe cliente");
            c.gridx = 0;
            c.gridy = 0;
            c.gridwidth = 1;
            c.insets = new Insets(10, 45, 10, 10);
            Font textoGrande = new Font("Arial", 1, 18);
            ediitarTextoPrincipalDialogo.setFont(textoGrande);
            panelDialogo.add(ediitarTextoPrincipalDialogo, c);

            final JTable tablaDialogo = new JTable();
            DefaultTableModel modeloTabla = new DefaultTableModel() {

                @Override
                public boolean isCellEditable(int row, int column) {
                    //all cells false
                    return false;
                }
            };
            ;

            modeloTabla.addColumn("Factura");
            modeloTabla.addColumn("Tipo Flujo");
            modeloTabla.addColumn("Fecha");
            modeloTabla.addColumn("Valor");

            //Llenar tabla
            ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura();
            ArrayList<String[]> flujosCliente = controladorFlujoFactura.getTodosFlujo_Factura(
                    " where factura_id in (select factura_id from Factura where cliente_id = "
                            + String.valueOf(jTextFieldIdentificacionClienteReporte.getText())
                            + ") order by factura_id");
            // {"flujo_id","factura_id","tipo_flujo","fecha","valor"};
            ArrayList<Calendar> fechasFlujos = new ArrayList<>();

            for (int i = 0; i < flujosCliente.size(); i++) {
                String fila[] = new String[4];
                String[] objeto = flujosCliente.get(i);
                fila[0] = objeto[1];
                fila[1] = objeto[2];
                fila[2] = objeto[3];
                fila[3] = objeto[4];

                //Filtrar, mirar las fechas
                String[] partirEspacios = objeto[3].split("\\s");
                //El primer string es la fecha sin hora
                //Ahora esparamos por -
                String[] tomarAgeMesDia = partirEspacios[0].split("-");

                //Realizar filtro
                int ageConsulta = Integer.parseInt(tomarAgeMesDia[0]);
                int mesConsulta = Integer.parseInt(tomarAgeMesDia[1]);
                int diaConsulta = Integer.parseInt(tomarAgeMesDia[2]);

                //Obtenemos dias, mes y ao de la consulta
                //Inicial
                int anioInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.YEAR);
                int mesInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.MONTH) + 1;
                int diaInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.DAY_OF_MONTH);
                //Final
                int anioFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.YEAR);
                int mesFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.MONTH) + 1;
                int diaFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.DAY_OF_MONTH);

                //Construir fechas
                Calendar fechaDeLaBD = new GregorianCalendar(ageConsulta, mesConsulta, diaConsulta);
                //Set year, month, day)

                Calendar fechaInicialRango = new GregorianCalendar(anioInicial, mesInicial, diaInicial);
                Calendar fechaFinalRango = new GregorianCalendar(anioFinal, mesFinal, diaFinal);

                if (fechaDeLaBD.compareTo(fechaInicialRango) <= 0
                        && fechaDeLaBD.compareTo(fechaFinalRango) >= 0) {
                    fechasFlujos.add(fechaDeLaBD);
                    modeloTabla.addRow(fila);
                }

            }

            if (modeloTabla.getRowCount() > 0) {
                tablaDialogo.setModel(modeloTabla);
                tablaDialogo.getColumn("Factura").setMinWidth(80);
                tablaDialogo.getColumn("Tipo Flujo").setMinWidth(80);
                tablaDialogo.getColumn("Fecha").setMinWidth(90);
                tablaDialogo.getColumn("Valor").setMinWidth(80);
                tablaDialogo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                JScrollPane scroll = new JScrollPane(tablaDialogo);
                scroll.setPreferredSize(new Dimension(330, 150));

                c.gridx = 0;
                c.gridy = 1;
                c.gridwidth = 1;
                c.insets = new Insets(0, 0, 0, 0);
                panelDialogo.add(scroll, c);

                TimeSeries localTimeSeries = new TimeSeries("Compras del cliente en el periodo");

                Map listaAbonos = new HashMap();

                for (int i = 0; i < modeloTabla.getRowCount(); i++) {
                    listaIDFlujos.add(Integer.parseInt(flujosCliente.get(i)[0]));

                    if (modeloTabla.getValueAt(i, 1).equals("abono")) {
                        Calendar fechaFlujo = fechasFlujos.get(i);
                        double valor = Double.parseDouble(String.valueOf(modeloTabla.getValueAt(i, 3)));

                        int anoDato = fechaFlujo.get(Calendar.YEAR);
                        int mesDato = fechaFlujo.get(Calendar.MONTH) + 1;
                        int diaDato = fechaFlujo.get(Calendar.DAY_OF_MONTH);
                        Day FechaDato = new Day(diaDato, mesDato, anoDato);

                        if (listaAbonos.get(FechaDato) != null) {
                            double valorAbono = (double) listaAbonos.get(FechaDato);
                            listaAbonos.remove(FechaDato);
                            listaAbonos.put(FechaDato, valorAbono + valor);
                        } else {
                            listaAbonos.put(FechaDato, valor);

                        }

                    }

                }
                Double maximo = 0.0;
                Iterator iterator = listaAbonos.keySet().iterator();
                while (iterator.hasNext()) {
                    Day key = (Day) iterator.next();
                    Double value = (double) listaAbonos.get(key);
                    maximo = Math.max(maximo, value);
                    localTimeSeries.add(key, value);
                }

                //localTimeSeries.add();
                TimeSeriesCollection datos = new TimeSeriesCollection(localTimeSeries);

                JFreeChart chart = ChartFactory.createTimeSeriesChart("Compras del cliente en el periodo", // Title
                        "Tiempo", // x-axis Label
                        "Total ($)", // y-axis Label
                        datos, // Dataset
                        true, // Show Legend
                        true, // Use tooltips
                        false // Configure chart to generate URLs?
                );
                /*Altering the graph */
                XYPlot plot = (XYPlot) chart.getPlot();
                plot.setAxisOffset(new RectangleInsets(5.0, 10.0, 10.0, 5.0));
                plot.setDomainCrosshairVisible(true);
                plot.setRangeCrosshairVisible(true);

                XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
                renderer.setBaseShapesVisible(true);
                renderer.setBaseShapesFilled(true);

                NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
                numberAxis.setRange(new Range(0, maximo * 1.2));
                Font font = new Font("Dialog", Font.PLAIN, 9);
                numberAxis.setTickLabelFont(font);
                numberAxis.setLabelFont(font);

                DateAxis axis = (DateAxis) plot.getDomainAxis();
                axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy"));
                axis.setAutoTickUnitSelection(false);
                axis.setVerticalTickLabels(true);

                axis.setTickLabelFont(font);
                axis.setLabelFont(font);

                LegendTitle leyendaChart = chart.getLegend();
                leyendaChart.setItemFont(font);

                Font fontTitulo = new Font("Dialog", Font.BOLD, 12);
                TextTitle tituloChart = chart.getTitle();
                tituloChart.setFont(fontTitulo);

                ChartPanel CP = new ChartPanel(chart);
                Dimension D = new Dimension(330, 300);
                CP.setPreferredSize(D);
                CP.setVisible(true);
                c.gridx = 0;
                c.gridy = 2;
                c.gridwidth = 1;
                c.insets = new Insets(10, 0, 0, 0);
                panelDialogo.add(CP, c);

                c.gridx = 0;
                c.gridy = 3;
                c.gridwidth = 1;
                c.anchor = GridBagConstraints.WEST;
                c.insets = new Insets(10, 30, 0, 0);

                JButton botonCerrar = new JButton("Cerrar");
                botonCerrar.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        dialogoEditar.dispose();
                    }
                });
                panelDialogo.add(botonCerrar, c);

                JButton botonGenerarPDF = new JButton("Guardar archivo");
                botonGenerarPDF.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        ReporteFlujosCliente reporteFlujosCliente = new ReporteFlujosCliente();
                        reporteFlujosCliente.guardarDocumentoDialogo(dialogoEditar, listaIDFlujos,
                                Integer.parseInt(jTextFieldIdentificacionClienteReporte.getText()),
                                clienteReporteClienteFechaInicial.getSelectedDate(),
                                clienteReporteClienteFechaFinal.getSelectedDate());

                    }
                });
                c.insets = new Insets(10, 100, 0, 0);

                panelDialogo.add(botonGenerarPDF, c);

                JButton botonImprimir = new JButton("Imprimir");
                botonImprimir.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        ReporteFlujosCliente reporteFlujosCliente = new ReporteFlujosCliente();
                        reporteFlujosCliente.imprimirFlujo(listaIDFlujos,
                                Integer.parseInt(jTextFieldIdentificacionClienteReporte.getText()),
                                clienteReporteClienteFechaInicial.getSelectedDate(),
                                clienteReporteClienteFechaFinal.getSelectedDate());

                    }
                });
                c.insets = new Insets(10, 230, 0, 0);

                panelDialogo.add(botonImprimir, c);
                dialogoEditar.add(panelDialogo);

                dialogoEditar.setVisible(true);

            } else {
                JOptionPane.showMessageDialog(this,
                        "El cliente no registra movimientos en el rango de fechas seleccionado");
            }

        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "Debe seleccionar un da inicial y final de fechas");
    }

}

From source file:ucar.unidata.idv.control.chart.TimeSeriesChart.java

/**
 * Make the plot// www. ja  v a2s .c o m
 *
 * @return The plot_
 */
public Plot doMakePlot() {

    IdvPreferenceManager pref = control.getControlContext().getIdv().getPreferenceManager();
    TimeZone timeZone = pref.getDefaultTimeZone();
    NumberAxis valueAxis = new FixedWidthNumberAxis("");
    final SimpleDateFormat sdf = new SimpleDateFormat(
            ((dateFormat != null) ? dateFormat : pref.getDefaultDateFormat()));
    sdf.setTimeZone(timeZone);
    DateAxis timeAxis = new DateAxis("Time (" + timeZone.getID() + ")", timeZone) {

        protected List xxxxxrefreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {

            List ticks = super.refreshTicksHorizontal(g2, dataArea, edge);

            List<Tick> result = new java.util.ArrayList<Tick>();

            Font tickLabelFont = getTickLabelFont();
            g2.setFont(tickLabelFont);

            if (isAutoTickUnitSelection()) {
                selectAutoTickUnit(g2, dataArea, edge);
            }

            DateTickUnit unit = getTickUnit();
            Date tickDate = calculateLowestVisibleTickValue(unit);
            Date upperDate = getMaximumDate();

            Date firstDate = null;
            while (tickDate.before(upperDate)) {

                if (!isHiddenValue(tickDate.getTime())) {
                    // work out the value, label and position
                    String tickLabel;
                    DateFormat formatter = getDateFormatOverride();
                    if (firstDate == null) {
                        if (formatter != null) {
                            tickLabel = formatter.format(tickDate);
                        } else {
                            tickLabel = getTickUnit().dateToString(tickDate);
                        }
                        firstDate = tickDate;
                    } else {
                        double msdiff = tickDate.getTime() - firstDate.getTime();
                        int hours = (int) (msdiff / 1000 / 60 / 60);
                        tickLabel = hours + "H";
                    }
                    //                tickLabel = tickLabel;
                    TextAnchor anchor = null;
                    TextAnchor rotationAnchor = null;
                    double angle = 0.0;
                    if (isVerticalTickLabels()) {
                        anchor = TextAnchor.CENTER_RIGHT;
                        rotationAnchor = TextAnchor.CENTER_RIGHT;
                        if (edge == RectangleEdge.TOP) {
                            angle = Math.PI / 2.0;
                        } else {
                            angle = -Math.PI / 2.0;
                        }
                    } else {
                        if (edge == RectangleEdge.TOP) {
                            anchor = TextAnchor.BOTTOM_CENTER;
                            rotationAnchor = TextAnchor.BOTTOM_CENTER;
                        } else {
                            anchor = TextAnchor.TOP_CENTER;
                            rotationAnchor = TextAnchor.TOP_CENTER;
                        }
                    }

                    Tick tick = new DateTick(tickDate, tickLabel, anchor, rotationAnchor, angle);
                    result.add(tick);
                    tickDate = unit.addToDate(tickDate, getTimeZone());
                } else {
                    tickDate = unit.rollDate(tickDate, getTimeZone());

                    continue;
                }

                // could add a flag to make the following correction optional...
                switch (unit.getUnit()) {

                case (DateTickUnit.MILLISECOND):
                case (DateTickUnit.SECOND):
                case (DateTickUnit.MINUTE):
                case (DateTickUnit.HOUR):
                case (DateTickUnit.DAY):
                    break;

                case (DateTickUnit.MONTH):
                    tickDate = calculateDateForPositionX(new Month(tickDate, getTimeZone()),
                            getTickMarkPosition());

                    break;

                case (DateTickUnit.YEAR):
                    tickDate = calculateDateForPositionX(new Year(tickDate, getTimeZone()),
                            getTickMarkPosition());

                    break;

                default:
                    break;

                }

            }

            return result;

        }

        private Date calculateDateForPositionX(RegularTimePeriod period, DateTickMarkPosition position) {

            if (position == null) {
                throw new IllegalArgumentException("Null 'position' argument.");
            }
            Date result = null;
            if (position == DateTickMarkPosition.START) {
                result = new Date(period.getFirstMillisecond());
            } else if (position == DateTickMarkPosition.MIDDLE) {
                result = new Date(period.getMiddleMillisecond());
            } else if (position == DateTickMarkPosition.END) {
                result = new Date(period.getLastMillisecond());
            }

            return result;

        }

    };
    timeAxis.setDateFormatOverride(sdf);

    final XYPlot[] xyPlotHolder = { null };

    xyPlotHolder[0] = new MyXYPlot(new TimeSeriesCollection(), timeAxis, valueAxis, null) {
        public void drawBackground(Graphics2D g2, Rectangle2D area) {
            super.drawBackground(g2, area);
            drawSunriseSunset(g2, xyPlotHolder[0], area);
        }
    };

    if (animationTimeAnnotation != null) {
        xyPlotHolder[0].addAnnotation(animationTimeAnnotation);
    }

    return xyPlotHolder[0];

}

From source file:gov.llnl.lustre.lwatch.PlotFrame2.java

/**
 * Define the JFreeChart chart./*  w w w  .  ja v  a 2s .  c om*/
 *
 * @param dataset dataset to be plotted in the chart.
 */

public JFreeChart createChart(XYDataset dataset) {

    // Load data for settings from last "Refresh" time
    String[] selectedRows = lastRefreshPlotParams.getCategories();
    String[] selectedVars = lastRefreshPlotParams.getVariables();
    String[] selectedCurves = lastRefreshPlotParams.getCurves();

    int savedGranularity = granularity;
    granularity = lastRefreshPlotParams.getGranularity();

    boolean showLegend = true;
    //if (((isAnAggPlot) && (nColsSelected * nCurvesSelected > 8)) ||
    //(nRowsSelected * nColsSelected * nCurvesSelected > 8))
    //showLegend = false;
    if (((isAnAggPlot) && (selectedVars.length * selectedCurves.length > 8))
            || (selectedRows.length * selectedVars.length * selectedCurves.length > 8))
        showLegend = false;

    //if (fromRefresh && (nRowsSelected > 0 && nColsSelected > 0 && nCurvesSelected > 0) &&
    //(!noVarSelected)) {
    if (fromRefresh && (selectedRows.length > 0 && selectedVars.length > 0 && selectedCurves.length > 0)
            && (!noVarSelected)) {
        //Debug.out("nRowsSelected = " + nRowsSelected +
        //"   nColsSelected = " + nColsSelected +
        //"   nCurvesSelected = " + nCurvesSelected);

        pD = new PlotDescriptor();
    }

    chart = ChartFactory.createTimeSeriesChart(fsName + " - " + type + " data", // title
            "Date", // x-axis label
            yAxisLabel, // y-axis label
            dataset, // data
            showLegend, // create legend
            false, // generate tooltips
            false // generate URLs
    );

    chart.setBackgroundPaint(Color.black); //white);  // Border color
    chart.setBorderVisible(true);
    TextTitle tTitle = chart.getTitle();
    tTitle.setPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.black); //lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    // Check need for logorihmic axis
    if (useLogRangeAxis) {
        LogarithmicAxis rangeAxis2 = new LogarithmicAxis(yAxisLabel);
        plot.setRangeAxis(0, rangeAxis2);
    }

    // Default axis annotation is in black. So if the chart background
    // Paint was set to black above, we need to set axis labels, 
    // tick labels and tick marks to be a contrasting color.
    plot.getDomainAxis().setLabelPaint(Color.white);
    plot.getDomainAxis().setTickLabelPaint(Color.white);
    plot.getDomainAxis().setTickMarkPaint(Color.white);
    plot.getRangeAxis().setLabelPaint(Color.white);
    plot.getRangeAxis().setTickLabelPaint(Color.white);
    plot.getRangeAxis().setTickMarkPaint(Color.white);

    // Grab the colors from the legend.
    //int nCurves = nRowsSelected * nColsSelected * nCurvesSelected;
    int nCurves = selectedRows.length * selectedVars.length * selectedCurves.length;
    if (localDebug) {
        Debug.out("selectedRows.length, selectedVars.length, selectedCurves.length = " + selectedRows.length
                + ", " + selectedVars.length + ", " + selectedCurves.length);
        Debug.out("Dimension legendColors to size = " + nCurves);
    }
    legendColors = new Color[nCurves];
    LegendItemCollection lic = plot.getLegendItems();
    for (int i = 0; i < lic.getItemCount(); i++) {
        LegendItem li = lic.get(i);
        legendColors[i] = (Color) li.getLinePaint();
        //if (localDebug)
        //Debug.out("Line Paint for legend " + i + " = " +
        //legendColors[i]);
    }

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(showIcons); // Controls icons at data pts.
        renderer.setBaseShapesFilled(false);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    if (granularity == Database.HOUR)
        axis.setDateFormatOverride(new SimpleDateFormat("MM/dd HH")); //("dd-MMM-yy"));
    else if (granularity == Database.DAY)
        axis.setDateFormatOverride(new SimpleDateFormat("MM/dd/yy")); //("dd-MMM-yy"));
    else if (granularity == Database.WEEK)
        axis.setDateFormatOverride(new SimpleDateFormat("MM/dd/yy")); //("dd-MMM-yy"));
    else if (granularity == Database.MONTH)
        axis.setDateFormatOverride(new SimpleDateFormat("MM/yy")); //("dd-MMM-yy"));
    else if (granularity == Database.YEAR)
        axis.setDateFormatOverride(new SimpleDateFormat("yyyy HH:mm")); //("dd-MMM-yy"));
    else // granualrity == Database.RAW or HEARTBEAT
        axis.setDateFormatOverride(new SimpleDateFormat("MM/dd HH:mm:ss")); //("dd-MMM-yy"));

    // Reset granularity;
    granularity = savedGranularity;

    return chart;

}