Line chart

This is just a simple line chart with data from 2 different columns.

Points to note:

  • terms is a list of all fields (both for x-axis and y-axis) to retrieve from the model.
  • Remember that for a Chart, the x and y terms in the series_options are written as x: [y, ...] pairs.
  • Any valid items in the Highcharts options object are valid chart_options.
  • This example also changes the default label for Houston!

code

ds = DataPool(
        series=[{
            'options': {
                'source': MonthlyWeatherByCity.objects.all()
            },
            'terms': [
                'month',
                {'Temperature in Houston': 'houston_temp'},
                'boston_temp'
            ]
        }]
)

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