Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class ChartElement
- Object
- SlideElement
- ChartElement
A chart on a slide: its data – categories, named series of values, colors – and its
kind. It is drawn by com.codename1.ui.chart.Chart, so a slide’s chart looks like and
animates like any other chart in the application, and toChart gives the live,
interactive component for a slide show that wants one.
PPTX charts (c:chartSpace) and ODF charts are read into this model; a kind or option the
model lacks falls back to the nearest kind.
Fields
public static final String COLUMN = "column" | Vertical bars (OOXML’s column chart). |
public static final String BAR = "bar" | Horizontal bars. |
public static final String LINE = "line" | Lines. |
public static final String AREA = "area" | Filled areas under lines. |
public static final String PIE = "pie" | A pie of the first series. |
public static final String DOUGHNUT = "doughnut" | A pie with a hole. |
public static final String SCATTER = "scatter" | Points: the categories, read as numbers, are x and every series is y; see xValues(). |
public static final String RADAR = "radar" | A radar (spider) chart. |
public final String kind | The kind, one of the constants. |
public final String title | The title, or null. |
public final boolean stacked | True when bars or areas of different series stack. |
public final boolean legend | True when a legend is shown. |
Constructors
Methods
Inherited fields
Inherited methods
Field details
COLUMN
public static final String COLUMN = "column"Vertical bars (OOXML’s column chart).
BAR
public static final String BAR = "bar"Horizontal bars.
LINE
public static final String LINE = "line"Lines.
AREA
public static final String AREA = "area"Filled areas under lines.
PIE
public static final String PIE = "pie"A pie of the first series.
DOUGHNUT
public static final String DOUGHNUT = "doughnut"A pie with a hole.
SCATTER
public static final String SCATTER = "scatter"Points: the categories, read as numbers, are x and every series is y; see
xValues().RADAR
public static final String RADAR = "radar"A radar (spider) chart.
kind
public final String kindThe kind, one of the constants.
title
public final String titleThe title, or null.
stacked
public final boolean stackedTrue when bars or areas of different series stack.
legend
public final boolean legendTrue when a legend is shown.
Constructor details
ChartElement
public ChartElement(String id, String kind, float x, float y, float width, float height, String[] categories, String[] seriesNames, double[][] values)A chart.
Parameters
idString- the id
kindString- one of the kind constants
xfloat- left edge in points
yfloat- top edge
widthfloat- width
heightfloat- height
categoriesString[]- the category labels
seriesNamesString[]- one name per series
valuesdouble[][]- one row of values per series, one value per category
ChartElement
public ChartElement(String id, String name, String kind, float x, float y, float width, float height, float rotation, String title, boolean stacked, boolean legend, String[] categories, String[] seriesNames, double[][] values, int[] colors)A chart with every property.
Parameters
idString- the id
nameString- a name, or null
kindString- one of the kind constants
xfloat- left edge
yfloat- top edge
widthfloat- width
heightfloat- height
rotationfloat- degrees clockwise
titleString- the title, or null
stackedboolean- whether series stack
legendboolean- whether a legend shows
categoriesString[]- the category labels
seriesNamesString[]- the series names
valuesdouble[][]- one row per series
colorsint[]- one 0xRRGGBB per series, or null for the chart theme’s
Method details
xValues
public double[] xValues()The x values of a scatter chart: its categories read as numbers, as PPTX’s xVal and
ODF’s x range hold them, or 1, 2, 3… where a category is not a number.
Returns
one x value per category
categoryCount
public int categoryCount()The number of categories.
Returns
the count
category
public String category(int i)A category label.
Parameters
iint- the index
Returns
the label
seriesCount
public int seriesCount()The number of series.
Returns
the count
seriesName
public String seriesName(int i)A series name.
Parameters
iint- the series
Returns
the name
values
public double[] values(int i)A copy of one series’ values.
Parameters
iint- the series
Returns
the values
seriesColor
public int seriesColor(int i)The color of a series, or -1 when the chart theme picks it.
Parameters
iint- the series
Returns
0xRRGGBB or -1
withData
public ChartElement withData(String[] cats, String[] names, double[][] data)This chart with other data.
Parameters
catsString[]- categories
namesString[]- series names
datadouble[][]- one row per series
Returns
the chart
withKind
public ChartElement withKind(String value)This chart as another kind.
Parameters
valueString- one of the kind constants
Returns
the chart
withTitle
public ChartElement withTitle(String value)This chart with a title.
Parameters
valueString- the title, or null
Returns
the chart
withStacked
public ChartElement withStacked(boolean value)This chart stacked or side by side.
Parameters
valueboolean- true to stack
Returns
the chart
withColors
public ChartElement withColors(int[] value)This chart with series colors.
Parameters
valueint[]- 0xRRGGBB per series, or null
Returns
the chart
toChart
public Chart toChart()A live
Chart component showing this data. Each call makes a new one; a slide show
places it over the slide so the audience gets tooltips and the entrance animation.Returns
the chart
withTransform
public SlideElement withTransform(float nx, float ny, float nw, float nh, float rot, boolean fh, boolean fv)This element moved, resized, rotated or flipped.
Parameters
nxfloat- left edge
nyfloat- top edge
nwfloat- width
nhfloat- height
rotfloat- degrees clockwise
fhboolean- mirrored horizontally
fvboolean- mirrored vertically
Returns
the changed element
withId
public SlideElement withId(String value)This element with another id, for copies.
Parameters
valueString- the id
Returns
the element
plainText
public String plainText()The text of the element for search, outlines and screen readers.
Returns
the text, empty when there is none
equals
public boolean equals(Object o)Indicates whether some other object is “equal to” this one.
The equals method implements an equivalence relation: It is reflexive: for any reference value x, x.equals(x) should return true. It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified. For any non-null reference value x, x.equals(null) should return false.
The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true).
hashCode
public int hashCode()Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.
The general contract of hashCode is: Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)