我正在尝试使用此.tsv 文件中的数据显示图表:
d3.tsv('GDP.tsv', function(data) {
for (var i = 0; i < data.length; i++) {
console.log(data[i]);
}
MG.data_graphic({
title: "Line Chart",
description: "This is a simple line chart. You can remove the area portion by adding area: false to the arguments list.",
data: data, /*This is very probably part of the issue*/
width: 240,
height: 128,
target: document.getElementById('graph-gdp'),
x_accessor: 'value', /*This is very probably part of the issue*/
y_accessor: 'time' /*This is very probably part of the issue*/
});
这将每一行输出为:
{na_item,unit,geo\time: "B1GQ,CP_MEUR,AL",
2005 : "6475.3 ",
2006 : "7090.8 ",
2007 : "7809.8 ",
2008 : "8800.3 ",
2009 : "8662.2 ",
2010 : "8996.6 ",
2011 : "9268.3 ",
2012 : "9585.8 ",
2013 : "9625.4 "(etc...)}
我将如何显示一行,因此选择它的名称(例如“B1GQ,CP_MEUR,AL”),并在图表上显示该数据,x=year 和 y=value?
抱歉,如果这是一个相当愚蠢的问题,但我对 .js、.tsv 文件和一般的 Web 开发是新手。我试过自己解决这个问题,但失败了。