chartit/django-chartit

Change series label on line charts

mpena2099 opened this issue · 2 comments

Hi! In the example:

cht = Chart(
        datasource = ds, 
        series_options = 
          [{'options':{
              'type': 'line',
              'stacking': False},
            'terms':{
              'month': [
                'boston_temp',
                'houston_temp']
              }}],
        chart_options = 
          {'title': {
               'text': 'Weather Data of Boston and Houston'},
           'xAxis': {
                'title': {
                   'text': 'Month number'}}})

How could I change the series name? I do not want to use "Boston Temp" and "Houston Temp" automatically...

Thanks!
Mauricio

@mpena2099 consider the following diff if you'd like to rename the term.

diff --git a/demoproject/demoproject/chartdemo.py b/demoproject/demoproject/chartdemo.py
index 3367376..d74b742 100755
--- a/demoproject/demoproject/chartdemo.py
+++ b/demoproject/demoproject/chartdemo.py
@@ -31,7 +31,7 @@ def basicline(_, title, code, doc, sidebar_items):
                 },
                 'terms': [
                     'month',
-                    'houston_temp',
+                    {'Temperature in Houston': 'houston_temp'},
                     'boston_temp'
                 ]
             }]
@@ -47,7 +47,7 @@ def basicline(_, title, code, doc, sidebar_items):
                 'terms': {
                     'month': [
                         'boston_temp',
-                        'houston_temp'
+                        'Temperature in Houston'
                     ]
                 }
             }],

This is partially documented in DataPool.__init__ but a more robust example has not been given. I'm leaving this issue open as a reminder to update the docs.

OK, it worked. Thanks!