Class DonutChart
- All Implemented Interfaces:
DataDescriptorCallback
,ClickableChartData<DonutChart>
,SimpleSeriesChart<DonutChart,
Series>
A donut chart is a circle diagram with an empty area in the middle. The chart displays data series As a circle with data points visualized as the slices of a circle. The length of each slice is determined by calculating their proportion to the entire circle. The color of circle slices is automatically calculated, but you can also specify them. Each circle slice is displayed separately on the legend, providing information to the user about the chart’s data categories. Slices are automatically displayed in percentage (meaning what percentage of the entire circle they represent). You can also modify if the actual data values, a percentage or no labels should be displayed on the slice. Slice thickness is automatically calculated, but you can also modify it.
This chart is does not allow you to modify the tooltip, you can only use a DOT
. However, the chart
enables you to create custom tooltips using any JBStrap component. If you want to display a tooltip that is different from the default one,
you need to create it on your own using ChartTooltipRenderer
. You only need to implement one method which returns the tooltip as a component.
In order to do this, you can reuse any JBStrap component. It is possible to display a button, a list or even another chart on the tooltip.
The chart also supports click events. This means that you can implement server-side business logic for the event that is triggered when a user clicks on
a data point. This is when a ChartClick
event is triggered. This event provides you information on where and which chart
the user clicked on. This can be reused in various ways, e.g. to update a list.
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class com.jbstrap.ui.components.charts.SeriesBasedChart
categoryColumn, dataDescriptor, defaultFilterCriteria, filterCriteria, series
Fields inherited from class com.jbstrap.ui.components.charts.BaseChart
brushable, canvas, defaultTooltipType, handlers, NAME, params, supportedTooltipTypes, tooltipContent, tooltipType, zoomable
-
Constructor Summary
ConstructorDescriptionDonutChart
(String name) Creates a donut chart.DonutChart
(String name, DataDescriptor dataDescriptor, String categoryColumnName) Creates a donut chart and sets the name of the associated DataDescriptor and category column. -
Method Summary
Modifier and TypeMethodDescriptionGets the border color for the circle slices.int
Gets the rounding radius of circle slice corners.int
Gets the width of the border around circle slices.Gets the type of the labels from a circle slice.Gets the size of the empty area (padding) between two circle slices.Gets the inner circle radius.protected void
init()
Chart initialization.setBorderColor
(String color) Sets the border color for the circle slices.setBorderRadius
(int radius) Sets the rounding radius of circle slice corners.setBorderWidth
(int width) Sets the border width.setDataLabels
(DataLabels labels) Sets the label for each circle slice.setPaddingAngle
(Integer padding) Sets the size of the empty area (padding) between two circle slices.Sets the series displayed on the chart.setThickness
(Integer thickness) Adjusts the radius of the inner circle.Methods inherited from class com.jbstrap.ui.components.charts.SeriesBasedChart
_addSeries, _getSeries, _getSeriesNames, clear, fetchData, generateJSON, getCategoryColumnName, getDataColumnBySeriesName, getDataDescriptor, getDefaultFilterCriteria, getFilterCriteria, onError, onSuccess, refreshData, registerDataColumn, removeSeries, setDataDescriptor, setDefaultFilterCriteria, setFilterCriteria
Methods inherited from class com.jbstrap.ui.components.charts.BaseChart
getCanvas, getDefaultTooltipType, getHandlers, getName, getSupportedTooltipTypes, runJs, setParent
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.components.charts.ClickableChartData
addClickHandler
Methods inherited from interface com.jbstrap.ui.components.charts.SimpleSeriesChart
getSeries, getSeriesName
-
Field Details
-
DATA_LBELS
- See Also:
-
PADDING
- See Also:
-
THICKNESS
- See Also:
-
BORDER_COLOR
- See Also:
-
BORDER_WIDTH
- See Also:
-
BORDER_RADIUS
- See Also:
-
-
Constructor Details
-
DonutChart
Creates a donut chart.- Parameters:
name
- Chart name (required)- Throws:
NullPointerException
- Thrown if the specified chart name isnull
-
DonutChart
Creates a donut chart and sets the name of the associated DataDescriptor and category column.- Parameters:
name
- Chart name (required)dataDescriptor
- The DataDescriptor instance from where the component retrieves its value setcategoryColumnName
- Category data column name- Throws:
NullPointerException
- Thrown if the specified chart name isnull
-
-
Method Details
-
init
protected void init()Description copied from class:BaseChart
Chart initialization.- Specified by:
init
in classBaseChart<DonutChart>
-
setDataLabels
Sets the label for each circle slice. By default, the label shows how much per cent a data point represents of the entire circle.- Parameters:
labels
- Label type Available types are listed in the enumDataLabels
. Ifnull
is specified, the label is not displayed on the circle slice.- Returns:
- Chart instance
-
getDataLabels
Gets the type of the labels from a circle slice.- Returns:
- Label type
-
setPaddingAngle
Sets the size of the empty area (padding) between two circle slices. The default padding size is 1.- Parameters:
padding
- Padding size between circle slices- Returns:
- Chart instance
-
getPaddingAngle
Gets the size of the empty area (padding) between two circle slices.- Returns:
- Padding size between circle slices
-
setThickness
Adjusts the radius of the inner circle. By default, the radius of the inner circle is 38% of the radius of the outer circle.- Parameters:
thickness
- The inner circle radius percentage- Returns:
- Chart instance
-
getThickness
Gets the inner circle radius.- Returns:
- The inner circle radius percentage
-
setBorderColor
Sets the border color for the circle slices. By default, circle slices are enclosed by a white border.- Parameters:
color
- Border color in CSS3 format- Returns:
- Chart instance
-
getBorderColor
Gets the border color for the circle slices.- Returns:
- Border color in CSS3 format
-
setBorderWidth
Sets the border width. By default, circle slices are enclosed by a 0 pixels thick border (no visible border).- Parameters:
width
- Border width in pixels If a number smaller than 0 is specified, border width is set to 0. No visible border is displayed.- Returns:
- Chart instance
-
getBorderWidth
public int getBorderWidth()Gets the width of the border around circle slices.- Returns:
- Border width around circle slices
-
setBorderRadius
Sets the rounding radius of circle slice corners. By default, circle slices are not rounded (the rounding radius is 0).- Parameters:
radius
- Rounding radius of circle slices in pixels If a number smaller than 0 is specified, the rounding radius is set to 0. Circle slices are not rounded.- Returns:
- Chart instance
-
getBorderRadius
public int getBorderRadius()Gets the rounding radius of circle slice corners.- Returns:
- Rounding radius of circle slices in pixels
-
setSeries
Sets the series displayed on the chart.- Specified by:
setSeries
in interfaceSimpleSeriesChart<DonutChart,
Series> - Parameters:
series
- Series instance displayed on the chart- Returns:
- Chart
-