Coder Social home page Coder Social logo

Comments (6)

zanzica avatar zanzica commented on August 11, 2024 1

I can confirm that the changes fixed this issue, thanks! Closing this issue as discussed with @wirew0rm .

from chart-fx.

RalphSteinhagen avatar RalphSteinhagen commented on August 11, 2024

@zanzica thanks for reporting. The fix is not quite as trivial without breaking the other use-cases. Hope that I found a good compromise. See also PR #131

from chart-fx.

zanzica avatar zanzica commented on August 11, 2024

I just noticed that the Javadoc for DefaultNumericAxis states:

Compared to the {@link NumberAxis}, this one has a few additional features:
* Re-calculates tick unit also when the {@link #autoRangingProperty() auto-ranging} is off

Is/was this supposed to be the correct behaviour?

from chart-fx.

RalphSteinhagen avatar RalphSteinhagen commented on August 11, 2024

yes, until you opened this issue. ;-)

The main original rationale was that one needs to (must) recompute the tick-unit if one zooms, drags or changes the axis range (e.g. sliding/increasing time-axis).

from chart-fx.

zanzica avatar zanzica commented on August 11, 2024

Unfortunately I realized that the implemented fix breaks custom TickUnitSuppliers. :-(
I'm reopening this issue (because this is related to its fix), but feel free to move this into a separate issue if it suits you better.

The use case for which I created a custom TickUnitSupplier is that I am working with timestamps in nanoseconds, and wanted to define custom tick units based on the range (instead of defining a static TickUnit).

In the attached example, the x axis unit (seconds -> millis -> micros -> nanos) can be configured with the "multiplier" variable.
DEMO_TickUnitSupplier.txt

The example works fine with revision 5385755 (before the fix was merged): For all x axis units, there are three tick marks visible, showing the correct time. (Screenshot is for nanoseconds, the others look the same.)
2020-03-24_DemoTickUnitSupplier_correct_nanos

The example is broken in revision d73b66c (when the fix was merged): It works correctly for seconds (but shows "stripes"? -> screenshot). For millis and micros, the example hangs, then eventually shows chart (but does not show x tick labels). For nanos, it shows up quickly but does not display x tick labels (-> screenshot).
2020-03-24_DemoTickUnitSupplier_broken_seconds
2020-03-24_DemoTickUnitSupplier_broken_nanos

When x tick labels are not displayed, I see the following log message:
DEBUG [24 Mar 2020 18:01:55,831] (DefaultLoggingEventBuilder.java) - major ticks numerically not resolvable
This leads back to DefaultNumericAxis#calculateMajorTickValues:
if (firstTick + axisRange.getTickUnit() == firstTick) {
if (LOGGER.isDebugEnabled()) {
LOGGER.atDebug().log("major ticks numerically not resolvable");
}
return tickValues;
}
As no tick unit was explicitly specified (since it was now expected to be handled by the TickUnitSupplier, axisRange.getTickUnit() defaults to 5. This offset is lost due to double precision when we compare firstTick + axisRange.getTickUnit() == firstTick when the double value for firstTick is sufficiently large (for x unit >= millis).

I am not sure how to fix this properly to make both static tick units and TickUnitSuppliers work correctly.
Personally, I would suggest reverting the current "fix" for the original issue for now - always recalculating the tick unit was, apparently, the intended behaviour and even documented in the Javadoc (even though it confused me when I tried to set the tick unit explicitly - maybe the Javadoc for #setTickUnit should give users a heads-up?). I think the TickUnitSupplier functionality is quite elegant and flexible, and I would currently prefer having TickUnitSuppliers work correctly over having static TickUnits work correctly ...

from chart-fx.

wirew0rm avatar wirew0rm commented on August 11, 2024

Reverted back to the original behaviour, thanks for the detailed error description.

Regarding documentation, it is unfortunately not as simple as updating the Javadoc, since this the documented behaviour is correct for the other axis implementations. We will have to think about this some more.

from chart-fx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.