I am using google chart to display pie chart in primefaces.PrimeFaces version is 6.1. Currently the tooltip has absolute value and percentage. i just want to display absolute value. My code is
<div id="savChart">
<pe:gChart value="#{dashboardMB.dynamicChartObj}" width="400" height="400"
title="Quanity Wise">
</pe:gChart>
</div>
GChartModelBuilder chartBuilder = new GChartModelBuilder();
chartBuilder.setChartType(GChartType.PIE);
chartBuilder.addColumns("Topping", "Slices");
chartBuilder.addRow("Sleep", 7);
chartBuilder.addRow("Work", 6);
chartBuilder.addOption("pieSliceText", "value");
chartBuilder.addOption("tooltip.text", "value");
chartBuilder.addOption("legend","{ position: 'top', 'alignment': 'start' }");
chartSavingModel = chartBuilder.build();
I need the tooltip like as shown below.
For pieSliceText, chartBuilder.addOption("pieSliceText", "value"); code works properly. As you can see, I added the chartBuilder.addOption("tooltip.text", "value");
that according to the Google Charts should work but it does not work for tooltip.
I add only one thing to the previous answer, to manage complex options, you need to pass them as a Map
, not as a String
, so, in your case, it becomes like this:
HashMap<String, String> opt = new HashMap<String, String>();
opt.put("text", "value");
chartBuilder.addOption("tooltip", opt);
and everything works.