This commit is contained in:
Coloryr committed 2024-05-13 09:33:41 +08:00
1 parent 72a5255653
commit 035f9b910a
41 files changed
+443 -336

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
package com.coloryr.allmusic.server.bstats.charts;
import com.coloryr.allmusic.server.bstats.json.JsonObjectBuilder;
import java.util.concurrent.Callable;
public class SingleLineChart extends CustomChart {
private final Callable<Integer> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SingleLineChart(String chartId, Callable<Integer> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
int value = callable.call();
if (value == 0) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder()
.appendField("value", value)
.build();
}
}