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

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

Introduction

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

Prototype

public void setLabel(String label) 

Source Link

Document

Sets the label for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:com.marvelution.jira.plugins.hudson.charts.BuildResultsRatioChartGenerator.java

/**
 * {@inheritDoc}//from   ww w.  j a v  a2 s . co  m
 */
@Override
public ChartHelper generateChart() {
    final Map<Integer, Build> buildMap = new HashMap<Integer, Build>();
    final CategoryTableXYDataset dataSet = new CategoryTableXYDataset();
    for (Build build : builds) {
        buildMap.put(Integer.valueOf(build.getBuildNumber()), build);
        dataSet.add(Double.valueOf(build.getBuildNumber()), Double.valueOf(build.getDuration()),
                getI18n().getText("hudson.charts.duration"));
    }
    final JFreeChart chart = ChartFactory.createXYBarChart("", "", false,
            getI18n().getText("hudson.charts.duration"), dataSet, PlotOrientation.VERTICAL, false, false,
            false);
    chart.setBackgroundPaint(Color.WHITE);
    chart.setBorderVisible(false);
    final BuildResultRenderer renderer = new BuildResultRenderer(server, buildMap);
    renderer.setBaseItemLabelFont(ChartDefaults.defaultFont);
    renderer.setBaseItemLabelsVisible(false);
    renderer.setMargin(0.0D);
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));
    renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer.setBaseToolTipGenerator(renderer);
    renderer.setURLGenerator(renderer);
    final XYPlot xyPlot = chart.getXYPlot();
    xyPlot.setAxisOffset(new RectangleInsets(1.0D, 1.0D, 1.0D, 1.0D));
    xyPlot.setRenderer(renderer);
    final NumberAxis domainAxis = new NumberAxis();
    domainAxis.setLowerBound(Collections.min(buildMap.keySet()));
    domainAxis.setUpperBound(Collections.max(buildMap.keySet()));
    final TickUnitSource ticks = NumberAxis.createIntegerTickUnits();
    domainAxis.setStandardTickUnits(ticks);
    xyPlot.setDomainAxis(domainAxis);
    final DateAxis rangeAxis = new DateAxis();
    final DurationFormat durationFormat = new DurationFormat();
    rangeAxis.setDateFormatOverride(durationFormat);
    rangeAxis.setLabel(getI18n().getText("hudson.charts.duration"));
    xyPlot.setRangeAxis(rangeAxis);
    ChartUtil.setupPlot(xyPlot);
    return new ChartHelper(chart);
}

From source file:greenapi.ui.charts.ChartPanelSupport.java

public void cleanLabels() {
    this.getChart().setTitle("");
    DateAxis localDateAxis = (DateAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis();
    localDateAxis.setLabel("");
    ValueAxis localValueAxis = ((XYPlot) this.chart.getPlot()).getRangeAxis();
    localValueAxis.setLabel("");
}

From source file:msec.org.Tools.java

public static String generateFullDayChart(String filename, OneDayValue[] data, String title) {
    if (data[0].getValues().length != 1440) {
        return "data size invalid";
    }/*from ww w . java  2 s.c  o  m*/
    if (data.length > 1) {
        if (data[1].getValues() == null || data[1].getValues().length != 1440) {
            return "data 1 invalid";
        }
    }

    XYDataset xydataset = createDataset(data);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(title, "time", "", xydataset, true, true, true);

    try {
        XYPlot xyplot = (XYPlot) jfreechart.getPlot();

        //
        DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
        dateaxis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
        dateaxis.setLabelFont(new Font("", Font.PLAIN, 16)); //
        dateaxis.setLabelPaint(ChartColor.gray);
        dateaxis.setTickLabelFont(new Font("", Font.PLAIN, 16));
        dateaxis.setTickLabelPaint(ChartColor.GRAY);

        GregorianCalendar endgc = (GregorianCalendar) gc.clone();
        endgc.add(GregorianCalendar.DATE, 1);
        dateaxis.setMaximumDate(endgc.getTime());

        dateaxis.setTickMarksVisible(true);
        dateaxis.setTickMarkInsideLength(5);
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 2));
        dateaxis.setVerticalTickLabels(true);
        dateaxis.setLabel("");

        //
        ValueAxis rangeAxis = xyplot.getRangeAxis();//?
        rangeAxis.setLabelFont(new Font("", Font.PLAIN, 16));
        rangeAxis.setLabelPaint(ChartColor.gray);
        rangeAxis.setTickLabelFont(new Font("", Font.PLAIN, 16));
        rangeAxis.setTickLabelPaint(ChartColor.gray);
        rangeAxis.setLowerBound(0);

        //
        jfreechart.getLegend().setItemFont(new Font("", Font.PLAIN, 12));
        jfreechart.getLegend().setItemPaint(ChartColor.gray);
        jfreechart.getLegend().setBorder(0, 0, 0, 0);//

        //
        jfreechart.getTitle().setFont(new Font("", Font.PLAIN, 18));//
        jfreechart.getTitle().setPaint(ChartColor.gray);

        //?
        xyplot.setRangeGridlinePaint(ChartColor.GRAY);
        xyplot.setBackgroundPaint(ChartColor.WHITE);
        xyplot.setOutlinePaint(null);//

        int w = 500;
        int h = 300;

        // ChartUtilities.saveChartAsPNG(new File(filename), jfreechart, w, h);
        ChartUtilities.saveChartAsJPEG(new File(filename), 0.8f, jfreechart, w, h);

        return "success";

    } catch (Exception e) {
        e.printStackTrace();
        return e.getMessage();
    }
}

