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

setData option for the Donut Chart #211

Closed
andrewharry opened this issue Apr 5, 2013 · 10 comments
Closed

setData option for the Donut Chart #211

andrewharry opened this issue Apr 5, 2013 · 10 comments

Comments

@andrewharry
Copy link

Would be great for the donut chart to also have the setData method.

In it's absence, what is the best way to destroy the donut chart and clean up event handlers?

@jcandeli
Copy link

I was able to extend the Donut object like so:

window.Morris.Donut.prototype.setData = function(data, redraw) {
    if (redraw == null) {
        redraw = true;
    }
    this.data = data;
    this.values = (function() {
    var _i, _len, _ref, _results;
    _ref = this.data;
    _results = [];
    for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        row = _ref[_i];
        _results.push(parseFloat(row.value));
    }
    return _results;
    }).call(this);
    this.dirty = true;
    if (redraw) {
        return this.redraw();
    }
}

@kcampion
Copy link

kcampion commented Oct 2, 2013

Thank you jcandeli, but this source doesn't work, I always have :
Uncaught TypeError: Object [object Object] has no method 'setData'

This would be a good idea if this part of source will be directly integrated in next release.

@jcandeli
Copy link

jcandeli commented Oct 2, 2013

Are you sure you added my code after the morris.js code? It seems to work for me in this jsfiddle.

http://jsfiddle.net/BUbF8/

@kcampion
Copy link

kcampion commented Oct 2, 2013

Yes I did, It works now after multiple tests.
I had problem with "setData" because I used Donut like

// wrong way
var donut = Morris.Donut({...}).select(0);

It's not the same thing that

// good way
var donut = Morris.Donut({...});
donut.select(0);

Thank you again for your Donut's extend

@jcandeli
Copy link

jcandeli commented Oct 2, 2013

Great. Glad it helped.

@TRTL4LIFE
Copy link

I would still like to see setData get added to all of them. I love this library, but sometimes I have to go an extra length to make it something display the way I want it.

@oesmith oesmith closed this as completed in c072224 Nov 9, 2013
@oesmith
Copy link
Contributor

oesmith commented Nov 9, 2013

Morris.Donut setData() method is in master now - check it out and let me know if it doesn't work for you!

@TRTL4LIFE
Copy link

Thanks! I'll try it out.

@sudeepdk
Copy link

can i use .CSV file to get data and show in charts ? Bcoz i m using .NET ans Sql srver to Get data from Database...

@sudeepdk
Copy link

Thanks....

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

6 participants