Giter Site home page Giter Site logo

implement month incrs about uplot HOT 3 CLOSED

leeoniya avatar leeoniya commented on May 10, 2024
implement month incrs

from uplot.

Comments (3)

benmccann avatar benmccann commented on May 10, 2024

month is by far the trickiest since each month has a different number of days. I ended up making the logic a bit more complicated in chart.js to account for this. I first plotted the first day of each month and then placed the days in between based on the total number of labels that I wanted to display (the code is slightly messy to maintain backwards compatibility with old versions of chart.js, but hopefully should be pretty understandable)

https://github.com/chartjs/Chart.js/blob/94afa634507036d8cd6b34d2c96eb225177b197e/src/core/core.scale.js#L886

from uplot.

leeoniya avatar leeoniya commented on May 10, 2024

b27a993 puts most of the machinery in place.

the strategy it uses is mostly the same as what the 12am snapping code did/does, plus a bit more. the axis.range() api had to change from only snapping the min/max to actually returning all the ticks, since they are no longer always evenly spaced from the min + a fixed incr multiple; now it's axis.ticks(). it's hard to tell from the demo [1], but the grid & axis labels are no longer evenly spaced. (Feb is narrower than March).

something unfortunate that emerged out of writing the demo is #53, since i was trying to verify that the tz offsets were working properly and wanted to zoom in more than what is currently attainable.

i think this is enough to close the issue?

[1] https://leeoniya.github.io/uPlot/demos/months.html

from uplot.

leeoniya avatar leeoniya commented on May 10, 2024

i'm calling this one done. please open new issues if you spot any bugs.

from uplot.

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.