Google chart - All series of the given axis must be of the same type

39 views
Skip to first unread message

Shekar Tippur

unread,
Oct 30, 2014, 4:33:01 AM10/30/14
to google-visua...@googlegroups.com
Hello,

I have a DataTable of the below form

User_name (String), Priority (string), Priority count (number), Time_Spent (number)

Since there are 2 string columns, I get the error - All series of the given axis must be of the same type.

How do I get over this issue.

I might have to create columns for priority and populate the data of the form

User_name, High, Medium, low, Time spent

How do I take the existing data table and transform to a new data table form?

- Shekar

Andrew Gallant

unread,
Oct 30, 2014, 8:39:12 AM10/30/14
to google-visua...@googlegroups.com
If you don't need all columns to draw your chart (or you can combine the string columns into a single column of data), you can use a DataView to restrict the columns you use, and/or use calculated columns that generate data based on the data in your DataTable.  Here's an example:

// assumes your DataTable is in a variable called "data"
var view = new google.visualization.DataView(data);
// use User name (column 0), Priority count (column 1), and Time spent (column 2)
view
.setColumns([0, 2, 3]);


You would then use the DataView when drawing your chart instead of your DataTable.

Shekar Tippur

unread,
Oct 30, 2014, 11:36:31 AM10/30/14
to google-visua...@googlegroups.com
I need the priority name to show up (high, medium, low) - as in strings.

- Shekar

Andrew Gallant

unread,
Oct 30, 2014, 7:40:55 PM10/30/14
to google-visua...@googlegroups.com
Do you want those to be your axis labels?  If so, change the setColumns call to this:

view.setColumns([1, 2, 3]);

Shekar Tippur

unread,
Nov 3, 2014, 5:17:14 PM11/3/14
to google-visua...@googlegroups.com
Sorry about the delay.
I dont see setColumns being defined as one of the options for combochart

var comboChartByUser = new google.visualization.ComboChart(document.getElementById('chart_div2'));

comboChartByUser.setColumns([0, 1, 2]);


Gives an error: TypeError: comboChartByUser.setColumns is not a function

- S

Reply all
Reply to author
Forward
0 new messages