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
Deepak Yadav
1.7k
36
1.3k
Chartjs is not working in aspx page in asp.net
Apr 19 2017 2:07 AM
Bar chart is not displaying propely
code is here
reference
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<script src="../Scripts/Chart.js"></script>
Aspx page
<body>
<canvas id="chartMonthlyBookingSales" </canvas>
</body>
<script type="text/javascript">
$(document).ready(function () {
ShowCurrentTime();
// HSCProgressPer();
// getchartdata();
// HSCDestination();
// HSCBooking();
// ss();
});
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
//<img src="~/Images/ajax-loader.gif" />
function ShowCurrentTime() {
debugger;
$.ajax({
type: "get",
url: "dashboard.aspx/GetJSONMonthlyBookingSales",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function(response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
MonthlyBookingSales(response.d);
console.log(response.d);
}
function MonthlyBookingSales(data) {
debugger;
var MonthName = [];
var ColorR = [];
var BookingCount = [];
// var Color = [];
for (var i = 0; i < data.length; i++) {
MonthName.push(data[i].Month);
BookingCount.push(data[i].BookingTotal);
ColorR.push(getRandomColor());
}
var barChartData = {
labels: MonthName,
datasets: [
{
label: "Total",
data: BookingCount,
backgroundColor: ColorR
}
]
}
var ctx1 = document.getElementById("chartMonthlyBookingSales").getContext("2d");
ctx1.canvas.height = 80;
var chart = new Chart(ctx1,
{
type: 'bar',
data: barChartData,
options:
{
scales: {
xAxes: [{
ticks: {
maxRotation: 90,
autoSkip: false
}
}]
},
title:
{
display: true,
text: ""
},
responsive: true,
maintainAspectRatio: true,
legend: {
display: false
}
}
});
}
});
</script>
Attachment:
chartsjserror.rar
Reply
Answers (
1
)
Parametrized Interface for datas sharing C#.net
how to delete multiple entries from db by passing id in mvc