Class AbstractScale
- java.lang.Object
-
- org.pepstock.charba.client.commons.NativeObjectContainer
-
- org.pepstock.charba.client.commons.AbstractNode
-
- org.pepstock.charba.client.options.AbstractModel<Options,IsDefaultScale>
-
- org.pepstock.charba.client.options.AbstractScale
-
- All Implemented Interfaces:
HasLabels
,IsDefaultScale
- Direct Known Subclasses:
GlobalScale
,Scale
public abstract class AbstractScale extends AbstractModel<Options,IsDefaultScale> implements IsDefaultScale, HasLabels
Scales are an integral part of a chart.
They are used to determine how data maps to a pixel value on the chart.
- linear
- logarithmic
- category
- time
- time series
- radial linear
- Author:
- Andrea "Stock" Stocchero
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractScale(IsDefaultScale defaultValues, NativeObject nativeObject)
Creates the object only with default provider and native object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Adapters
getAdapters()
Returns the adapters element.AngleLines
getAngleLines()
Returns the angle lines element.IsColor
getBackgroundColor()
Returns the background color of the scale area.String
getBackgroundColorAsString()
Returns the background color of the scale area.Bounds
getBounds()
Returns the property controls the scale boundary strategy (bypassed by min/max time options).Display
getDisplay()
The display option controls the visibility of axis.
Controls the axis global visibility (visible when true, hidden when false).int
getGrace()
Returns the value in pixels is added to the maximum data value and subtracted from the minimum data.
This extends the scale range as if the data values were that much greater.double
getGraceAsPercentage()
Returns the value in percentage, value between 0 and 1, is added to the maximum data value and subtracted from the minimum data.
This extends the scale range as if the data values were that much greater.Grid
getGrid()
Returns the grid element.LabelsHandler
getLabelsHandler()
Returns an labels option handler instance.double
getMax()
Returns the user defined maximum number for the scale, overrides maximum value from data.Date
getMaxAsDate()
If defined, this will override the data maximum.String
getMaxAsString()
Returns the user defined maximum number for the scale, overrides maximum value from data.int
getMaxIndex()
Returns the maximum item at passed index to display.double
getMin()
Returns the user defined minimum number for the scale, overrides minimum value from data.Date
getMinAsDate()
If defined, this will override the data minimum.String
getMinAsString()
Returns the user defined minimum number for the scale, overrides minimum value from data.int
getMinIndex()
Returns the minimum item at passed index to displayPointLabels
getPointLabels()
Returns the point labels element.AxisPosition
getPosition()
An axis can either be positioned at the edge of the chart, at the center of the chart area, or dynamically with respect to a data value.
To position the axis at the edge of the chart, set the position option to one of: 'top', 'left', 'bottom', 'right'.
To position the axis at the center of the chart area, set the position option to 'center'.String
getStack()
Returns the stack group.
Axes at the same position with same stack are stacked.double
getStackWeight()
Returns the weight of the scale in stack group.
Used to determine the amount of allocated space for the scale within the group.double
getStartAngle()
Returns the starting angle to draw arcs for the first item in a data set.double
getSuggestedMax()
Returns the adjustment used when calculating the maximum data value.double
getSuggestedMin()
Returns the adjustment used when calculating the minimum data value.Ticks
getTicks()
Returns the ticks element.Time
getTime()
Returns the time element.ScaleTitle
getTitle()
Returns the scale title element.double
getWeight()
The weight used to sort the axis.boolean
isAlignToPixels()
Returnstrue
to align pixel values to device pixels.boolean
isAnimate()
Returns whether to animate scaling the chart from the center.boolean
isBeginAtZero()
Iftrue
, scale will include 0 if it is not already included.boolean
isOffset()
Iftrue
, extra space is added to the both edges and the axis is scaled to fit in the chart area.boolean
isReverse()
Returns the reversed order of tick labels.boolean
isSingleStacked()
Returns if you might want to stack positive and negative values together.boolean
isStacked()
Returns if the axis are stacked or not.void
setAlignToPixels(boolean alignToPixels)
Setstrue
to align pixel values to device pixels.void
setAnimate(boolean animate)
Sets whether to animate scaling the chart from the center.void
setBackgroundColor(String backgroundColor)
Sets the background color of the scale area.void
setBackgroundColor(IsColor backgroundColor)
Sets the default background color to use in the chart, on all objects, if not override by the specific configuration.void
setBeginAtZero(boolean beginAtZero)
Iftrue
, scale will include 0 if it is not already included.void
setBounds(Bounds bounds)
Sets the property controls the scale boundary strategy (bypassed by min/max time options).void
setDisplay(boolean display)
Iftrue
, shows the axis.void
setDisplay(Display display)
The display option controls the visibility of axis.
Controls the axis global visibility (visible when true, hidden when false).void
setGrace(int grace)
Sets the value in pixels is added to the maximum data value and subtracted from the minimum data.
This extends the scale range as if the data values were that much greater.void
setGraceAsPercentage(double grace)
Sets the value in percentage, value between 0 and 1, is added to the maximum data value and subtracted from the minimum data.
This extends the scale range as if the data values were that much greater.void
setLabels(String... labels)
Sets the labels of the data.void
setLabels(Labels labels)
Sets the labels of the data.void
setMax(double max)
Sets the user defined maximum number for the scale, overrides maximum value from data.void
setMax(String max)
Sets the user defined maximum number for the scale, overrides maximum value from data.void
setMax(Date max)
If defined, this will override the data maximum.void
setMaxIndex(int max)
Sets the maximum item at passed index to display.void
setMin(double min)
Sets the user defined minimum number for the scale, overrides minimum value from data.void
setMin(String min)
Sets the user defined minimum number for the scale, overrides minimum value from data.void
setMin(Date min)
If defined, this will override the data minimum.void
setMinIndex(int min)
Sets the minimum item at passed index to display.void
setOffset(boolean offset)
Iftrue
, extra space is added to the both edges and the axis is scaled to fit in the chart area.void
setPosition(AxisPosition position)
An axis can either be positioned at the edge of the chart, at the center of the chart area, or dynamically with respect to a data value.
To position the axis at the edge of the chart, set the position option to one of: 'top', 'left', 'bottom', 'right'.
To position the axis at the center of the chart area, set the position option to 'center'.void
setReverse(boolean reverse)
Sets the reversed order of tick labels.void
setSingleStacked(boolean stacked)
Sets if you might want to stack positive and negative values together.void
setStack(String stack)
Sets the stack group.
Axes at the same position with same stack are stacked.void
setStacked(boolean stacked)
Sets if the axis are stacked or not.void
setStackWeight(double stackWeight)
Sets the weight of the scale in stack group.
Used to determine the amount of allocated space for the scale within the group.void
setStartAngle(double startAngle)
Sets the starting angle to draw arcs for the first item in a data set.void
setSuggestedMax(double suggestedMax)
Sets the adjustment used when calculating the maximum data value.void
setSuggestedMin(double suggestedMin)
Sets the adjustment used when calculating the minimum data value.void
setWeight(double weight)
The weight used to sort the axis.-
Methods inherited from class org.pepstock.charba.client.options.AbstractModel
getDefaultValues, getParent, loadPadding, setCallbackToModel, setCallbackToModel, setEventToModel
-
Methods inherited from class org.pepstock.charba.client.commons.AbstractNode
checkAndAddToParent, getChildKey, getParentNode, getRootNode, retrieveRoot, setArrayValueAndAddToParent, setArrayValueAndAddToParent, setArrayValueAndAddToParent, setElementAndAddToParent, setInternalCallbackToModel, setInternalCallbackToModel, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent
-
Methods inherited from class org.pepstock.charba.client.commons.NativeObjectContainer
checkDefaultValuesArgument, empty, getArrayValue, getElement, getIncrementalId, getNativeChart, getNativeEvent, getNativeObject, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, has, has, isType, keys, loadNativeObject, remove, remove, setArrayValue, setArrayValue, setArrayValue, setElement, setEmptyValue, setNewIncrementalId, setNewIncrementalId, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, toJSON, type
-
-
-
-
Constructor Detail
-
AbstractScale
protected AbstractScale(IsDefaultScale defaultValues, NativeObject nativeObject)
Creates the object only with default provider and native object. This is used when the scale is the root element.- Parameters:
defaultValues
- default provider instance.nativeObject
- native object to store properties.
-
-
Method Detail
-
getLabelsHandler
public final LabelsHandler getLabelsHandler()
Description copied from interface:HasLabels
Returns an labels option handler instance.- Specified by:
getLabelsHandler
in interfaceHasLabels
- Returns:
- an labels option handler instance
-
getTitle
public final ScaleTitle getTitle()
Returns the scale title element.- Specified by:
getTitle
in interfaceIsDefaultScale
- Returns:
- the scale title element
-
getTicks
public final Ticks getTicks()
Returns the ticks element.- Specified by:
getTicks
in interfaceIsDefaultScale
- Returns:
- the ticks
-
getGrid
public final Grid getGrid()
Returns the grid element.- Specified by:
getGrid
in interfaceIsDefaultScale
- Returns:
- the grid
-
getAngleLines
public final AngleLines getAngleLines()
Returns the angle lines element.- Specified by:
getAngleLines
in interfaceIsDefaultScale
- Returns:
- the angleLines
-
getPointLabels
public final PointLabels getPointLabels()
Returns the point labels element.- Specified by:
getPointLabels
in interfaceIsDefaultScale
- Returns:
- the pointLabels
-
getTime
public final Time getTime()
Returns the time element.- Specified by:
getTime
in interfaceIsDefaultScale
- Returns:
- the time
-
getAdapters
public final Adapters getAdapters()
Returns the adapters element.- Specified by:
getAdapters
in interfaceIsDefaultScale
- Returns:
- the adapters
-
setBeginAtZero
public final void setBeginAtZero(boolean beginAtZero)
Iftrue
, scale will include 0 if it is not already included.- Parameters:
beginAtZero
- iftrue
, scale will include 0 if it is not already included.
-
isBeginAtZero
public final boolean isBeginAtZero()
Iftrue
, scale will include 0 if it is not already included.- Specified by:
isBeginAtZero
in interfaceIsDefaultScale
- Returns:
- if
true
, scale will include 0 if it is not already included.
-
setBackgroundColor
public void setBackgroundColor(IsColor backgroundColor)
Sets the default background color to use in the chart, on all objects, if not override by the specific configuration.- Parameters:
backgroundColor
- background color to use in the chart.
-
setBackgroundColor
public void setBackgroundColor(String backgroundColor)
Sets the background color of the scale area.- Parameters:
backgroundColor
- the background color of the scale area.
-
getBackgroundColorAsString
public String getBackgroundColorAsString()
Returns the background color of the scale area.- Specified by:
getBackgroundColorAsString
in interfaceIsDefaultScale
- Returns:
- the background color of the scale area.
-
getBackgroundColor
public IsColor getBackgroundColor()
Returns the background color of the scale area.- Returns:
- the background color of the scale area.
-
setGrace
public final void setGrace(int grace)
Sets the value in pixels is added to the maximum data value and subtracted from the minimum data.
This extends the scale range as if the data values were that much greater.- Parameters:
grace
- the value in pixels is added to the maximum data value and subtracted from the minimum data
-
getGrace
public final int getGrace()
Returns the value in pixels is added to the maximum data value and subtracted from the minimum data.
This extends the scale range as if the data values were that much greater.- Specified by:
getGrace
in interfaceIsDefaultScale
- Returns:
- the value in pixels is added to the maximum data value and subtracted from the minimum data
-
setGraceAsPercentage
public final void setGraceAsPercentage(double grace)
Sets the value in percentage, value between 0 and 1, is added to the maximum data value and subtracted from the minimum data.
This extends the scale range as if the data values were that much greater.- Parameters:
grace
- the value in percentage is added to the maximum data value and subtracted from the minimum data
-
getGraceAsPercentage
public final double getGraceAsPercentage()
Returns the value in percentage, value between 0 and 1, is added to the maximum data value and subtracted from the minimum data.
This extends the scale range as if the data values were that much greater.- Specified by:
getGraceAsPercentage
in interfaceIsDefaultScale
- Returns:
- the value in percentage is added to the maximum data value and subtracted from the minimum data
-
setMin
public final void setMin(double min)
Sets the user defined minimum number for the scale, overrides minimum value from data.- Parameters:
min
- the user defined minimum number for the scale, overrides minimum value from data.
-
getMin
public final double getMin()
Returns the user defined minimum number for the scale, overrides minimum value from data.- Specified by:
getMin
in interfaceIsDefaultScale
- Returns:
- the user defined minimum number for the scale, overrides minimum value from data.
-
setMin
public final void setMin(Date min)
If defined, this will override the data minimum.- Parameters:
min
- If defined, this will override the data minimum.
-
getMinAsDate
public final Date getMinAsDate()
If defined, this will override the data minimum.- Returns:
- If defined, this will override the data minimum.
-
setMax
public final void setMax(double max)
Sets the user defined maximum number for the scale, overrides maximum value from data.- Parameters:
max
- user defined maximum number for the scale, overrides maximum value from data.
-
getMax
public final double getMax()
Returns the user defined maximum number for the scale, overrides maximum value from data.- Specified by:
getMax
in interfaceIsDefaultScale
- Returns:
- user defined maximum number for the scale, overrides maximum value from data.
-
setMax
public final void setMax(Date max)
If defined, this will override the data maximum.- Parameters:
max
- if defined, this will override the data maximum.
-
getMaxAsDate
public final Date getMaxAsDate()
If defined, this will override the data maximum.- Returns:
- if defined, this will override the data maximum.
-
setMin
public final void setMin(String min)
Sets the user defined minimum number for the scale, overrides minimum value from data.- Parameters:
min
- the user defined minimum number for the scale, overrides minimum value from data.
-
getMinAsString
public final String getMinAsString()
Returns the user defined minimum number for the scale, overrides minimum value from data.- Returns:
- the user defined minimum number for the scale, overrides minimum value from data.
-
setMax
public final void setMax(String max)
Sets the user defined maximum number for the scale, overrides maximum value from data.- Parameters:
max
- user defined maximum number for the scale, overrides maximum value from data.
-
getMaxAsString
public final String getMaxAsString()
Returns the user defined maximum number for the scale, overrides maximum value from data.- Returns:
- user defined maximum number for the scale, overrides maximum value from data.
-
setMinIndex
public final void setMinIndex(int min)
Sets the minimum item at passed index to display.- Parameters:
min
- The minimum item at passed index to display
-
getMinIndex
public final int getMinIndex()
Returns the minimum item at passed index to display- Returns:
- The minimum item at passed index to display
-
setMaxIndex
public final void setMaxIndex(int max)
Sets the maximum item at passed index to display.- Parameters:
max
- the maximum item at passed index to display.
-
getMaxIndex
public final int getMaxIndex()
Returns the maximum item at passed index to display.- Returns:
- the maximum item at passed index to display.
-
setSuggestedMax
public final void setSuggestedMax(double suggestedMax)
Sets the adjustment used when calculating the maximum data value.- Parameters:
suggestedMax
- adjustment used when calculating the maximum data value.
-
getSuggestedMax
public final double getSuggestedMax()
Returns the adjustment used when calculating the maximum data value.- Specified by:
getSuggestedMax
in interfaceIsDefaultScale
- Returns:
- adjustment used when calculating the maximum data value.
-
setSuggestedMin
public final void setSuggestedMin(double suggestedMin)
Sets the adjustment used when calculating the minimum data value.- Parameters:
suggestedMin
- adjustment used when calculating the minimum data value.
-
getSuggestedMin
public final double getSuggestedMin()
Returns the adjustment used when calculating the minimum data value.- Specified by:
getSuggestedMin
in interfaceIsDefaultScale
- Returns:
- adjustment used when calculating the minimum data value.
-
setAlignToPixels
public final void setAlignToPixels(boolean alignToPixels)
Setstrue
to align pixel values to device pixels.- Parameters:
alignToPixels
-true
to align pixel values to device pixels.
-
isAlignToPixels
public final boolean isAlignToPixels()
Returnstrue
to align pixel values to device pixels.- Specified by:
isAlignToPixels
in interfaceIsDefaultScale
- Returns:
true
to align pixel values to device pixels
-
setReverse
public final void setReverse(boolean reverse)
Sets the reversed order of tick labels.- Parameters:
reverse
- reversed order of tick labels.
-
isReverse
public final boolean isReverse()
Returns the reversed order of tick labels.- Specified by:
isReverse
in interfaceIsDefaultScale
- Returns:
- if
true
reversed order of tick labels.
-
setStacked
public final void setStacked(boolean stacked)
Sets if the axis are stacked or not.- Parameters:
stacked
- if the axis are stacked or not.
-
isStacked
public final boolean isStacked()
Returns if the axis are stacked or not.- Specified by:
isStacked
in interfaceIsDefaultScale
- Returns:
- if the axis are stacked or not.
-
setSingleStacked
public final void setSingleStacked(boolean stacked)
Sets if you might want to stack positive and negative values together.- Parameters:
stacked
- if you might want to stack positive and negative values together
-
isSingleStacked
public final boolean isSingleStacked()
Returns if you might want to stack positive and negative values together.- Specified by:
isSingleStacked
in interfaceIsDefaultScale
- Returns:
- if you might want to stack positive and negative values together
-
setWeight
public final void setWeight(double weight)
The weight used to sort the axis. Higher weights are further away from the chart area.- Parameters:
weight
- weight of axis
-
getWeight
public final double getWeight()
The weight used to sort the axis. Higher weights are further away from the chart area.- Specified by:
getWeight
in interfaceIsDefaultScale
- Returns:
- weight of axis.
-
setDisplay
public final void setDisplay(boolean display)
Iftrue
, shows the axis.- Parameters:
display
- iftrue
, shows the axes.
-
setDisplay
public final void setDisplay(Display display)
The display option controls the visibility of axis.
Controls the axis global visibility (visible when true, hidden when false). When display: 'auto', the axis is visible only if at least one associated dataset is visible.- Parameters:
display
- display option controls the visibility of axis
-
getDisplay
public final Display getDisplay()
The display option controls the visibility of axis.
Controls the axis global visibility (visible when true, hidden when false). When display: 'auto', the axis is visible only if at least one associated dataset is visible.- Specified by:
getDisplay
in interfaceIsDefaultScale
- Returns:
- display option controls the visibility of axis
-
setOffset
public final void setOffset(boolean offset)
Iftrue
, extra space is added to the both edges and the axis is scaled to fit in the chart area.- Parameters:
offset
- extra space of axis
-
isOffset
public final boolean isOffset()
Iftrue
, extra space is added to the both edges and the axis is scaled to fit in the chart area.- Specified by:
isOffset
in interfaceIsDefaultScale
- Returns:
- extra space of axis.
-
setPosition
public final void setPosition(AxisPosition position)
An axis can either be positioned at the edge of the chart, at the center of the chart area, or dynamically with respect to a data value.
To position the axis at the edge of the chart, set the position option to one of: 'top', 'left', 'bottom', 'right'.
To position the axis at the center of the chart area, set the position option to 'center'.- Parameters:
position
- position of axis
-
getPosition
public final AxisPosition getPosition()
An axis can either be positioned at the edge of the chart, at the center of the chart area, or dynamically with respect to a data value.
To position the axis at the edge of the chart, set the position option to one of: 'top', 'left', 'bottom', 'right'.
To position the axis at the center of the chart area, set the position option to 'center'.- Specified by:
getPosition
in interfaceIsDefaultScale
- Returns:
- position of axis.
-
setBounds
public final void setBounds(Bounds bounds)
Sets the property controls the scale boundary strategy (bypassed by min/max time options).- Parameters:
bounds
- property controls the scale boundary strategy (bypassed by min/max time options).
-
getBounds
public final Bounds getBounds()
Returns the property controls the scale boundary strategy (bypassed by min/max time options).- Specified by:
getBounds
in interfaceIsDefaultScale
- Returns:
- property controls the scale boundary strategy (bypassed by min/max time options).
-
setStack
public final void setStack(String stack)
Sets the stack group.
Axes at the same position with same stack are stacked.- Parameters:
stack
- the stack group.
Axes at the same position with same stack are stacked
-
getStack
public final String getStack()
Returns the stack group.
Axes at the same position with same stack are stacked.- Specified by:
getStack
in interfaceIsDefaultScale
- Returns:
- the stack group.
Axes at the same position with same stack are stacked
-
setStackWeight
public final void setStackWeight(double stackWeight)
Sets the weight of the scale in stack group.
Used to determine the amount of allocated space for the scale within the group.- Parameters:
stackWeight
- the weight of the scale in stack group.
Used to determine the amount of allocated space for the scale within the group.
-
getStackWeight
public final double getStackWeight()
Returns the weight of the scale in stack group.
Used to determine the amount of allocated space for the scale within the group.- Specified by:
getStackWeight
in interfaceIsDefaultScale
- Returns:
- the weight of the scale in stack group.
Used to determine the amount of allocated space for the scale within the group
-
setLabels
public final void setLabels(String... labels)
Sets the labels of the data.
-
setLabels
public final void setLabels(Labels labels)
Sets the labels of the data.
-
setAnimate
public final void setAnimate(boolean animate)
Sets whether to animate scaling the chart from the center.- Parameters:
animate
- whether to animate scaling the chart from the center.
-
isAnimate
public final boolean isAnimate()
Returns whether to animate scaling the chart from the center.- Specified by:
isAnimate
in interfaceIsDefaultScale
- Returns:
- whether to animate scaling the chart from the center.
-
setStartAngle
public void setStartAngle(double startAngle)
Sets the starting angle to draw arcs for the first item in a data set.- Parameters:
startAngle
- starting angle to draw arcs for the first item in a data set.
-
getStartAngle
public double getStartAngle()
Returns the starting angle to draw arcs for the first item in a data set.- Specified by:
getStartAngle
in interfaceIsDefaultScale
- Returns:
- starting angle to draw arcs for the first item in a data set.
-
-