Giter Site home page Giter Site logo

Wish to have yaxis 0 tick always showing, but forceNiceScale does not seem to work properly with min/max values -1 < value < 1 about apexcharts.js HOT 4 OPEN

ehbats avatar ehbats commented on May 18, 2024
Wish to have yaxis 0 tick always showing, but forceNiceScale does not seem to work properly with min/max values -1 < value < 1

from apexcharts.js.

Comments (4)

rosco54 avatar rosco54 commented on May 18, 2024

By setting max: 0.11 and min: -0.1, you set the range (0.21), and this must be divided into even spacings. So you get either 7 divisions of 0.03 (most likely) or 3 divisions of 0.07 (unlikely), and neither of those land on zero.

You could try the following:

max: 0.12,
min: -0.1
which is guaranteed to produce divisions that land on zero (range 0.22 = 11 divisions of 0.02 spacing, or

max: 0.12,
min: -0.12,
which is almost guaranteed to land on zero.

PS. This is not a bug. The documentation needs to be updated but even in it's current form doesn't imply that it will guarantee a zero tick. As of 3.46.0, user options are honored if self-consistent but an option will be tweaked or ignored if it's in conflict with other user-defined options. Min and/or max are always honored, then stepSize and tickAmount, in roughly that order of priority. For example, setting min: 0, max: 10 and stepSize: 3 is in conflict, so stepSize would be tweaked to fit. ForceNiceScale is used to choose between various alternative outcomes under certain conditions.

from apexcharts.js.

ehbats avatar ehbats commented on May 18, 2024

@rosco54 Thanks a lot for your quick answer! These infos will sure help me out a lot trying to figure this out. I tried tweaking my code a little bit more and noticed that even when nor min or max are passed, some of my charts with small values still don't land on 0. Do you think it would be a nice feature to have some way of forcing the 0 to show up? I think it would make some charts a lot easier to read. In this case i misstagged my issue and I apologize, it should have been a feature request. But still, do you think that would be possible?

I think it would be a lot more friendly if that existed instead of having to add extra complexity on my code to do these kinds of maths to have a chance that it might land on 0

from apexcharts.js.

rosco54 avatar rosco54 commented on May 18, 2024

Yes, it would be nice, and the unrestricted auto scaling generally does that. Indirectly though, as a side effect of how it does the scaling, so it's not 100% guaranteed even when no user-defined options are present. The solution in that case, may be to increase the margin space on the chart area so that you don't have to try to make allowance for it using min or max settings.

from apexcharts.js.

rosco54 avatar rosco54 commented on May 18, 2024

@ehbats Would you be able to add one of those "charts with small values [that] still don't land on 0" to this issue? One of those that don't include min or max. I would like to see how that is happening and I can't seem to conjure up an example of my own that doesn't land on zero.

from apexcharts.js.

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.