File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ it in a Django template::
2626
2727 <script id="source" language="javascript" type="text/javascript">
2828 $(function () {
29- $.plot($("#linear-graph"), {{ graph.series_json|safe }}, {{ graph.options_json|safe }});
29+ $.plot($("#linear-graph"), {{ graph.series_json }}, {{ graph.options_json }});
3030 });
3131 </script>
3232
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ it in a Django template:
3333 <div id="linear-graph" style="width:600px;height:400px"></div>
3434 <script id="source" language="javascript" type="text/javascript">
3535 $(function () {
36- $.plot($("#linear-graph"), {{ graph.series_json|safe }}, {{ graph.options_json|safe }});
36+ $.plot($("#linear-graph"), {{ graph.series_json }}, {{ graph.options_json }});
3737 });
3838 </script>
3939
Original file line number Diff line number Diff line change 1515import inspect
1616import json
1717import time
18+ from django .utils .safestring import mark_safe
1819
1920
2021__title__ = 'pyflot'
2324__license__ = 'MIT'
2425__copyright__ = 'Copyright 2011 Brian Luft'
2526
27+ def safe_json (obj ):
28+ return mark_safe (json .dumps (obj ))
29+
2630
2731def update (d , u ):
2832 """
@@ -84,7 +88,7 @@ def series_json(self):
8488 associated with this graph formatted as JSON,
8589 suitable for passing to the ``$.plot`` method.
8690 """
87- return json . dumps ([self .prepare_series (s ) for s in self ._series ])
91+ return safe_json ([self .prepare_series (s ) for s in self ._series ])
8892
8993 @property
9094 def options_json (self ):
@@ -93,7 +97,7 @@ def options_json(self):
9397 for this graph in a format suitable for passing to
9498 the ``$.plot`` method as the options parameter.
9599 """
96- return json . dumps (self ._options )
100+ return safe_json (self ._options )
97101
98102 def __getattr__ (self , value ):
99103 """
Original file line number Diff line number Diff line change 99 < script type ="text/javascript " src ="pyflot/templates/jquery.flot.min.js "> </ script >
1010 < script type ="text/javascript ">
1111 $ ( function ( ) {
12- $ . plot ( $ ( "#testgraph" ) , { { graph . series_json | safe } } , { { graph . options_json | safe } } ) ;
12+ $ . plot ( $ ( "#testgraph" ) , { { graph . series_json } } , { { graph . options_json } } ) ;
1313 } ) ;
1414 </ script >
1515 </ head >
You can’t perform that action at this time.
0 commit comments