Pie Chart
How to create and configure the Pie chart
Introduction
A pie chart visualizes data as proportional segments of a circle. It makes easier to see relative sizes of categories at a glance, ideal for highlighting distribution and composition.
Preparation
The query .sql
file that the Pie Chart accepts must contain only 2 columns, one for the labels and another one for the values.
labels | values |
---|---|
Drinks | 145 |
Snacks | 539 |
Fruits | 987 |
Syntax
You can use <PieChart ... />
to add it to your view. Within the tag you must add the properties to configure the chart.
Properties
To configure and customize the chart, you can add properties, some of which are required and some of which are optional.
The name of your .sql
file from which your chart will get the data. It’s not necessary to specify the full path, just the name, because we will search all folders until we find it
Specifies the height of the chart in px. You must enclose the number in brackets like height={720}
. The default value is 400px.
Specifies the width of the chart in px. You must enclose the number in brackets like width={480}
. By default it takes the 100% or the available width.
Contains some options to customize your chart.
See the Config section to learn more about the options.
Includes options to control the behavior of the chart. For example, react to changes in the parameters to update the data immediately.
See the Reactive To Params section to learn more about it.
Config
Display the category name directly on the chart.
Display a circular space withing the pie allowing to show the total sum of the values.
When the showHole
property is true allow to show the total sum of the values.
Display the color legend for each series displayed.
Add a visual pattern to each series to help colorblind people distinguish them.
Reactive To Params
Within the opts
property we can include some options to modify the behavior of the chart. At the moment only the reactToParams
option is available.
If true, the chart will react to any change in the params to update the data displayed without the need to run the view manually.