[FIX] CHART: 'ischartempty' not defined error

This commit is contained in:
Horilla
2023-10-26 12:49:48 +05:30
parent 5135e3790d
commit dfcbbc7b54
2 changed files with 32 additions and 15 deletions

View File

@@ -1,5 +1,21 @@
$(document).ready(function () { $(document).ready(function () {
//Hired candididates recruitment wise chart //Hired candididates recruitment wise chart
function isChartEmpty(chartData) {
if (!chartData) {
return true;
}
for (let i = 0; i < chartData.length; i++) {
if (chartData[i]) {
const hasNonZeroValues = chartData.some((value) => value !== 0);
if (hasNonZeroValues) {
return false;
}
}
}
return true;
}
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/onboarding/hired-candidate-chart", url: "/onboarding/hired-candidate-chart",

View File

@@ -12,18 +12,19 @@ var objectiveStatusData = {
], ],
}; };
function isChartEmpty(chartData) { function isChartEmpty(chartData) {
if (!chartData) { if (!chartData) {
return true; return true;
} }
for (let i = 0; i < chartData.length; i++) { for (let i = 0; i < chartData.length; i++) {
if (chartData[i] && chartData[i].data) {
const hasNonZeroValues = chartData[i].data.some((value) => value !== 0); if (chartData[i]) {
if (hasNonZeroValues) { const hasNonZeroValues = chartData.some((value) => value !== 0);
return false; if (hasNonZeroValues) {
} return false;
} }
} }
return true; }
return true;
} }
// chart constructor // chart constructor
@@ -73,7 +74,7 @@ $.ajax({
"X-Requested-With": "XMLHttpRequest", "X-Requested-With": "XMLHttpRequest",
}, },
success: (response) => { success: (response) => {
if (isChartEmpty(response.data)) { if (isChartEmpty(response.objective_value)) {
$("#objectiveChart") $("#objectiveChart")
.parent() .parent()
.html( .html(
@@ -174,7 +175,7 @@ $.ajax({
"X-Requested-With": "XMLHttpRequest", "X-Requested-With": "XMLHttpRequest",
}, },
success: (response) => { success: (response) => {
if (isChartEmpty(response.data)) { if (isChartEmpty(response.key_result_value)) {
$("#keyResultChart") $("#keyResultChart")
.parent() .parent()
.html( .html(
@@ -274,7 +275,7 @@ $.ajax({
"X-Requested-With": "XMLHttpRequest", "X-Requested-With": "XMLHttpRequest",
}, },
success: (response) => { success: (response) => {
if (isChartEmpty(response.data)) { if (isChartEmpty(response.feedback_value)) {
$("#feedbackChart") $("#feedbackChart")
.parent() .parent()
.html( .html(