I am currently creating a server control panel that relies heavily on graphs and charts.
I use Django for the backend and Highcharts / Highstock (http://www.highcharts.com/) for graphs (although we also look at D3, depending on how it progresses).
My question is: what is a good way to generate all our charts and still remain DRY?
(I know Django-Chartit, but it is a bit limited for our purposes and does not offer us some customization that we need).
1. How to get data
First of all, Iβd better encode the data for the graphs inside JavaScript itself. For instance:.
series: [{ name: 'Virtualised', data: [80, 81, 84, 84, 85, 80, 90, 85, 80, 88, 89, 90] }, { name: 'Physical', data: [15, 14, 12, 8, 10, 12, 12, 14, 10, 12, 8, 9] }]
Or should I get all the data through AJAX calls - for example, JSON through Query.get() ?
2. Dynamic Javascript Creation
If we go with option 1 and encode the data directly in JavaScript, how can I generate these Javascript files dynamically?
Currently, our JS is served directly by our web server (NGinx). Or should I use the built-in <script> inside my HTML files?
3. Security / Performance with AJAX
If we go to option 2 of the JSON / AJAX route - will there be performance problems if you say that twenty JQuery.get() calls per page? I donβt know which way to release them?
And what about security - we would like to expose the AJAX endpoint for diagrams, but how can you resolve this, but not allow anyone to access this URL directly?
4. DRY
In any case, I noticed that we have a full load of repetitions with all these diagrams.
What is the best way to cut it? Chart tag templates? Or is there a smarter way?
Cheers, Victor