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 8786501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:38:38+00:00 2026-06-13T21:38:38+00:00

I have LineGraph using googlechart. This graph is created with the following code function

  • 0

enter image description here

I have LineGraph using googlechart. This graph is created with the following code

function drawChart() {
    var data = google.visualization.arrayToDataTable([ 

      ['Categegories', 'R1' , 'R2' , 'R3' , 'R4' , 'R5' , 'R6' ],

      ['A',          1,     4,       2,    4,       1,  null],

      ['D',          3,  null,    null,    7,    null,     1],

      ['G',          null,  null,    null,       8,    null,  null],

    ]);

    var options = {
      title: 'Graph',
      pointSize: 6,
      vAxis: {minValue:0, maxValue:10,gridlines:{count:6}},
    };

    var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
    chart.draw(data, options);
  }

Now surprisingly if I remove a data row ['D', 3, null, null, 7, null, 1],

It produces an error saying that All series on a given axis must be of the same data type


I have reduce my code to just one line and I found that there is problem with null values

e.g.

['Category', 'R1' , 'R2' , 'R3' ],
['A',       2,  1,  1]

It generates the graph while if I add null value any where in the data i.e in the place of (2,1,1) it does not..

Waiting for some expert guidance about setting some kind option for handling null values… It is very strange that some time null values works and some time not.. 🙁

  • 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-06-13T21:38:39+00:00Added an answer on June 13, 2026 at 9:38 pm

    Finally, I have got a solution to my problem. I hope this will help many others like me. The problem is basically a limitation of arrayToDataTable method. The row of data must have the correct type in all columns. Since we have null values in rows, the API is either assuming that the data type of that column in null or it is throwing an error about not getting a valid data type. To fix this, you will have to switch to the a standard DataTable constructor

    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Year');
    data.addColumn('number', 'Health (P)');
    data.addColumn('number', 'Health (A)');
    data.addColumn('number', 'Gender (P)');
    data.addColumn('number', 'Gender (A)');
    data.addColumn('number', 'Education (P)');
    data.addColumn('number', 'Education (A)');
    data.addColumn('number', 'Agriculture (P)');
    data.addColumn('number', 'Agriculture (A)');
    data.addColumn('number', 'Social protection (P)');
    data.addColumn('number', 'Social protection (A)');
    data.addColumn('number', 'Environment (P)');
    data.addColumn('number', 'Environment (A)');
    data.addColumn('number', 'Water/sanitation (P)');
    data.addColumn('number', 'Water/sanitation (A)');
    data.addRows([
    
        ['2008',81.06,null,1.32,null,94.68,0,13.41,null,30.36,null,19.78,null,36.87,null],
        ['2009',27.13,null,22.34,null,33.6,null,79.92,null,1.34,null,89.77,0,15.68,null],
        ['2010',104.89,0,14.61,null,33.46,null,30.29,null,22.28,null,107.81,null,1.39,null],
        ['2011',55,0,110.69,null,1.3,null,106.24,0,14.45,null,27.34,null,30.71,null],
        ['2012',29.96,null,27.88,null,44.77,null,133.83,null,1.31,null,105.01,null,17.83,null],
        ['2013',0,null,0,null,0,null,0,null,0,null,0,null,0,null]
    ]);
    

    Copied from the following link
    https://groups.google.com/forum/?fromgroups=#!topic/google-visualization-api/2Jafk8PyjV4

    Alternatively, with arrayToDataTable() you can specify the type in the header row. See the docs for more https://developers.google.com/chart/interactive/docs/datatables_dataviews#arraytodatatable

    var data = google.visualization.arrayToDataTable([
          ['Categegories', {label: 'R1', type: 'number'} , {label: 'R2', type: 'number'} , {label: 'R3', type: 'number'} , {label: 'R4', type: 'number'} , {label: 'R5', type: 'number'} , {label: 'R6', type: 'number'} ],
    
          ['A',          1,     4,       2,    4,       1,  null],
    
          ['D',          3,  null,    null,    7,    null,     1],
    
          ['G',          null,  null,    null,       8,    null,  null],
    
        ]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a google line chart visualization with a data set that has
I can get the line graph to be displayed using gRaphael, but I have
I see how to do this with a line graph, but I have to
I'm using nvd3.js to create a line graph that displays ratings that I have
I'm using Google Chart ( http://code.google.com/apis/chart/ ) to produce some graphs for my company.
I have a data.frame with the following characteristics: +-----------------------------------------+ | earning budget ts total
I have a pretty simple line graph that is rendered by the code below.
I have some pretty simple code to plot a time series line graph. The
I have a data set (~10000 rows) with the following form: +---------------------------+---------------+-------------+ | DateTimeCreated
I am current working on library d3.js.I have line graph using Dynamic Line Graph

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.