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;
}
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;
}
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;
}
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;
}
Aggregations