Package org.pepstock.charba.client.items
Class ScaleItem
- java.lang.Object
-
- org.pepstock.charba.client.commons.NativeObjectContainer
-
- org.pepstock.charba.client.items.BaseBoxItem
-
- org.pepstock.charba.client.items.BaseBoxNodeItem
-
- org.pepstock.charba.client.items.ScaleItem
-
- All Implemented Interfaces:
IsArea
- Direct Known Subclasses:
AxisItem
public class ScaleItem extends BaseBoxNodeItem
Wraps the scale item of CHART JS chart.
This is a wrapper of scale of Chart (of CHART.JS).- Author:
- Andrea "Stock" Stocchero
-
-
Constructor Summary
Constructors Constructor Description ScaleItem(CallbacksEnvelop<NativeObject> envelop)
Creates the item using an envelop (fromcallbacks
package) of native java script object which contains all properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AxisKind
getAxis()
Which kind of axis this is.
Possible values are: ''x', 'y' or 'r'.double
getBasePixel()
Returns the pixel for the minimum chart value.
The coordinate (0, 0) is at the upper-left corner of the canvas.double
getBaseValue()
Returns the minimum chart value.int
getCharbaId()
Returns the unique id of scale.IsChart
getChart()
Returns the CHARBA chart instance.double
getDecimalForPixel(double pixel)
Used to get the data value from a given pixel.
This is the inverse of getPixelForValue.
The coordinate (0, 0) is at the upper-left corner of the canvas.int
getDrawingArea()
Returns the drawing area dimension of scale.double
getEnd()
Returns the end value of scale.ScaleId
getId()
Returns the id of scaleString
getLabelForValue(double value)
Used to get the label to display in the tooltip for the given value.double
getLabelRotation()
Returns the label rotation ratio.double
getMax()
Returns the max value of scale.Date
getMaxAsDate()
Returns the max value of scale.String
getMaxAsString()
Returns the max value of scale.double
getMin()
Returns the minimum value of scale.Date
getMinAsDate()
Returns the minimum value of scale.String
getMinAsString()
Returns the minimum value of scale.double
getPixelForDateValue(Date value)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.double
getPixelForDateValue(Date value, double index)
Returns the location of the given data point.
Value can either be an index or a numerical value.
The coordinate (0, 0) is at the upper-left corner of the canvas.double
getPixelForDecimal(double decimal)
Utility for getting the pixel location of a percentage of scale.
The coordinate (0, 0) is at the upper-left corner of the canvas.double
getPixelForStringValue(String value)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.double
getPixelForStringValue(String value, double index)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.double
getPixelForTick(double index)
Returns the location of the tick at the given index.
The coordinate (0, 0) is at the upper-left corner of the canvas.double
getPixelForValue(double value)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.double
getPixelForValue(double value, double index)
Returns the location of the given data point.
Value can either be an index or a numerical value.
The coordinate (0, 0) is at the upper-left corner of the canvas.List<String>
getPointLabels()
Returns the list of point labels of scale.String
getPositionAsString()
Returns the position of node as string.double
getStart()
Returns the start value of scale.List<ScaleTickItem>
getTicks()
Returns the list of ticks.AxisType
getType()
Returns the type of scaleScaleValueItem
getValueAtEvent(BaseNativeEvent event)
Returns the value on the axis related to an event position.ScaleValueItem
getValueAtPixel(double position)
Returns the value on the axis related to a position, passed as pixels.double
getValueForPixel(double pixel)
Used to get the data value from a given pixel.
This is the inverse of getPixelForValue.
The coordinate (0, 0) is at the upper-left corner of the canvas.int
getXCenter()
Returns the X center of scale.int
getYCenter()
Returns the Y center of scale.-
Methods inherited from class org.pepstock.charba.client.items.BaseBoxNodeItem
getMaxHeight, getMaxWidth, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getPosition, getWeight, isActive, isFullSize
-
Methods inherited from class org.pepstock.charba.client.items.BaseBoxItem
getBottom, getHeight, getLeft, getRight, getTop, getWidth, isInside
-
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, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, toJSON, type
-
-
-
-
Constructor Detail
-
ScaleItem
public ScaleItem(CallbacksEnvelop<NativeObject> envelop)
Creates the item using an envelop (fromcallbacks
package) of native java script object which contains all properties.- Parameters:
envelop
- envelop of native java script object which contains all properties.
-
-
Method Detail
-
getChart
public final IsChart getChart()
Returns the CHARBA chart instance.- Returns:
- the CHARBA chart instance
-
getId
public final ScaleId getId()
Returns the id of scale- Returns:
- the id of scale.
-
getCharbaId
public final int getCharbaId()
Returns the unique id of scale.- Returns:
- the unique id of scale.
-
getAxis
public final AxisKind getAxis()
Which kind of axis this is.
Possible values are: ''x', 'y' or 'r'.- Returns:
- the kind of axis.
-
getType
public final AxisType getType()
Returns the type of scale- Returns:
- the type of scale.
-
getMax
public final double getMax()
Returns the max value of scale.- Returns:
- the max value of scale.
-
getMin
public final double getMin()
Returns the minimum value of scale.- Returns:
- the minimum value of scale.
-
getMaxAsString
public final String getMaxAsString()
Returns the max value of scale.- Returns:
- the max value of scale.
-
getMinAsString
public final String getMinAsString()
Returns the minimum value of scale.- Returns:
- the minimum value of scale.
-
getMaxAsDate
public final Date getMaxAsDate()
Returns the max value of scale.- Returns:
- the max value of scale. If missing returns is
null
.
-
getMinAsDate
public final Date getMinAsDate()
Returns the minimum value of scale.- Returns:
- the minimum value of scale. If missing returns is
null
.
-
getTicks
public final List<ScaleTickItem> getTicks()
Returns the list of ticks.- Returns:
- the list of ticks.
-
getLabelRotation
public final double getLabelRotation()
Returns the label rotation ratio.- Returns:
- the label rotation ratio.
-
getStart
public final double getStart()
Returns the start value of scale.- Returns:
- the start value of scale.
-
getEnd
public final double getEnd()
Returns the end value of scale.- Returns:
- the end value of scale.
-
getXCenter
public final int getXCenter()
Returns the X center of scale.- Returns:
- the X center of scale.
-
getYCenter
public final int getYCenter()
Returns the Y center of scale.- Returns:
- the Y center of scale.
-
getDrawingArea
public final int getDrawingArea()
Returns the drawing area dimension of scale.- Returns:
- the drawing area dimension of scale.
-
getPointLabels
public final List<String> getPointLabels()
Returns the list of point labels of scale.- Returns:
- the list of point labels of scale.
-
getPositionAsString
public final String getPositionAsString()
Returns the position of node as string. This is implements the possibility to have a specific position for scale item, not mapped in thePosition
enumeration, like forRadialAxis
.- Returns:
- the position of node.
-
getValueAtEvent
public final ScaleValueItem getValueAtEvent(BaseNativeEvent event)
Returns the value on the axis related to an event position.- Parameters:
event
- event instance used to get the value from the scale- Returns:
- the value on the axis related to an event position
-
getValueAtPixel
public final ScaleValueItem getValueAtPixel(double position)
Returns the value on the axis related to a position, passed as pixels.- Parameters:
position
- position in pixel used to get the value from the scale- Returns:
- the value on the axis related to a position, passed as pixels
-
getDecimalForPixel
public final double getDecimalForPixel(double pixel)
Used to get the data value from a given pixel.
This is the inverse of getPixelForValue.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
pixel
- pixel value- Returns:
- the data value from a given pixel
-
getPixelForDecimal
public final double getPixelForDecimal(double decimal)
Utility for getting the pixel location of a percentage of scale.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
decimal
- number value to use- Returns:
- the pixel location of a percentage of scale
-
getPixelForTick
public final double getPixelForTick(double index)
Returns the location of the tick at the given index.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
index
- tick index to use- Returns:
- the location of the tick at the given index
-
getLabelForValue
public final String getLabelForValue(double value)
Used to get the label to display in the tooltip for the given value.- Parameters:
value
- value of the data- Returns:
- the label to display in the tooltip for the given value
-
getPixelForStringValue
public final double getPixelForStringValue(String value)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value
- value of the data- Returns:
- the location of the given data point
-
getPixelForStringValue
public final double getPixelForStringValue(String value, double index)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value
- value of the data as stringindex
- index of the data- Returns:
- the location of the given data point
-
getPixelForDateValue
public final double getPixelForDateValue(Date value)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value
- value of the data- Returns:
- the location of the given data point
-
getPixelForDateValue
public final double getPixelForDateValue(Date value, double index)
Returns the location of the given data point.
Value can either be an index or a numerical value.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value
- value of the data as dateindex
- index of the data- Returns:
- the location of the given data point
-
getPixelForValue
public final double getPixelForValue(double value)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value
- value of the data- Returns:
- the location of the given data point
-
getPixelForValue
public final double getPixelForValue(double value, double index)
Returns the location of the given data point.
Value can either be an index or a numerical value.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value
- value of the dataindex
- index of the data- Returns:
- the location of the given data point
-
getValueForPixel
public final double getValueForPixel(double pixel)
Used to get the data value from a given pixel.
This is the inverse of getPixelForValue.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
pixel
- pixel value- Returns:
- the data value from a given pixel
-
getBaseValue
public final double getBaseValue()
Returns the minimum chart value.- Returns:
- the minimum chart value
-
getBasePixel
public final double getBasePixel()
Returns the pixel for the minimum chart value.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Returns:
- the pixel for the minimum chart value
-
-