I want to add a click event in chart, here is my js code,
render_top_customer_graph:function(){
var self = this
var ctx = self.$(".top_user");
rpc.query({
model: "request.request",
method: "get_the_top_customer",
}).then(function (arrays) {
var data = {
labels: arrays[1],
datasets: [
{
label: "Ticket Count",
data: arrays[0],
backgroundColor: [
"rgba(255, 99, 132,1)",
"rgba(54, 162, 235,1)",
"rgba(75, 192, 192,1)",
"rgba(153, 102, 255,1)",
"rgba(10,20,30,1)"
],
borderColor: [
"rgba(255, 99, 132, 0.2)",
"rgba(54, 162, 235, 0.2)",
"rgba(75, 192, 192, 0.2)",
"rgba(153, 102, 255, 0.2)",
"rgba(10,20,30,0.3)"
],
borderWidth: 1
},
]
};
//options
var options = {
responsive: true,
title: {
display: true,
position: "top",
text: "Helpdesk User vs Requests",
fontSize: 18,
fontColor: "#121"
},
legend: {
display: true,
position: "bottom",
labels: {
fontColor: "#333",
fontSize: 16
}
},
scales: {
yAxes: [{
ticks: {
min: 0
}
}]
}
};
//create Chart class object
var chart = new Chart(ctx, {
type: "horizontalBar",
data: data,
options: options,
});
});
},
xml file:
var self = this
var ctx = self.$(".top_user");
rpc.query({
model: "request.request",
method: "get_the_top_customer",
}).then(function (arrays) {
var data = {
labels: arrays[1],
datasets: [
{
label: "Ticket Count",
data: arrays[0],
backgroundColor: [
"rgba(255, 99, 132,1)",
"rgba(54, 162, 235,1)",
"rgba(75, 192, 192,1)",
"rgba(153, 102, 255,1)",
"rgba(10,20,30,1)"
],
borderColor: [
"rgba(255, 99, 132, 0.2)",
"rgba(54, 162, 235, 0.2)",
"rgba(75, 192, 192, 0.2)",
"rgba(153, 102, 255, 0.2)",
"rgba(10,20,30,0.3)"
],
borderWidth: 1
},
]
};
//options
var options = {
responsive: true,
title: {
display: true,
position: "top",
text: "Helpdesk User vs Requests",
fontSize: 18,
fontColor: "#121"
},
legend: {
display: true,
position: "bottom",
labels: {
fontColor: "#333",
fontSize: 16
}
},
scales: {
yAxes: [{
ticks: {
min: 0
}
}]
}
};
//create Chart class object
var chart = new Chart(ctx, {
type: "horizontalBar",
data: data,
options: options,
});
});
},