Anonymous avatar Anonymous committed 01dd506

updated the README

Comments (0)

Files changed (4)

 * Your Django models
 * ...
 
+And could be rendered using the js library of your choice : google
+charts, d3js, raphael etc...
+
 ### A graph consist of 3 parts :
 
 * a method : the method lie in a Backend you create (or you can use
 
 ## Installation
 
-MustacheBox has no particular dependencies.
-As a django-app it need a working version of Django >= 1.3
+MustacheBox has no particular dependencies.  As a django-app it need a
+working version of Django >= 1.3.
+
+If you want to use the example backend and the page listing all the
+graphs already created you must install the docutils.
+
 so just clone this repository :
 
 ### Clone
 easy however. For a starting point, you can use the
 monitor_backend. This backend exist for testing and example purpose.
 
-    GRAPH_BACKEND="mustachebox.backends.monitoring_backend"
+    GRAPH_BACKEND="mustachebox.backends.example_backend"
 
 ### include MustacheBox to your urls :
 
 
 To start playing with MustacheBox, you can visit :
 
-(http://localhost:8000/graphs/monitoring/)
+(http://localhost:8000/grapher/all/)
 
-You can also look at how the templatetag works with :
+That list all the graphs the example backend can give you.
 
-(http://localhost:8000/grapher/template_tag_test/)
-
-This is the same graph as before but rendered using a templatetag.
 
 This software is released under [GPLv3](http://www.gnu.org/licenses/gpl.html)

mustachebox/backends/example_backend.py

     """
 
     def area(self, **kwargs):
+        """
+        Render a graph area using google chart.
+
+        The data are formated as follow ::
+
+            {
+                2004: ['2004', 7160, 546],
+                2005: ['2005', 5654, 5435],
+                2006: ['2006', 7656, 6545],
+                2007: ['2007', 5435, 6545],
+                'label': ['year', 'sales', 'expenses']
+            }
+        """
         self.template = 'area'
         return time_serie(**kwargs)
 
     def bar_chart(self, **kwargs):
+        """
+        Render a barchart graph using google chart.
+
+        The data are formated as follow ::
+
+            {
+                2004: ['2004', 7160, 546],
+                2005: ['2005', 5654, 5435],
+                2006: ['2006', 7656, 6545],
+                2007: ['2007', 5435, 6545],
+                'label': ['year', 'sales', 'expenses']
+            }
+        """
         self.template = "barchart"
         return time_serie(**kwargs)
 
     def column_chart(self, **kwargs):
+        """
+        Render a barchart graph using google chart.
+
+        The data are formated as follow ::
+
+            {
+                2004: ['2004', 7160, 546],
+                2005: ['2005', 5654, 5435],
+                2006: ['2006', 7656, 6545],
+                2007: ['2007', 5435, 6545],
+                'label': ['year', 'sales', 'expenses']
+            }
+        """
         self.template = 'columnchart'
         return time_serie(**kwargs)
 
     def pie_chart(self):
         """
-        define a generic pie chart
+        Define a generic pie chart using google chart
+
+        The data are formated as follow::
+
+            {'label': ['name', 'count'],
+             'activities': [
+                             ['eat': 12],
+                             ['read': 5],
+                             ['work': 23],
+                             ['sleep': 4],
+                             ['wathc TV': 10]
+                           ]
+            }
         """
         self.template = "pie_chart"
 
 
     def line_chart(self):
         """
-        define a generic line chart
-        response is a list of dict :
-        [
-          {'date': 1107151200000,
-           'value': 289
-           },
-          {'date': 1109743200000,
-           'value': 766
-           }
-           ...
-        ]
+        Define a generic line chart using D3js
+
+        Data are formated as follow ::
+
+            [
+              {'date': 1107151200000,
+               'value': 289
+              },
+              {'date': 1109743200000,
+               'value': 766
+              }
+               <...>
+            ]
         """
         response = []
         self.template = "line_chart"

mustachebox/templates/mustachebox/all_graph.html

 {% for obj in object_list %}
 <div class="graph">
   <h3><a href={% url graph obj.name %}>{{obj.name}}</a></h3>
-  <p>{{obj.doc}}</p>
+  <p>
+
+{{obj.doc|parse_docstring}}
+
+</p>
   <div>
     <h4>Exemple</h4>
     {% graph obj.name %}

mustachebox/templatetags/graph.py

 
 from django import template
 from django.conf import settings
-
+from django.utils.safestring import mark_safe
 register = template.Library()
 
 
                 autoescape=context.autoescape))
 
 register.tag('graph', do_graph_node)
+
+
+@register.filter(name='parse_docstring')
+def parse_docstring(value):
+    if value is None:
+        return
+    from docutils import core
+    publish_args = {'source': value, 'writer_name': 'html4css1'}
+    parts = core.publish_parts(**publish_args)
+    return mark_safe(parts['fragment'])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.