open flash chart & django

19 views
Skip to first unread message

patrickk

unread,
Jan 17, 2008, 10:08:40 AM1/17/08
to Django users
has anybody succesfully used "open flash chart" with django?
i´ve been downloading the files and installed it, but the (flash)data
isn´t displayed.

questions are:
- where do you put the files? guess OpenFlashChart.py should be
somewhere on the PYTHONPATH whereas the .swf and .js-files are in the
media-folder.
- how do you actually render data? what does the view look like?

thanks,
patrick

Marty Alchin

unread,
Jan 17, 2008, 10:20:10 AM1/17/08
to django...@googlegroups.com
I've been considering this, but haven't gotten around to actually
doing so. Keep us posted if you have any success.

-Gul

mail....@gmail.com

unread,
Jan 17, 2008, 12:23:31 PM1/17/08
to Django users
I'm embarrassed to admit I can't remember exactly which flash charting
solution I went with, but I believe it was XML/SWF:
http://www.maani.us/xml_charts/index.php?menu=Introduction

You can see it here: http://classicmotorsports.net/project-cars/1970-datsun-240z/
Scroll down to "on the dyno", then click on the Aug. dyno run.

Using it is pretty simple. All the flash stuff is in my media folder.
Object tag in the page template looks like this:
<object type="application/x-shockwave-flash" data="/media/flash/
charts.swf?library_path=/media/flash/
charts_library&amp;xml_source=dyno_run.xml"
width="700" height="375" id="dynoRun" >
<param name="movie" value="/media/flash/charts.swf?
library_path=/media/flash/charts_library&amp;xml_source=dyno_run.xml" /
>
<param name="flashVersion" value="8" />
</object>

You'll note it calls dyno_run.xml
the path to that is defined in my urls.py so as far as Flash is
concerned, it's a relative url to the page calling it
(r'^project-cars/(?P<slug>(\w|-)+)/dyno-runs/(?P<object_id>\d+)/$',
'classic.projects.views.get_dyno_runs'),

In views, I'm just gathering up whatever data I want to plot, so I
won't bore you with that.

Then, the dyno_run.xml is pretty straightforward:
<chart>
<axis_value bold='false' size='10' />
<axis_category skip='4' bold='false' size='10' />
<chart_grid_v thickness='1' color='cccccc' />
<chart_pref line_thickness='2' point_shape='none' />
<chart_type>line</chart_type>
<legend_transition type='zoom' duration='.5' />
<legend_label size='14' />
<chart_value position='cursor' size='12' color='000000'
background_color='cccccc' alpha='70' />
<chart_data>
<row>
{% for item in run_values_list %}<string>{{item.rpm}}</string>{%
endfor %}
</row>
<row>
<string>Horsepower</string>
{% for item in run_values_list %}<number>{{item.hp}}</
number>{% endfor %}
</row>
<row>
<string>Torque</string>
{% for item in run_values_list %}<number>{{item.torque}}</
number>{% endfor %}
</row>
</chart_data>
</chart>

patrickk

unread,
Jan 18, 2008, 7:19:56 AM1/18/08
to Django users
thanks, this works fine.

I´ll still try to get "open flash chart" working and I´ll post my
experience here.

patrick.

On 17 Jan., 18:23, "bax...@gretschpages.com" <mail.bax...@gmail.com>
wrote:

mail....@gmail.com

unread,
Jan 18, 2008, 2:05:30 PM1/18/08
to Django users
For whatever it's worth, I messed around with open flash charts a fair
bit before going with the xml-based solution... I never got it
working, either, got close, but could never really make sense of the
output strings. But then, I'm not much of a programmer. I do know that
I found the xml-based charts more attractive by default, and
considerably easier to customize and manipulate.

In the end, I got tired of trying to force open flash charts to work
for me instead of against me, and building an xml template is stupid
easy. I use slideshowpro basically the same way.

patrickk

unread,
Jan 18, 2008, 3:38:26 PM1/18/08
to Django users
I also like the way xmls/wf works. it´s very easy (to setup and
install). unfortunately, it just doesn´t look so good (to me). I´m not
much of a programmer myself - and for our current project, the "look"
is very important. I´ll try some other tools as well ...

keep you updated.

patrick


On Jan 18, 8:05 pm, "bax...@gretschpages.com" <mail.bax...@gmail.com>
wrote:

patrickk

unread,
Jan 22, 2008, 5:52:16 AM1/22/08
to Django users
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):

### nothing really required. whatever you want to do here. points
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'

# we add 3 sets of data:
g.set_data( data_1 )
g.set_data( data_2 )
g.set_data( data_3 )

# we add the 3 line types and key labels
g.line_dot( 3, 5, '#333333', 'Page views', 10 )
g.line_dot( 3, 5, '#666666', 'Visits', 10) # <-- 3px thick +
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())


that´s it. works quite well. I customized some of the .as-files to get
the look & feel of our site.

patrick
Reply all
Reply to author
Forward
0 new messages