From source file:wattsup.jsdk.ui.ChartPanelSupport.java

/**
 * Sets empty the chart's labels./*from  w w w.j a v  a 2  s .  co m*/
 */
public void cleanLabels() {
    this.getChart().setTitle("");
    DateAxis localDateAxis = (DateAxis) ((XYPlot) this.chart_.getPlot()).getDomainAxis();
    localDateAxis.setLabel("");
    ValueAxis localValueAxis = ((XYPlot) this.chart_.getPlot()).getRangeAxis();
    localValueAxis.setLabel("");
}

From source file:msec.org.Tools.java

public static String generateDaysChart(String filename, ArrayList<OneDayValue> data, OneAttrDaysChart chart,
        String title, int duration) {
    if (data.size() == 0) {
        return "data size invalid";
    }/*w  w w  .j a v a  2  s  .c  o m*/

    int date = Integer.parseInt(data.get(0).getDate());
    GregorianCalendar startgc = new GregorianCalendar(date / 10000, date % 10000 / 100 - 1, date % 100);

    XYDataset xydataset = createDaysDataset(data, startgc, chart);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(title, "time", "", xydataset, true, true, true);

    try {
        XYPlot xyplot = (XYPlot) jfreechart.getPlot();

        //
        DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
        dateaxis.setDateFormatOverride(new SimpleDateFormat("MM/dd"));
        dateaxis.setLabelFont(new Font("", Font.PLAIN, 16)); //
        dateaxis.setLabelPaint(ChartColor.gray);
        dateaxis.setTickLabelFont(new Font("", Font.PLAIN, 16));
        dateaxis.setTickLabelPaint(ChartColor.GRAY);

        dateaxis.setMinimumDate(startgc.getTime());
        GregorianCalendar endgc = (GregorianCalendar) startgc.clone();
        endgc.add(GregorianCalendar.DATE, duration);
        dateaxis.setMaximumDate(endgc.getTime());

        dateaxis.setTickMarksVisible(true);
        dateaxis.setTickMarkInsideLength(5);
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.DAY, 1));
        dateaxis.setVerticalTickLabels(true);
        dateaxis.setLabel("");

        //
        ValueAxis rangeAxis = xyplot.getRangeAxis();//?
        rangeAxis.setLabelFont(new Font("", Font.PLAIN, 16));
        rangeAxis.setLabelPaint(ChartColor.gray);
        rangeAxis.setTickLabelFont(new Font("", Font.PLAIN, 16));
        rangeAxis.setTickLabelPaint(ChartColor.gray);
        rangeAxis.setLowerBound(0);

        //
        jfreechart.getLegend().setItemFont(new Font("", Font.PLAIN, 12));
        jfreechart.getLegend().setItemPaint(ChartColor.gray);
        jfreechart.getLegend().setBorder(0, 0, 0, 0);//

        //
        jfreechart.getTitle().setFont(new Font("", Font.PLAIN, 18));//
        jfreechart.getTitle().setPaint(ChartColor.gray);

        //?
        xyplot.setRangeGridlinePaint(ChartColor.GRAY);
        xyplot.setBackgroundPaint(ChartColor.WHITE);
        xyplot.setOutlinePaint(null);//

        int w = 500;
        int h = 300;

        // ChartUtilities.saveChartAsPNG(new File(filename), jfreechart, w, h);
        ChartUtilities.saveChartAsJPEG(new File(filename), 0.8f, jfreechart, w, h);

        return "success";

    } catch (Exception e) {
        e.printStackTrace();
        return e.getMessage();
    }
}

