GithubHelp home page GithubHelp logo

Comments (2)

9SL9 avatar 9SL9 commented on July 22, 2024

If I change your example code with this it causes crash
self.data = @[@[@1, @1, @1, @1, @1, @1, @1],];

from graphkit.

michalkonturek avatar michalkonturek commented on July 22, 2024

Thank you for reporting this issue. I have renamed the title to be more adequate to the problem.

The crash is caused by NaN, which is a special float value meaning "not a valid float number". In most cases it is caused by division by zero, and that is the case in this instance also.

In order to calculate scale value, GKLineGraph uses minValue and maxValue of all line data values.

CGFloat scale = (value - [self _minValue]) / ([self _maxValue] - [self _minValue]);

From the code above you can clearly see that you will cause division by zero each time you pass values which are the same number.

To fix that problem, simply pass data for another line (at index 0), and set that line color to clear.

self.data = @[
                  @[@2, @2, @2, @2, @2, @2, @6],
                  @[@1, @1, @1, @1, @1, @1, @1]
                  ];

from graphkit.

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.