用Chartit绘制Django图表(highcharts包装)

时间:2013-10-02 02:05:13

标签: django highcharts django-views

对于一个django项目,我试图绘制一个演员所有电影的收视率/年份。我使用Django-chartit绘制图表,因为它只是高级图表的包装。我想知道是否有一种方法可以实现这一点,当你将鼠标悬停在图表中的一个点上时,它会显示更多细节。现在它只显示x / y信息,即年份/等级,但我也希望它显示更多细节,例如电影的名称。电影模型包含了我想要包含的许多细节,但我在Chartit的文档中没有看到如何做到这一点。

这是我的视图代码:

def film_chart_view(request):
    if 'q' in request.GET and request.GET['q']:
        q = request.GET['q']
        # grab the first person on the list
        person_search = Person.objects.filter(short = q)[0]
    #Step 1: Create a DataPool with the data we want to retrieve.
        filmdata = \
            DataPool(
               series=
                [{'options': {
                   'source': person_search.film_set.all()},
                  'terms': [
                    'year', 'rating', 'name']}
                 ])

        #Step 2: Create the Chart object
        cht = Chart(
                datasource = filmdata,
                series_options =
                  [{'options':{
                      'type': 'line',
                      'stacking': False},
                    'terms':{
                      'year': [
                        'rating',]
                      }}],
                chart_options =
                  {'title': {
                       'text': 'Ratings'},
                   'xAxis': {
                        'title': {
                           'text': 'Year'}}})

        #Step 3: Send the chart object to the template.
        return render_to_response('home/search_results.html',{'filmchart': cht})

当您将鼠标悬停在图表上的某个点上时,我基本上希望弹出更多信息。

我想知道这是否可能在图表中,或者我是否必须放弃它并直接使用highcharts?

0 个答案:

没有答案