// Found this on the django-users mailing list, need to test
ok, I finally got open-flash-chart to work.
1. create an xhtml-file and insert (something like) this:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/
flash/swflash.cab#version=8,0,0,0"
width="600"
height="400"
id="graph-2"
align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="/media/site/chart/open-flash-chart.swf?
width=600&height=400&data=/chart_data/" />
<param name="quality" value="high" />
<param name="bgcolor" value="#FFFFFF" />
<embed src="/media/site/chart/open-flash-chart.swf?
width=600&height=400&data=/chart_data/"
quality="high"
bgcolor="#FFFFFF"
width="600"
height="400"
name="open-flash-chart"
align="middle"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"; />
</object>
2. define the url for the chart, eg: (r'^chart/$',
'www.views.charts.chart'),
3. define the url for the chart-data, e.g.: (r'^chart_data/$',
'www.views.charts.chart_data'),
4. the views:
def chart(request):
to the html-file created above
return render_to_response('site/charts/chart.html', {
'var': 'var',
}, context_instance=RequestContext(request) )
def chart_data(request):
import random
g = graph()
data_1 = []
data_2 = []
data_3 = []
for i in range(12):
data_1.append( random.randint(14,19) )
data_2.append( random.randint(8,13) )
data_3.append( random.randint(1,7) )
g.title('PageViews (2007)', '{color: #999999; font-size: 16; text-
align: center}' );
g.bg_colour = '#ffffff'
g.set_data( data_1 )
g.set_data( data_2 )
g.set_data( data_3 )
g.line_dot( 3, 5, '#333333', 'Page views', 10 )
g.line_dot( 3, 5, '#666666', 'Visits', 10)
dots
g.line_hollow( 2, 4, '#999999', 'Unique visitors', 10 )
g.set_x_labels(
'Jänner,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember'.split(',')
)
g.set_x_label_style( 11, '0x666666', 2, 1)
g.set_y_max(20)
g.y_label_steps(4)
g.set_y_label_style( 10, '0x666666')
return HttpResponse(g.render())