This repository has been archived by the owner on Nov 25, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f5d1bc6
Showing
9 changed files
with
1,301 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright (c) 2008 Jacob Kaplan-Moss | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of Django nor the names of its contributors may be used | ||
to endorse or promote products derived from this software without | ||
specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Google Charts template tag | ||
========================== | ||
|
||
This is a suite of template tags to assist in generating charts using Google's | ||
`Chart API`__. There's deliberately no Python-level API; try pygooglechart__ | ||
for that. | ||
|
||
Currently the library is long on code, and short on testing and documentation. | ||
It's only been tested against Django trunk (r7135) and Python 2.5. | ||
|
||
For example usage, see ``docs/examples.html``. | ||
|
||
__ http://code.google.com/apis/chart/ | ||
__ http://pygooglechart.slowchop.com/ | ||
|
||
Contributing | ||
------------ | ||
|
||
I use Mercurial; the canonical repository lives at | ||
http://toys.jacobian.org/hg/uri. Please feel free to send patches or links to | ||
other branches to <jacob@jacobian.org> | ||
|
||
See ``TODO.taskpaper`` for my current to-do list. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
- add docstrings to tags so that the auto-admin docs work. | ||
- actually implement "saveas" | ||
- tests and examples: start as reST with special blocks; those blocks get rendered *and* source displayed | ||
- Generate sane default axes (if not given) for line graphs. This includes hiding the bottom axis and drawing a fake x axis at 0 if the data spans 0. Perhaps "{% axes auto %}" or something... | ||
- chart-data might need to take options as to how to deal with the data -- strings should have customizable splitters, multiple datasets in the same variable should be supported, ... | ||
- chart-data should handle querysets in some logical manner (or maybe chart-data-from-qs tag) Being able to say {% chart-data qs fieldname %} would rock. Perhaps this would be best done in a "map" filter: {% chart-data qs|map:"fieldname" %}? | ||
Archive: | ||
- Axes @done | ||
- Shape markers @done | ||
- Default options for required data @done | ||
- Allow "extending" graphs:: @done | ||
- Return value of {% graph as g %} should be an object (i.e. {{ g.url }}). @done | ||
- Alt text @done | ||
- there should be a chart-range tag to allow scaling of data to particular ranges @done | ||
- otherwise automatic ranges should be determined @done | ||
- negative values should be automatically scaled unless manual scales exist @done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,313 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Google Charts!</title> | ||
<style type="text/css" media="screen"> | ||
th { font-size: 18px; text-align: left; border-top: 1px #ccc solid; padding-top: 4px; } | ||
table { margin-left: auto; margin-right: auto; } | ||
</style> | ||
</head> | ||
<body> | ||
<h2>Chart tag examples</h2> | ||
<table> | ||
<tbody> | ||
|
||
<tr> | ||
<th colspan="2">3D pie chart, simple data, labels</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-data data1 %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "pie" %} | ||
{% chart-labels "One" "Two" "Three" %} | ||
{% chart-alt "It worked!" %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=300x200&cht=p&chl=One|Two|Three&chd=e:VVqq.." width="300" height="200" alt="It worked!" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Line chart, legend, fill, colors, saving as a variable</th> | ||
<tr> | ||
<td><pre>{% chart as c %} | ||
{% chart-data data2 %} | ||
{% chart-type "line" %} | ||
{% chart-size "300x200" %} | ||
{% chart-colors "CC0000" %} | ||
{% chart-fill "EEEEEE" %} | ||
{% chart-legend "Sweet" %} | ||
{% endchart %} | ||
<img src="{{ c.url }}" width="300" height="200" /></pre></td> | ||
<td> | ||
<img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chco=CC0000&chf=c,s,EEEEEE&chdl=Sweet&chd=e:ALAtBmC1EcGYIsLWOXRuVdZhd9ivn4tYzO5b.." width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Titles, multiple colors, background</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-title "Hello, World!" %} | ||
{% chart-data data2 data3 %} | ||
{% chart-type "line" %} | ||
{% chart-size "300x200" %} | ||
{% chart-colors "CC0000" "00CC00" %} | ||
{% chart-background "EEEEEE" %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chtt=Hello,+World%21&cht=lc&chs=300x200&chco=CC0000,00CC00&chf=bg,s,EEEEEE&chd=e:AKApBcCkEAFxH2KPM9QATXXCbCfXj.o9uPz15w,..5wz1uPo9j.fXbCXCTXQAM9KPH2FxEACkBcApAK" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Venn charts, background gradients</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-data venn %} | ||
{% chart-type "venn" %} | ||
{% chart-size "300" "200" %} | ||
{% chart-background-gradient "45" "000000" "0" "FFFFFF" "0.6" %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?cht=v&chs=300x200&chf=bg,lg,45,000000,0,FFFFFF,0.6&chd=e:..zMmZTNTNTNGa" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Pie charts, stripes</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-data data1 %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "pie" %} | ||
{% chart-background-stripes "45" "cccccc" "0.05" "FFFFFF" "0.05" %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=300x200&cht=p&chf=bg,ls,45,cccccc,0.05,FFFFFF,0.05&chd=e:VVqq.." width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Bar chart, chart-bar-width</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-data data1 %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "bar" %} | ||
{% chart-bar-width 60 0 6 %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=300x200&cht=bhg&chbh=60,0,6&chd=e:VVqq.." width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Extension, column charts (grouped & stacked), filters in data expressions</th> | ||
<tr> | ||
<td><pre>{% chart as columns %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "column-grouped" %} | ||
{% chart-data data2|slice:"6:10" %} | ||
{% chart-data data3|slice:"6:10" %} | ||
{% chart-colors "CC0000" "0000CC" %} | ||
{% chart-bar-width 30 5 10 %} | ||
{% endchart %} | ||
{{ columns.img }} | ||
|
||
{% chart extends columns %} | ||
{% chart-type "column-stacked" %} | ||
{% chart-bar-width 70 6 0 %} | ||
{% endchart %}</pre></td> | ||
<td> | ||
<img src="http://chart.apis.google.com/chart?chs=300x200&cht=bvg&chco=CC0000,0000CC&chbh=30,5,10&chd=e:LwQAU5ac,..3LvBng" width="300" height="200" /> | ||
|
||
<img src="http://chart.apis.google.com/chart?chs=300x200&cht=bvs&chco=CC0000,0000CC&chbh=70,6,0&chd=e:LwQAU5ac,..3LvBng" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Scatter chart</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-data data2 %} | ||
{% chart-data data3 %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "scatter" %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=300x200&cht=s&chd=e:AKApBcCkEAFxH2KPM9QATXXCbCfXj.o9uPz15w,..5wz1uPo9j.fXbCXCTXQAM9KPH2FxEACkBcApAK" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Chart-line-style, chart-grid</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-data data2 data3 %} | ||
{% chart-type "line" %} | ||
{% chart-size "300x200" %} | ||
{% chart-colors "CC0000" "00CC00" %} | ||
{% chart-line-style 3 6 3 %} | ||
{% chart-line-style 1 1 2 %} | ||
{% chart-grid 15 15 1 1 %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chco=CC0000,00CC00&chls=3,6,3|1,1,2&chg=15,15,1,1&chd=e:AKApBcCkEAFxH2KPM9QATXXCbCfXj.o9uPz15w,..5wz1uPo9j.fXbCXCTXQAM9KPH2FxEACkBcApAK" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Extension, ranger markers, fill-area</th> | ||
<tr> | ||
<td><pre>{% chart as line %} | ||
{% chart-type "line" %} | ||
{% chart-size "300x200" %} | ||
{% chart-range-marker "v" "E5ECF9" ".75" ".25" %} | ||
{% chart-fill-area "76A4FB" %} | ||
{% endchart %} | ||
|
||
{% chart extends line %} | ||
{% chart-data data2 %} | ||
{% endchart %}</pre></td> | ||
<td> | ||
|
||
<img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chm=R,E5ECF9,0,.75,.25|B,76A4FB,0,0,0&chd=e:ALAtBmC1EcGYIsLWOXRuVdZhd9ivn4tYzO5b.." width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">More markers</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-data data2 data3 %} | ||
{% chart-type "line" %} | ||
{% chart-size "300x200" %} | ||
{% chart-colors "CC0000" "00CC00" %} | ||
{% chart-marker "circle" "cccc0077" 1 4 90 %} | ||
{% chart-marker "x" "0000CC" 0 9.3 20 %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chco=CC0000,00CC00&chm=o,cccc0077,1,4,90|x,0000CC,0,9.3,20&chd=e:AKApBcCkEAFxH2KPM9QATXXCbCfXj.o9uPz15w,..5wz1uPo9j.fXbCXCTXQAM9KPH2FxEACkBcApAK" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Sensible defaults</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-data data2 data3 %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=200x200&cht=lc&chd=e:AKApBcCkEAFxH2KPM9QATXXCbCfXj.o9uPz15w,..5wz1uPo9j.fXbCXCTXQAM9KPH2FxEACkBcApAK" width="200" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Axes</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-type "line" %} | ||
{% chart-size "300x200" %} | ||
{% chart-range-marker "v" "E5ECF9" ".75" ".25" %} | ||
{% chart-fill-area "76A4FB" %} | ||
{% chart-data data2|slice:"::-1" %} | ||
{% axis "left" %} | ||
{% axis-range 0 100 %} | ||
{% endaxis %} | ||
{% axis "bottom" %} | ||
{% axis-labels "Jan" "Feb" "Mar" "Apr" %} | ||
{% endaxis %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chm=R,E5ECF9,0,.75,.25|B,76A4FB,0,0,0&chd=e:..5bzOtYn4ivd9ZhVdRuOXLWIsGYEcC1BmAtAL&chxt=y,x&chxr=0,0,100&chxl=1:|Jan|Feb|Mar|Apr" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">More axes</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "column-grouped" %} | ||
{% chart-data data2|slice:"6:10" %} | ||
{% chart-data data3|slice:"6:10" %} | ||
{% chart-colors "CC0000" "0000CC" %} | ||
{% chart-bar-width 30 5 10 %} | ||
{% chart-background-stripes 0 "cccccc" 0.25 "ffffff" 0.25 %} | ||
{% axis "top" %} | ||
{% axis-labels "Group 1" "Group 2" "Group 3" "Control" %} | ||
{% axis-label-positions 10 37 62 87 %} | ||
{% axis-style "000000" "14" %} | ||
{% endaxis %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=300x200&cht=bvg&chco=CC0000,0000CC&chbh=30,5,10&chf=bg,ls,0,cccccc,0.25,ffffff,0.25&chd=e:LwQAU5ac,..3LvBng&chxt=t&chxl=0:|Group+1|Group+2|Group+3|Control&chxp=0,10,37,62,87&chxs=0,000000,14" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Data provided as literals</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "pie-3d" %} | ||
{% chart-data "60,30,10" %} | ||
{% chart-colors "cc00ee" %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=300x200&cht=p3&chco=cc00ee&chd=e:..gAKr" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Automatic scaling of negative data</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "line" %} | ||
{% chart-data data4 %} | ||
{% chart-range-marker "h" "000000" ".499" ".501" %} | ||
{% axis "bottom" hide %} | ||
{% axis "left" %} | ||
{% axis-labels 5 0 -5 %} | ||
{% endaxis %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=300x200&cht=lc&chm=r,000000,0,.499,.501&chd=e:mXsdyE296791.i...K9G541nwgqukheIX1R2MbHyEHBjANAIBUDvHRLzRIXEdWjvp-v01B5Z8w--.9.q-G7W3gyutMnIgzabUROmJnFhCeAnAAArClFrJ0O1UiathFnatcy83s7f-N.t.8-68o5O00vkptjddEWyQ4LlHGDmBPAGAPBpEQH-MpSGYGeakzq.wv116C&chxt=x,y&chxs=0,000000,11,0,_&chxl=0:|||1:|5|0|-5" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">All-negative data</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "line" %} | ||
{% chart-data "-1,-5,-10" %} | ||
{% axis "left" %} | ||
{% axis-range "-10" "0" %} | ||
{% endaxis %} | ||
{% axis "bottom" hide %} | ||
{% chart-range-marker "h" "000000" 1 .997 %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=300x200&cht=lc&chm=r,000000,0,1,0.997&chd=e:5lf.AA&chxt=y,x&chxr=0,-10,0&chxs=1,000000,11,0,_&chxl=1:||" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Explicit chart data range</th> | ||
<tr> | ||
<td><pre>{% chart %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "line" %} | ||
{% chart-data data4 %} | ||
{% chart-colors "00cc00" %} | ||
{% chart-line-style 4 %} | ||
{% chart-data-range -10 10 %} | ||
{% chart-range-marker "h" "000000" ".499" ".501" %} | ||
{% axis "bottom" hide %} | ||
{% axis "left" %} | ||
{% axis-labels 10 0 -10 %} | ||
{% endaxis %} | ||
{% endchart %}</pre></td> | ||
<td><img src="http://chart.apis.google.com/chart?chs=300x200&cht=lc&chco=00cc00&chls=4&chm=r,000000,0,.499,.501&chd=e:jLmOpCretdu6vwv.vkuis7qzoPlWiQfEb6Y6WNT5SDQxQGQEQqR3ToV5Ykbheqh3k-n5qgssuYvev-v0vDtqrvpWmljkgZdNaIXTUzSwRPQTQAQVRSS1U6XaaRdWgijtmuper1tvvGv2v9vcuUsmqZnxk2huehbZYcVyTjRzQnQDQHQ0SIT.WUZDcDfNiZlfoXq6tA&chxt=x,y&chxs=0,000000,11,0,_&chxl=0:|||1:|10|0|-10" width="300" height="200" /></td> | ||
</tr> | ||
|
||
<tr> | ||
<th colspan="2">Explicit "auto" chart data range</th> | ||
<tr> | ||
<td><pre>{% chart as sine %} | ||
{% chart-size "300x200" %} | ||
{% chart-type "line" %} | ||
{% chart-data data4|slice:"::-1" %} | ||
{% chart-data-range -10 10 %} | ||
{% chart-colors "0000cc" %} | ||
{% chart-line-style 2 2 2 %} | ||
{% chart-range-marker "h" "000000" ".499" ".501" %} | ||
{% axis "bottom" hide %} | ||
{% endchart %} | ||
|
||
{% chart extends sine %} | ||
{% chart-data-range "auto" %} | ||
{% endchart %}</pre></td> | ||
<td> | ||
|
||
<img src="http://chart.apis.google.com/chart?chs=300x200&cht=lc&chco=0000cc&chls=2,2,2&chm=r,000000,0,.499,.501&chd=e:6C11wvq.kzeaYGSGMpH-EQBpAPAGBPDmHGLlQ4WydEjdptvk005O8o-6.8.t-N7f3sy8tcnahFatUiO1J0FrClArAAAnCeFhJnOmURabgznItMyu3g7W-G.q.9--8w5Z1Bv0p-jvdWXERILzHRDvBUAIANBjEHHyMbR2X1eIkhquwg1n549G.K...i916729yEsdmX&chxt=x&chxs=0,000000,11,0,_&chxl=0:||" width="300" height="200" /></td> | ||
</tr> | ||
|
||
</tbody> | ||
</table> | ||
</body> | ||
</html> | ||
|
Oops, something went wrong.