(d3.js)(.csv)从堆积条形图中排除列 [英] (d3.js)(.csv) Exclude column from Stacked Bar Graph

查看:135
本文介绍了(d3.js)(.csv)从堆积条形图中排除列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个.csv文件来生成两个单独的图形.一个是简单的表,另一个是堆积的条形图.当前正在直接从文件读取数据,而不是将其转换为字符串.

I am using a single .csv file to generate two separate graphs. One is a simple table and the other is a stacked bar graph. The data is currently being read directly from the file as opposed to being converted to a string.

数据是值的列表,其中最后一列是每行中值的总和.例如:

The data is a list of values where the last column is a sum of the values in each row. Ex:

Value1,Value2,Value3,Value4,Total
2,2,2,4,10
1,3,2,1,7
5,2,1,1,9

我希望总计"列显示在表中,而不显示在堆积的条形图中,但希望继续使用单个数据源.有什么方法可以从堆叠的条形图中排除特定的数据列?

I would like the "Total" column to appear in my table, but not in my stacked bar graph, but would like to continue using a single data source. Is there any way to exclude a specific column of data from my stacked bar graph?

我正在使用 http://bl.ocks.org/mbostock/3886208的复制/粘贴版本

推荐答案

根据您链接到的示例,然后

Based on the example you linked to, then

color.domain(d3.keys(data[0]
     .filter(function(key) { 
           return key !== "State" && key !== "65 Years and Over";
})); 

这篇关于(d3.js)(.csv)从堆积条形图中排除列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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