Fluent builder for a chart's title, axis labels, dimensions, orientation and data points. Obtained from ChartManager.newChartBuilder() and passed to buildBarChart() or buildXYLineChart() to render it as PNG bytes. Each setter returns this builder so calls can be chained.
Group: Builders
Properties
| Property | Returns | Description |
|---|---|---|
| data | List<DataPoint> | Data points added to this builder so far, in the order they were added. |
| height | int | Height, in pixels, the rendered chart image will be. Zero until set via height(int). |
| showLegend | boolean | Whether the rendered chart includes a legend. |
| title | String | Title displayed at the top of the rendered chart. Null until set via title(String). |
| vertOrientiation | boolean | Whether a bar chart renders with vertical bars rather than horizontal ones; has no effect on line charts. |
| width | int | Width, in pixels, the rendered chart image will be. Zero until set via width(int). |
| xLabel | String | Label displayed on the chart's x-axis. Null until set via xLabel(String). |
| yLabel | String | Label displayed on the chart's y-axis. Null until set via yLabel(String). |
Methods
dateRange(boolean b) · height(int i) · width(int i) · title(String i) · xLabel(String i) · yLabel(String i) · isVertOrientiation(boolean i) · showLegend(boolean i) · addXY(Number x, Number y) · addXY(ZonedDateTime x, Number y) · addXY(Date x, Number y) · add(Number value, String rowLabel, String colLabel) · getHeight() · setHeight(int height) · getWidth() · setWidth(int width) · getTitle() · setTitle(String title) · getxLabel() · setxLabel(String xLabel) · getyLabel() · setyLabel(String yLabel) · isVertOrientiation() · setVertOrientiation(boolean isVertOrientiation) · isShowLegend() · setShowLegend(boolean showLegend) · getData()
dateRange(boolean b)
Returns: ChartBuilder
Sets whether the x-axis should be treated as a date range and rendered with date-formatted tick units. Set automatically by addXY(Date, Number); call directly to force date formatting when adding points of another type.
| Parameter | Description |
|---|---|
b | true to render the x-axis as dates |
height(int i)
Returns: ChartBuilder
Sets the rendered chart image's height.
| Parameter | Description |
|---|---|
i | the image height, in pixels |
width(int i)
Returns: ChartBuilder
Sets the rendered chart image's width.
| Parameter | Description |
|---|---|
i | the image width, in pixels |
title(String i)
Returns: ChartBuilder
Sets the chart's title.
| Parameter | Description |
|---|---|
i | the chart title |
xLabel(String i)
Returns: ChartBuilder
Sets the chart's x-axis label.
| Parameter | Description |
|---|---|
i | the x-axis label |
yLabel(String i)
Returns: ChartBuilder
Sets the chart's y-axis label.
| Parameter | Description |
|---|---|
i | the y-axis label |
isVertOrientiation(boolean i)
Returns: ChartBuilder
Sets whether a bar chart is rendered with vertical bars rather than horizontal ones; has no effect on line charts.
| Parameter | Description |
|---|---|
i | true for vertical bars, false for horizontal |
showLegend(boolean i)
Returns: ChartBuilder
Sets whether the rendered chart includes a legend.
| Parameter | Description |
|---|---|
i | true to show a legend |
addXY(Number x, Number y)
Returns: ChartBuilder
Adds a line chart data point. Use this overload for a plain numeric x-axis; use addXY(Date, Number) or addXY(ZonedDateTime, Number) for a date-based x-axis.
| Parameter | Description |
|---|---|
x | the point's x-axis value |
y | the point's y-axis value |
addXY(ZonedDateTime x, Number y)
Returns: ChartBuilder
Adds a line chart data point at the given date and time, rendering the x-axis as a date range. See addXY(Date, Number).
| Parameter | Description |
|---|---|
x | the point's date and time |
y | the point's y-axis value |
addXY(Date x, Number y)
Returns: ChartBuilder
Adds a line chart data point at the given date, plotted by the date's epoch millisecond value, and sets dateRange(true) so the x-axis is rendered with date-formatted tick units.
| Parameter | Description |
|---|---|
x | the point's date |
y | the point's y-axis value |
add(Number value, String rowLabel, String colLabel)
Returns: ChartBuilder
Adds a bar chart data point.
| Parameter | Description |
|---|---|
value | the bar's value, plotted on the y-axis |
rowLabel | the series (row) key; data points sharing the same row label are grouped into one series and shown together in the legend |
colLabel | the category (x-axis) label for this data point |
getHeight()
Returns: int
Height, in pixels, the rendered chart image will be. Zero until set via height(int).
setHeight(int height)
Returns: void
Sets the rendered chart image's height, the same value as height(int) but as a plain setter.
| Parameter | Description |
|---|---|
height | the image height, in pixels |
getWidth()
Returns: int
Width, in pixels, the rendered chart image will be. Zero until set via width(int).
setWidth(int width)
Returns: void
Sets the rendered chart image's width, the same value as width(int) but as a plain setter.
| Parameter | Description |
|---|---|
width | the image width, in pixels |
getTitle()
Returns: String
Title displayed at the top of the rendered chart. Null until set via title(String).
setTitle(String title)
Returns: void
Sets the title displayed at the top of the rendered chart, the same value as title(String) but as a plain setter.
| Parameter | Description |
|---|---|
title | the chart title |
getxLabel()
Returns: String
Label displayed on the chart's x-axis. Null until set via xLabel(String).
setxLabel(String xLabel)
Returns: void
Sets the label displayed on the chart's x-axis, the same value as xLabel(String) but as a plain setter.
| Parameter | Description |
|---|---|
xLabel | the x-axis label |
getyLabel()
Returns: String
Label displayed on the chart's y-axis. Null until set via yLabel(String).
setyLabel(String yLabel)
Returns: void
Sets the label displayed on the chart's y-axis, the same value as yLabel(String) but as a plain setter.
| Parameter | Description |
|---|---|
yLabel | the y-axis label |
isVertOrientiation()
Returns: boolean
Whether a bar chart renders with vertical bars rather than horizontal ones; has no effect on line charts.
setVertOrientiation(boolean isVertOrientiation)
Returns: void
Sets whether a bar chart renders with vertical bars rather than horizontal ones; has no effect on line charts. The same value as isVertOrientiation(boolean) but as a plain setter.
| Parameter | Description |
|---|---|
isVertOrientiation | true for vertical bars, false for horizontal |
isShowLegend()
Returns: boolean
Whether the rendered chart includes a legend.
setShowLegend(boolean showLegend)
Returns: void
Sets whether the rendered chart includes a legend, the same value as showLegend(boolean) but as a plain setter.
| Parameter | Description |
|---|---|
showLegend | true to show a legend |
getData()
Returns: List<DataPoint>
Data points added to this builder so far, in the order they were added.