Package limn.components.chart
Class ChartAxis
java.lang.Object
limn.components.chart.ChartAxis
One axis of a
CartesianChart: the value axis that carries the numbers, or the
category axis that carries the labels. Reach them with
CartesianChart.valueAxis() and CartesianChart.categoryAxis(); both are
created with the chart and live as long as it does.
An axis is automatic until told otherwise: it reads the data, rounds the range
outward to values a human would have chosen, and picks a tick spacing near
setTickCount(int). setMin(Double) and setMax(Double) pin
either end; whichever end stays null keeps following the data.
Four settings apply only to the value axis and are ignored on the category axis,
which has no numbers to place: min, max, tickCount and
beginAtZero. format is likewise a value-axis setting; category labels
come from Chart.setLabels(java.util.List).
-
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the automatic range always reaches zero.format()How tick values are turned into text: the format set, or the default, which the ticks write with more decimals when their spacing needs them (seesetFormat(java.util.function.DoubleFunction<java.lang.String>)).booleanhasGrid()Whether this axis draws grid lines across the plot.booleanWhether this axis draws its labels at all.@Nullable Doublemax()The pinned upper bound, ornullwhile it follows the data.@Nullable Doublemin()The pinned lower bound, ornullwhile it follows the data.setBeginAtZero(boolean value) Whether the automatic range must include zero.setFormat(DoubleFunction<String> value) Sets the tick text format.setGrid(boolean value) Shows or hides this axis' grid lines (value axis on, category axis off by default).Pins the upper bound;nullhands it back to the data.Pins the lower bound;nullhands it back to the data.setTickCount(int value) Sets how many ticks the automatic scale aims for (clamped to[2, 20]).Sets a title drawn beside the axis (nullfor none).setVisible(boolean value) Shows or hides the axis labels.intThe tick count the automatic scale aims for.@Nullable Stringtitle()The axis title, ornullfor none.
-
Method Details
-
min
The pinned lower bound, ornullwhile it follows the data. -
setMin
Pins the lower bound;nullhands it back to the data. -
max
The pinned upper bound, ornullwhile it follows the data. -
setMax
Pins the upper bound;nullhands it back to the data. -
beginsAtZero
public boolean beginsAtZero()Whether the automatic range always reaches zero. -
setBeginAtZero
Whether the automatic range must include zero. On by default for bars, off for lines, and that difference is not a preference: the length of a bar is the value, so a bar axis that starts anywhere else draws a ratio that is not the data's. A line encodes value as position, so it may zoom into the range that matters. -
tickCount
public int tickCount()The tick count the automatic scale aims for. -
setTickCount
Sets how many ticks the automatic scale aims for (clamped to[2, 20]). It is a target, not a promise: the scale rounds the spacing to 1, 2 or 5 times a power of ten first, and honours that over the count. -
format
How tick values are turned into text: the format set, or the default, which the ticks write with more decimals when their spacing needs them (seesetFormat(java.util.function.DoubleFunction<java.lang.String>)). -
setFormat
Sets the tick text format. Defaults toNumberFormats.number(), written with as many more decimals as the tick spacing needs: ticks a thousandth apart read0.001, 0.002, 0.003rather than four zeros. A format set here is used as it is. The chart's ownChart.setValueFormat(DoubleFunction)does not reach here, so an axis and its tooltips can read differently (compact ticks, exact tooltips). -
hasGrid
public boolean hasGrid()Whether this axis draws grid lines across the plot. -
setGrid
Shows or hides this axis' grid lines (value axis on, category axis off by default). -
isVisible
public boolean isVisible()Whether this axis draws its labels at all. -
setVisible
Shows or hides the axis labels. Hiding them gives the plot their gutter back, the shape a sparkline wants. -
title
The axis title, ornullfor none. -
setTitle
Sets a title drawn beside the axis (nullfor none).
-