File tree Expand file tree Collapse file tree 4 files changed +15
-15
lines changed
Expand file tree Collapse file tree 4 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -93,16 +93,16 @@ Graphos is a Django app to normalize data to create beautiful charts. It provide
9393
9494 python manage.py migrate
9595
96- * Make sure mongo server is running(You should have mongodb properly setup for this)
97-
98- mongod --dbpath ~/data/db
99-
10096* Run server
10197
10298 python manage.py runserver
10399
104100The installed demo app shows the various suported chart types.
105101
102+ In case you want to use mongo data while charting, you must have mongodb properly setup and ** pymongo** installed. Make sure mongo server is running.
103+
104+ mongod --dbpath ~/data/db
105+
106106
107107### Overview of Plot generation
108108
Original file line number Diff line number Diff line change @@ -29,9 +29,6 @@ <h2>Google charts<h2>
2929{{ g_chart.as_html }}
3030
3131
32- < h2 > Mongo Data with LineChart</ h2 >
33- {{ m_chart.as_html }}
34-
3532< br />
3633</ div >
3734{% endblock %}
Original file line number Diff line number Diff line change 1- import pymongo
2-
31from .models import Account
42
53
86
97
108def get_db (db_name ):
9+ import pymongo
1110 DB_HOST = ["localhost" ]
1211 DB_PORT = 27017
1312 db = pymongo .Connection (DB_HOST , DB_PORT )[db_name ]
1413 return db
1514
1615
1716def get_mongo_cursor (db_name , collection_name , max_docs = 100 ):
17+ import pymongo
1818 db = pymongo .Connection (host = DB_HOST ,
1919 port = DB_PORT )[db_name ]
2020 collection = db [collection_name ]
Original file line number Diff line number Diff line change 2727
2828import markdown
2929import datetime
30- import pymongo
3130from dateutil .parser import parse
3231
3332class MongoJson (FlotAsJson ):
@@ -158,16 +157,20 @@ def get_context_data(self, **kwargs):
158157def home (request ):
159158 chart = flot .LineChart (SimpleDataSource (data = data ), html_id = "line_chart" )
160159 g_chart = gchart .LineChart (SimpleDataSource (data = data ))
160+ context = {'chart' : chart ,
161+ 'g_chart' : g_chart }
162+ return render (request , 'demo/home.html' , context )
163+
164+
165+ def other (request ):
161166 cursor = get_mongo_cursor ("graphos_mongo" ,
162167 "zips" ,
163168 max_docs = 100 )
164169 m_data = MongoDBDataSource (cursor = cursor , fields = ['_id' , 'pop' ])
165170 m_chart = flot .LineChart (m_data )
166-
167- context = {'chart' : chart ,
168- 'g_chart' : g_chart ,
169- 'm_chart' : m_chart }
170- return render (request , 'demo/home.html' , context )
171+ context = {}
172+ context ['m_chart' ] = m_chart
173+ return render (request , 'demo/other.html' , context )
171174
172175
173176@cache_page (60 * 60 * 24 )
You can’t perform that action at this time.
0 commit comments