salesforce
  1. salesforce-apex-gaugeseries-component

apex:gaugeSeries Component

The apex:gaugeSeries component in Visualforce allows you to render a gauge chart and display data in a graphical format. It is a powerful component that can be used to display data in an intuitive and visually appealing way.

Syntax

The syntax for apex:gaugeSeries component is as follows:

<apex:gaugeSeries dataField="fieldName" xField="axisFieldName" minimum="minValue" maximum="maxValue" donut="true/false" gaugeHeight="heightInPixels" gaugeWidth="widthInPixels" colorSet="#hexColor">

Example

Consider the following example to display temperature data:

<apex:page controller="TemperatureController">
  <apex:chart height="400" width="400" data="{!temperatureData}">
    <apex:gaugeSeries dataField="Temperature" xField="City__c" minimum="0" maximum="100" colorSet="#7ED321" gaugeHeight="220" gaugeWidth="220" donut="true"/>
    <apex:axis type="Gauge" position="bottom" minimum="0" maximum="100" steps="10" margin="-10"/>
  </apex:chart>
</apex:page>

Output

The above code will produce a gauge chart representation of temperature data based on minimum and maximum values. The gauge chart will display temperature data in a graphical manner.

Explanation

In the example above, the apex:gaugeSeries component is used to render a gauge chart with the following attributes:

  • dataField: The field containing the data to be displayed on the gauge chart.
  • xField: The field containing the axis data to be displayed on the gauge chart.
  • minimum: The minimum value of the gauge chart.
  • maximum: The maximum value of the gauge chart.
  • colorSet: The set of hex colors to be used on the gauge chart.
  • gaugeHeight: The height of the gauge chart.
  • gaugeWidth: The width of the gauge chart.
  • donut: A Boolean value indicating whether the gauge chart should be donut-shaped.

Use

The apex:gaugeSeries component can be used to display data in an intuitive and visually appealing way in Visualforce. It can be used to display data in a variety of domains including finance, health, and sports.

Important Points

  • The apex:gaugeSeries component requires a valid data source to display data.
  • Gauge charts work best when displaying data that has clear minimum and maximum values.
  • The apex:axis component can be used to customize the axis of the gauge chart.

Summary

The apex:gaugeSeries component in Visualforce is a powerful tool for displaying data in a graphical format. With attributes such as dataField, minimum, maximum, and colorSet, you can customize the appearance of the gauge chart to suit your needs. To get started with using gauge charts in Visualforce, make sure to have a valid data source and start experimenting with different configurations.

Published on: