0
我不明白這個sytax錯誤不知道我在這裏可能會做錯什麼用動態數據創建圓環圖c3.js
SyntaxError:missing;之前的聲明
爲什麼我需要一個;在聲明不是這些假設結束語句之前?
這裏是JS小提琴 https://jsfiddle.net/n5v84svm/10/
我的代碼
checkIt(data){
var countriesByName = d3.nest()
.key(function(d) { return d.Country_Names; })
.entries(data);
console.log(countriesByName)
function makePie(){
var chart = c3.generate({
data: {
columns: [
function(m) {
var obj = [];
for (var i in m) {
obj.push('Road ' + m.countriesByName[i].key.values.Food and tobacco);
}
return obj;
}
],
type : 'donut'
}
});
}
makePie();
};
d3.json("https://gist.githubusercontent.com/heenaI/cbbc5c5f49994f174376/raw/82cd19eff7db367193cf8ce00144a40ea8d140ac/data.json", checkIt);
我的數據集看起來像這樣(完整的數據集可以在小提琴可見)
[
{
"Continent": "Europe",
"Country_Names": "Albania",
"Total": "3.8",
"Change_total": "-38.7",
"Main activity electricity and heat production": "0.1",
"Main activity electricity plants": "",
"Main activity CHP plants": "",
"Unallocated autoproducers/Other energy industry own use": "0.1",
"Other": "1.4",
"Manufacturing industries and construction": "1",
"Iron and steel": "0",
"Chemical and petrochemical": "0",
"Machinery": "",
"Mining and quarrying": "",
"Food and tobacco": "0.1",
"Paper, pulp and printing": "",
"Construction": "0",
"Transport": "2.2",
"Road": "2.2",
"Domestic aviation": "",
"Rail": "0",
"Domestic navigation": "0.1",
"Residential": "0.2",
"Commercial and public services": "0",
"Agriculture/forestry": "0.2",
"Sub-bituminous coal/Lignite": "",
"Other bituminous coal": "",
"Natural gas": "0",
"Motor gasoline excl. bio": "0.3",
"Gas/diesel oil excl. bio": "2.2"
}]