0

I need to display bar-charts in my Django project.I am using Django-nvd3 to display charts.I manage to run the bar-charts in separate projects but when integrating into my current project it does not display the charts. This is how I integrate the charts in my working project.

In my view.py

def demo_discretebarchart_with_date(request):
    try:
        request.session['user_login_data']
        dept_data=SuUserDepartment.objects.filter(org=request.session['user_login_data']['org'])
        allsurveyassign=SuSureyAndUser.objects.count()
        answered=SuSureyAndUser.objects.filter(is_answered=1).count()
        unanswred=SuSureyAndUser.objects.exclude(is_answered__isnull=False).count()

        """
        discretebarchart page
        """
        start_time = int(time.mktime(datetime.datetime(2014, 6, 1).timetuple()) * 1000)
        nb_element = 10

        xdata = list(range(nb_element))
        xdata = [start_time + x * 1000000000 for x in xdata]
        ydata = [i + random.randint(1, 10) for i in range(nb_element)]

        extra_serie1 = {"tooltip": {"y_start": "", "y_end": " cal"}}
        chartdata = {
            'x': xdata, 'name1': '', 'y1': ydata, 'extra1': extra_serie1,
        }
        charttype = "discreteBarChart"
        chartcontainer = 'discretebarchart_container'  # container name
        data = {
            'charttype': charttype,
            'chartdata': chartdata,
            'chartcontainer': chartcontainer,
            'extra': {
                'x_is_date': True,
                'x_axis_format': '%d-%b',
                'tag_script_js': True,
                'jquery_on_ready': True,
            },
        }

        return render(request, 'pages/forms/discretebarchart_with_date.html',data,context_instance=RequestContext(request))   


    except KeyError, e:
        messages={'alert':'No activity within 120 minutes; please log in again'}
        return render(request, 'index.html',{'messages': messages},context_instance=RequestContext(request))

I have an HTML template, base.html.In base.html I include the .js files,.css files and{% load nvd3_tags %} tag.In discretebarchart_with_date.html page I extend the base.html and add {% include_container chartcontainer 400 800 %}.But when I run the project,it did not display the chart. I inspect the div tag and this is what I got enter image description here

enter image description here

In other projects,that display charts without any problem give like this
enter image description here

How can I fix this error?

Rinsha CP
  • 51
  • 3
  • 11
Nuwan Indika
  • 901
  • 4
  • 14
  • 27

1 Answers1

0

Oiriginal poster provides the answer to his/her problem but it is buried in the comments to his/her original question.

Here it is for the sake of convenience:

guys i finger out the error.i put 'jquery_on_ready': False in view.py data dic.thank you. – user3480706

I'm not 100% sure but I think users that post a question that eventually gets solved by their own effort can post an answer describing the solution.

BringBackCommodore64
  • 4,910
  • 3
  • 27
  • 30