Package com.jbstrap.ui.components.charts
Class AxesBasedChart<T>
java.lang.Object
com.jbstrap.ui.components.charts.BaseChart<T>
com.jbstrap.ui.components.charts.SeriesBasedChart<T>
com.jbstrap.ui.components.charts.AxesBasedChart<T>
- Type Parameters:
T
- Chart type
- All Implemented Interfaces:
DataDescriptorCallback
- Direct Known Subclasses:
AreaChart
,BarChart
,BubbleChart
,DotChart
,HorizontalBarChart
,HorizontalStackedBarChart
,LineChart
,PopulationPyramidChart
,StackedAreaChart
,StackedBarChart
The parent class of all axis-based charts. This class cannot be instantiated, it can only be used by chart instances as
a parent class. The class implements all common settings for axis-based charts.
- Since:
- 4.0
- Author:
- JBStrap
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
protected static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected static final com.google.common.collect.ImmutableList<TooltipType>
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
ModifierConstructorDescriptionprotected
AxesBasedChart
(String name, DataDescriptor dataDescriptor, String categoryColumnName, TooltipType defaultTooltipType) -
Method Summary
Modifier and TypeMethodDescriptionprotected Parameters
getXAxis()
Determines the date format of the X axis.Gets the color of the labels on the X axis.Gets the starting position of the stripes on the X axis.Gets the rotation of the data values on the X axis.Gets the title of the X axis.Gets the data type of the X axis.Gets the postfix for the values on the X axis.Gets the prefix for the values on the X axis.protected Parameters
getYAxis()
Gets the color of the labels on the Y axis.Gets the maximum value for the Y axis.Gets the start value of the Y axis.Gets the starting position of the stripes on the Y axis.Gets the title for the Y axis.Gets the postfix for the values on the Y axis.Gets the prefix for the values on the Y axis.protected void
init()
Chart initialization.boolean
Checks if the X axis is displayed on the chart.boolean
Checks if the gridlines on the X axis are displayed on the chart.boolean
Checks if the X axis is displayed on the chart.boolean
Checks if the ticks are displayed on the X axis.boolean
Checks if the labels are displayed on the X axis.boolean
Checks if the X axis is striped or not.boolean
Checks if the Y axis is displayed on the chart.boolean
Checks if the gridlines on the Y axis are displayed on the chart.boolean
Checks if the Y axis is displayed on the chart.boolean
Checks if the ticks are displayed on the Y axis.boolean
Checks if the labels are displayed on the Y axis.boolean
Checks if the Y axis is striped or not.setXAxisDateFormat
(String pattern) The format of the date type values on the X axis.setXAxisFontColor
(String color) Sets the font color on the X axis.setXAxisShow
(boolean show) Sets if the X axis should be displayed on the chart.setXAxisShowGrid
(boolean showGrid) Sets if the gridlines on the X axis should be displayed.setXAxisShowLine
(boolean showLine) Sets if the X axis line is displayed on the chart.setXAxisShowTicks
(boolean showTicks) Sets if the value-marking ticks are displayed on the X axis.setXAxisShowValueLabel
(boolean showValueLabel) Sets if the values on the X axis should be displayed as labels.setXAxisStriped
(boolean striped) Sets if the X axis should be striped.setXAxisStripedStart
(StripedStart stripedStart) Sets the way the X axis should be striped.setXAxisTickTextRotate
(TickTextRotate tickTextRotate) Sets the rotation of the texts on the X axis.setXAxisTitle
(String title) Sets the title for the X axis.protected T
setXAxisType
(AxisType axisType) Sets the data type of the X axis.setXAxisValuePostfix
(String postfix) Sets the postfix for the values on the X axis.setXAxisValuePrefix
(String prefix) Sets the prefix for the values on the X axis.setYAxisFontColor
(String color) Sets the color of the labels on the Y axis.setYAxisMaxValue
(Number maxValue) Sets the maximum values of the Y axis.setYAxisMinValue
(Number minValue) Sets the start value of the Y axis.setYAxisShow
(boolean show) Sets if the Y axis should be displayed on the chart.setYAxisShowGrid
(boolean showGrid) Sets if the gridlines on the Y axis should be displayed.setYAxisShowLine
(boolean showLine) Sets if the Y axis line is displayed on the chart.setYAxisShowTicks
(boolean showTicks) Sets if the value-marking ticks are displayed on the Y axis.setYAxisShowValueLabel
(boolean showValueLabel) Sets if the values on the Y axis should be displayed as labels.setYAxisStriped
(boolean striped) Sets if the Y should be striped.setYAxisStripedStart
(StripedStart stripedStart) Sets the way the Y axis should be striped.setYAxisTitle
(String title) Sets the title for the Y axis.setYAxisValuePostfix
(String postfix) Sets a postfix for the values on the Y axis.setYAxisValuePrefix
(String prefix) Sets the prefix for the values on the Y axis.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
-
Field Details
-
X_AXIS
- See Also:
-
Y_AXIS
- See Also:
-
SHOW
- See Also:
-
SHOW_GRID
- See Also:
-
TITLE
- See Also:
-
STRIPED
- See Also:
-
STRIPED_START
- See Also:
-
PREFIX
- See Also:
-
POSTFIX
- See Also:
-
FONT_COLOR
- See Also:
-
SHOW_VALUE_LABEL
- See Also:
-
SHOW_LINE
- See Also:
-
SHOW_TICKS
- See Also:
-
FORMAT
- See Also:
-
TICK_TEXT_ROTATE
- See Also:
-
HORIZONTAL
- See Also:
-
MIN_VALUE
- See Also:
-
MAX_VALUE
- See Also:
-
SUPPORTED_TOOLTIP_TYPES
-
-
Constructor Details
-
AxesBasedChart
protected AxesBasedChart(String name, DataDescriptor dataDescriptor, String categoryColumnName, TooltipType defaultTooltipType) - Parameters:
name
- Chart name (required)dataDescriptor
- The DataDescriptor that contains the chart parameters Ifnull
is specified, the chart does not receive data from the database. Instead, you have to programmatically pass the data to the chart.categoryColumnName
- The DataDescriptor column name where the chart’s category (X axis) data come from If the chart does not use a DataDescriptor, this setting is ignored. If the chart retrieves data from a DataDescriptor and the category column name is not specified, by default it retrieves data from the CATEGORY column in the DataDescriptor.- Throws:
NullPointerException
- Thrown if the name of the chart or the parameter class isnull
IllegalArgumentException
- Thrown if there is a DataDescriptor specified for the chart, but the DataDescriptor does not contain the column specified in the parameter categoryColumnName or the parameter categoryColumnName is not specified and in the DataDescriptor there is no column by the name CATEGORY
-
-
Method Details
-
getXAxis
- Returns:
- Parameter class containing X axis settings
-
getYAxis
- Returns:
- Parameter class containing Y axis settings
-
setXAxisShow
Sets if the X axis should be displayed on the chart. By default, the X axis is displayed.- Parameters:
show
- Iftrue
is set, the X axis is displayed on the chart If not, the X axis is not displayed.- Returns:
- Chart instance
-
isXAxisShow
public boolean isXAxisShow()Checks if the X axis is displayed on the chart.- Returns:
- If
true
, the X axis is displayed on the chart, otherwisefalse
-
setYAxisShow
Sets if the Y axis should be displayed on the chart. By default, the Y axis is displayed.- Parameters:
show
- Iftrue
is set, the Y axis is displayed on the chart If not, the Y axis is not displayed.- Returns:
- Chart instance
-
isYAxisShow
public boolean isYAxisShow()Checks if the Y axis is displayed on the chart.- Returns:
- If
true
, the Y axis is displayed on the chart, otherwisefalse
-
setXAxisShowGrid
Sets if the gridlines on the X axis should be displayed. By default, the gridlines are not displayed.- Parameters:
showGrid
- Iftrue
is specified, the gridlines on the X axis are displayed, helping the user to determine the position of a data point on the axis. Iffalse
, the gridlines are not displayed.- Returns:
- Chart instance
-
isXAxisShowGrid
public boolean isXAxisShowGrid()Checks if the gridlines on the X axis are displayed on the chart.- Returns:
- If
true
, the gridlines on the X axis are displayed on the chart, Otherwise,false
is set.
-
setYAxisShowGrid
Sets if the gridlines on the Y axis should be displayed. By default, the gridlines are not displayed.- Parameters:
showGrid
- Iftrue
is specified, the gridlines on the Y axis are displayed, helping the user to determine the position of a data point on the axis. Iffalse
, the gridlines are not displayed.- Returns:
- Chart instance
-
isYAxisShowGrid
public boolean isYAxisShowGrid()Checks if the gridlines on the Y axis are displayed on the chart.- Returns:
- If
true
, the gridlines on the Y axis are displayed on the chart, Otherwise,false
is set.
-
setXAxisTitle
Sets the title for the X axis.- Parameters:
title
- X axis title If not specified ornull
is specified, no title is displayed on the axis.- Returns:
- Chart instance
-
getXAxisTitle
Gets the title of the X axis.- Returns:
- X axis title If not specified, the method returns
null
.
-
setYAxisTitle
Sets the title for the Y axis.- Parameters:
title
- Y axis title If not specified ornull
is specified, no title is displayed on the axis.- Returns:
- Chart instance
-
getYAxisTitle
Gets the title for the Y axis.- Returns:
- Y axis title If not specified, the method returns
null
.
-
setXAxisStriped
Sets if the X axis should be striped. By default, the X axis is not striped. If this setting is applied, the intervals between every second value on the axis are darkened so that the axis values appear striped. This feature helps the user to better navigate between data values on the X axis.- Parameters:
striped
- Iftrue
is set, the axis is striped, otherwise not striped- Returns:
- Chart instance
-
isXAxisStriped
public boolean isXAxisStriped()Checks if the X axis is striped or not.- Returns:
- If
true
, the X axis is displayed on the chart, otherwise false
-
setYAxisStriped
Sets if the Y should be striped. By default, the Y axis is not striped. If this setting is applied, the intervals between every second value on the axis are darkened so that the axis values appear striped. This feature helps the user to better navigate between data values on the Y axis.- Parameters:
striped
- Iftrue
is set, the axis is striped, otherwise not striped- Returns:
- Chart instance
-
isYAxisStriped
public boolean isYAxisStriped()Checks if the Y axis is striped or not.- Returns:
- If
true
, the Y axis is striped, otherwise false
-
setXAxisStripedStart
Sets the way the X axis should be striped. By default, the X axis is striped starting from the first interval, that is, the first interval and every interval with an odd number has a darker background.- Parameters:
stripedStart
- Sets where the stripes start Available values are listed in the enumStripedStart
. Ifnull
is specified, stripes start at the first interval, following the default setting.- Returns:
- Chart instance
-
getXAxisStripedStrart
Gets the starting position of the stripes on the X axis.- Returns:
- Starting position of the stripes on the X axis
-
setYAxisStripedStart
Sets the way the Y axis should be striped. By default, the Y axis is striped starting from the first interval, that is, the first interval and every interval with an odd number has a darker background.- Parameters:
stripedStart
- Sets where the stripes start Available values are listed in the enumStripedStart
. Ifnull
is specified, stripes start at the first interval, following the default setting.- Returns:
- Chart instance
-
getYAxisStripedStrart
Gets the starting position of the stripes on the Y axis.- Returns:
- Starting position of the stripes on the Y axis
-
setXAxisValuePrefix
Sets the prefix for the values on the X axis.- Parameters:
prefix
- Prefix Ifnull
is specified, no prefix is displayed before the values.- Returns:
- Chart instance
-
getXAxisValuePrefix
Gets the prefix for the values on the X axis.- Returns:
- Prefix for the values on the X axis or
null
if no prefix is set for the values
-
setYAxisValuePrefix
Sets the prefix for the values on the Y axis.- Parameters:
prefix
- Prefix Ifnull
is specified, no prefix is displayed before the values.- Returns:
- Chart instance
-
getYAxisValuePrefix
Gets the prefix for the values on the Y axis.- Returns:
- Prefix for the values on the Y axis or
null
if no prefix is set for the values
-
setXAxisValuePostfix
Sets the postfix for the values on the X axis.- Parameters:
postfix
- Postfix for the values Ifnull
is specified, no postfix is displayed after the values.- Returns:
- Chart instance
-
getXAxisValuePostfix
Gets the postfix for the values on the X axis.- Returns:
- Postfix for the values on the X axis or
null
if no postfix is set for the values
-
setYAxisValuePostfix
Sets a postfix for the values on the Y axis.- Parameters:
postfix
- Postfix for the values Ifnull
is specified, no postfix is displayed after the values.- Returns:
- Chart instance
-
getYAxisValuePostfix
Gets the postfix for the values on the Y axis.- Returns:
- Postfix for the values on the Y axis or
null
if no postfix is set for the values
-
setXAxisFontColor
Sets the font color on the X axis.- Parameters:
color
- X axis font color If not specified ornull
is specified, labels are displayed using the theme’s grey color.- Returns:
- Chart instance
-
getXAxisFontColor
Gets the color of the labels on the X axis.- Returns:
- The color of the labels on the X axis If not specified, the method returns
null
.
-
setYAxisFontColor
Sets the color of the labels on the Y axis.- Parameters:
color
- The color of the label on the Y axis. If not specified ornull
is specified, labels are displayed using the theme’s grey color.- Returns:
- Chart instance
-
getYAxisFontColor
Gets the color of the labels on the Y axis.- Returns:
- Y axis label color If not specified, the method returns
null
.
-
setXAxisShowValueLabel
Sets if the values on the X axis should be displayed as labels. By default, values on the axis are displayed.- Parameters:
showValueLabel
- Iftrue
is specified, labels are displayed on the axis, otherwise not- Returns:
- Chart instance
-
isXAxisShowValueLabel
public boolean isXAxisShowValueLabel()Checks if the labels are displayed on the X axis.- Returns:
- If
true
, values on the X axis are displayed, otherwise not
-
setYAxisShowValueLabel
Sets if the values on the Y axis should be displayed as labels. By default, values on the axis are displayed.- Parameters:
showValueLabel
- Iftrue
is specified, labels are displayed on the axis, otherwise not- Returns:
- Chart instance
-
isYAxisShowValueLabel
public boolean isYAxisShowValueLabel()Checks if the labels are displayed on the Y axis.- Returns:
- If
true
, the labels on the Y axis are displayed, otherwise not
-
setXAxisShowLine
Sets if the X axis line is displayed on the chart. By default, the axis line is displayed.- Parameters:
showLine
- Iftrue
, the axis line is displayed on the chart, otherwise not- Returns:
- Chart instance
-
isXAxisShowLine
public boolean isXAxisShowLine()Checks if the X axis is displayed on the chart.- Returns:
- If
true
, the X axis line is displayed on the chart, otherwise false
-
setYAxisShowLine
Sets if the Y axis line is displayed on the chart. By default, the axis line is displayed.- Parameters:
showLine
- Iftrue
, the axis line is displayed on the chart, otherwise not- Returns:
- Chart instance
-
isYAxisShowLine
public boolean isYAxisShowLine()Checks if the Y axis is displayed on the chart.- Returns:
- If
true
, the Y axis line is displayed on the chart, otherwise not
-
setXAxisShowTicks
Sets if the value-marking ticks are displayed on the X axis. By default, ticks are displayed on the X axis.- Parameters:
showTicks
- Iftrue
is specified, ticks are displayed, Otherwise not- Returns:
- Chart instance
-
isXAxisShowTicks
public boolean isXAxisShowTicks()Checks if the ticks are displayed on the X axis.- Returns:
- If
true
, ticks are displayed, otherwisefalse
-
setYAxisShowTicks
Sets if the value-marking ticks are displayed on the Y axis. By default, ticks are displayed on the Y axis.- Parameters:
showTicks
- Iftrue
is specified, ticks are displayed, Otherwise not- Returns:
- Chart instance
-
isYAxisShowTicks
public boolean isYAxisShowTicks()Checks if the ticks are displayed on the Y axis.- Returns:
- If
true
, ticks are displayed, otherwisefalse
-
setXAxisType
Sets the data type of the X axis. The default data type of the X axis is TEXT. If the data are specified using a DataDescriptor, the X axis automatically takes the necessary data type. This setting cannot be modified once the chart has been displayed.- Parameters:
axisType
- X axis data type * Available types are listed in the enumAxisType
. Ifnull
is specified, the data type of the X axis is text. Values on the X axis are displayed as text.- Returns:
- Chart instance
-
getXAxisType
Gets the data type of the X axis.- Returns:
- X axis data type
-
setXAxisDateFormat
The format of the date type values on the X axis. If the X axis is not a date type axis, this setting is ignored.- Parameters:
pattern
- The format of the dates on the X axis Ifnull
is specified, the framework’s default date format.- Returns:
- Chart instance
-
getXAxisDateFormat
Determines the date format of the X axis.- Returns:
- The date format of the X axis
-
setXAxisTickTextRotate
Sets the rotation of the texts on the X axis. By default, data values on the X axis are automatically rotated according to the length of the data values.- Parameters:
tickTextRotate
- Rotation angle of the texts on the X axis Available values are listed in the enumTickTextRotate
. Ifnull
is set, data values are automatically rotated.- Returns:
- Chart instance
-
getXAxisTickTextRotate
Gets the rotation of the data values on the X axis.- Returns:
- Rotation of the data values on the X axis
-
setYAxisMinValue
Sets the start value of the Y axis. If the data series contains a value smaller than the one specified, values smaller than the minimum value are not displayed on the chart. By default, the chart’s minimum value is not specified and every data point is displayed.- Parameters:
minValue
- Minimum value of the Y axis Ifnull
is set, no minimum value is specified for the axis- Returns:
- Chart instance
-
getYAxisMinValue
Gets the start value of the Y axis.- Returns:
- Start value of the Y axis If not specified, the method returns
null
.
-
setYAxisMaxValue
Sets the maximum values of the Y axis. If the data series contains a value greater than the one specified, values greater than the maximum value are not displayed on the chart. By default, the chart’s maximum value is not specified and every data point is displayed.- Parameters:
maxValue
- Y axis maximum value Ifnull
is set, no maximum value is specified for the axis- Returns:
- Chart instance
-
getYAxisMaxValue
Gets the maximum value for the Y axis.- Returns:
- Y axis maximum value If not specified, the method returns
null
.
-
init
protected void init()Description copied from class:BaseChart
Chart initialization.
-