Package org.aesh.charts.axis
Class Axis
java.lang.Object
org.aesh.charts.axis.Axis
Renders a numeric axis with labels and tick marks.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidautoRange(double dataMin, double dataMax) Auto-set min/max from data range, rounding to nice tick-aligned bounds.doubledenormalize(double normalized) Map a normalized position (0.0-1.0) back to a data value.voiddrawXAxis(Canvas canvas, int xLeft, int xRight, int y, ChartStyle style) Draw a bottom X-axis on the canvas.voiddrawYAxis(Canvas canvas, int x, int yTop, int yBottom, ChartStyle style) Draw a left Y-axis on the canvas.formatTick(double value) Format a tick value as a label string.label()intCompute the width needed for Y-axis labels, tick mark, and optional vertical label text.doublemax()max(double max) doublemin()min(double min) doublenormalize(double value) Map a data value to a normalized position (0.0 = min, 1.0 = max).scale()tickCount(int tickCount) tickFormatter(Function<Double, String> formatter) Set a custom tick label formatter.double[]Generate tick values for this axis.
-
Constructor Details
-
Axis
public Axis()
-
-
Method Details
-
min
-
max
-
label
-
scale
-
tickCount
-
format
-
tickFormatter
Set a custom tick label formatter. Takes priority overformat(String). Use this to map numeric tick values to arbitrary label strings (#589).- Parameters:
formatter- function that converts a tick value to a label string- Returns:
- this axis for fluent chaining
-
min
public double min() -
max
public double max() -
label
-
scale
-
autoRange
public void autoRange(double dataMin, double dataMax) Auto-set min/max from data range, rounding to nice tick-aligned bounds. Uses a "nice number" algorithm that picks tick intervals from {1, 2, 2.5, 5, 10} * 10^n, then aligns min/max to those intervals. This produces tight, readable axis bounds like 0-20 or 0-25 instead of excessive padding like -1 to 30 (#585). -
normalize
public double normalize(double value) Map a data value to a normalized position (0.0 = min, 1.0 = max). -
denormalize
public double denormalize(double normalized) Map a normalized position (0.0-1.0) back to a data value. -
tickValues
public double[] tickValues()Generate tick values for this axis. -
formatTick
Format a tick value as a label string. -
labelWidth
public int labelWidth()Compute the width needed for Y-axis labels, tick mark, and optional vertical label text. -
drawYAxis
Draw a left Y-axis on the canvas.- Parameters:
canvas- the canvasx- x position of the axis lineyTop- top y positionyBottom- bottom y positionstyle- chart style
-
drawXAxis
Draw a bottom X-axis on the canvas.- Parameters:
canvas- the canvasxLeft- left x positionxRight- right x positiony- y position of the axis linestyle- chart style
-