i am storing value like first title and 2nd point...
sending value in form of string and convert it to array inside javascript ,values comes but it assume it single value.
chart not showing
DataTable dt = new DataTable();
string values = "";
if (ds.Tables[0].Rows.Count > 0)
{
dt.Columns.Add("task_title");
dt.Columns.Add("resume_recived");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string jobid = ds.Tables[0].Rows[i][0].ToString();
string jobtitle = ds.Tables[0].Rows[i][1].ToString();
string resumecount = sql.getsinglevallue("select count(applicationid) from applications where jobid='" + jobid + "' and clientid='" + Session["idclient"].ToString() + "'");
dt.Rows.Add(jobtitle, resumecount);
if (i < (ds.Tables[0].Rows.Count - 1))
{
values+=jobtitle+","+ resumecount+",";
}
else
{
values += jobtitle + "," + resumecount;
}
}
}
ScriptManager.RegisterStartupScript(Page, GetType(), "disp_confirm", "<script>Showpointchart('" + values + "','" + ds.Tables[0].Rows.Count + "')</script>", false);
function Showpointchart(dt,jobcount) {
var jobarray = dt.split(',');
// alert(title);
//$('#myModal').modal('show');
//$('#myModal').on('shown.bs.modal', function () {
var task_titles="";
var resumecount="";
for (var i = 0; i < jobcount; i++) {
//coz on second is point and on first is title
if (i % 2 == 0) {
if (i == jobcount - 2) {
task_titles += jobarray[i];
}
else{
task_titles += jobarray[i] + ",";
}
}
else {
if (i == jobcount - 1) {
resumecount += jobarray[i];
}
else {
resumecount += jobarray[i] + ",";
}
}
}
var ctx = document.getElementById("bar-chart").getContext('2d');
alert(task_titles);
alert(resumecount);
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [task_titles],
datasets: [{
label: "Points",
data: [3,5],
backgroundColor: ["#3e95cd"]
}]
},
options: {
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}],
xAxes: [{
ticks: {
callback: function (value, index, values) {
// return only first 4 charater of remark.
//return (value.substr(0, 10) + "..");
return (value);
}
}
}]
},
tooltips: {
callbacks: {
title: function (tooltipItem, data) {
// Returns text to render as the title of the tooltip.
return data.labels[tooltipItem[0].index];
}
}
}
}
});
}
<canvas id="bar-chart" width="300" height="300"></canvas>