Scatter plot with data from multiple models

We can do more complicated plots from multiple databases on the same chart. In this chart we plot a scatter plot of daily weather of Boston from the DailyWeather database and the monthly average temperature of Boston as a from the MonthlyWeatherByCity database on the same chart.

Points to note:

  • Notice that the data is filtered naturally using filter method in django.
  • The zIndex parameter (one of the many Highcharts series options) is used to force the monthly temperature to be on the top.


ds = DataPool(
        [{'options': {
            'source': DailyWeather.objects.filter(city="Boston")},
          'terms': [
         {'options': {
            'source': MonthlyWeatherByCity.objects.all()},
          'terms': [
            {'month_boston': 'month'}, 

cht = Chart(
        datasource = ds, 
        series_options = 
              'type': 'scatter'},
              'month': [
              'type': 'scatter',
              'zIndex': 1},
              'month_boston': [
        chart_options = 
          {'title': {
               'text': 'Boston Daily weather and Monthly Average'},
           'yAxis': {
             'title': {
               'text': 'Temperature'}}})