Search in sources :

Example 1 with LineDataSet

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;
}
Also used : Line(com.pingunaut.wicket.chartjs.chart.impl.Line) SystemInfo(org.apache.syncope.common.lib.info.SystemInfo) LineDataSet(com.pingunaut.wicket.chartjs.data.sets.LineDataSet) ArrayList(java.util.ArrayList)

Aggregations

Line (com.pingunaut.wicket.chartjs.chart.impl.Line)1 LineDataSet (com.pingunaut.wicket.chartjs.data.sets.LineDataSet)1 ArrayList (java.util.ArrayList)1 SystemInfo (org.apache.syncope.common.lib.info.SystemInfo)1