Direct data input from Django for a D3 graph

前端 未结 2 860
失恋的感觉
失恋的感觉 2021-01-05 08:59

It seems all the D3 example graphs take an external .csv or .tsv file as input data. Is there any way to modify the code to take data from a variable in Django. Suppose {{ d

2条回答
  •  时光说笑
    2021-01-05 09:41

    Instead of loading data asynchronously (ajax-style), you can use correctly formatted JSON in a string passed to your template tag variable and |safed.

    Check out the working example http://bl.ocks.org/4040034 which is based on http://bl.ocks.org/3885304

    You should also check out the related questions on SO, there are tons on the subject.

提交回复
热议问题