Code Monkey home page Code Monkey logo

Comments (6)

danh32 avatar danh32 commented on June 9, 2024

Sounds like there are two cases here:

  1. Multiple points in your adapter, but they all return the same Y value.

For this case, we should definitely be drawing a straight line, so this sounds like a bug for sure.

  1. A single point in your adapter.

This is something of an undefined edge-case. A line isn't appropriate, since it implies there are at least two points in the graph. A dot is generally more correct, but leaves us in an odd position. Spark tries to shrink the bounds of the graph as tightly as it can to the Sparkline. In the case of a dot, it really can't since a single point has no size. It leaves a lot of ambiguity in where the dot should be placed.

An easy work-around in your adapter would be to just duplicate the single point, if you wish to get a line. But that's assuming that problem 1 above is fixed.

from spark.

zoltish avatar zoltish commented on June 9, 2024
  1. Yup, thats what I meant.

  2. I can understand that, its a lot of logic for such a "minor" thing. Personally I dont mind, Ill work around it.

Thanks for the quick answers. Much appreciated!

from spark.

danh32 avatar danh32 commented on June 9, 2024

The root issue is that the scale we calculate is infinity, due to a straight line technically having 0 height. A quick and dirty workaround until I can get the real fix out would be to add this to your SparkAdapter:

        @Override
        public RectF getDataBounds() {
            RectF bounds = super.getDataBounds();

            if (bounds.top == bounds.bottom) {
                bounds.top -= 1;
                bounds.bottom += 1;
            }

            return bounds;
        }

It's basically just enforcing a height on the data bounds, leaving your line directly in the center. Hoping to get a real fix in for you later this week.

from spark.

zoltish avatar zoltish commented on June 9, 2024

Thanks a lot Dan! Im so thankful for finding your library, both for its functionality and for your quick responses. Will patiently wait for your fix as I have a few other things to tackle in the meanwhile myself. Thanks again!

from spark.

danh32 avatar danh32 commented on June 9, 2024

You're welcome! Very glad you like it!

from spark.

danh32 avatar danh32 commented on June 9, 2024

Just released 1.1.2, which should contain this fix!

from spark.

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.