areski / django-nvd3

Django wrapper for nvd3 - It's time for beautiful charts
Other
416 stars 124 forks source link

django-nvd3 pieChart layout breaks with values below zero #28

Open jayme-github opened 10 years ago

jayme-github commented 10 years ago

I tried the django-nvd3 pieChart example and the chart layout seems to break when mixing values above and below zero.

The following code is generated:

$(function(){nv.addGraph(function() {
    var chart = nv.models.pieChart();
    chart.x(function(d) { return d.label })
        .y(function(d) { return d.value });
    chart.height(450);

    chart.showLegend(true);
    chart.showLabels(true);
    d3.select('#piechart_container svg')
        .datum(data_piechart_container[0].values)
        .transition().duration(500)
        .attr('height', 450)
        .call(chart);

    return chart;
    });
});
data_piechart_container=[{"values": [{"value": "26.03558213", "label": "some"}, {"value": "0.01824000", "label": "dummy"}, {"value": "0.00000322", "label": "values"}, {"value": "1234.43777452", "label": "here"}], "key": "Serie 1"}];

Leading to a chart looking like this: chart

When increasing all values above 0 (or decrease below 0) the layout seems correct. It's clear to me that those small values would not really be visible in the first place but deselecting the big ones would bring them up.

Is there a way to get around this or am I doing something wrong here?

areski commented 10 years ago

Values below zero on the piechart, that doesn't seem a good idea. I would simply recommend to sanitize your data before hand

jayme-github commented 10 years ago

Don't get me wrong here, the values are not negative, only very small and already sanitized! Maybe the problem is the big spike between values above 1k and values below 0. But I don't see why this should not be possible.

areski commented 10 years ago

I think I got confused by what you wrote here "when mixing values above and below zero." Anyway I think the best way to track this down would be to test directly on nvd3 https://github.com/novus/nvd3 and reproduce it there, if that's the case, then you can open an issue to nvd3

jayme-github commented 10 years ago

Thanks for your reply. As this is reproducible when using nvd3 directly, I've opened a nvd3 issue and I'm closing this one. https://github.com/novus/nvd3/issues/492

areski commented 10 years ago

I think we can leave this open until thisis solved, it's likely we need to update our libs once they have solved the issue. Thanks for tracking this down ;)