コード例 #1
0
ファイル: views.py プロジェクト: leotop/django-graphos
def other(request):
    cursor = get_mongo_cursor("graphos_mongo", "zips", max_docs=100)
    m_data = MongoDBDataSource(cursor=cursor, fields=['_id', 'pop'])
    m_chart = flot.LineChart(m_data)
    context = {}
    context['m_chart'] = m_chart
    return render(request, 'demo/other.html', context)
コード例 #2
0
ファイル: views.py プロジェクト: mahmoudhossam/django-graphos
 def get_context_data(self, *args, **kwargs):
     accounts_cursor = get_db("accounts").docs.find()
     field_names = self.request.REQUEST.getlist("fields[]") or ['Year', 'Net Profit']
     data_source = MongoDBDataSource(accounts_cursor,
                                   fields=field_names)
     chart = flot.LineChart(data_source)
     return {"chart": chart}
コード例 #3
0
ファイル: views.py プロジェクト: epkugelmass/django-graphos
def time_series_demo(request):
    create_demo_mongo()
    db = get_db('charts')

    query = get_query('year_ago', None,
                      'employee=/example/employee/500ff1b8e147f74f7000000c/')
    coll_name = "mapreduce_daily__sumof__time_record__hours"
    cursor = db[coll_name].find(query)
    data_source_2 = DemoMongoDBDataSource(cursor, fields=["_id", "value"])
    chart_2 = flot.LineChart(data_source_2)

    accounts_cursor = get_db("accounts").docs.find()
    data_source_3 = MongoDBDataSource(accounts_cursor,
                                      fields=['Year', 'Sales', 'Expenses'])

    chart_3 = gchart.LineChart(data_source_3)
    data_source_4 = MongoDBDataSource(accounts_cursor,
                                      fields=['Year', 'Sales'])
    chart_4 = CustomFlot2(data_source_4)
    period = 'weekly'
    start = 'year_ago'
    end = None
    series = [{
        'resource': 'time_record',
        'field': 'hours',
        'filter': 'employee=/example/employee/500ff1b8e147f74f7000000c/',
        'mapreduce_function': 'sumof'
    }, {
        'resource': 'other_time_record',
        'field': 'hours',
        'filter': 'employee=/example/employee/500ff1b8e147f74f7000000c/',
        'mapreduce_function': 'sumof'
    }]

    datasets = build_timeseries_chart(period=period,
                                      series=series,
                                      start=start,
                                      end=end)

    context = {
        'datasets': json.dumps(datasets),
        'chart_2': chart_2,
        "chart_3": chart_3,
        "chart_4": chart_4,
    }
    return render(request, 'demo/mongodb_source.html', context)
コード例 #4
0
ファイル: views.py プロジェクト: epkugelmass/django-graphos
def home(request):
    chart = flot.LineChart(SimpleDataSource(data=data), html_id="line_chart")
    g_chart = gchart.LineChart(SimpleDataSource(data=data))
    cursor = get_mongo_cursor("graphos_mongo", "zips", max_docs=100)
    m_data = MongoDBDataSource(cursor=cursor, fields=['_id', 'pop'])
    m_chart = flot.LineChart(m_data)

    context = {'chart': chart, 'g_chart': g_chart, 'm_chart': m_chart}
    return render(request, 'demo/home.html', context)
コード例 #5
0
ファイル: views.py プロジェクト: epkugelmass/django-graphos
 def get_context_data(self, *args, **kwargs):
     accounts_cursor = get_db("accounts").docs.find()
     data_source = MongoDBDataSource(accounts_cursor,
                                     fields=['Year', 'Net Profit'])
     chart = flot.LineChart(data_source)
     return {"chart": chart}