• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

GChart

GChart is a JSF wrapper of the Google Charts API, the chart library used by Google Analytics and other Google services. It also provides an organizational chart and a geo chart.

GChart Tag Documentation

GChart is a Google Charts visualization component.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
apiKey String false Google Charts API key.
converter Converter false EL expression resolves to a converter instance or literal converter ID defining a component converter.
extender String false JavaScript extender function name.
height Integer false Chart height in pixels.
language String false en Language code for the chart.
title String false Chart title.
value GChartModel true Value of the chart. Use the GChartModelBuilder to create a new GChartModel
width Integer false Chart width in pixels.
Tag Documentation Widget Source
Basic usage

The component needs a GChartModel, created with a GChartModelBuilder. The select AJAX event contains a JSONArray with the selected rows.

MushroomsOnionsType
Multiple Series

A chart can have multiple series: choose the right GChartType (COLUMN here) and fill more columns.

Organizational Chart

Google Charts is versatile: here it displays an organizational chart. A TreeNode can generate the GChartModel for this kind of chart.

Geo Chart

A geo chart shows data about countries. Rows are added with simple strings or with java.util.Locale.

Important

Due to the Google Charts Terms of Service it is not possible to download the library to a server: the API is loaded from the servers of Google, so the client must be connected to the internet for the component to work.

Usage


<script src="https://www.gstatic.com/charts/loader.js"></script>

<div class="card">
    <h5>Basic usage</h5>
    <p>The component needs a <code>GChartModel</code>, created with a <code>GChartModelBuilder</code>. The <i>select</i> AJAX event contains a <code>JSONArray</code> with the selected rows.</p>
    <h:form id="formBasic">
        <p:messages id="messages"/>

        <p:outputPanel id="container" layout="block">
            <h:panelGrid columns="4">
                <h:outputText value="Mushrooms"/>
                <h:outputText value="Onions"/>
                <h:outputText value="Type"/>
                <h:panelGroup/>
                <p:inputText converter="jakarta.faces.Integer" value="#{basicGChartController.mushrooms}"/>
                <p:inputText converter="jakarta.faces.Integer" value="#{basicGChartController.onions}"/>
                <h:selectOneMenu value="#{basicGChartController.chartType}">
                    <f:selectItems value="#{basicGChartController.types}"/>
                </h:selectOneMenu>
                <p:commandButton value="Generate" update="container messages" action="#{basicGChartController.generateModel}"/>
            </h:panelGrid>

            <pe:gChart value="#{basicGChartController.chart}" title="How Much Pizza I Ate Last Night">
                <p:ajax listener="#{basicGChartController.onSelect}" update="messages"/>
            </pe:gChart>
        </p:outputPanel>
    </h:form>
</div>

<div class="card">
    <h5>Multiple Series</h5>
    <p>A chart can have multiple series: choose the right <code>GChartType</code> (<code>COLUMN</code> here) and fill more columns.</p>
    <h:form id="formMultiple">
        <pe:gChart value="#{multipleSeriesGChartController.chart}" title="Company Performance"/>
    </h:form>
</div>

<div class="card">
    <h5>Organizational Chart</h5>
    <p>Google Charts is versatile: here it displays an organizational chart. A <code>TreeNode</code> can generate the <code>GChartModel</code> for this kind of chart.</p>
    <h:form id="formOrganizational">
        <p:tabView>
            <p:tab title="Standard">
                <pe:gChart value="#{organizationalGChartController.standardModel}"/>
            </p:tab>
            <p:tab title="TreeDataModel">
                <pe:gChart value="#{organizationalGChartController.treeModel}"/>
            </p:tab>
        </p:tabView>
    </h:form>
</div>

<div class="card">
    <h5>Geo Chart</h5>
    <p>A geo chart shows data about countries. Rows are added with simple strings or with <code>java.util.Locale</code>.</p>
    <h:form id="formGeochart">
        <pe:gChart value="#{geoChartGChartController.chart}"/>
    </h:form>
</div>