Graphing data, website views what platform to use
I have been tasked with producing a analytic tool for some of the data which we get in about the activities the company i work for has with its clients.
Last week i made a mock up view of one possible graph using some PHP and the Flot Jquery graphing tool. Unfortunatly I dont think I am going to be able to use flot for what i need in the long term as to make the graph i needed work I had to hack 8 divs one of top of the other otherwise i just got a flat line...
So now i am looking at technologies to work with for this tool. One of the senior members here recommends using Django for the framework and do the graphs using reportlabs or matplotlib
I have spent the last couple of days looking for decent tutorials on how to produce graphs using report labs or matplotlib and using django to display them, unfortunately i havent been able to find much which is of any use. the 2 examples i found on the django site werent terriably useful and most examples give you something like:
drawing = Drawing()
data = [
(13, 5, 20, 22, 37, 45, 19, 4),
(14, 6, 21, 23, 38, 46, 20, 5)
]
bc = VerticalBarChart()
bc.x = 50
bc.y = 50
bc.height = 125
bc.width = 300
bc.data = data
bc.strokeColor = colors.black
bc.valueAxis.valueMin = 0
bc.valueAxis.valueMax = 50
bc.valueAxis.valueStep = 10
bc.categoryAxis.labels.boxAnc开发者_如何学编程hor = 'ne'
bc.categoryAxis.labels.dx = 8
bc.categoryAxis.labels.dy = -2
bc.categoryAxis.labels.angle = 30
bc.categoryAxis.categoryNames = ['Jan-99','Feb-99','Mar-99',
'Apr-99','May-99','Jun-99','Jul-99','Aug-99']
drawing.add(bc)
but how do you then intergrate that with django`s views? this was my attempt which produced a blank screen...
def chartTest(request):
import mycharts
drawing = Drawing()
d = mycharts.testChart(drawing)
binaryStuff = d.asString('gif')
return HttpResponse(binaryStuff,'image/gif')
I did manage to make matplotlib produce a graph but it had a grey background which for life of me I couldn't work out how to make it go away and found it hard looking on Google for any information about why it is like that.
I am a little bit stuck atm, so if anyone has any ideas on where I can find helpful advice on learning these tools that would be most awesome.
thanks
Have a look at Google Charts Tools http://code.google.com/apis/chart/
Also have a look at jqPlot http://www.jqplot.com/ - it uses jQuery - a javascript library.
I usually pass all my data down into the template, and the charts/graphs are rendered in the client's browser.
Also check out d3.js. Beautiful plots that are natively HTML5, and great for interaction too.
http://mbostock.github.com/d3/
精彩评论