来自外部json文件的D3js条形图

时间:2012-11-26 15:49:53

标签: javascript json d3.js bar-chart

我一直在研究如何将数据从json加载到条形图,但我无法让它工作。

我有一个看起来像这样的JSON文件(它的一部分):

[{
    "id":1,
    "geslacht":"Vrouw",
    "totaal punten":60,
    "project 1":9,
    "ucd":6,
    "internetstandaarden":7,
    "understanding design":7,
    "Teamproject deel 1":6,
    "Taal in context":6,
    "Vormgeving":7,
    "Marketing":6,
    "Students in Motion":7,
    "Teamproject deel 2":7,
    "H&C":6,
    "Programmeren":7,
    "M&I":7,
    "Project 3":6,
    "Mediageschiedenis":6,
    "Business Mapping":7,
    "Plug & Play":7,
    "SLC":7,
    "Studieregie":8,
},{
    "id":2,
    "geslacht":"Man",
    "totaal punten":43,
    "project 1":8,
    "ucd":6,
    "internetstandaarden":0,
    "understanding design":7,
    "Teamproject deel 1":6,
    "Taal in context":0,
    "Vormgeving":7,
    "Marketing":7,
    "Students in Motion":7,
    "Teamproject deel 2":7,
    "H&C":6,
    "Programmeren":7,
    "M&I":0,
    "Project 3":6,
    "Mediageschiedenis":0,
    "Business Mapping":7,
    "Plug & Play":7,
    "SLC":8,
    "Studieregie":6,
}]

如何创建此条形图?

1 个答案:

答案 0 :(得分:0)

我建议使用图表库,例如Highcharts。它使用起来非常简单,并提供各种不同的图表类型。您可能需要稍微改变JSON文件的格式(我认为 - 乍一看)