In this example we use a GeoChart to show data about countries. As you can see to add rows to our datatable we can use simple strings or java.util.Locale.
Source
<script src="https://www.gstatic.com/charts/loader.js"></script>
<pe:gChart value="#{geoChartGChartController.chart}" />
@Named
@RequestScoped
public class GeoChartGChartController implements Serializable {
private static final long serialVersionUID = 253762400419864192L;
private GChartModel chartModel = null;
public GChartModel getChart() {
return chartModel;
}
@PostConstruct
public void generateModel() {
final Locale englishLocale = Locale.ENGLISH;
final Map<String, Object> colorAxis = new HashMap<String, Object>();
colorAxis.put("colors", new String[] {"white", "orange"});
chartModel = new GChartModelBuilder().setChartType(GChartType.GEO).addColumns("Country", "Popularity")
.addRow(Locale.GERMANY.getDisplayCountry(englishLocale), 1200)
.addRow(Locale.FRANCE.getDisplayCountry(englishLocale), 1800).addRow("Russia", 1800)
.addRow(Locale.ITALY.getDisplayCountry(englishLocale), 2000)
.addRow(Locale.CHINA.getDisplayCountry(englishLocale), 2200)
.addRow(Locale.US.getDisplayCountry(englishLocale), 2500).addOption("colorAxis", colorAxis).build();
}
}