charts not renderring in django-nvd3

I am trying to use django-nvd3 with my django project, and am trying to get the line-chart example working. I get the following errors in the chrome js console when my page loads:

Uncaught TypeError: Cannot set property 'monthEnd' of undefined nv.d3.js:115 (anonymous function) nv.d3.js:115 (anonymous function) nv.d3.js:14369 Uncaught TypeError: Object # has no method 'lineChart' (index):13 (anonymous function) (index):13 (anonymous function) nv.d3.js:63

I have basically copied the code from here:

my view is:

from django.shortcuts import render_to_response, render
import random
import datetime
import time

def demo_linechart(request):
    lineChart page
    start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000)
    nb_element = 100
    xdata = range(nb_element)
    xdata = map(lambda x: start_time + x * 1000000000, xdata)
    ydata = [i + random.randint(1, 10) for i in range(nb_element)]
    ydata2 = map(lambda x: x * 2, ydata)

    tooltip_date = "%d %b %Y %H:%M:%S %p"
    extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"},
                   "date_format": tooltip_date}
    chartdata = {'x': xdata,
                 'name1': 'series 1', 'y1': ydata, 'extra1': extra_serie,
                 'name2': 'series 2', 'y2': ydata2, 'extra2': extra_serie}
    charttype = "lineChart"

    kw_extra = {
        'x_is_date': True,
        'x_axis_format':"%d %b %Y",

    data = {
        'charttype': charttype,
        'chartdata': chartdata,
    return render(request, 'smcore/nvd3.html', data)

my html is:

{% load static %}

<link rel="stylesheet" type="text/css" href="" />
<script type="text/javascript" src='{% static 'smcore/jquery-latest.js' %}'></script>
<script type="text/javascript" src='{% static 'smcore/d3.min.js' %}'></script>
<script type="text/javascript" src='{% static 'nvd3/nv.d3.js' %}'></script>

{% load nvd3_tags %}
    {% load_chart charttype chartdata "linechart_container" kw_extra %}

    {#    {% load_chart charttype chartdata "linechart_container" True '%d %b %Y %H' %}#}
    <h1>Fruits vs Calories</h1>
    {#    {% include_container "piechart_container" 400 500 %}#}
    {% include_container "linechart_container" 400 600 %}


my url is:

url(r'testvis/$', temp.demo_linechart, name='testvis'),

I am using nv.version = '1.1.15b'; d3 = {version: "2.7.0"}; // semver

please help!!


For me, the solution was in the first comment from samesense here:


data = {
    'charttype': charttype,
    'chartdata': chartdata,
    'extra': {'x_is_date': True,
    'x_axis_format': "%d %b %Y %H"},
Then you fix the template to make it look like the piechart example.
{% load_chart charttype chartdata "linechart_container" True "%d %b %Y %H" %}
{% load_chart charttype chartdata "linechart_container" extra %}


 ? NVD3 Charts Remove 0 Value Bars
 ? How can I use django-nvd3 to draw multi line chart with different values in X-axis?
 ? nvd3 - how to disable tooltip in discrete bar chart
 ? Webpage showing differently on browser and on PhoneGap
 ? Webpage showing differently on browser and on PhoneGap
 ? Webpage showing differently on browser and on PhoneGap
 ? Why is this Javascript library available in browser but not in PhoneGap?
 ? Phonegap can't use whitelist
 ? Phonegap ajax/php post not working
 ? Basic/novice PhoneGap and AJAX