Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6573379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:07:31+00:00 2026-05-25T15:07:31+00:00

I have generated a variable data in Django with the following format: data =

  • 0

I have generated a variable data in Django with the following format:

data = [['100',10],['90',9],['80',8]]

and I’ve passed it off to my template using render_to_response:

return render_to_response('template.html', {
                                            'data': data,
                                            },
                                            context_instance=RequestContext(request))

In the template header I have placed a call to Google Charts to generate a line chart:

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Number');
  data.addColumn('number', 'Number/10');
  data.addRows( {{ data }} );

var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240, title: "Numbers"});
}
</script>

When I do this, nothing is displayed. If I strip the strings out of data and try again, the chart appears, but obviously with no x-axis labels.

I have also tried adding the data using the arrayToDataTable function:

var data = google.visualization.arrayToDataTable([
      ['Number', 'Number/10'],
      {% for datum in data %}
          {{ datum }},
      {% endfor %}],
      false);

but this again fails to display any chart.

Any suggestions on how I can change one of the above, or try another approach to get the x-axis labels to appear?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:07:31+00:00Added an answer on May 25, 2026 at 3:07 pm

    You have to disable the autoescaping of your results. You can do so by adding the safe filter:

    data.addRows( {{ data|safe }} );
    

    or

    {% autoescape off %}
    [...]
        {{ data }}
    [...]
    {% endautoescape %}
    

    My advice is, if you can install additional packages, to use one of these wrappers:

    • http://code.google.com/p/google-chartwrapper/ (last updated 2011)

    • https://github.com/jacobian/django-googlecharts/ (archived 2017)

    • https://code.google.com/p/django-graphs/ (last updated 2008)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have generated a C# SharePoint Sequential Workflow project using the very handy STSDEV
I have generated using openssl mycert.pem which contents the certificate. And I converted the
I have a generated HTML page with flash content in it. I am trying
I'm trying to parse returned information that can have a variable amount of data
I have 2 spinner, each spinner's data loaded from database using AsyncTask i call
i have a table array dynamically generated from a data query and stored in
I have a msi package generated by wix that creates a system environment variable
Does PHP have a method of having auto-generated class variables? I think I've seen
I have generated a collection of images. Some of them are blank as in
I have generated inputs with price values. Example: <input type=text value=59,00/> Now I should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.