문제

I need your help. I want to change this graph: http://bl.ocks.org/mbostock/3885211 to read from a json file instead of tsv. That is the format of my Json file.

{
  "name":"chrome" ,

  "values": [   
      { "time" : 1232323 , "value:" :  12}, 
      { "time" : 12323323 , "value:" : 19   
   ]},

{   
  "counter":"Mozilla" ,

  "values": [   
    { "time" : 1232sd3 , "value:" : 18}, 
    { "time" : 11232323 , "value:" : 20}   
  ]},

{    
  "name":"IE" ,

  "values": [   
    {"time" : 12387823 ,"value:" :  100},
    {"time" : 12323 ,"value:" : 123123}
  ]}

]

I have tried a lot but it does not work with Json file.

Really appreciate your help :(

도움이 되었습니까?

해결책

OK. So I decided to spend some time and help you solve the problem. The conversion to JSON was poorly done (for the code that is written on the page).

A quick way to get json from the data would be to use vim to retab the data file before running it through a script like this one https://github.com/turian/common-scripts/blob/master/tsv-to-json.py

I created had to manually reformat the data (since I was just trying to set up an example) but you might want to change the code so that it writes into an array first before producing json (you may also need to change the common.json to json).

The complete example is hosted here http://jsfiddle.net/dvqFj/1/

Good luck

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top