堆积的条形图逆转 [英] Stacked bar chart reversed

查看:110
本文介绍了堆积的条形图逆转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有问题。
我创建了一个条形图,您可以在此链接中看到它:

解决方案

您需要将所有的处理放在异步d3.csv()调用中。

  

d3.csv(fullpath.csv,function(error,data){
data.forEach(function(d){
arr [d.User_ID] = 0;
});

var margin = {
//...rest of code ...


I have little problem. I created a bar chart , you can see it on this link: Stacked Bar Chart

The problem is that if you refresh 2-3 times this page , it will reverse the bar charts like that:

why it's happen? and how can I solve it?

Thanks!!

and the CSV file in this link: CSV file

解决方案

You need to put all your processing inside the asynchronous d3.csv() call.

See this PLUNK.

d3.csv("fullpath.csv", function(error, data) {
    data.forEach(function(d) {
        arr[d.User_ID] = 0;
    });

    var margin = {
    //...rest of code...

这篇关于堆积的条形图逆转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