Search code examples
jsfprimefaceschartsjqplotdatatip

Primefaces 5.2 : customize charts datatip


I want to customize the datatip in Primefaces 5.2 charts. So it means, that I want to change the datatipFormat and the content on it.

It tried this:

--- XHTML ---

<p:chart type="line" 
         model="#{lineChartController.lineModel}"
         title="#{lineChartController.lineModel.title}"
         showDatatip="#{lineChartController.lineModel.showDatatip}"
         datatipFormat="#{lineChartController.datatipFormat}"
         ... />

--- Java ---

public String getDatatipFormat()
{
    return "<span style=\"display:none;\">%s</span><span>%s</span>";
}

isShowDatatip() returns true.

The customized datatipFormat doesn't seem to work, moreover I don't know how to put the data I want on the %s.

To resume:

Thanks


Solution

  • I found the solution.

    Here, it leads me to the wrong direction.

    I put my Java code on the LineChartController and my showDatatip leads to a LineChartModel ... which contains a setDatatipFormat(String) method.

    So I use it:

    LineChartModel lineModel = new LineChartModel();
    ...
    lineModel.setDatatipFormat("<table><thead><tr><th>Date</th></tr></thead><tbody><td>%s</td><td>%s EUR</td></tbody></table>");
    

    And I still don't know how to put the data I want in the %s.