[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 () {
//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({
type: "GET",
url: "/onboarding/hired-candidate-chart",

View File

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