我是D3.js的新手。我喜歡它,但我很難找出構建數據的最佳方法。帶點的D3多線圖
我會理想地想創建一個簡單的多線圖,它具有超過所選點的點數。首先,我創建了多條線,但試圖添加點使我難住,我認爲這與我的數據結構有關。
Here is my working fiddle。我不知道我是否應該嘗試使用d3.nest重新排列數據
我有一個json對象,我從Google表格中檢索,這些對象都很好,很流暢。這就是它的樣子:
var data = [{
"description": "Global warming is a serious and pressing problem. We should begin taking steps now even if this involves significant costs",
"year2013": 40,
"year2012": 36,
"year2011": 41,
"year2010": 46,
"year2009": 48,
"year2008": 60,
"year2006": 68,
}, {
"description": "The problem of global warming should be addressed, but its effects will be gradual, so we can deal with the problem gradually by taking steps that are low in cost",
"year2013": 44,
"year2012": 45,
"year2011": 40,
"year2010": 40,
"year2009": 39,
"year2008": 32,
"year2006": 24,
}, {
"description": "Until we are sure that global warming is really a problem, we should not take any steps that would have economic costs",
"year2013": 16,
"year2012": 18,
"year2011": 19,
"year2010": 13,
"year2009": 13,
"year2008": 8,
"year2006": 7,
}, {
"description": "Don't know/refused",
"year2013": 1,
"year2012": 1,
"year2011": 1,
"year2010": 1,
"year2009": 1,
"year2008": 0,
"year2006": 1,
}]
任何幫助,將不勝感激,我一直在這裏好幾天。
乾杯!