public final class PercentageCallback extends Object implements FormatterCallback
DataLabelsPlugin.ID
plugin in order to provide the percentage of the value.DataLabelsPlugin.ID
options, it will return the percentage for each data
index per dataset.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FORMAT
Default number format, "##0.##%".
|
static String |
NAN_AS_STRING
Default value of NaN as string, "NaN".
|
Constructor and Description |
---|
PercentageCallback()
Creates the formatter using the default values.
|
PercentageCallback(boolean stacked)
Creates the formatter using the argument as flag to compute the percentage on stacked datasets.
|
PercentageCallback(String format)
Creates the formatter using the argument as number format.
|
PercentageCallback(String format,
boolean stacked)
Creates the formatter using the arguments as number format and as flag to compute the percentage on stacked datasets.
|
Modifier and Type | Method and Description |
---|---|
String |
getFormat()
Returns the number format as string to apply.
|
String |
invoke(IsChart chart,
double value,
ScriptableContext context)
Returns the
formatter property at runtime, using the chart instance and the plugin context. |
boolean |
isStacked()
Returns
true if it computes the percentage on stacked datasets. |
public static final String NAN_AS_STRING
public static final String DEFAULT_FORMAT
public PercentageCallback()
false
.public PercentageCallback(String format)
false
.format
- number format to applypublic PercentageCallback(boolean stacked)
stacked
- if true
computes the percentage on stacked datasets.public PercentageCallback(String format, boolean stacked)
format
- number format to applystacked
- if true
computes the percentage on stacked datasets.public String getFormat()
public boolean isStacked()
true
if it computes the percentage on stacked datasets.true
computes the percentage on stacked datasets.public String invoke(IsChart chart, double value, ScriptableContext context)
FormatterCallback
formatter
property at runtime, using the chart instance and the plugin context.invoke
in interface FormatterCallback
chart
- chart instancevalue
- to be formattedcontext
- DataLabelsPlugin.ID
plugin context instance