From source file:edu.jhuapl.graphs.jfreechart.JFreeChartTimeSeriesGraphSource.java

/**
 * Initializes the graph.  This method generates the backing {@link JFreeChart} from the time series and graph
 * parameter data.//w ww .  j  av  a  2  s .  co m
 *
 * @throws GraphException if the initialization fails
 */
public void initialize() throws GraphException {
    String title = getParam(GraphSource.GRAPH_TITLE, String.class, DEFAULT_TITLE);
    String xLabel = getParam(GraphSource.GRAPH_X_LABEL, String.class, DEFAULT_DOMAIN_LABEL);
    String yLabel = getParam(GraphSource.GRAPH_Y_LABEL, String.class, DEFAULT_RANGE_LABEL);
    Shape graphShape = getParam(GraphSource.GRAPH_SHAPE, Shape.class, DEFAULT_GRAPH_SHAPE);
    Paint graphColor = getParam(GraphSource.GRAPH_COLOR, Paint.class, DEFAULT_GRAPH_COLOR);
    boolean legend = getParam(GraphSource.GRAPH_LEGEND, Boolean.class, DEFAULT_GRAPH_LEGEND);
    boolean graphToolTip = getParam(GraphSource.GRAPH_TOOL_TIP, Boolean.class, DEFAULT_GRAPH_TOOL_TIP);
    Stroke graphStroke = getParam(GraphSource.GRAPH_STROKE, Stroke.class, DEFAULT_GRAPH_STROKE);
    Font titleFont = getParam(GraphSource.GRAPH_FONT, Font.class, DEFAULT_GRAPH_TITLE_FONT);
    boolean graphBorder = getParam(GraphSource.GRAPH_BORDER, Boolean.class, DEFAULT_GRAPH_BORDER);
    boolean legendBorder = getParam(GraphSource.LEGEND_BORDER, Boolean.class, DEFAULT_LEGEND_BORDER);
    Double offset = getParam(GraphSource.AXIS_OFFSET, Double.class, DEFAULT_AXIS_OFFSET);

    checkSeriesType(data);
    @SuppressWarnings("unchecked")
    List<? extends TimeSeriesInterface> timeData = (List<? extends TimeSeriesInterface>) data;

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    int seriesCount = 1;
    for (TimeSeriesInterface series : timeData) {
        dataset.addSeries(buildTimeSeries(series, seriesCount));
        seriesCount += 1;
    }

    // actually create the chart
    this.chart = ChartFactory.createTimeSeriesChart(title, xLabel, yLabel, dataset, false, graphToolTip, false);

    // start customizing it
    Paint backgroundColor = getParam(GraphSource.BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR);
    Paint plotColor = getParam(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Paint.class, backgroundColor);
    Paint graphDomainGridlinePaint = getParam(GraphSource.GRAPH_DOMAIN_GRIDLINE_PAINT, Paint.class,
            backgroundColor);
    Paint graphRangeGridlinePaint = getParam(GraphSource.GRAPH_RANGE_GRIDLINE_PAINT, Paint.class,
            backgroundColor);

    this.chart.setBackgroundPaint(backgroundColor);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(plotColor);
    plot.setAxisOffset(new RectangleInsets(offset, offset, offset, offset));
    plot.setDomainGridlinePaint(graphDomainGridlinePaint);
    plot.setRangeGridlinePaint(graphRangeGridlinePaint);

    if (graphBorder) {

    } else {
        plot.setOutlinePaint(null);
    }

    //Use a TextTitle to change the font of the graph title
    TextTitle title1 = new TextTitle();
    title1.setText(title);
    title1.setFont(titleFont);
    chart.setTitle(title1);

    //Makes a wrapper for the legend to remove the border around it
    if (legend) {
        LegendTitle legend1 = new LegendTitle(chart.getPlot());
        BlockContainer wrapper = new BlockContainer(new BorderArrangement());
        if (legendBorder) {
            wrapper.setFrame(new BlockBorder(1, 1, 1, 1));
        } else {
            wrapper.setFrame(new BlockBorder(0, 0, 0, 0));
        }
        BlockContainer items = legend1.getItemContainer();
        items.setPadding(2, 10, 5, 2);
        wrapper.add(items);
        legend1.setWrapper(wrapper);
        legend1.setPosition(RectangleEdge.BOTTOM);
        legend1.setHorizontalAlignment(HorizontalAlignment.CENTER);

        if (params.get(GraphSource.LEGEND_FONT) instanceof Font) {
            legend1.setItemFont(((Font) params.get(GraphSource.LEGEND_FONT)));
        }

        chart.addSubtitle(legend1);
    }

    boolean include0 = getParam(GraphSource.GRAPH_RANGE_INCLUDE_0, Boolean.class, true);
    NumberAxis numAxis = (NumberAxis) plot.getRangeAxis();
    double rangeLower = getParam(GraphSource.GRAPH_RANGE_LOWER_BOUND, Double.class, numAxis.getLowerBound());
    double rangeUpper = getParam(GraphSource.GRAPH_RANGE_UPPER_BOUND, Double.class, numAxis.getUpperBound());
    boolean graphRangeIntegerTick = getParam(GraphSource.GRAPH_RANGE_INTEGER_TICK, Boolean.class, false);
    boolean graphRangeMinorTickVisible = getParam(GraphSource.GRAPH_RANGE_MINOR_TICK_VISIBLE, Boolean.class,
            true);

    if (include0) {
        rangeLower = 0;
    }

    numAxis.setRange(rangeLower, rangeUpper);

    if (graphRangeIntegerTick) {
        numAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    numAxis.setMinorTickMarksVisible(graphRangeMinorTickVisible);
    setupFont(numAxis, GraphSource.GRAPH_Y_AXIS_FONT);

    if (params.get(GraphSource.GRAPH_Y_AXIS_LABEL_FONT) instanceof Font) {
        numAxis.setLabelFont(((Font) params.get(GraphSource.GRAPH_Y_AXIS_LABEL_FONT)));
    }

    TimeResolution minimumResolution = getMinimumResolution(timeData);
    DateFormat dateFormat = getParam(GraphSource.GRAPH_DATE_FORMATTER, DateFormat.class,
            new DefaultDateFormatFactory().getFormat(minimumResolution));

    if (params.get(DATE_AXIS) instanceof DateAxis) {
        DateAxis dateAxis = (DateAxis) params.get(DATE_AXIS);
        dateAxis.setLabel(xLabel);
        plot.setDomainAxis(dateAxis);
    }
    DateAxis dateAxis = ((DateAxis) plot.getDomainAxis());
    dateAxis.setDateFormatOverride(dateFormat);

    if (params.get(GraphSource.GRAPH_X_AXIS_LABEL_FONT) instanceof Font) {
        dateAxis.setLabelFont(((Font) params.get(GraphSource.GRAPH_X_AXIS_LABEL_FONT)));
    }

    int minTick = getParam(GraphSource.GRAPH_MIN_DOMAIN_TICK, Integer.class, 1);
    if (minTick <= 0) {
        minTick = 1;
    }

    dateAxis.setTickUnit(getDateTickUnit(minimumResolution, minTick), false, false);
    //dateAxis.setMinorTickMarksVisible(true);
    //dateAxis.setMinorTickCount(7);
    dateAxis.setMinorTickMarkOutsideLength(2);

    Integer minorTick = getParam(GraphSource.GRAPH_MINOR_TICKS, Integer.class, null);
    if (minorTick != null) {
        int minorVal = minorTick;
        if (minorVal > 0) {
            dateAxis.setMinorTickCount(minorVal);
        }
    }

    setupFont(dateAxis, GraphSource.GRAPH_X_AXIS_FONT);

    //double lowerMargin = getParam(DOMAIN_AXIS_LOWER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_LOWER_MARGIN);
    double lowerMargin = getParam(DOMAIN_AXIS_LOWER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_LOWER_MARGIN);
    dateAxis.setLowerMargin(lowerMargin);

    //double upperMargin = getParam(DOMAIN_AXIS_UPPER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_UPPER_MARGIN);
    double upperMargin = getParam(DOMAIN_AXIS_UPPER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_UPPER_MARGIN);
    dateAxis.setUpperMargin(upperMargin);

    Date domainLower = getParam(GraphSource.GRAPH_DOMAIN_LOWER_BOUND, Date.class, dateAxis.getMinimumDate());
    Date domainUpper = getParam(GraphSource.GRAPH_DOMAIN_UPPER_BOUND, Date.class, dateAxis.getMaximumDate());

    dateAxis.setRange(domainLower, domainUpper);

    // depending on the domain axis range, display either 1 tick per day, week, month or year
    TickUnits standardUnits = new TickUnits();
    standardUnits.add(new DateTickUnit(DateTickUnitType.DAY, 1));
    standardUnits.add(new DateTickUnit(DateTickUnitType.DAY, 7));
    standardUnits.add(new DateTickUnit(DateTickUnitType.MONTH, 1));
    standardUnits.add(new DateTickUnit(DateTickUnitType.YEAR, 1));
    dateAxis.setStandardTickUnits(standardUnits);

    TimeSeriesRenderer renderer = new TimeSeriesRenderer(dataset);
    setupRenderer(renderer, graphColor, graphShape, graphStroke);
    renderer.setBaseFillPaint(Color.BLACK);
    renderer.setSeriesOutlinePaint(0, Color.WHITE);

    //renderer.setUseOutlinePaint(true);

    plot.setRenderer(renderer);
    this.initialized = true;
}

From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java

/**
 * Generates a simple Time Axis.//  w  w w  . j av  a 2 s.c  o m
 *
 * @return the generated Time Axis.
 */
private DateAxis generateTimeAxis() {
    DateAxis xAxis = new DateAxis("");
    xAxis.setLowerMargin(0.05);
    xAxis.setUpperMargin(0.02);
    xAxis.setLabel(null);
    xAxis.setTickLabelsVisible(true);
    xAxis.setTickMarksVisible(true);

    xAxis.setAxisLineVisible(true);
    xAxis.setNegativeArrowVisible(false);
    xAxis.setPositiveArrowVisible(false);
    xAxis.setVisible(true);
    xAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    Locale locale = JiveGlobals.getLocale();
    // If the tick units have not yet been setup or the locale has changed
    if (tickUnits == null || !locale.equals(oldLocale)) {
        tickUnits = createTickUnits(locale, JiveGlobals.getTimeZone());
        oldLocale = locale;
    }
    xAxis.setStandardTickUnits(tickUnits);

    return xAxis;
}

From source file:desmoj.extensions.grafic.util.Plotter.java

/**
 * configure domainAxis (label, timeZone, locale, tick labels)
 * of time-series chart/*from ww w  .  j av  a 2  s .co  m*/
 * @param dateAxis
 */
private void configureDomainAxis(DateAxis dateAxis) {
    if (this.begin != null)
        dateAxis.setMinimumDate(this.begin);
    if (this.end != null)
        dateAxis.setMaximumDate(this.end);
    dateAxis.setTimeZone(this.timeZone);

    Date dateMin = dateAxis.getMinimumDate();
    Date dateMax = dateAxis.getMaximumDate();
    //DateFormat formatter = new SimpleDateFormat("d.MM.yyyy HH:mm:ss.SSS");;
    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM, locale);
    String label = "Time: " + formatter.format(dateMin) + " .. " + formatter.format(dateMax);
    formatter = new SimpleDateFormat("z");
    label += " " + formatter.format(dateMax);
    dateAxis.setLabel(label);

    TimeInstant max = new TimeInstant(dateMax);
    TimeInstant min = new TimeInstant(dateMin);
    TimeSpan diff = TimeOperations.diff(max, min);

    if (TimeSpan.isLongerOrEqual(diff, new TimeSpan(1, TimeUnit.DAYS)))
        formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);
    else if (TimeSpan.isLongerOrEqual(diff, new TimeSpan(1, TimeUnit.HOURS)))
        formatter = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
    else if (TimeSpan.isLongerOrEqual(diff, new TimeSpan(1, TimeUnit.MINUTES)))
        formatter = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale);
    else
        formatter = new SimpleDateFormat("HH:mm:ss.SSS");
    dateAxis.setDateFormatOverride(formatter);
    dateAxis.setVerticalTickLabels(true);
}

