Code Monkey home page Code Monkey logo

Comments (5)

joshwcomeau avatar joshwcomeau commented on July 16, 2024

hey @Mattasher,

Thanks for pointing this out! Hadn't run into this bug yet.

So, I don't really like the idea of adding another prop that's so specific to this problem. One thing I've been thinking about, though, is to provide min and max props.

Sometimes, for example, you have several trends side-by-side, and you want them to all share the same data scale.

It would also solve this problem; If your data was [5, 5, 5, 5, 5], and you provided a min of 0 and a max of 10, your data would be a flat line along the middle. If the data was [0, 0, 0, 0, 0], it would run along the bottom.

(of course, a potential problem with that approach is if you provide data outside the supplied range... but maybe I can just clamp it to the range provided, and add a console warning).

from react-trend.

joshwcomeau avatar joshwcomeau commented on July 16, 2024

Published a basic fix, where lines will run along the baseline when all values are the same.

In the future, a minor version bump will allow the min/max props I described above (or something similar).

from react-trend.

Mattasher avatar Mattasher commented on July 16, 2024

Excellent! Thanks. If you want to see it in action I've added trendlines to http://growhive.io/ in the upper left corner you'll have to leave "The Nursery" and go to other Sectors to accumulate Score & Nectar.

from react-trend.

joshwcomeau avatar joshwcomeau commented on July 16, 2024

@Mattasher this is awesome!! Thanks so much for sharing, love seeing where things get used :)

I do see the issue, where once the trend fills up with the same value (eg. my score of 3 has been static the whole while), the line jumps back down to baseline. Min/max will fix that, hopefully I can make some time for it soon.

from react-trend.

joshwcomeau avatar joshwcomeau commented on July 16, 2024

(sadly, min/max is not something we need at Unsplash yet, so it's hard to justify the time for it - if you'd like to work on it, though, I'd gladly accept PRs!)

from react-trend.

Related Issues (13)

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.