List Info

Thread: render xml component in container




render xml component in container
user name
2008-01-03 00:44:58
Hi,

I'm looking for the most pythonic [or djangonautic] way to render a FusionChart [http://www.fusioncharts.com/gadgets/docs/] in Django.  I searched through the forums and didn't see this addressed directly -- my apologies if this is very basic and obvious!

1. I have a django template, container.html:

{% block head %}
<script language=&quot;JavaScript" src="/site_media/swf/Charts/FusionCharts.js"></script>
{% endblock head %}

{% block main_content %}
 &lt;div id="chartdiv&quot; align=&quot;center&quot;>&nbsp;
        The chart will appear within this DIV. This text will be replaced by the chart.&nbsp;
 &nbsp;   </div&gt; 
&nbsp;    <script type=";text/javascript"

 &nbsp;      var myChart = new FusionCharts("/site_media/swf/Charts/HLinearGauge.swf", "myChartId", "400&quot;, "200&quot;, "0&quot;, "0&quot;); 

 &nbsp;      myChart.setDataXML("your_data.xml");&nbsp;

 ;       myChart.render("chartdiv"); 

&nbsp;    </script> 
{% endblock main_content %}

2. your_data.xml is also a django template, stored in myapp/templates/you/your_data.xml, and the TEMPLATE_DIRS setting includes myapp/template

<chart lowerLimit='0' upperLimit='100 ' lowerLimitDisplay='Bad' upperLimitDisplay='Good' palette='1' numberSuffix='%' chartRightMargin=' 20'>
 &nbsp; <colorRange>
 &nbsp;     <color minValue='0' maxValue='75 ' code='FF654F' label='Bad'/>
 &nbsp;    <color minValue='75' maxValue=' 90' code='F6BD0F' label='Moderate' />
 &nbsp;    <color minValue='90' maxValue ='100' code='8BBA00' label='Good '/>
 &nbsp; </colorRange>
 &nbsp; <pointers>
&nbsp;     <pointer value=9;{{ your.value }}' />
 &nbsp; </pointers >
</chart>

3. I have a view --- def your_data(request).  I want this view to

a) populate the your.value object in the xml template -- your_data.xml
b) render the containing template, container.html.

Any suggestions on the best approach for this ... ?

Thanks!

TU


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users"; group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to django-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )