absolute value in tooltip using pe:gChart

Community Driven Extensions Project
Post Reply
maniratna
Posts: 1
Joined: 30 Apr 2020, 11:43

30 Apr 2020, 11:57

I am using google chart to display pie chart in primefaces.PrimeFaces version is 6.1. with PFE 6.1.1 .i just wanted to display absolute value in tooltip. My code is
<div id="savChart">
<pe:gChart value="#{dashboardMB.dynamicChartObj}" width="400" height="400">
</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("tooltip.text", "value");
chartBuilder.addOption("legend","{ position: 'top', 'alignment': 'start' }");
chartSavingModel = chartBuilder.build();
I read the Google Charts documentation. https://developers.google.com/chart/int ... on-options and tried everything but still percentage value appears in tooltip and failed to style legend for the chart.

I inspected the page and options for chart was like - chart:"{\"type\":\"PieChart\",\"options\":{\"pieSliceText\":\"value\",\"tooltip\":\"{text: \\u0027value\\u0027}\",\"legend\":\"{ position: \\u0027top\\u0027, \\u0027alignment\\u0027: \\u0027start\\u0027 }\"}. Came to a conclusion that may be JSON data is created incorrectly. I am not able to fix my problem.

Melloware
Posts: 1805
Joined: 22 Apr 2013, 15:48

04 May 2020, 13:21

Try this...

Code: Select all

HashMap<String, String> opt = new HashMap<String, String>();
opt.put("text", "value");
chartBuilder.addOption("tooltip", opt);
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 8.0.1 / PF Extensions 8.0.2

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest