use of com.pingunaut.wicket.chartjs.data.sets.LineDataSet in project syncope by apache.
the class LoadWidget method build.
private Line build(final SystemInfo systeminfo) {
List<String> labels = new ArrayList<>();
List<Double> cpuValues = new ArrayList<>();
List<Long> memValues = new ArrayList<>();
for (SystemInfo.LoadInstant instant : systeminfo.getLoad()) {
labels.add(DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.format(systeminfo.getStartTime() + instant.getUptime()));
cpuValues.add(instant.getSystemLoadAverage() * 1000);
memValues.add(instant.getTotalMemory());
}
Line line = new Line();
line.getOptions().setPointDot(false);
line.getOptions().setDatasetFill(false);
line.getOptions().setResponsive(true);
line.getOptions().setMaintainAspectRatio(true);
line.getOptions().setShowScale(false);
line.getOptions().setMultiTooltipTemplate("<%= datasetLabel %>");
line.getData().setLabels(labels);
List<LineDataSet> datasets = new ArrayList<>();
LineDataSet cpuDataSet = new LineDataSet(cpuValues);
cpuDataSet.setLabel("CPU");
cpuDataSet.setPointColor("purple");
cpuDataSet.setStrokeColor("purple");
datasets.add(cpuDataSet);
LineDataSet memDataSet = new LineDataSet(memValues);
memDataSet.setLabel("MEM");
memDataSet.setPointColor("grey");
memDataSet.setStrokeColor("grey");
datasets.add(memDataSet);
line.getData().setDatasets(datasets);
return line;
}
Aggregations