From bda65d0a44481d2f0bed1f7de3b6db6df6846438 Mon Sep 17 00:00:00 2001 From: Horilla Date: Fri, 13 Oct 2023 14:33:17 +0530 Subject: [PATCH] [ADD] DASHBOARD: Redirect on chart click --- onboarding/static/dashboard/onboardChart.js | 145 ++++++++++++-------- 1 file changed, 87 insertions(+), 58 deletions(-) diff --git a/onboarding/static/dashboard/onboardChart.js b/onboarding/static/dashboard/onboardChart.js index 83ffd3aa4..fb1ad2823 100644 --- a/onboarding/static/dashboard/onboardChart.js +++ b/onboarding/static/dashboard/onboardChart.js @@ -1,60 +1,89 @@ $(document).ready(function () { - //Hired candididates recruitment wise chart - $.ajax({ - type: "GET", - url: "/onboarding/hired-candidate-chart", - success: function (response) { - - const ctx = document.getElementById('hiredCandidate'); - new Chart(ctx, { - type: 'bar', - data: { - labels: response.labels, - datasets: [{ - label: '#Hired candidates', - data: response.data, - backgroundColor: response.background_color, - borderColor: response.border_color, - borderWidth: 1 - }] - }, - options: { - scales: { - y: { - beginAtZero: true - } - } - } - }); - } - }); + //Hired candididates recruitment wise chart + $.ajax({ + type: "GET", + url: "/onboarding/hired-candidate-chart", + success: function (response) { + const ctx = document.getElementById("hiredCandidate"); + new Chart(ctx, { + type: "bar", + data: { + labels: response.labels, + datasets: [ + { + label: "#Hired candidates", + data: response.data, + backgroundColor: response.background_color, + borderColor: response.border_color, + borderWidth: 1, + }, + ], + }, + options: { + scales: { + y: { + beginAtZero: true, + }, + }, + onClick: (e, activeEls) => { + let datasetIndex = activeEls[0].datasetIndex; + let dataIndex = activeEls[0].index; + let datasetLabel = e.chart.data.datasets[datasetIndex].label; + let value = e.chart.data.datasets[datasetIndex].data[dataIndex]; + let label = e.chart.data.labels[dataIndex]; + localStorage.removeItem("savedFilters"); + window.location.href = + "/recruitment/candidate-view" + + "?recruitment=" + + label + + "&hired=true"; + }, + }, + }); + }, + }); - //onboarding started candidate chart - $.ajax({ - type: "GET", - url: "/onboarding/onboard-candidate-chart", - success: function (response) { - const ctx = document.getElementById('onboardCandidate'); - new Chart(ctx, { - type: 'bar', - data: { - labels: response.labels, - datasets: [{ - label: '#onboarding candidates', - data: response.data, - backgroundColor: response.background_color, - borderColor: response.border_color, - borderWidth: 1 - }] - }, - options: { - scales: { - y: { - beginAtZero: true - } - } - } - }); - } - }); -}); \ No newline at end of file + //onboarding started candidate chart + $.ajax({ + type: "GET", + url: "/onboarding/onboard-candidate-chart", + success: function (response) { + const ctx = document.getElementById("onboardCandidate"); + new Chart(ctx, { + type: "bar", + data: { + labels: response.labels, + datasets: [ + { + label: "#onboarding candidates", + data: response.data, + backgroundColor: response.background_color, + borderColor: response.border_color, + borderWidth: 1, + }, + ], + }, + options: { + scales: { + y: { + beginAtZero: true, + }, + }, + onClick: (e, activeEls) => { + let datasetIndex = activeEls[0].datasetIndex; + let dataIndex = activeEls[0].index; + let datasetLabel = e.chart.data.datasets[datasetIndex].label; + let value = e.chart.data.datasets[datasetIndex].data[dataIndex]; + let label = e.chart.data.labels[dataIndex]; + localStorage.removeItem("savedFilters"); + window.location.href = + "/recruitment/candidate-view" + + "?recruitment=" + + label + + "&start_onboard=true"; + }, + }, + }); + }, + }); +});