From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java

/**
 * some jFreeChart Axis settings for Histogram
 * @param plot            jFreeChart plot instance
 * @param domainAxisLabel   Label of domain Axis
 *///w w w  .  ja v a 2  s .com
private void buildHistogramAxisFormat(XYPlot plot, String domainAxisLabel) {
    switch (this.statistic.getTypeData()) {
    case Statistic.DATA_Observations:
        ValueAxis rangeAxis = (ValueAxis) plot.getRangeAxis();
        rangeAxis.setLabel("Count");
        break;
    case Statistic.DATA_TimeSeries:
        DateAxis dateAxis = new DateAxis();
        DateAxis[] rangeAxisArray = new DateAxis[1];
        rangeAxisArray[0] = dateAxis;
        plot.setRangeAxes(rangeAxisArray);
        dateAxis = (DateAxis) plot.getRangeAxis();
        dateAxis.setMinimumDate(new Date(0));
        long diff = dateAxis.getMaximumDate().getTime();
        String format, unit;
        if (diff > 24 * 60 * 60 * 1000) {
            format = "d.MM.yyyy";
            unit = "[day]";
        } else if (diff > 60 * 60 * 1000) {
            format = "H:mm";
            unit = "[h]";
        } else if (diff > 60 * 1000) {
            format = "m:ss";
            unit = "[min]";
        } else if (diff > 1000) {
            format = "s.S";
            unit = "[sec]";
        } else {
            format = "S";
            unit = "[millisec]";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        dateAxis.setDateFormatOverride(sdf);
        dateAxis.setLabel("Time " + unit);
        dateAxis.setLabelFont(Grafic.FONT_DEFAULT);
        break;
    }

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLabel(domainAxisLabel);
    /*
    domainAxis.setLowerBound(statistik.getHistogramLow());
    domainAxis.setUpperBound(statistik.getHistogramHigh());
    TickUnits tu = new TickUnits(); tu.add(new NumberTickUnit(statistik.getHistogramIntervalLength()));
    domainAxis.setStandardTickUnits(tu);
    domainAxis.setAutoTickUnitSelection(true);
    domainAxis.setVerticalTickLabels(false);
    */
}

From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java

/**
 * some jFreeChart Axis settings for TimeValueDiagram
 * @param plot            jFreeChart plot instance
 * @param rangeAxisLabel   Label of rangeAxis
 *///ww w  .ja  v  a2  s  .c o  m
private void buildTimeValueDiagramAxisFormat(XYPlot plot, String rangeAxisLabel) {
    System.out.println("StatisticGrafic.buildTimeValueDiagramAxisFormat");
    ValueAxis rangeAxis = (ValueAxis) plot.getRangeAxis();
    double a = 0.1 * Math.max(Math.abs(statistic.getValueLow()), Math.abs(statistic.getValueHigh()));
    rangeAxis.setLowerBound(statistic.getValueLow() - a);
    rangeAxis.setUpperBound(statistic.getValueHigh() + a);
    rangeAxis.setLabel(rangeAxisLabel);
    rangeAxis.setLabelFont(FONT_DEFAULT);

    DateAxis dateAxis = new DateAxis();
    DateAxis[] domainAxisArray = new DateAxis[1];
    domainAxisArray[0] = dateAxis;
    plot.setDomainAxes(domainAxisArray);

    dateAxis.setLowerBound(statistic.getTimeLow());
    dateAxis.setUpperBound(statistic.getTimeHigh());

    long diff = statistic.getTimeHigh() - statistic.getTimeLow();
    String format, unit;
    if (diff > 24 * 60 * 60 * 1000) {
        format = "d.MM.yyyy";
        unit = "[day]";
    } else if (diff > 60 * 60 * 1000) {
        format = "H:mm";
        unit = "[h]";
    } else if (diff > 60 * 1000) {
        format = "m:ss";
        unit = "[min]";
    } else if (diff > 1000) {
        format = "s.S";
        unit = "[sec]";
    } else {
        format = "S";
        unit = "[millisec]";
    }
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    dateAxis.setDateFormatOverride(sdf);
    SimpleDateFormat sdf1 = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss.SSS");
    String von = sdf1.format(dateAxis.getMinimumDate());
    String bis = sdf1.format(dateAxis.getMaximumDate());
    dateAxis.setLabel(von + "    Time " + unit + "   " + bis);
    dateAxis.setLabelFont(FONT_DEFAULT);

}