Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when data are null or 0 for donut graph #705

Open
leccyril opened this issue Feb 13, 2017 · 8 comments
Open

error when data are null or 0 for donut graph #705

leccyril opened this issue Feb 13, 2017 · 8 comments

Comments

@leccyril
Copy link

Hi,

when all data are empty or 0 % it cause 4 errors in console js for each value we set 👍

Error: attribute d: Expected number, "M,0,0".
q @ raphael-min.js:10
raphael-min.js:10 Error: attribute d: Expected moveto path command ('M' or 'm'), "Z".
q @ raphael-min.js:10
raphael-min.js:10 Error: attribute d: Expected number, "M,0,0".
q @ raphael-min.js:10
raphael-min.js:10 Error: attribute d: Expected moveto path command ('M' or 'm'), "Z".
q @ raphael-min.js:10
raphael-min.js:10 Error: attribute d: Expected number, "M,0,0".
q @ raphael-min.js:10
raphael-min.js:10 Error: attribute d: Expected moveto path command ('M' or 'm'), "Z".

is there any way to prevent this ? an option or handle when there is no data ? imagine for 3 i have data and for one no yet data it will cause an exception in logs....

thanks !

an great lib !

@Nadosha
Copy link

Nadosha commented Jun 27, 2017

Have you solved this?

@JattJames
Copy link

Same here, has this been solved yet

@DSKonstantin
Copy link

Some by resolved this issue? Also, I want to show 'NaN' it gets the error in the console too.
Thanks.

@pierresh
Copy link

pierresh commented Jan 31, 2018

If you do not have data, just provide an empty array as data, you would not have any error message ;-)

@DSKonstantin
Copy link

@pierresh it works, thank you! 👍

@pierresh
Copy link

You are welcome!

By the way, I found a solution to prevent the error message in console, we just need to check if the path to be drawn by Raphael contains a 'NaN'. Below is a solution in Coffee script file:

render: ->
    if !/NaN/.test @hilight
      @arc = @drawDonutArc(@hilight, @color)
    
    if !/NaN/.test @path
      @seg = @drawDonutSegment(
        @path, 
        @color, 
        @backgroundColor, 
        => @fire('hover', @index),
        => @fire('click', @index),
        => @fire('mouseout', @index)
      )

And below is the solution in Javascript (about line 2059 in morris.js)

DonutSegment.prototype.render = function() {
      var _this = this;
      if (!/NaN/.test(this.hilight)) {
        this.arc = this.drawDonutArc(this.hilight, this.color);
      }
      if (!/NaN/.test(this.path)) {
        return this.seg = this.drawDonutSegment(this.path, this.color, this.backgroundColor, function() {
          return _this.fire('hover', _this.index);
        }, function() {
          return _this.fire('click', _this.index);
        }, function() {
          return _this.fire('mouseout', _this.index);
        });
      }
    };

pierresh pushed a commit to pierresh/morris.js that referenced this issue Jan 31, 2018
pierresh pushed a commit to pierresh/morris.js that referenced this issue Feb 11, 2018
pierresh pushed a commit to pierresh/morris.js that referenced this issue Nov 6, 2018
@AhmedElAtari
Copy link

AhmedElAtari commented Jul 2, 2019

If you don't have the data in the first rendering, just provide an empty array with a null object. (code below)

Morris.Donut({
  element: 'donut-example',
  data: [{}]
});

@h3rb
Copy link

h3rb commented Oct 6, 2019

I simply have a "0", not a NaN. Same error showing up for an .Area({})

Even when I put in 1.23456 instead of 0, or 0.0000001 it has this error
... turns out the data works fine with Line, Bar, just not Area. It's based on the example Area code provided. Will create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants