Search in sources :

Example 1 with TickUnits

use of org.jfree.chart.axis.TickUnits in project spf4j by zolyfarkas.

the class QuantizedXYZDatasetImpl method createXTickUnits.

public TickUnits createXTickUnits() {
    TickUnits tux = new TickUnits();
    if (data.length == 0) {
        return tux;
    }
    ZoneId systemDefault = ZoneId.systemDefault();
    final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HH:mm:ss").withZone(systemDefault);
    final DateTimeFormatter shortFormat = DateTimeFormatter.ofPattern("yyyyMMdd'T'HH").withZone(systemDefault);
    final DateTimeFormatter mediumFormat = DateTimeFormatter.ofPattern("yyyyMMdd'T'HH:mm").withZone(systemDefault);
    final long[] timestamps = new long[data[0].length];
    long time = startTimeMillis;
    for (int i = 0; i < timestamps.length; i++) {
        timestamps[i] = time;
        time += stepMillis;
    }
    // base
    tux.add(new TimestampTickUnitImpl(1, timestamps, stepMillis, formatter));
    long nr = 5000L / stepMillis;
    if (nr > 1) {
        tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, formatter));
    }
    nr = 15000L / stepMillis;
    if (nr > 1) {
        tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, formatter));
    }
    // minute
    nr = 60000L / stepMillis;
    if (nr > 1) {
        tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, mediumFormat));
    }
    // 15 minute
    nr = 900000L / stepMillis;
    if (nr > 1) {
        tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, mediumFormat));
    }
    // hour
    nr = 3600000L / stepMillis;
    if (nr > 1) {
        tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, shortFormat));
    }
    // 6 hour
    nr = 21600000L / stepMillis;
    if (nr > 1) {
        tux.add(new TimestampTickUnitImpl(nr, timestamps, stepMillis, shortFormat));
    }
    return tux;
}
Also used : TickUnits(org.jfree.chart.axis.TickUnits) ZoneId(java.time.ZoneId) DateTimeFormatter(java.time.format.DateTimeFormatter)

Example 2 with TickUnits

use of org.jfree.chart.axis.TickUnits in project webanno by webanno.

the class MonitoringPage method createProgressChart.

private JFreeChart createProgressChart(Map<String, Integer> chartValues, int aMaxValue, boolean aIsPercentage) {
    // fill dataset
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    if (aMaxValue > 0) {
        for (String chartValue : chartValues.keySet()) {
            dataset.setValue(chartValues.get(chartValue), "Completion", chartValue);
        }
    }
    // create chart
    JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setOutlineVisible(false);
    plot.setBackgroundPaint(null);
    plot.setNoDataMessage("No data");
    plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0, 20, 0, 20));
    if (aMaxValue > 0) {
        plot.getRangeAxis().setRange(0.0, aMaxValue);
        ((NumberAxis) plot.getRangeAxis()).setNumberFormatOverride(new DecimalFormat("0"));
        // as 0 0 1 1 1 - NumberTickUnit automatically determines the range
        if (!aIsPercentage && aMaxValue <= 10) {
            TickUnits standardUnits = new TickUnits();
            NumberAxis tick = new NumberAxis();
            tick.setTickUnit(new NumberTickUnit(1));
            standardUnits.add(tick.getTickUnit());
            plot.getRangeAxis().setStandardTickUnits(standardUnits);
        }
    } else {
        plot.getRangeAxis().setVisible(false);
        plot.getDomainAxis().setVisible(false);
    }
    BarRenderer renderer = new BarRenderer();
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    // renderer.setGradientPaintTransformer(new
    // StandardGradientPaintTransformer(
    // GradientPaintTransformType.HORIZONTAL));
    renderer.setSeriesPaint(0, Color.BLUE);
    chart.getCategoryPlot().setRenderer(renderer);
    return chart;
}
Also used : TickUnits(org.jfree.chart.axis.TickUnits) NumberAxis(org.jfree.chart.axis.NumberAxis) DecimalFormat(java.text.DecimalFormat) StandardBarPainter(org.jfree.chart.renderer.category.StandardBarPainter) RectangleInsets(org.jfree.ui.RectangleInsets) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot) NumberTickUnit(org.jfree.chart.axis.NumberTickUnit)

Example 3 with TickUnits

use of org.jfree.chart.axis.TickUnits in project lotro-companion by dmorcellet.

the class CharacterLevelChartController method getLevelTicks.

private TickUnitSource getLevelTicks() {
    TickUnits ret = new TickUnits();
    ret.add(new NumberTickUnit(1));
    ret.add(new NumberTickUnit(5));
    ret.add(new NumberTickUnit(10));
    return ret;
}
Also used : TickUnits(org.jfree.chart.axis.TickUnits) NumberTickUnit(org.jfree.chart.axis.NumberTickUnit)

Example 4 with TickUnits

use of org.jfree.chart.axis.TickUnits in project spf4j by zolyfarkas.

the class QuantizedXYZDatasetImpl method createYTickUnits.

public TickUnits createYTickUnits() {
    TickUnits tu = new TickUnits();
    final List<ComparablePair<Quanta, Integer>> lquantas = this.getQuantas();
    tu.add(new QuantizedNumberTickUnit(1, lquantas));
    return tu;
}
Also used : TickUnits(org.jfree.chart.axis.TickUnits) ComparablePair(org.spf4j.base.ComparablePair)

Aggregations

TickUnits (org.jfree.chart.axis.TickUnits)4 NumberTickUnit (org.jfree.chart.axis.NumberTickUnit)2 DecimalFormat (java.text.DecimalFormat)1 ZoneId (java.time.ZoneId)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 JFreeChart (org.jfree.chart.JFreeChart)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 CategoryPlot (org.jfree.chart.plot.CategoryPlot)1 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)1 StandardBarPainter (org.jfree.chart.renderer.category.StandardBarPainter)1 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)1 RectangleInsets (org.jfree.ui.RectangleInsets)1 ComparablePair (org.spf4j.base.ComparablePair)1