Vaadin Charts 是否提供了一种动态格式化工具提示的方法。 我想将一些逻辑绑定到工具提示上的值表示。 代替SOME_STRING,我需要 reverseNormalization func来改变值。
Map coefficients = new HashMap();
Chart chart = new Chart(ChartType.LINE);
Configuration conf = chart.getConfiguration();
Tooltip tooltip = conf.getTooltip();
tooltip.setFormatter(
"function() { " +
"return SOME_STRING }"
);
func reverseNormalization(String name, Double normalizedValue) {
return normalizedValue * coefficients.get(name);;
}
答案 0 :(得分:0)
以下是一个例子:
conf.getTooltip().setPointFormatter(
"function() { " +
"var category = this.x; " +
"var multiplier = 10; " +
"switch (category) " +
"{ " +
" case 0: " +
" multiplier = 10; " +
" break; " +
" case 1: " +
" multiplier = 20; " +
" break; " +
" case 2: " +
" multiplier = 30; " +
" break; " +
" default: " +
" multiplier = 50; " +
"}" +
"var tipTxt = this.series.name + ': <b>' + this.y*multiplier + '</b><br>'; " +
"return tipTxt; " +
"}"
);
this.x 将为您提供工具提示所呈现的点的类别值(从零开始)。您可以使用this.x,this.y和this.series.name来应用动态计算和格式。