Gauge Chart Customization
A gauge chart, also known as a dial chart, is used to display a single value within a predefined range of values. It's ideal for showing how a particular metric (sales, production levels, progress towards a goal) measures up against a set target or benchmark. This example shows how to customize gauge charts in the SurveyJS Dashboard library.
SurveyJS Dashboard is built upon the Plotly.js library. It is a multi-platform graphing library that includes all the most commonly used interactive charts and provides rich customization capabilities.
A Plotly.js chart is configured using JSON objects and consists of two parts: data and layout. Data is an array of JSON objects that configure graphs on the canvas. Layout is a JSON object that configures surrounding elements and additional custom shapes. To customize any SurveyJS Dashboard chart, handle the onPlotCreating
event raised by the PlotlySetup
object. Assign the chart data array to the options.data
property and the layout JSON object—to the options.layout
property.
In this demo, the onPlotCreating
event and Plotly.js API are used to create a new appearance for gauges based on pie and scatter charts. Refer to the code listing for more information.