Skip to content

linear DefaultNumericAxis doesn't round to tick units #675

@protogenes

Description

@protogenes

Describe the bug
Using a linear DefaultNumericAxis and setting setAutoRangeRounding(true) will always round to the next best integer number instead of the tick unit.

final double minRounded = round ? axisTransform.getRoundedMinimumRange(min) : min;

LinearAxis doesn't have a transform and does the correct operation

minRounded = Math.floor(min / tickUnitRounded) * tickUnitRounded;

Is it necessary to pass the tick unit to getRoundedMaximumRange etc.?

To Reproduce

import io.fair_acc.chartfx.axes.spi.AxisRange
import io.fair_acc.chartfx.axes.spi.DefaultNumericAxis

var axis = new DefaultNumericAxis();
axis.setAutoRanging(true);
axis.setAutoRangeRounding(true);
var range = axis.autoRange(0.001, 0.002, 1000, 0)
assert range.getMax() < 0.002 + range.getTickUnit() : "Range max grew multiple tick units"

Environment:

  • OS: Win 10
  • Java version: 17.0.9
  • JavaFx version: 22.0.2
  • ChartFx version: 7908d4c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions