vaadinvaadin7vaadin-charts

Vaadin Charts Tooltip Format


The following is the formatter I am using.

 Tooltip tooltip = new Tooltip();
 tooltip.setxDateFormat("MMM dd, YYYY");
 tooltip.setFormatter("function()  { var d = new Date(this.x);" + "return " + "'<b>'+this.series.name +'</b><br/>"
                + "<strong>Value :</strong> '+ this.y +'<br/>" + "<strong>Start Date :</strong> '+ this.x; " + "}");

 chartConfig.setTooltip(tooltip);

This is the tooltip I am getting

How to:

1) Round of value with two decimal places

2) Using Date Format like Nov 30, 2016

Kindly assist.


Solution

  • Vaadin Charts uses Highcharts on the client side, which means that you can use Highcharts JS APIs for formatting, the following calls should work:

    Highcharts.numberFormat(this.y, 2)
    
    Highcharts.dateFormat('%b %d %Y', new Date(this.x))