TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
L A
NA
170
171.1k
Google Chart - DataTable.addRow()
Jun 19 2017 1:11 PM
Hello,
I`m trying add rows to a DataTable() but my column headers have spacing and special symbols like Meat/Poultry, Dairy Products, etc.,
$.ajax({
url:
"@Url.Action("
TotalSales
", "
Chart
")"
,
data:
"{}"
,
dataType:
"json"
,
type:
"POST"
,
contentType:
"application/json"
,
success:
function
(data) {
var
Data =
new
google.visualization.DataTable();
Data.addColumn(
'number'
,
'Confections'
);
Data.addColumn(
'number'
,
'Meat/Poultry'
);
Data.addColumn(
'number'
,
'Condiments'
);
Data.addColumn(
'number'
,
'Dairy Products'
);
Data.addColumn(
'number'
,
'Beverages'
);
Data.addColumn(
'number'
,
'Grains/Cereals'
);
Data.addColumn(
'number'
,
'Seafood'
);
Data.addColumn(
'number'
,
'Produce'
);
Data.addColumn(
'number'
,
'ShippingYear'
);
for
(
var
i = 0; i < data.length; i++) {
console.log(
"Im in ComboChart Success"
);
Data.addRow([data[i].ShippingYear, data[i].Confections,
data[i].Meat/ Poultry, data[i].Condiments, data[i].Dairy Products, data[i].Beverages,
data[i].Grains/ Cereals, data[i].Seafood, data[i].Produce]);
console.log(
"Inserting data"
);
}
var
options = {
height: 600,
width: 700,
title:
'Total Category Wise Sales 1996_1997'
,
vAxis: {
title:
'Sales'
,
format:
'currency'
},
hAxis: {
title:
'ShippingYear'
}
};
var
chartspace =
new
google.visualization.BarChart(document.getElementById(
'comboChart'
));
chartspace.draw(Data, options);
},
error:
function
() {
alert(
"Error loading data! Please try again."
);
}
});
In the above ajax call, Line # 21, 22 cause error.
I can`t add column names which are different. Please help me to achieve this.
Thanks in advance.
Reply
Answers (
7
)
Background Color in MVC
how to create login page in jquery and in asp.net