Class Percentage
- java.lang.Object
-
- org.pepstock.charba.client.impl.callbacks.Percentage
-
public final class Percentage extends Object
Utility to calculate the percentage of the value based on the datasets of chart.- Author:
- Andrea "Stock" Stocchero
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
compute(IsChart chart, double value, AbstractDatasetContext context)
Computes the percentage of the value based on the data of datasets.static double
compute(IsChart chart, double value, AbstractDatasetContext context, boolean stacked)
Computes the percentage of the value based on the data of datasets.
-
-
-
Method Detail
-
compute
public static double compute(IsChart chart, double value, AbstractDatasetContext context)
Computes the percentage of the value based on the data of datasets. If the dataset is composed byDataPoint
, it uses theDataPoint.getY()
value to compute the percentage. The stack is ignored.- Parameters:
chart
- chart instancevalue
- current value to be evaluatedcontext
- data labels plugin context- Returns:
- the percentage value, a double between 0 and 1. If the datasets does not contains any data, it will return
Double.NaN
.
-
compute
public static double compute(IsChart chart, double value, AbstractDatasetContext context, boolean stacked)
Computes the percentage of the value based on the data of datasets. If the dataset is composed byDataPoint
, it uses theDataPoint.getY()
value to compute the percentage.- Parameters:
chart
- chart instancevalue
- current value to be evaluatedcontext
- data labels plugin contextstacked
- iftrue
, it calculates the total at the same data index (cross datasets), otherwise iffalse
it calculates the total at the same dataset index (single dataset)- Returns:
- the percentage value, a double between 0 and 1. If the datasets does not contains any data, it will return
Double.NaN
.
-
-