<?php
    // session_start();
    // if(!isset($_SESSION['user']))
    // {
    //     header('location:index.php');
    // }
    include('config.php');
    // $user_name = $_SESSION['user'];
?>

<!DOCTYPE html>
<html lang="en" class="light-style customizer-hide">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
        <title>Dynata Dashboard</title>
        <meta name="description" content="" />
        <!-- Fonts -->
        <link rel="preconnect" href="https://fonts.googleapis.com" />
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
        <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css2?family=Liter&display=swap" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap" rel="stylesheet">
        
        <link href="assets/css/main.d810cf0ae7f39f28f336.css" rel="stylesheet">
        <link href="assets/css/animate.css" rel="stylesheet">
        <link href="assets/css/animate.min.css" rel="stylesheet">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/fontawesome.min.css" integrity="sha512-d0olNN35C6VLiulAobxYHZiXJmq+vl+BGIgAxQtD5+kqudro/xNMvv2yIHAciGHpExsIbKX3iLg+0B6d0k4+ZA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> -->
        <link rel="stylesheet" href="assets/select2/select2.min.css">
        <link rel="stylesheet" href="https://cdn.datatables.net/2.0.3/css/dataTables.dataTables.css" />
        <script type="text/javascript" src="assets/scripts/jquery.min.js"></script>
        <link rel="stylesheet" href="assets/css/styleX.css">
        <link rel="stylesheet" href="assets/css/styleX2.css">
        <!-- <link rel="stylesheet" href="assets/css/styleX3.css"> -->
		<script src="https://cdn.jsdelivr.net/npm/pptxgenjs@3.11.0/dist/pptxgen.bundle.js"></script>

        <style>
            body {
                font-family: "Roboto", serif;
                font-size: 16px;
                color: #333;
            }
            h1, h2, h3, h4, h5, h6,input, button, select, optgroup, textarea {
                font-family: "Open Sans", serif;
                font-weight: bold;
                color: #000;
            }
            /* @font-face {
                font-family: 'Aptos';
                src: url('assets/fonts/aptos-font/Aptos-Regular.ttf') format('truetype');
                font-weight: normal;
                font-style: normal;
            }

            @font-face {
                font-family: 'Aptos';
                src: url('../fonts/Aptos-Bold.ttf') format('truetype');
                font-weight: bold;
                font-style: normal;
            }
            body {
                font-family: 'Aptos', sans-serif !important;
                font-size: 16px;
                color: #333;
            }

            h1, h2, h3, h4, h5, h6,input, button, select, optgroup, textarea {
                font-family: 'Aptos', sans-serif !important;
                font-weight: bold;
                color: #000;
            } */
            .top_col
            {
                max-width:100px !important;
            }
            .offscreen {
            position: absolute;
            top: -10000px;
            left: -10000px;
            visibility: hidden;
        }
        #ppt_frame
        {
            position: absolute;
            top: 0px;
            /* z-index: 999999; */
            width: 100%;
            height: 100%;
            display:none;
        }
        iframe
        {
            width: 100%;
            height: 100%;
        }
        .left-section, .right-section {
            max-height: 430px; /* Adjust height as needed */
            overflow-y: auto;
            overflow-x: hidden;
        }

        /* .pr2, .pr4 {
            padding-right: 15px;
        } */

        .cardBg {
            background-color: #FFFFFF; /* Adjust to match your theme */
            border: 1px solid #ddd;
            border-radius: 5px;
            padding: 5px;
        }
        .card-header>.nav {
            margin-left: 0rem !important;
            height: 100%;
            width: 100%;
        }
        .card-header {
            height: 2.5rem;
        }
        .nav-link {
            display: block;
            padding: .2rem 1rem;
        }
        .female_selected_shadow
        {
            filter: drop-shadow(0px 3px 7px #FF94D4);
        }
        .male_selected_shadow
        {
            filter: drop-shadow(0px 3px 7px #8BCAFF);
        }
        .selected_shadow
        {
            filter: drop-shadow(0px 0px 7px #000000);
        }
        .switchG {
            position: relative;
            height: 32px;
            width: auto;
            margin: 0px;
            background: #FFFFFF;
            border-radius: 32px;
            left: 4%;
            float:right;

        }

        .switch-labelG {
            font-weight: bold;
            position: relative;
            z-index: 2;
            float: left;
            width: 70px;
            line-height: 32px;
            font-size: 12px;
            color: #676a6c;
            text-align: center;
            cursor: pointer;
            margin-bottom:0px;
        }

        .switch-inputG {
            display: none;
        }

        .switch-inputG:checked + .switch-labelG {
            color: #FFF;
            transition: 0.15s ease-out;
            transition-property: color, text-shadow;
        }

        .switch-inputG:checked + .switch-labelG-y ~ .switch-selectorG {
            transform: translateX(0%);
            background-color: #1AB394;
        }

        .switch-inputG:checked + .switch-labelG-i ~ .switch-selectorG {
            transform: translateX(200%);
            background-color: #f8ac59;
        }

        .switch-inputG:checked + .switch-labelG-n ~ .switch-selectorG {
            transform: translateX(100%);
            background-color: #ed5565;
        }

        .switch-selectorG {
            position: absolute;
            z-index: 1;
            top: 0px;
            left: 0px;
            display: block;
            width: 70px;
            height: 32px;
            border-radius: 32px;
            background-color: #1ab394;
            transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
        }
        label {
    display: inline-block;
    margin-bottom: .5rem;
    font-size: 0.8rem;
    font-weight: 400;
}
.btn-group .btn {
    font-size: .7rem;
    font-weight: 500;
}
.vertical-nav-menu {
    margin: 0;
    padding: 0;
    position: relative;
    list-style: disc;
}
.vertical-nav-menu li a {
    height: auto !important;
}
.yesno_img
{
    height: 40px;
    width: 40px;
}

.cat_img
{
    height: 40px;
    width: 40px;
}

h6.img_txt {
    font-size: 0.7rem;
}
.cardShadow {
    box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px !important;
}

.cardShadow2 {
    box-shadow: rgba(0, 0, 0, 0.16) 0px 6px 6px, rgba(0, 0, 0, 0.23) 0px 6px 6px !important;
}

img.toggle_cat {
    height: 25px;
}
.app-header {
   
    z-index: 999;
    
}
ul.vertical-nav-menu > li.mm-active > ul.mm-show > li.mm-active.active > a[aria-expanded="true"] {
    background-color: #002060 !important;
    color: #FFFFFF !important;
    font-weight: 500 !important;
}
.scroll-section
{
    max-height: 100%; 
    overflow-y: auto;
    overflow-x: hidden;
}

.logo_div
{
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    margin-top:5px;
}

.dynata_logo1
{
    height: 40px;
}

.dynata_logo2
{
    height: 70px;
}
.app-header__logo
{
    width: 5%;
}
.app-theme-white .app-footer .app-footer__inner, .app-theme-white .app-header {
    background-color: white !important;
}
.bottom_border_div {
    height: 1px;
    background-color: #E97132;
    border-radius: 50px;
    width: 90%;
    margin: 0px auto;
}
.custom_base {
    font-size: 0.6rem;
    text-align: right;
    padding-right: 5px;
}
.qno {
    letter-spacing: 0px;
    font-size: 0.6rem;
}
.app-header {
    height: 50px;
    display: flex;
    align-items: normal;
}

.app-header__content,.app-header-left,.app-header-right
{
    height: 100% !important;
}
.app-header__content
{
    padding:0px !important;
}
.app-header-left
{
    display: block !important;
    width:22%
}
.app-header-right
{
    width:100%;
    align-items: start !important;
    flex-direction: column !important;
}

.filterDiv
{
    display:flex;
    width:100%
}

.filterDiv2
{
    display:flex;
    width:100%
}

.allfilterSpace
{
    display: block;
    width: 83%;
}

.random1
{
    display:flex;
}

.random2
{
    display:flex;
    margin-left:229px;
}

.allbuttonSpace
{
    display:flex;
    width:19%
}

.overallbasediv
{
    text-align:center;
    margin-left:-16px;
    border-radius:5px;
    background-color:#002060;
    max-height:30px;
}
.heading_div {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ashclassX
{
    margin-top: 0px
}

.ashclassX2
{
    margin-top: -1vh;
}

.ashiconX
{
    font-size:1.3rem;
    color:#002060;
}

.ashiconX2
{
    font-size:1.2rem;
    color:#002060;
}

.outer_li 
{
    margin-left: 2rem;
}



@media screen and (max-width: 1285px) and (max-height: 805px) {
    .ashiconX
    {
        font-size:1.1rem;
        color:#002060;
    }

    .ashiconX2
    {
        font-size:1.0rem;
        color:#002060;
    }
}
.custom-break {
    margin: -10px 0;
}

.addFD
{
    background-color:#ffe6cc !important;
}

.lowerBase
{
    color : #ff3333;
}

.highcharts-label > text
{
    font-weight: normal !important;
    font-size: 0.8rem !important;
}

.circle {
    background-color: #002060;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left:-8px;
}

.trendconsX
{
    text-align:center;
    font-weight:600;
    font-size:1.2rem;
    margin:0px auto
}

h6.placeholder {
    font-size: 0.8rem;
    text-align: center;
    margin-top: 10px;
    font-weight: 500;
    font-style: italic;
}

@media only screen and (min-width: 800px) and (max-width: 1400px) {
        /* #overallBase
        {
            font-weight: 500 !important;
            color:pink !important;
        }
        h6
        {
            font-size:0.9rem !important;
        }
        h5
        {
            font-size:13px !important;
        } */

        /* h4
        {
            font-size:1rem !important;
        } */
        
        .highcharts-axis-labels.highcharts-xaxis-labels 
        {
            font-size: 0.8rem !important;
        }
        .nav-item a.active {
            font-size: 0.77rem;
        }
        .card-header>.nav .nav-link {
            font-size: 0.77rem;
        }
        
        .vertical-nav-menu li a {
            font-size:0.7rem !important;
        }
        /* .app-sidebar {
            width: 220px !important;
            min-width: 220px !important;
        } */
        /* button.multiselect.dropdown-toggle.btn.btn-default {
            margin-top: 5px !important;
            border: 1px solid grey !important;
            width: 70px !important;
            margin-left: 3px !important;
            margin-bottom: 5px !important;
            background-color: #E7F4FE;
            text-align: left !important;
            padding-left: 5px !important;
            padding-right: 5px !important;
            box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px !important;
            text-transform: uppercase;
            color: #002060;
            font-size: 0.5rem;
        }

        .btn-brandXXX {
            color: black !important;
            height: 25px;
            cursor: pointer;
            margin-bottom: 5px;
            box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
            font-size: 0.6rem;
            text-transform: uppercase;
            color: black;
            width: 65px;
        }

        .btn-brandXXX2 {
            height: 26px;
            cursor: default;
            margin-bottom: 5px;
            border: 1px solid black;
            box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
            font-size: 0.7rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 10px;
            background-color: white;
        }

        .circle {
            background-color: #002060;
            height: 15px;
            width: 15px;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-left: -8px;
        }

        .fa-filter {
            font-size: 8px;
            color: white;
        } */
        /* .trendconsX
        {
            text-align:center;
            font-weight:600;
            font-size:1.1rem;
            margin:0px auto
        }
        .dynata_logo1 {
    height: 30px;
}
        .dynata_logo2 {
            height: 60px;
        }

        .app-header 
        {
            height:147px !important;
        }
        .sidebar 
{
    height: 76%;
    width: 0;
    position: fixed;
    top: 147px;
    left: 0;
    background-color: #F2F2F2;
    overflow-x: hidden;
    padding-top:10px;
    transition: 0.5s;
}
.fixed-header .app-main {
    padding-top: 147px;
} */

    .btn-brandXXX 
    {
        color: black !important;
        height: 29px;
        cursor: pointer;
        margin-bottom: 5px;
        box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
        font-size: 0.6rem;
        text-transform: uppercase;
        color: black;
        width: 65px;
    }

    .btn-brandXXX2 {
        height: 29px;
        cursor: default;
        margin-bottom: 5px;
        border: 1px solid black;
        box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
        font-size: 0.7rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        background-color: white;
    }

    .circle {
        background-color: #002060;
        height: 15px;
        width: 15px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-left: -8px;
    }

    .fa-filter {
        font-size: 8px;
        color: white;
    }
    .trendconsX
    {
        text-align:center;
        font-weight:600;
        font-size:1.1rem;
        margin:0px auto
    }
            
    .dynata_logo1 
    {
        height: 30px;
    }

    .dynata_logo2 
    {
        height: 60px;
    }

    .random2
    {
        display:flex;
        margin-left:215px;
    }
}

li::marker 
{
    font-size: 0.7em !important;
}

.section1 h6
{
    font-size:0.781rem;
    color: #446391;
    line-height: 1.4;
    font-weight:500;
}

.section2 h6
{
    font-size:0.781rem;
    color: #446391;
    line-height: 1.4;
    font-weight:500;
}

.section3
{
    margin-top: 40px;
}

.section4 h6
{
    font-size:0.781rem;
    color: #446391;
    font-style: italic;
    line-height: 1.4;
    font-weight:500;
}

.section5 h6
{
    font-size:0.781rem;
    color: #446391;
    line-height: 1.4;
    font-weight:500;
}

.section6 h6
{
    font-size:0.781rem;
    color: #446391;
    line-height: 1.4;
    font-weight:500;
}

.written_content
{
    padding:10px 10px;
}

.country_flg_div
{
    display: flex;
    background-color: #E4ECF3;
    justify-content: space-around;
    border-radius: 20px;
    margin-top:10px;
}

.country_flg_img img
{
    height:50px;
    margin-top:10px;
}

.country_flg_img 
{
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-content: stretch;
    justify-content: center;
    align-items: center;
}

table.section7_tbl thead th {
    font-size: 0.8rem;
    font-weight: 600;
}

table.section7_tbl {
    width: 100%;
}

table.section7_tbl thead th {
    font-size: 0.8rem;
    font-weight: 600;
    background-color: #DBDEE8;
}

table.section7_tbl tbody td {
    font-size: 0.8rem;
    font-weight: 600;
}
span.setImg {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    gap: 5px;
    margin-left: 20px;
}

.cpcp
{
    background-color: #F8FAFC;
    height: 90%;
    margin-top: 5%;
    margin-bottom: 5%;
    padding: 10px;
    display: flex;
    vertical-align: bottom;
    align-items: center;
    border-radius: 10px;
    font-style: italic;
}

.newD
{
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    border: 1px solid #D3D3D3;
    padding: 10px 0px;
}

.img_txt
{
    
    display: flex;
    flex-direction: column;
    align-items: center;
}
.newcountryf
{
    height: 45px;
    width: 45px;
}

.newcountryt, .newcountryp {
    font-size: 0.9rem;
    font-weight: 500;
}

.pr13 {
    margin-right: -18px;
}

.pr14 {
    margin-left: -12px;
    margin-right: -15px;
}
.pr15 {
    margin-left: -15px;
}

.additionalpadding
{
   margin: 0px 0.1rem;
}

.newborder
{
    border-right: 0px;
    border-bottom: 0px;
}

.newborder3
{
    border-bottom: 0px;
}

.newborder2
{
    border-right: 0px;
}

.custom-tab-pane1x h5.div-head , .Qtext{
    font-size: 11px;
}


.xChart {
    margin: 5px; 
}
.xChart {
    padding-top: 10%;
}
.xbar {
    border: 1px solid;
    margin-bottom: 10%;
    padding: 2%;
    text-align: center;
    font-size: 12px;
}
.xbar {
    margin: 0 auto;
}

.xbar.bar1 {
    background: #1C2977;
    color: #FFF;
}

.xbar.bar2 {
    background: #2A3EB3;
    color: #FFF;
}

.xbar.bar3 {
    background: #5164D6;
    color: #FFF;
}

.xbar.bar4 {
    background: #97A2E6;
    color: #FFFFFF;
}

.xbar.bar5 {
    background: #B9C1EF;
    color: #000000;
}

.xbar.bar6 {
    background: #DCE0F7;
    color: #000000;
}

.xbar.bar7 {
    background: #DBDEE8;
    color: #000000;
}

.labelss {
    padding-top: 10%;
    margin: auto 5px;
}

.rox1 .xchartRow.r4 {
    border-bottom: 0px solid gray;
}
.rox2 .xchartRow.r7 {
    border-bottom: 0px solid gray;
}
.xchartRow {
    font-size: 12px;
    text-align: center;
    padding: 3.5% 1%;
}

.xbar_row {
    padding: 1% 0% !important;
}

.rox2 .xChart {
    border-left: 2px solid;
}

.rox2 .xbar {
    margin: 0;
}
.rox2 .xChart {
    border-left: 1px solid #7e7e7e;
}
.rox2 .xbar {
    box-shadow: 4px 4px 9px 0px #c7c7c7;
}
.rox2 .xbar {
    border: 1px solid transparent;
}
.rox2 .xbar.bar5 ,
.rox2 .xbar.bar6 ,
.rox2 .xbar.bar7 {
    background: #b4c7e7;
}

/* .custom_tab_selection {
    display: flex;
    gap: 10px;
    align-items: end;
}

.custom_tab_name {
    font-size: 0.9rem;
    font-weight: 400;
}

.custom_input {
    width: 20px;  
    height: 20px;
    accent-color: black; 
} */

.custom_tab_selection {
    display: flex;
    gap: 10px;
    align-items: center; /* Aligns items vertically in the center */
}

.custom_tab_name {
    font-size: 0.9rem;
    font-weight: 400;
    margin-top:7px;
}

.custom_input {
    width: 20px;  /* Adjust size */
    height: 20px;
    accent-color: black; /* Change selected color to black */
}

.per {
    font-size: 0.7rem !important;
}

h6#activetabname {
    font-size: 1.2rem;
    font-weight: 600;
    color: #002060;
    text-align: center;
}

#activetabnamedefination
{
    font-size: 0.7rem;
    font-weight: 600;
    color: #002060;
    text-align: center;
    font-style:italic;
}

span.firstTxt {
    font-size: 0.7rem;
    font-weight: 600;
}

li#outer_0 {
    list-style: none;
    margin-left:0.5rem;
}
.nxt_head {
    margin-left: 1rem;
    font-weight:bold;
}
#outer_0 > a {
    font-size: 1.1rem !important;
    font-weight: bold !important;
}

.pikachutxt {
    font-size: 0.6rem;
    font-weight: 600;
    color: #002060;
    text-align: center;
    font-style: italic;
}

.fixing
{
    padding-top:110px;
}

.glossTbl tbody tr td:nth-child(1) {
    width: 10%;
}

.glossTbl tbody tr td:nth-child(2) {
    width: 30%;
    text-align:left;
}

.glossTbl tbody tr td:nth-child(3) {
    text-align:left;
}

.additionalFilterBtn
{
    background-color: white;
    position: absolute;
    left: 5px;
    top: 4px;
    height: 25px;
}

.filter_wrap_div {
    width: 50%;
    margin: 0px auto;
    cursor:pointer !important;
}

.customfilterselect
{
    background-color: aliceblue;
    box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
    border-radius:10px;
}
.contentX {
    display: flex;
    justify-content: space-between;
}

.contentX1 {
    margin-top:20px;
}

.contentX2 {
    width: 30%;
}
 /* .tableZZ {
        display: grid;
        grid-template-columns: 60px repeat(7, 90px);
        gap: 2%;
        padding: 5px;
        align-items: center;
      } */


      .tableZZ {
    display: grid;
    grid-template-columns: 12% repeat(7, 12%);
    gap: 1%;
    padding: 1%;
    align-items: center;
}

      .labelZZ {
        font-weight: bold;
        font-size: 14px;
        text-align: left;
      }

      .headerZZ {
        font-weight: bold;
        font-size: 14px;
        text-align: center;
         display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        font-weight: 600;
        font-size: 2vh;
      }
      .headerZZ img {
        width: 30px;
        height: 30px;
        border-radius: 60px;
        box-shadow: 2px 2px 5px -2px black;
        }

      .cellZZ {
        text-align: center;
      }

      /* .donutZZ {
        position: relative;
        width: 60px;
        height: 60px;
        margin: 0 auto;
      } */

        .donutZZ {
    position: relative;
    width: 50px;
    height: 50px;
    margin: 0 auto;
    font-size: 11px !important;
}

      .donutZZ svg {
        transform: rotate(-90deg);
      }

      .donutZZ circle {
        fill: none;
        stroke-width: 6;
      }

      .trackZZ {
        stroke: #e0e0e0;
      }

      .progressZZ {
        stroke: black;
        stroke-linecap: round;
      }

      .valueZZ {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 14px;
        font-weight: bold;
        color: black;
      }

      /* .tableZZ { 
  display: grid; 
  grid-template-columns: 60px repeat(7, 90px);
  gap: 10px;
  padding: 5px;
  align-items: center;
} */

.headerZZ { 
  font-weight: bold;
  font-size: 14px;
  text-align: center;
}

.labelZZ { 
  font-size: 10px;
  text-align: left;
}

/* .donutZZ { 
  position: relative;
  width: 50px;
  height: 50px;
  margin: 0 auto;
} */

.donutZZ svg {
  display: block;
  transform: rotate(-90deg); /* Start donut from top */
}

.donutZZ circle {
  transition: stroke-dashoffset 0.3s;
}

.donutZZ .value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: black;
  font-weight: bold;
  text-align: center;
}





#purchase_behaviour_chart2_y th, #purchase_behaviour_chart2_y td {
    padding: 8px;
}

#purchase_behaviour_chart2_y2 th, #purchase_behaviour_chart2_y2 td {
    padding: 8px;
}

.data_table thead th {
    background: #1976d2;
    color: white;
    font-size: 0.8rem;
}

.quickfix{
    text-align: end !important;
    margin-left: 45%;
    display:none !important;
}

tr.allbase {
    background-color: white !important;
    border: none !important;
    font-size: 0.7rem !important;
}

.allbase td{
    border: none !important;
    font-size: 0.7rem !important;
    padding: 0px;
}
        </style>
    </head>

    <body>
        <div class="app-container app-theme-white body-tN-shadow fixed-sidebar fixed-header" id="app-containerX">
            <div class="app-header" style="height:30px;background-color:#FFFFFF">
                <div class="app-header__content">
                    <div class="app-header-left">
                        <div class="logo_div" style="background-color:#FFFFFF">
                            <img class="dynata_logo1" src="assets/images/dynata_logo.png" alt="">
                            <img class="dynata_logo2" src="assets/images/dynata_logo3.png" alt="">
                        </div>
                        <div class="heading_div mt-3" style="background-color:#FFFFFF">
                            <button type="button" class="btn btn-sm btn-brand" onclick="tabSidebar()" style="height:30px;cursor:pointer;border:0px" id="openbtn" data-status="1">
                                <i class="fa fa-bars" style="font-size:1.3rem;color:#002060"></i>
                            </button>
                            <h4 class="trendconsX"><span style="color:#002060">CONSUMPTION</span> <span style="color:#E97132;font-style: italic">TRENDS</span></h4>
                        </div>
                    </div>
                    <div class="app-header-right" style="padding-left:5px;background-color:#002060">
                        <div class="filterDiv">
                            <div class="allfilterSpace">
                                <div class="random1">
                                    <div class="ashclassX" style="margin-right:3px">
                                        <div style="margin-top:5px">
                                            <button type="button" class="btn btn-brandXXX2" style="background-color:white">
                                                <span class="circle">
                                                    <i class="fa fa-filter"></i>
                                                </span>
                                                <span>FILTER</span>
                                            </button>
                                        </div>
                                    </div>
                                    <div class="ashclassX">
                                        <div style="margin-top:5px">
                                            <button type="button" class="btn-transition btn btn-light btn-sm btn-brandXXX" onclick="flagConstruct()" style="background-color:#adebad" data-toggle="tooltip" data-placement="bottom" title="">
                                                Apply
                                            </button>
                                            <button type="button" class="btn-transition btn btn-light btn-sm btn-brandXXX" onclick="resetFilters()" style="background-color:#ff9999" data-toggle="tooltip" data-placement="bottom" title="">
                                                Reset
                                            </button>
                                        </div>
                                    </div>
                                    <div class="ashclassX">
                                        <select id="quarter" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            <?php 
                                                foreach($quarter as $key => $value){
                                                    echo '<option value="'.($key+1).'" data-name="'.$value.'">'.$value.'</option>'; 
                                                }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="ashclassX">
                                        <select id="region" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            <?php 
                                                foreach($region as $key => $value){
                                                    echo '<option value="'.($key+1).'" data-name="'.$value.'">'.$value.'</option>'; 
                                                }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="ashclassX">
                                        <select id="country" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important" onchange="countryFX(this.id);">
                                            <?php 
                                                foreach($country as $key => $value){
                                                    echo '<option value="'.($key+1).'" data-name="'.$value.'">'.$value.'</option>'; 
                                                }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="ashclassX">
                                        <select id="city" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            
                                        </select>
                                    </div>
                                </div>
                                <div class="random2">
                                    <div class="ashclassX2">
                                        <select id="age" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            <?php 
                                                foreach($ageX as $key => $value){
                                                    echo '<option value="'.$key.'" data-name="'.$value.'">'.$value.'</option>'; 
                                                }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="ashclassX2">
                                        <select id="gender" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            <?php 
                                                foreach($gender as $key => $value){
                                                    echo '<option value="'.($key+1).'" data-name="'.$value.'">'.$value.'</option>'; 
                                                }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="ashclassX2">
                                        <select id="HHI" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            
                                        </select>
                                    </div>
                                    <div class="ashclassX2" style="display:none">
                                        <select id="HHI2" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            
                                        </select>
                                    </div>
                                    <div class="ashclassX2">
                                        <select id="childrenHouseholdType" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            <?php 
                                                foreach($child as $key => $value){
                                                    echo '<option value="'.($key+1).'" data-name="'.$value.'">'.$value.'</option>'; 
                                                }
                                            ?>
                                        </select>
                                    </div>
                                    <!-- <div class="ashclassX2">
                                        <select id="halal" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            <?php 
                                                // foreach($halal as $key => $value){
                                                //     echo '<option value="'.($key+1).'" data-name="'.$value.'">'.$value.'</option>'; 
                                                // }
                                            ?>
                                        </select>
                                    </div> -->
                                    <!-- <div class="ashclassX2">
                                        <select id="race" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                        
                                        </select>
                                    </div> -->
                                    <div class="ashclassX2" style="display:none">
                                        <select id="protienF" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            <?php 
                                                foreach($PDC0label as $key => $value){
                                                    echo '<option value="'.($key).'" data-name="'.$value.'">'.$value.'</option>'; 
                                                }
                                            ?>
                                        </select>
                                    </div>
                                </div>
                                <div class="random2" style="display:none">
                                    <div class="ashclassX2">
                                        <select id="category_hml" class="form-control" multiple="multiple" style="height:35px;font-size:0.8rem !important;border: 1px solid grey !important">
                                            <?php 
                                                foreach($category_HML as $key => $value){
                                                    echo '<option value="'.$key.'" data-name="'.$value.'">'.$value.'</option>'; 
                                                }
                                            ?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div style="width:2%"></div>
                            <div class="allbuttonSpace">
                                <div class="ashclassX">
                                    <div style="margin-top:5px">
                                        <button type="button" class="btn btn-sm btn-brand" data-value="Trends" onclick="trends(this);" style="height:30px;cursor:pointer;margin-bottom:5px;border:0px;background-color:white" id="trends_btn">
                                            <i class="fa fa-line-chart ashiconX"></i>
                                        </button>
                                        <button type="button" class="btn btn-sm btn-brand" data-value="Tbl" onclick="swapTable(this);" style="height:30px;cursor:pointer;margin-bottom:5px;border:0px;background-color:white" id="swap_tbl_btn">
                                            <i class="fa fa-table ashiconX"></i>
                                        </button>
										
                                        <button type="button" class="btn btn-sm btn-brand" onclick="exportExcelFlag();" style="height:30px;cursor:pointer;margin-bottom:5px;border:0px;background-color:white">
                                            <i class="fa fa-file-excel-o ashiconX2"></i>
                                        </button>
										<button type="button" class="btn btn-sm btn-brand" onclick="exportPptFlag();" style="height:30px;cursor:pointer;margin-bottom:5px;border:0px;background-color:white">
                                            <i class="fa fa-file-powerpoint-o ashiconX2"></i>
                                        </button>
                                        <button type="button" class="btn btn-sm btn-brand" onclick="logout();" style="height:30px;cursor:pointer;margin-bottom:5px;border:0px;background-color:white">
                                            <i class="fa fa-power-off ashiconX2"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="filterDiv2">
                            <div id="filterdefination_overall_div" style="width:83%;border-radius: 5px;color:white">
                                <textarea class="paraX" style="height:auto;max-width:200px;word-wrap:break-word;display:none;color:#002060">Filters:All Selected</textarea>
                                <h6 class="mt-2 paraY" style="height:auto;color:#FFFFFF;font-size:0.8rem;font-weight:normal">Applied Filters:All Selected</h6>
                            </div>
                            <div style="width:2%"></div>
                            <div class="overallbasediv" style="width:15%">
                                <h6 class="ml-2 mt-2" style="height:auto;color:#FFFFFF;font-size:1rem;font-weight:normal">Sample Size:<span id="overallBase">517</span></h6>
                            </div>
                            <div id="filterdefination_trend_div" style="display:none">
                                <p class="ml-2 mt-3 paraYT" style="height:auto;color:#000000">Filters:All Selected</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div><!-- app-header div-->
            <div id="mySidebar" class="sidebar">
                <?php include("tabs.php"); ?>
            </div>
            <div class="app-main" id="main">
                <div class="splash">
                    <div class="splash-title">
                        <div class="spinner">

                        </div>
                    </div>
                </div>
                <div class="app-main__outer" style="background-color: #E4ECF3;">
                    <div class="app-main__inner" style="padding: 0px;padding-right:15px">
                        <div class="tab-content">
                            <div class="card cardShadow2 pr3" id="activetabnamedivsection" style="background-color:#DCEAF7; position: fixed; z-index: 99999;display:none;margin-top:0px;height:110px">
                                <div class="contentX">
                                    <div class="contentX1 mx-auto">
                                        <h6 class="ml-2 mt-2" id="activetabname">Category Consumption</h6>
                                        <h6 class="ml-2 mt-2" id="activetabnamedefination"></h6>
                                    </div>
                                    <div class="contentX2">
                                        <h5 class="div-head">
                                            <b><span class="qno">(S13)</span> Category HML (<i class="fa fa-filter" style="color:#002060"></i>)</b>
                                        </h5>
                                        <div class="bottom_border_div"></div>
                                        <div class="row">
                                            <div class="col-lg-4 text-center animate__animated animate__fadeInLeft">
                                                <div class="filter_wrap_div">
                                                    <h6 class="img_txt" style="margin-top:7px">Heavy</h6>
                                                    <h5 style="color:#73B74A" id="">23%</h5>
                                                </div>
                                            </div>
                                            <div class="col-lg-4 text-center animate__animated animate__fadeInLeft">
                                                <div class="filter_wrap_div">
                                                    <h6 class="img_txt" style="margin-top:7px">Medium</h6>
                                                    <h5 style="color:#FF9933" id="">23%</h5>
                                                </div>
                                            </div>
                                            <div class="col-lg-4 text-center animate__animated animate__fadeInLeft">
                                                <div class="filter_wrap_div">
                                                    <h6 class="img_txt" style="margin-top:7px">Light</h6>
                                                    <h5 style="color:#E6542D" id="">23%</h5>
                                                </div>
                                            </div>
                                        </div>
                                        <span class="custom_base" id="" style="float:right">(Base:1200)</span>
                                    </div>
                                </div>
                                <!-- <div class="row" style="margin-top:20px">
                                    
                                </div> -->
                            </div>
                            <!-- <div class="card cardShadow2 pr3" id="categorydivsection" style="background-color:#DCEAF7;position: fixed; right:25px; z-index: 99999;display:none;margin-top:0px;height:110px">
                                
                            </div> -->
<!----------------------------------------------------- OUTER TAB START ------------------------------------------------------------------>

<!----------------------------------------------------- OUTER TAB 1 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane1 active" id="tab-eg7-0-0" role="tabpanel" data-status="active" style="margin-top:5px;padding-top:0px">
    <div class="tab-content">
        <div class="row">
            <div class="col-lg-3"></div>
            <div class="col-lg-3">
                <div class="custom_tab_selection">
                    <input type="radio" value="1" class="custom_input fdsX" checked onchange="customtabchangeFunction(this);" />
                    <h6 class="custom_tab_name">Dairy Product</h6>
                </div>
            </div>
            <div class="col-lg-3">
                <div class="custom_tab_selection">
                    <input type="radio" value="2" class="custom_input fdsX" onchange="customtabchangeFunction(this);"/>
                    <h6 class="custom_tab_name">Baked Product</h6>
                </div>
            </div>
            <div class="col-lg-3">
                <div class="custom_tab_selection">
                    <input type="radio" value="3" class="custom_input fdsX" onchange="customtabchangeFunction(this);"/>
                    <h6 class="custom_tab_name">Health & Nutrition</h6>
                </div>
            </div>
        </div>
        <div class="tab-pane active" id="tab-eg9-2" role="tabpanel">
            <?php include "consumption1.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-3" role="tabpanel">
            <?php include "consumption2.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-61" role="tabpanel">
            <?php include "consumption3.php"; ?>
        </div>
        <div class="footerX mt-1"></div>
    </div>
</div>

<div class="tab-pane fixing custom-tab-pane1" id="tab-eg7-0-1" role="tabpanel" data-status="inactive" style="margin-top:5px;padding-top:0px">
    <div class="tab-content">
        <div class="row">
            <div class="col-lg-3"></div>
            <div class="col-lg-3">
                <div class="custom_tab_selection">
                    <input type="radio" value="4" class="custom_input fdsX2" checked onchange="customtabchangeFunction2(this);" />
                    <h6 class="custom_tab_name">Past 7 days</h6>
                </div>
            </div>
            <div class="col-lg-3">
                <div class="custom_tab_selection">
                    <input type="radio" value="5" class="custom_input fdsX2" onchange="customtabchangeFunction2(this);"/>
                    <h6 class="custom_tab_name">Past 3 months</h6>
                </div>
            </div>
            <div class="col-lg-3">
                <div class="custom_tab_selection">
                    <input type="radio" value="6" class="custom_input fdsX2" onchange="customtabchangeFunction2(this);"/>
                    <h6 class="custom_tab_name">Past 1 year</h6>
                </div>
            </div>
        </div>
        <div class="tab-pane active" id="tab-eg9-73" role="tabpanel">
            <?php include "consumption4.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-74" role="tabpanel">
            <?php include "consumption5.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-75" role="tabpanel">
            <?php include "consumption6.php"; ?>
        </div>
        <div class="footerX mt-1"></div>
    </div>
</div>

<!----------------------------------------------------- OUTER TAB 1 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 2 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane2" id="tab-eg7-1-0" role="tabpanel" data-status="inactive">
    <?php include "CH_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane2" id="tab-eg7-1-1" role="tabpanel" data-status="inactive">
    <?php include "CH_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 2 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 3 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane3" id="tab-eg7-2-0" role="tabpanel" data-status="inactive">
    <?php include "CM.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 3 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 4 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane4" id="tab-eg7-3-0" role="tabpanel" data-status="inactive">
    <?php include "FD_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane4" id="tab-eg7-3-1" role="tabpanel" data-status="inactive">
    <?php include "FD_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane4" id="tab-eg7-3-2" role="tabpanel" data-status="inactive">
    <?php include "FD_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane4" id="tab-eg7-3-3" role="tabpanel" data-status="inactive">
    <?php include "FD_4.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane4" id="tab-eg7-3-4" role="tabpanel" data-status="inactive">
    <?php include "FD_5.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane4" id="tab-eg7-3-5" role="tabpanel" data-status="inactive">
    <?php include "FD_6.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane4" id="tab-eg7-3-6" role="tabpanel" data-status="inactive">
    <?php include "FD_7.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 4 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 5 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane5" id="tab-eg7-4-0" role="tabpanel" data-status="inactive">
    <?php include "Y_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane5" id="tab-eg7-4-1" role="tabpanel" data-status="inactive">
    <?php include "Y_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane5" id="tab-eg7-4-2" role="tabpanel" data-status="inactive">
    <?php include "Y_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane5" id="tab-eg7-4-3" role="tabpanel" data-status="inactive">
    <?php include "Y_4.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane5" id="tab-eg7-4-4" role="tabpanel" data-status="inactive">
    <?php include "Y_5.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 5 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 6 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane6" id="tab-eg7-5-0" role="tabpanel" data-status="inactive">
    <?php include "MD_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane6" id="tab-eg7-5-1" role="tabpanel" data-status="inactive">
    <?php include "MD_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane6" id="tab-eg7-5-2" role="tabpanel" data-status="inactive">
    <?php include "MD_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane6" id="tab-eg7-5-3" role="tabpanel" data-status="inactive">
    <?php include "MD_4.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 6 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 7 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane7" id="tab-eg7-6-0" role="tabpanel" data-status="inactive">
    <?php include "CEM_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane7" id="tab-eg7-6-1" role="tabpanel" data-status="inactive">
    <?php include "CEM_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane7" id="tab-eg7-6-2" role="tabpanel" data-status="inactive">
    <?php include "CEM_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 7 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 8 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane8" id="tab-eg7-7-0" role="tabpanel" data-status="inactive">
    <?php include "PD_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane8" id="tab-eg7-7-1" role="tabpanel" data-status="inactive">
    <?php include "PD_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane8" id="tab-eg7-7-2" role="tabpanel" data-status="inactive">
    <?php include "PD_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane8" id="tab-eg7-7-3" role="tabpanel" data-status="inactive">
    <?php include "PD_4.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 8 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 9 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane9" id="tab-eg7-8-0" role="tabpanel" data-status="inactive">
    <?php include "AD_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 9 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 10 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane10" id="tab-eg7-9-0" role="tabpanel" data-status="inactive">
    <?php include "CK_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 10 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 11 --------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane11" id="tab-eg7-10-0" role="tabpanel" data-status="inactive">
    <?php include "SD_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane11" id="tab-eg7-10-1" role="tabpanel" data-status="inactive">
    <?php include "SD_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane11" id="tab-eg7-10-2" role="tabpanel" data-status="inactive">
    <?php include "SD_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 11 --------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 12 --------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane12" id="tab-eg7-11-0" role="tabpanel" data-status="inactive" style="padding-top:105px">
    <?php include "CL_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 12 --------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 13 --------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane13" id="tab-eg7-12-0" role="tabpanel" data-status="inactive">
    <?php include "BC_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane13" id="tab-eg7-12-1" role="tabpanel" data-status="inactive">
    <?php include "BC_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane13" id="tab-eg7-12-2" role="tabpanel" data-status="inactive">
    <?php include "BC_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane13" id="tab-eg7-12-3" role="tabpanel" data-status="inactive">
    <?php include "BC_4.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 13 --------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 14 --------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane14" id="tab-eg7-13-0" role="tabpanel" data-status="inactive">
    <?php include "CC_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane14" id="tab-eg7-13-1" role="tabpanel" data-status="inactive">
    <?php include "CC_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane14" id="tab-eg7-13-2" role="tabpanel" data-status="inactive">
    <?php include "CC_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane14" id="tab-eg7-13-3" role="tabpanel" data-status="inactive">
    <?php include "CC_4.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 14 --------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 15 --------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane15" id="tab-eg7-14-0" role="tabpanel" data-status="inactive">
    <?php include "BAR_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane15" id="tab-eg7-14-1" role="tabpanel" data-status="inactive">
    <?php include "BAR_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane15" id="tab-eg7-14-2" role="tabpanel" data-status="inactive">
    <?php include "BAR_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane15" id="tab-eg7-14-3" role="tabpanel" data-status="inactive">
    <?php include "BAR_4.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 15 --------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 16 --------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane16" id="tab-eg7-15-0" role="tabpanel" data-status="inactive">
    <?php include "BB_1.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane16" id="tab-eg7-15-1" role="tabpanel" data-status="inactive">
    <?php include "BB_2.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<div class="tab-pane fixing custom-tab-pane16" id="tab-eg7-15-2" role="tabpanel" data-status="inactive">
    <?php include "BB_3.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 16 --------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 17 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane17" id="tab-eg7-16-0" role="tabpanel" data-status="inactive" style="margin-top:5px;padding-top:0px">
    <?php include "intro.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 17 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 18 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane18" id="tab-eg7-17-0" role="tabpanel" data-status="inactive" style="margin-top:5px;padding-top:0px">
    <?php include "profiling.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 18 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 19 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane19" id="tab-eg7-18-0" role="tabpanel" data-status="inactive" style="margin-top:5px;padding-top:0px">
    <?php include "health.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 19 ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 20 ---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane20" id="tab-eg7-19-0" role="tabpanel" data-status="inactive" style="margin-top:5px;padding-top:0px">
    <?php include "CM_T.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!----------------------------------------------------- OUTER TAB 20 bvbvbvb---------------------------------------------------->

<!-----------------------------------------------------OUTER TAB 21---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane21" id="tab-eg7-20-0" role="tabpanel" data-status="inactive" style="margin-top:5px;padding-top:0px">
    <?php include "CH_T.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!-----------------------------------------------------OUTER TAB 21---------------------------------------------------->


<!-----------------------------------------------------OUTER TAB 22---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane22" id="tab-eg7-21-0" role="tabpanel" data-status="inactive" style="margin-top:5px;padding-top:0px">
    <?php include "FD_T.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!-----------------------------------------------------OUTER TAB 22---------------------------------------------------->

<!-----------------------------------------------------OUTER TAB 23---------------------------------------------------->

<div class="tab-pane fixing custom-tab-pane23" id="tab-eg7-22-0" role="tabpanel" data-status="inactive" style="margin-top:5px;padding-top:0px">
    <?php include "Y_T.php"; ?>
    <div class="footerX mt-1"></div>
</div>

<!-----------------------------------------------------OUTER TAB 23---------------------------------------------------->




<!----------------------------------------------------- OUTER TAB END -------------------------------------------------------------------->
                        </div> <!-- tab-content -->
                    </div><!-- app-main inner-->
                </div><!-- app-main outer-->
            </div><!-- app-main div-->
        </div><!-- app-container div-->
        

        <div class="card animate__animated animate__fadeInDown" id="alert_div" style="display:none">
            <h6>Excel export is getting downloaded !!</h6>
        </div>
        <div class="card animate__animated animate__fadeInDown" id="alert_div2" style="display:none">
            <h6>Excel export is downloaded successfully !!</h6>
        </div>

        <div class="card animate__animated animate__fadeInDown" id="alert_div3" style="display:none">
            <h6>PPT export is getting downloaded !!</h6>
        </div>
        <div class="card animate__animated animate__fadeInDown" id="alert_div4" style="display:none">
            <h6>PPT export is downloaded successfully !!</h6>
        </div>

        <!-- <div class="popup-btn" onclick="openF()" id="filter_div">
            <a href="javascript:void(0)">
                FILTERS
            </a>
        </div> -->
        <div class="switchG" id="category_toggle_1" style="display:none;">
            <input id="switch-y_ps" name="trippleG_p" type="radio" value="Y" class="switch-inputG" checked/>
            <label for="switch-y_ps" class="switch-labelG switch-labelG-y active" data-target="#tab-eg9-6" data-name="Shopper" onclick="innertabClick(event)" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Protien Drink">
                <img class="toggle_cat" src="assets/images/protein_drink.png" alt="">
            </label>
            <input id="switch-n_pns" name="trippleG_p" type="radio" value="N" class="switch-inputG"/>
            <label for="switch-n_pns" class="switch-labelG switch-labelG-n" data-target="#tab-eg9-7" data-name="Non-Shopper" onclick="innertabClick(event)" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Protien Shake">
                <img class="toggle_cat" src="assets/images/protein_shake.png" alt="">
            </label>
            <input id="switch-i_pc" name="trippleG_p" type="radio" value="I" class="switch-inputG"/>
            <label for="switch-i_pc" class="switch-labelG switch-labelG-i" data-target="#tab-eg9-63" data-name="Combine" onclick="innertabClick(event)" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Protien Powder">
                <img class="toggle_cat" src="assets/images/protein_powder.png" alt="">
            </label>
            <span class="switch-selectorG"></span>
        </div>
        <div id="frame" style="display:none">
            
        </div>
        
        <script type="text/javascript" src="assets/scripts/main.d810cf0ae7f39f28f336.js"></script>
        <script type="text/javascript" src="assets/select2/select2.min.js"></script>
        <script async defer src="https://buttons.github.io/buttons.js"></script>
        <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
	    <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
        <script src="https://cdn.datatables.net/2.0.3/js/dataTables.js"></script>
        <script src="assets/wizard/js/jquery.steps.js"></script>
	    <script src="assets/wizard/js/main.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.min.js.map"></script>

        <!-- <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/modules/variable-pie.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/highcharts-more.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/modules/exporting.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/modules/offline-exporting.js"></script>
        <script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.20.1/package/dist/xlsx.full.min.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/modules/heatmap.js"></script>
        
        <script src="https://code.highcharts.com/highcharts-more.js"></script>
        <script src="https://code.highcharts.com/maps/modules/map.js"></script>
        <script src="https://code.highcharts.com/maps/modules/exporting.js"></script> -->
        <!-- <script src="https://cdn.jsdelivr.net/npm/pptxgenjs@3.3.1/dist/pptxgen.bundle.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/pptxgenjs/3.8.0/pptxgen.min.js"></script> -->

        <script src="https://cdn.jsdelivr.net/npm/pptxgenjs@4.0.1/dist/pptxgen.bundle.js"></script>

        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/highcharts.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/modules/variable-pie.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/highcharts-more.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/modules/exporting.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/modules/offline-exporting.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/modules/histogram-bellcurve.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/modules/wordcloud.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/modules/heatmap.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/modules/treemap.js"></script>
        <script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.20.1/package/dist/xlsx.full.min.js"></script>

         <!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/linways/table-to-excel@v1.0.4/dist/tableToExcel.js"></script> -->
        <script>
            ////////debugger;
            var flagg = ["dynata/flags/sg.png","dynata/flags/th.png","dynata/flags/ma.png","dynata/flags/in.png","dynata/flags/ph.jpg","dynata/flags/vi.jpg"];
            var flaggXX = ["","dynata/flags/sg.png","dynata/flags/th.png","dynata/flags/ma.png","dynata/flags/in.png","dynata/flags/ph.jpg","dynata/flags/vi.jpg"];
            var flagg2 = ["https://keresearch.in/dynata_demo/dynata/flags/sg.png","https://keresearch.in/dynata_demo/dynata/flags/th.png","https://keresearch.in/dynata_demo/dynata/flags/ma.png","https://keresearch.in/dynata_demo/dynata/flags/in.png","https://keresearch.in/dynata_demo/dynata/flags/ph.jpg","https://keresearch.in/dynata_demo/dynata/flags/vi.jpg"];
            
            var condX = ``;
            var condX2 = ``;
            var trendcondX = ``;
            var conX = ``;
            var filtercondX = ``;
            var trendsfiltercondX = ``;

            var dairymilkcondX = ``;
            var forzencondX = ``;
            var yougurtcondX = ``;
            var maltcondX = ``;
            var condensedcondX = ``;
            var protiencondX = ``;
            var adultcondX = ``;
            var cakecondX = ``;
            var sportscondX = ``;
            var choclatecondX = ``;
            var biscuitcondX = ``;
            var chipscondX = ``;
            var barcondX = ``;
            var breadcondX = ``;
            
            var overallBase = ``;
            var excelStatus = false;
            var trendStatus = false;
            var activetabid = 'tab-0-0';
            var currentID = 'tab-eg7-0-0';
            var dataOuter = '0';
            var dataInner = '0';
            var targetedHighchartContainer = $(`#tab-eg7-6 .overall_div_chart .chart_div .card > div`);
            var tblX = "w1";

            var innerTabE = ["Dairy milk (from cows)"]
            var classArr = [];
            var outerTab = <?php echo json_encode($tabs3); ?>;
            var innerTab = <?php echo json_encode($subtabs); ?>;
            var tabsDefination = <?php echo json_encode($tabs_defination); ?>;

            var statusArr = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
            
            var quarterTxt = [];
            var countryTxt = [];
            var regionTxt = [];
            var cityTxt = [];
            //var raceTxt = [];
            var HHITxt = [];
            var genderTxt = [];
            var ageTxt = [];
            var childrenHouseholdTypeTxt = [];
            //var halalTxt = [];

            var protienFTxt = [];

            var dairymilkFStatus1 = false;

            var frozenFStatus1 = false;
            var frozenFStatus2 = false;
            var frozenFStatus3 = false;
            var frozenFStatus4 = false;
            var frozenFStatus5 = false;
            var frozenFStatus6 = false;
            var frozenFStatus7 = false;

            var yougurtFStatus1 = false;
            var yougurtFStatus2 = false;
            var yougurtFStatus3 = false;
            var yougurtFStatus4 = false;
            var yougurtFStatus5 = false;

            var maltFStatus1 = false;
            var maltFStatus2 = false;
            var maltFStatus3 = false;
            var maltFStatus4 = false;

            var condensedFStatus1 = false;
            var condensedFStatus2 = false;
            var condensedFStatus3 = false;

            var protienFStatus1 = false;
            var protienFStatus2 = false;
            var protienFStatus3 = false;
            var protienFStatus4 = false;

            var adultFStatus1 = false;

            var cakeFStatus1 = false;

            var sportsFStatus1 = false;
            var sportsFStatus2 = false;
            var sportsFStatus3 = false;

            var choclateFStatus1 = false;

            var biscuitFStatus1 = false;
            var biscuitFStatus2 = false;
            var biscuitFStatus3 = false;
            var biscuitFStatus4 = false;

            var chipsFStatus1 = false;
            var chipsFStatus2 = false;
            var chipsFStatus3 = false;
            var chipsFStatus4 = false;

            var barFStatus1 = false;
            var barFStatus2 = false;
            var barFStatus3 = false;
            var barFStatus4 = false;

            var breadFStatus1 = false;
            var breadFStatus2 = false;
            var breadFStatus3 = false;

            var colorPallet68 = [
                "#273aa5",
                "#8391e2",
                "#d6daf5",
                "#55BAD0",
                "#63CABC",
            ]

            var colorPallet69 = [
                "#1C2977",
                "#273aa5",
                "#455ad3",
                "#8391e2",
                "#d6daf5",
                "#3480EE",
                "#3D97FF",
                "#55BAD0",
                "#63CABC",
                "#72D9A8",
                "#00ACC1",
                "#4DD0E1",
                "#80DEEA",
                "#B2EBF2",
                "#E0F7FA"
            ]

            var colorPallet = [
                "#4D6893",
                "#70A6FF",
                "#BBE48F",
                "#7C985E",
                "#EC891D",
                "#F2AD61",
                "#7F7F7F",
                "#D9D9D9"
            ]

            var colorPallet701 = [
                "#c8deff",
                "#70a7ff",
                "#156dff",
                "#0046b8"
            ]

            var colorPallet2 = [
                '#4596CE',
                '#1C4482',
                '#6685B7',
                '#A4B7D4',
                '#E1E7F1',
                '#00B0F0'
            ];
            var colorPallet4 = [
                '#4596CE',
                '#1C4482',
                '#6685B7',
                '#A4B7D4',
                '#00B0F0',
                '#1C2977',
            ];
            var colorPallet3 = [
                '#00B0F0',
                '#1C2977',
            ];
            var colorPallet = [
                // 'rgba(33, 150, 243, 0.4)',
                // 'rgba(96, 125, 139, 0.4)',
                // 'rgba(54, 162, 235, 0.4)',
                // 'rgba(25, 118, 210, 0.4)',
                // 'rgba(21, 101, 192, 0.4)',
                // 'rgba(66, 165, 245, 0.4)',
                // 'rgba(100, 181, 246, 0.4)'
                // 'rgba(3, 169, 244, 0.4)', 
                // 'rgba(2, 136, 209, 0.4)', 
                // 'rgba(1, 87, 155, 0.4)',  
                // 'rgba(0, 131, 143, 0.4)', 
                // 'rgba(0, 172, 193, 0.4)', 
                // 'rgba(77, 182, 172, 0.4)',
                // 'rgba(0, 191, 255, 0.4)', 
                // 'rgba(70, 130, 180, 0.4)' 
                "#ADD8E6", // Light Blue
                "#D3D3D3", // Light Grey
                "#A8E6CF", // Soft Teal
                "#D1C4E9", // Muted Purple
                "#FFF9C4", // Pale Yellow
                "#C8E6C9", // Cool Mint
                "#FFCCBC", // Warm Peach
                "#FFAB91", // Pastel Coral
                "#FFD180"  // Light Lavender
            ];



            var colorPalletX1 = [
                "#4D6893",
                "#7C985E",
            ]

            var colorPalletX2 = [
                "#4D6893",
                "#70A6FF",
                "#BBE48F",
            ]

            var colorPalletX3 = [
                "#4D6893",
                "#70A6FF",
                "#BBE48F",
                "#7C985E",
            ]

            var colorPalletX4 = [
                "#4D6893",
                "#70A6FF",
                "#BBE48F",
                "#7C985E",
                "#F2AD61",
            ]

            var colorPalletX5 = [
                "#4D6893",
                "#70A6FF",
                "#BBE48F",
                "#7C985E",
                "#EC891D",
                "#F2AD61",
                "#7F7F7F",
                "#D9D9D9"
            ]

            var colorPallet99 = [
                "#4D6893",
                "#70A6FF",
                "#BBE48F",
                "#7C985E",
                "#EC891D",
                "#F2AD61",
                "#7F7F7F",
                "#D9D9D9"
            ]


            var functionFlag = [
                [false,false],
                [false,false],
                [false],
                [false,false,false,false,false,false,false],
                [false,false,false,false,false],
                [false,false,false,false],
                [false,false,false],
                [false,false,false,false],
                [false],
                [false],
                [false,false,false],
                [false],
                [false,false,false,false],
                [false,false,false,false],
                [false,false,false,false],
                [false,false,false],
                [false],
                [false],
                [false],
                [false],
                [false],
                [false],
                [false],
                [false],
            ];

            var allAjax = [
                [consumptionAjax,consumptionAjax2],
                [firstAjax,firstAjaxN],
                [secondAjax],
                [thirdAjax, forthAjax, fifthAjax, sixthAjax, seventhAjax,eightthAjax,ninethAjax],
                [tenthAjax,eleventhAjax,twelvethAjax,thirteenthAjax,fourteenthAjax],
                [fifteenthAjax,sixteenthAjax,seventeenthAjax,eighteenthAjax],
                [nineteenthAjax,twentythAjax,twentyOnethAjax],
                [twentyTwothAjax,twentyThreethAjax,twentyFourthAjax,twentyFivethAjax],
                [twentySixthAjax],
                [twentySeventhAjax],
                [twentyEightthAjax,twentyNinethAjax,thirtythAjax],
                [thirtyOnethAjax],
                [thirtyTwothAjax,thirtyThreethAjax,thirtyFourthAjax,thirtyFivethAjax],
                [thirtySixthAjax,thirtySeventhAjax,thirtyEightthAjax,thirtyNinethAjax],
                [fortythAjax,fortyOnethAjax,fortyTwothAjax,fortyThreethAjax],
                [fortyFourthAjax,fortyFivethAjax,fortySixthAjax],
                [introAjax],
                [profileAjax],
                [healthAjax],
                [fortySeventhAjax],
                [fortyEighthAjax],
                [fortyNinthAjax],
                [fiftythAjax],
                [fiftyOneAjax],
            ];

            var ajaxFlag = [
                false,false,
                false,false,
                false,
                false,false,false,false,false,false,false,
                false,false,false,false,false,
                false,false,false,false,
                false,false,false,
                false,false,false,false,
                false,
                false,
                false,false,false,
                false,
                false,false,false,false,
                false,false,false,false,
                false,false,false,false,
                false,false,false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ];

            var consumptionLabel = ["Ever Tried","Consumed in Past 1 Year","Consumed in Past 3 Months","Consumed in Past 7 Days"]

            var quarterLabel = <?php echo json_encode($quarter); ?>;
            var countryLabel = <?php echo json_encode($country); ?>;
            var countryLabel3 = <?php echo json_encode($country3); ?>;
            var countryLabel4 = <?php echo json_encode($country4); ?>;
            var regionLabel = <?php echo json_encode($region); ?>;
            var cityLabel = <?php echo json_encode($city); ?>;
            var cityLabel2 = <?php echo json_encode($cityVietnam); ?>;
            var ageLabel = <?php echo json_encode($age); ?>;
            var ageLabelX = <?php echo json_encode($ageX); ?>;
            var ageLabelXXX = <?php echo json_encode($ageXXX); ?>;
            var ageLabel2 = <?php echo json_encode($age2); ?>;
            var genderLabel = <?php echo json_encode($gender); ?>;
            var raceLabel = <?php echo json_encode($race); ?>;
            var occupationLabel = <?php echo json_encode($occupation); ?>;
            var childrenLabel = <?php echo json_encode($children); ?>;
            var halalLabel = <?php echo json_encode($halal); ?>;
            var dietLabel = <?php echo json_encode($diet); ?>;
            var wfhLabel = <?php echo json_encode($P6L); ?>;
            var childrenLabel2 = <?php echo json_encode($child); ?>;
            var categoryHML = <?php echo json_encode($category_HML); ?>;

            var HHI_profile_label = <?php echo json_encode($HHI_profile_label); ?>;
            var HHI_profile_label2 = <?php echo json_encode($HHI_profile_label2); ?>;
            var HHI_filter_label = <?php echo json_encode($HHI_filter_label); ?>;

            // PD - Protein Drink

            var PDC0label = <?php echo json_encode($PDC0labelX); ?>;
            var PDC1label = <?php echo json_encode($PDC1labelX); ?>;
            var PDC1alabel = <?php echo json_encode($PDC1alabelX); ?>;
            var PDC2label = <?php echo json_encode($PDC2labelX); ?>;
            var PDC3label = <?php echo json_encode($PDC3labelX); ?>;
            var PDC5label = <?php echo json_encode($PDC5labelX); ?>;
            var PDC6label = <?php echo json_encode($PDC6labelX); ?>;
            var PDC7label = <?php echo json_encode($PDC7labelX); ?>;
            var PDC8label = <?php echo json_encode($PDC8labelX); ?>;
            var PDC9label = <?php echo json_encode($PDC9labelX); ?>;
            var PDC10label = <?php echo json_encode($PDC10labelX); ?>;
            var PDC11label = <?php echo json_encode($PDC11labelX); ?>;
            var PDC12label = <?php echo json_encode($PDC12labelX); ?>;
            var PDC15label = <?php echo json_encode($PDC15labelX); ?>;
            var PDC16label = <?php echo json_encode($PDC16labelX); ?>;
            var PDC17_1label = <?php echo json_encode($PDC17_1labelX); ?>;
            var PDC17label = <?php echo json_encode($PDC17labelX); ?>;
            var PDC18label = <?php echo json_encode($PDC18labelX); ?>;
            var PDC19label = <?php echo json_encode($PDC19labelX); ?>;
            var PDC20label = <?php echo json_encode($PDC20labelX); ?>;
            

            // CM - Dairy Milk Label

            var CMC0label = <?php echo json_encode($CMC0labelX); ?>;
            var CMC2label = <?php echo json_encode($CMC2labelX); ?>;
            var CMC3label = <?php echo json_encode($CMC3labelX); ?>;
            var CMC4blabel = <?php echo json_encode($CMC4blabelX); ?>;
            var CMC5label = <?php echo json_encode($CMC5labelX); ?>;
            var CMC5label2 = <?php echo json_encode($CMC5labelX2); ?>;
            var CMC6label = <?php echo json_encode($CMC6labelX); ?>;
            var CMC7label = <?php echo json_encode($CMC7labelX); ?>;
            var CMC7label2 = <?php echo json_encode($CMC7labelX2); ?>;
            var CMC8label = <?php echo json_encode($CMC8labelX); ?>;
            var CMC9label = <?php echo json_encode($CMC9labelX); ?>;
            var CMC10label = <?php echo json_encode($CMC10labelX); ?>;
            var CMC11label = <?php echo json_encode($CMC11labelX); ?>;
            var CMC11label2 = <?php echo json_encode($CMC11labelX2); ?>;
            var CMC12label = <?php echo json_encode($CMC12labelX); ?>;
            var CMC12label2 = <?php echo json_encode($CMC12labelX2); ?>;
            var CMC12labelX3 = <?php echo json_encode($CMC12labelX3); ?>;
            var CMC15label = <?php echo json_encode($CMC15labelX); ?>;
            var CMC16label = <?php echo json_encode($CMC16labelX); ?>;
            var CMC17_1label = <?php echo json_encode($CMC17_1labelX); ?>;
            var CMC17label = <?php echo json_encode($CMC17labelX); ?>;
            var CMC18label = <?php echo json_encode($CMC18labelX); ?>;
            var CMC19label = <?php echo json_encode($CMC19labelX); ?>;
            var CMC19label2 = <?php echo json_encode($CMC19labelX2); ?>;
            var CMC20label = <?php echo json_encode($CMC20labelX); ?>;

            // CH - Cheese Label

            var CHF1label = <?php echo json_encode($CHF1labelX); ?>; 
            var CHF1_1label = <?php echo json_encode($CHF1_1labelX); ?>; 
            var CHF2label = <?php echo json_encode($CHF2labelX); ?>; 
            var CHF3label = <?php echo json_encode($CHF3labelX); ?>; 
            var CHF4label = <?php echo json_encode($CHF4labelX); ?>; 
            var CHF5label = <?php echo json_encode($CHF5labelX); ?>; 
            var CHF6label = <?php echo json_encode($CHF6labelX); ?>; 
            var CHF7label = <?php echo json_encode($CHF7labelX); ?>; 
            var CHF8label = <?php echo json_encode($CHF8labelX); ?>; 
            var CHFC8label = <?php echo json_encode($CHFC8labelX); ?>; 
            var CHFC11label = <?php echo json_encode($CHFC11labelX); ?>; 
            var CHFC12label = <?php echo json_encode($CHFC12labelX); ?>; 
            var CHFC15label = <?php echo json_encode($CHFC15labelX); ?>; 
            var CHR1label = <?php echo json_encode($CHR1labelX); ?>; 
            var CHRF1label = <?php echo json_encode($CHRF1labelX); ?>; 
            var CHR2label = <?php echo json_encode($CHR2labelX); ?>; 
            var CHR3label = <?php echo json_encode($CHR3labelX); ?>; 
            var CHR4label = <?php echo json_encode($CHR4labelX); ?>; 
            var CHR5label = <?php echo json_encode($CHR5labelX); ?>; 
            var CHR6label = <?php echo json_encode($CHR6labelX); ?>; 
            var CHR7label = <?php echo json_encode($CHR7labelX); ?>; 
            var CHR8label = <?php echo json_encode($CHR8labelX); ?>; 
            var CHRC8label = <?php echo json_encode($CHRC8labelX); ?>; 
            var CHRC11label = <?php echo json_encode($CHRC11labelX); ?>; 
            var CHRC12label = <?php echo json_encode($CHRC12labelX); ?>; 
            var CHRC15label = <?php echo json_encode($CHRC15labelX); ?>; 
            var CHC16label = <?php echo json_encode($CHC16labelX); ?>; 
            var CHC17_1label = <?php echo json_encode($CHC17_1labelX); ?>; 
            var CHC17label = <?php echo json_encode($CHC17labelX); ?>; 
            var CHC18label = <?php echo json_encode($CHC18labelX); ?>; 
            var CHC19label = <?php echo json_encode($CHC19labelX); ?>; 
            var CHC20label = <?php echo json_encode($CHC20labelX); ?>; 

            // FD - Frozen

            var FDC0label = <?php echo json_encode($FDC0labelX); ?>;
            var FDC2label = <?php echo json_encode($FDC2labelX); ?>;
            var FDC3label = <?php echo json_encode($FDC3labelX); ?>;
            var FDC4alabel = <?php echo json_encode($FDC4alabelX); ?>;
            var FDC6label = <?php echo json_encode($FDC6labelX); ?>;
            var FDC7label = <?php echo json_encode($FDC7labelX); ?>;
            var FDC8label = <?php echo json_encode($FDC8labelX); ?>;
            var FDC9label = <?php echo json_encode($FDC9labelX); ?>;
            var FDC10label = <?php echo json_encode($FDC10labelX); ?>;
            var FDC11label = <?php echo json_encode($FDC11labelX); ?>;
            var FDC12label = <?php echo json_encode($FDC12labelX); ?>;
            var FDC15label = <?php echo json_encode($FDC15labelX); ?>;
            var FDC16label = <?php echo json_encode($FDC16labelX); ?>;
            var FDC17label = <?php echo json_encode($FDC17labelX); ?>;
            var FDC17_1label = <?php echo json_encode($FDC17_1labelX); ?>;
            var FDC18label = <?php echo json_encode($FDC18labelX); ?>;
            var FDC19label = <?php echo json_encode($FDC19labelX); ?>;
            var FDC20label = <?php echo json_encode($FDC20labelX); ?>;

            // Y - Yougurt

            var YC0label = <?php echo json_encode($YC0labelX); ?>;
            var YC2label = <?php echo json_encode($YC2labelX); ?>;
            var YC3label = <?php echo json_encode($YC3labelX); ?>;
            var YC4alabel = <?php echo json_encode($YC4alabelX); ?>;
            var YC4dlabel = <?php echo json_encode($YC4dlabelX); ?>;
            var YC4elabel = <?php echo json_encode($YC4elabelX); ?>;
            var YC5label = <?php echo json_encode($YC5labelX); ?>;
            var YC6label = <?php echo json_encode($YC6labelX); ?>;
            var YC7label = <?php echo json_encode($YC7labelX); ?>;
            var YC8label = <?php echo json_encode($YC8labelX); ?>;
            var YC9label = <?php echo json_encode($YC9labelX); ?>;
            var YC10label = <?php echo json_encode($YC10labelX); ?>;
            var YC11label = <?php echo json_encode($YC11labelX); ?>;
            var YC12label = <?php echo json_encode($YC12labelX); ?>;
            var YC15label = <?php echo json_encode($YC15labelX); ?>;
            var YC16label = <?php echo json_encode($YC16labelX); ?>;
            var YC17label = <?php echo json_encode($YC17labelX); ?>;
            var YC17_1label = <?php echo json_encode($YC17_1labelX); ?>;
            var YC18label = <?php echo json_encode($YC18labelX); ?>;
            var YC19label = <?php echo json_encode($YC19labelX); ?>;
            var YC20label = <?php echo json_encode($YC20labelX); ?>;

            // MD - Malt

            var MDC0label = <?php echo json_encode($MDC0labelX); ?>;
            var MDC1label = <?php echo json_encode($MDC1labelX); ?>;
            var MDC2label = <?php echo json_encode($MDC2labelX); ?>;
            var MDC3label = <?php echo json_encode($MDC3labelX); ?>;
            var MDC4blabel = <?php echo json_encode($MDC4blabelX); ?>;
            var MDC6label = <?php echo json_encode($MDC6labelX); ?>;
            var MDC7label = <?php echo json_encode($MDC7labelX); ?>;
            var MDC8label = <?php echo json_encode($MDC8labelX); ?>;
            var MDC9label = <?php echo json_encode($MDC9labelX); ?>;
            var MDC10label = <?php echo json_encode($MDC10labelX); ?>;
            var MDC11label = <?php echo json_encode($MDC11labelX); ?>;
            var MDC12label = <?php echo json_encode($MDC12labelX); ?>;
            var MDC15label = <?php echo json_encode($MDC15labelX); ?>;
            var MDC16label = <?php echo json_encode($MDC16labelX); ?>;
            var MDC17_1label = <?php echo json_encode($MDC17_1labelX); ?>;
            var MDC17label = <?php echo json_encode($MDC17labelX); ?>;
            var MDC18label = <?php echo json_encode($MDC18labelX); ?>;
            var MDC19label = <?php echo json_encode($MDC19labelX); ?>;
            var MDC20label = <?php echo json_encode($MDC20labelX); ?>;

            // CEM - Condensed

            var CEMC0label = <?php echo json_encode($CEMC0labelX); ?>;
            var CEMC1label = <?php echo json_encode($CEMC1labelX); ?>;
            var CEMC5label = <?php echo json_encode($CEMC5labelX); ?>;
            var CEMC8label = <?php echo json_encode($CEMC8labelX); ?>;
            var CEMC9label = <?php echo json_encode($CEMC9labelX); ?>;
            var CEMC10label = <?php echo json_encode($CEMC10labelX); ?>;
            var CEMC11label = <?php echo json_encode($CEMC11labelX); ?>;
            var CEMC12label = <?php echo json_encode($CEMC12labelX); ?>;
            var CEMC15label = <?php echo json_encode($CEMC15labelX); ?>;
            var CEMC16label = <?php echo json_encode($CEMC16labelX); ?>;
            var CEMC17_1label = <?php echo json_encode($CEMC17_1labelX); ?>;
            var CEMC17label = <?php echo json_encode($CEMC17labelX); ?>;
            var CEMC18label = <?php echo json_encode($CEMC18labelX); ?>;
            var CEMC19label = <?php echo json_encode($CEMC19labelX); ?>;
            var CEMC20label = <?php echo json_encode($CEMC20labelX); ?>;

            // Ad - Adult

            var ADC0label = <?php echo json_encode($ADC0labelX); ?>;
            var ADC2label = <?php echo json_encode($ADC2labelX); ?>;
            var ADC3label = <?php echo json_encode($ADC3labelX); ?>;
            var ADC4blabel = <?php echo json_encode($ADC4blabelX); ?>;
            var ADC5label = <?php echo json_encode($ADC5labelX); ?>;
            var ADC6label = <?php echo json_encode($ADC6labelX); ?>;
            var ADC7label = <?php echo json_encode($ADC7labelX); ?>;
            var ADC8label = <?php echo json_encode($ADC8labelX); ?>;
            var ADC9label = <?php echo json_encode($ADC9labelX); ?>;
            var ADC10label = <?php echo json_encode($ADC10labelX); ?>;
            var ADC11label = <?php echo json_encode($ADC11labelX); ?>;
            var ADC12label = <?php echo json_encode($ADC12labelX); ?>;
            var ADC15label = <?php echo json_encode($ADC15labelX); ?>;
            var ADC16label = <?php echo json_encode($ADC16labelX); ?>;
            var ADC17_1label = <?php echo json_encode($ADC17_1labelX); ?>;
            var ADC17label = <?php echo json_encode($ADC17labelX); ?>;
            var ADC18label = <?php echo json_encode($ADC18labelX); ?>;
            var ADC19label = <?php echo json_encode($ADC19labelX); ?>;
            var ADC20label = <?php echo json_encode($ADC20labelX); ?>;

            // CK - Cakes

            var CKC0label = <?php echo json_encode($CKC0labelX); ?>;
            var CKC2label = <?php echo json_encode($CKC2labelX); ?>;
            var CKC6label = <?php echo json_encode($CKC6labelX); ?>;
            var CKC7label = <?php echo json_encode($CKC7labelX); ?>;
            var CKC8label = <?php echo json_encode($CKC8labelX); ?>;
            var CKC9label = <?php echo json_encode($CKC9labelX); ?>;
            var CKC10label = <?php echo json_encode($CKC10labelX); ?>;
            var CKC11label = <?php echo json_encode($CKC11labelX); ?>;
            var CKC12label = <?php echo json_encode($CKC12labelX); ?>;
            var CKC15label = <?php echo json_encode($CKC15labelX); ?>;
            var CKC16label = <?php echo json_encode($CKC16labelX); ?>;
            var CKC17_1label = <?php echo json_encode($CKC17_1labelX); ?>;
            var CKC17label = <?php echo json_encode($CKC17labelX); ?>;
            var CKC18label = <?php echo json_encode($CKC18labelX); ?>;
            var CKC19label = <?php echo json_encode($CKC19labelX); ?>;
            var CKC20label = <?php echo json_encode($CKC20labelX); ?>;

            // SD - Sports Drink

            var SDC0label = <?php echo json_encode($SDC0labelX); ?>;
            var SDC1label = <?php echo json_encode($SDC1labelX); ?>;
            var SDC3label = <?php echo json_encode($SDC3labelX); ?>;
            var SDC6label = <?php echo json_encode($SDC6labelX); ?>;
            var SDC7label = <?php echo json_encode($SDC7labelX); ?>;
            var SDC8label = <?php echo json_encode($SDC8labelX); ?>;
            var SDC9label = <?php echo json_encode($SDC9labelX); ?>;
            var SDC10label = <?php echo json_encode($SDC10labelX); ?>;
            var SDC11label = <?php echo json_encode($SDC11labelX); ?>;
            var SDC12label = <?php echo json_encode($SDC12labelX); ?>;
            var SDC15label = <?php echo json_encode($SDC15labelX); ?>;
            var SDC16label = <?php echo json_encode($SDC16labelX); ?>;
            var SDC17_1label = <?php echo json_encode($SDC17_1labelX); ?>;
            var SDC17label = <?php echo json_encode($SDC17labelX); ?>;
            var SDC18label = <?php echo json_encode($SDC18labelX); ?>;
            var SDC19label = <?php echo json_encode($SDC19labelX); ?>;
            var SDC20label = <?php echo json_encode($SDC20labelX); ?>;

            // CL - Chocolate

            var CLC0label = <?php echo json_encode($CLC0labelX); ?>;
            var CLC1label = <?php echo json_encode($CLC1labelX); ?>;
            var CLC4Clabel = <?php echo json_encode($CLC4clabelX); ?>;
            var CLC7label = <?php echo json_encode($CLC7labelX); ?>;
            var CLC8label = <?php echo json_encode($CLC8labelX); ?>;
            var CLC9label = <?php echo json_encode($CLC9labelX); ?>;
            var CLC10label = <?php echo json_encode($CLC10labelX); ?>;
            var CLC11label = <?php echo json_encode($CLC11labelX); ?>;
            var CLC12label = <?php echo json_encode($CLC12labelX); ?>;
            var CLC15label = <?php echo json_encode($CLC15labelX); ?>;
            var CLC16label = <?php echo json_encode($CLC16labelX); ?>;
            var CLC17_1label = <?php echo json_encode($CLC17_1labelX); ?>;
            var CLC17label = <?php echo json_encode($CLC17labelX); ?>;
            var CLC18label = <?php echo json_encode($CLC18labelX); ?>;
            var CLC19label = <?php echo json_encode($CLC19labelX); ?>;
            var CLC20label = <?php echo json_encode($CLC20labelX); ?>;

            // BC - Biscuit

            var BCC0label = <?php echo json_encode($BCC0labelX); ?>;
            var BCC1label = <?php echo json_encode($BCC1labelX); ?>;
            var BCC2label = <?php echo json_encode($BCC2labelX); ?>;
            var BCC3label = <?php echo json_encode($BCC3labelX); ?>;
            var BCC7label = <?php echo json_encode($BCC7labelX); ?>;
            var BCC8label = <?php echo json_encode($BCC8labelX); ?>;
            var BCC9label = <?php echo json_encode($BCC9labelX); ?>;
            var BCC10label = <?php echo json_encode($BCC10labelX); ?>;
            var BCC11label = <?php echo json_encode($BCC11labelX); ?>;
            var BCC12label = <?php echo json_encode($BCC12labelX); ?>;
            var BCC15label = <?php echo json_encode($BCC15labelX); ?>;
            var BCC16label = <?php echo json_encode($BCC16labelX); ?>;
            var BCC17_1label = <?php echo json_encode($BCC17_1labelX); ?>;
            var BCC17label = <?php echo json_encode($BCC17labelX); ?>;
            var BCC18label = <?php echo json_encode($BCC18labelX); ?>;
            var BCC19label = <?php echo json_encode($BCC19labelX); ?>;
            var BCC20label = <?php echo json_encode($BCC20labelX); ?>;

            // CC - Chips

            var CCC0label = <?php echo json_encode($CCC0labelX); ?>;
            var CCC1label = <?php echo json_encode($CCC1labelX); ?>;
            var CCC2label = <?php echo json_encode($CCC2labelX); ?>;
            var CCC7label = <?php echo json_encode($CCC7labelX); ?>;
            var CCC8label = <?php echo json_encode($CCC8labelX); ?>;
            var CCC9label = <?php echo json_encode($CCC9labelX); ?>;
            var CCC10label = <?php echo json_encode($CCC10labelX); ?>;
            var CCC11label = <?php echo json_encode($CCC11labelX); ?>;
            var CCC12label = <?php echo json_encode($CCC12labelX); ?>;
            var CCC15label = <?php echo json_encode($CCC15labelX); ?>;
            var CCC16label = <?php echo json_encode($CCC16labelX); ?>;
            var CCC17_1label = <?php echo json_encode($CCC17_1labelX); ?>;
            var CCC17label = <?php echo json_encode($CCC17labelX); ?>;
            var CCC18label = <?php echo json_encode($CCC18labelX); ?>;
            var CCC19label = <?php echo json_encode($CCC19labelX); ?>;
            var CCC20label = <?php echo json_encode($CCC20labelX); ?>;

            // BAR - Protien Bar

            var BARC0label = <?php echo json_encode($BARC0labelX); ?>;
            var BARC2label = <?php echo json_encode($BARC2labelX); ?>;
            var BARC3label = <?php echo json_encode($BARC3labelX); ?>;
            var BARC4alabel = <?php echo json_encode($BARC4alabelX); ?>;
            var BARC7label = <?php echo json_encode($BARC7labelX); ?>;
            var BARC8label = <?php echo json_encode($BARC8labelX); ?>;
            var BARC9label = <?php echo json_encode($BARC9labelX); ?>;
            var BARC10label = <?php echo json_encode($BARC10labelX); ?>;
            var BARC11label = <?php echo json_encode($BARC11labelX); ?>;
            var BARC12label = <?php echo json_encode($BARC12labelX); ?>;
            var BARC15label = <?php echo json_encode($BARC15labelX); ?>;
            var BARC16label = <?php echo json_encode($BARC16labelX); ?>;
            var BARC17_1label = <?php echo json_encode($BARC17_1labelX); ?>;
            var BARC17label = <?php echo json_encode($BARC17labelX); ?>;
            var BARC18label = <?php echo json_encode($BARC18labelX); ?>;
            var BARC19label = <?php echo json_encode($BARC19labelX); ?>;
            var BARC20label = <?php echo json_encode($BARC20labelX); ?>;

            // BB - Bread

            var BBC0label = <?php echo json_encode($BBC0labelX); ?>;
            var BBC1label = <?php echo json_encode($BBC1labelX); ?>;
            var BBC2label = <?php echo json_encode($BBC2labelX); ?>;
            var BBC6label = <?php echo json_encode($BBC6labelX); ?>;
            var BBC7label = <?php echo json_encode($BBC7labelX); ?>;
            var BBC8label = <?php echo json_encode($BBC8labelX); ?>;
            var BBC9label = <?php echo json_encode($BBC9labelX); ?>;
            var BBC10label = <?php echo json_encode($BBC10labelX); ?>;
            var BBC11label = <?php echo json_encode($BBC11labelX); ?>;
            var BBC12label = <?php echo json_encode($BBC12labelX); ?>;
            var BBC15label = <?php echo json_encode($BBC15labelX); ?>;
            var BBC16label = <?php echo json_encode($BBC16labelX); ?>;
            var BBC17_1label = <?php echo json_encode($BBC17_1labelX); ?>;
            var BBC17label = <?php echo json_encode($BBC17labelX); ?>;
            var BBC18label = <?php echo json_encode($BBC18labelX); ?>;
            var BBC19label = <?php echo json_encode($BBC19labelX); ?>;
            var BBC20label = <?php echo json_encode($BBC20labelX); ?>;
            
            var P7label = <?php echo json_encode($P7L); ?>;
            var S13label = <?php echo json_encode($S13_arr); ?>;
            var S13label2 = <?php echo json_encode($S13_arr2); ?>;

            var productLabel = <?php echo json_encode($productL); ?>;

            var educationXX = <?php echo json_encode($educationXX); ?>;
            var relationXX = <?php echo json_encode($relationXX); ?>;

            var incomeLabel = ["SGD 10,001 to 12,000","SGD 12,001 to 14,000","SGD 14,001 to 16,000","SGD 16,001 to 18,000","SGD 18,001 to 20,000","SGD 20,001 and above"];

            // PPT Variables

            var trends1Data = [];
            var trends2Data = [];
            var trends3Data = [];


            // Trends

            var tab1label = <?php echo json_encode($tab1label); ?>;

            
            $(document).ready(function(){
                ////////debugger;
                $(".splash").hide();
                $("#outer_0").addClass("mm-active");
                $("#outer_0 > a").addClass("outer_div");
                $("#outer_0 > ul > li:first").addClass("mm-active");
                $("#outer_0 > ul > li:first").addClass("active");
                $("#outer_0 > ul > li:first > a").attr("aria-expanded", "true");
                $("#outer_0 > ul > li:first > a").addClass("active");

                $(`#quarter`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Quarter`,
                    nSelectedText: `Quarter`,
                    allSelectedText: `Quarter`,
                    buttonText: function(options, select) {
                        return `Quarter`;
                    },
                    onChange: function(option, checked, select) {
                        if ($(`#quarter option:selected`).length > 0) {
                            $(`#quarter`).next('.btn-group').find('.multiselect').addClass("addFD");
                        } else {
                            $(`#quarter`).next('.btn-group').find('.multiselect').removeClass("addFD");
                        }
                    }
                });
                $(`#quarter`).multiselect('selectAll', false);
                $(`#quarter`).multiselect("deselectAll", false);
                $(`#quarter`).multiselect('updateButtonText');

                $(`#country`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Country`,
                    nSelectedText: `Country`,
                    allSelectedText: `Country`,
                    buttonText: function(options, select) {
                        return `Country`;
                    },
                    onChange: function(option, checked, select) {
                        if ($(`#country option:selected`).length > 0) {
                            $(`#country`).next('.btn-group').find('.multiselect').addClass("addFD");
                        } else {
                            $(`#country`).next('.btn-group').find('.multiselect').removeClass("addFD");
                        }
                    }
                });
                $(`#country`).multiselect('selectAll', false);
                $(`#country`).multiselect("deselectAll", false);
                $(`#country`).multiselect('updateButtonText');

                $(`#region`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Region`,
                    nSelectedText: `Region`,
                    allSelectedText: `Region`,
                    buttonText: function(options, select) {
                        return `Region`;
                    },
                    onChange: function(option, checked, select) {
                        if ($(`#region option:selected`).length > 0) {
                            $(`#region`).next('.btn-group').find('.multiselect').addClass("addFD");
                        } else {
                            $(`#region`).next('.btn-group').find('.multiselect').removeClass("addFD");
                        }
                    }
                });
                $(`#region`).multiselect('selectAll', false);
                $(`#region`).multiselect("deselectAll", false);
                $(`#region`).multiselect('updateButtonText');

                $(`#city`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `City Type`,
                    nSelectedText: `City Type`,
                    allSelectedText: `City Type`,
                    buttonText: function(options, select) {
                        return `City Type`;
                    },
                    onChange: function(option, checked, select) {
                        if ($(`#city option:selected`).length > 0) {
                            $(`#city`).next('.btn-group').find('.multiselect').addClass("addFD");
                        } else {
                            $(`#city`).next('.btn-group').find('.multiselect').removeClass("addFD");
                        }
                    }
                });
                $(`#city`).multiselect('selectAll', false);
                $(`#city`).multiselect("deselectAll", false);
                $(`#city`).multiselect('updateButtonText');

                // $(`#race`).multiselect({
                //     includeSelectAllOption: true,
                //     enableFiltering: false,
                //     enableFullValueFiltering: false,
                //     nonSelectedText: `Race`,
                //     nSelectedText: `Race`,
                //     allSelectedText: `Race`,
                //     buttonText: function(options, select) {
                //         return `Race`;
                //     },
                //     onChange: function(option, checked, select) {
                //         if ($(`#race option:selected`).length > 0) {
                //             $(`#race`).next('.btn-group').find('.multiselect').addClass("addFD");
                //         } else {
                //             $(`#race`).next('.btn-group').find('.multiselect').removeClass("addFD");
                //         }
                //     }
                // });
                // $(`#race`).multiselect('selectAll', false);
                // $(`#race`).multiselect("deselectAll", false);
                // $(`#race`).multiselect('updateButtonText');

                $(`#HHI`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Gross HHI`,
                    nSelectedText: `Gross HHI`,
                    allSelectedText: `Gross HHI`,
                    buttonText: function(options, select) {
                        return `Gross HHI`;
                    },
                    onChange: function(option, checked, select) {
                        if ($(`#HHI option:selected`).length > 0) {
                            $(`#HHI`).next('.btn-group').find('.multiselect').addClass("addFD");
                        } else {
                            $(`#HHI`).next('.btn-group').find('.multiselect').removeClass("addFD");
                        }
                    }
                });
                $(`#HHI`).multiselect('selectAll', false);
                $(`#HHI`).multiselect("deselectAll", false);
                $(`#HHI`).multiselect('updateButtonText');

                $(`#HHI2`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Gross HHI`,
                    nSelectedText: `Gross HHI`,
                    allSelectedText: `Gross HHI`,
                    buttonText: function(options, select) {
                        return `Gross HHI`;
                    },
                    onChange: function(option, checked, select) {
                        if ($(`#HHI option:selected`).length > 0) {
                            $(`#HHI`).next('.btn-group').find('.multiselect').addClass("addFD");
                        } else {
                            $(`#HHI`).next('.btn-group').find('.multiselect').removeClass("addFD");
                        }
                    }
                });
                $(`#HHI2`).multiselect('selectAll', false);
                $(`#HHI2`).multiselect("deselectAll", false);
                $(`#HHI2`).multiselect('updateButtonText');

                $(`#gender`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Gender`,
                    nSelectedText: `Gender`,
                    allSelectedText: `Gender`,
                    buttonText: function(options, select) {
                        return `Gender`;
                    },
                    onChange: function(option, checked, select) {
                        if ($(`#gender option:selected`).length > 0) {
                            $(`#gender`).next('.btn-group').find('.multiselect').addClass("addFD");
                        } else {
                            $(`#gender`).next('.btn-group').find('.multiselect').removeClass("addFD");
                        }
                    }
                });
                $(`#gender`).multiselect('selectAll', false);
                $(`#gender`).multiselect("deselectAll", false);
                $(`#gender`).multiselect('updateButtonText');

                $(`#age`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Age`,
                    nSelectedText: `Age`,
                    allSelectedText: `Age`,
                    buttonText: function(options, select) {
                        return `Age`;
                    },
                    onChange: function(option, checked, select) {
                        if ($(`#age option:selected`).length > 0) {
                            $(`#age`).next('.btn-group').find('.multiselect').addClass("addFD");
                        } else {
                            $(`#age`).next('.btn-group').find('.multiselect').removeClass("addFD");
                        }
                    }
                });
                $(`#age`).multiselect('selectAll', false);
                $(`#age`).multiselect("deselectAll", false);
                $(`#age`).multiselect('updateButtonText');

                // $(`#halal`).multiselect({
                //     includeSelectAllOption: true,
                //     enableFiltering: false,
                //     enableFullValueFiltering: false,
                //     nonSelectedText: `Halal diet`,
                //     nSelectedText: `Halal diet`,
                //     allSelectedText: `Halal diet`,
                //     buttonText: function(options, select) {
                //         return `Halal diet`;
                //     },
                //     onChange: function(option, checked, select) {
                //         if ($(`#halal option:selected`).length > 0) {
                //             $(`#halal`).next('.btn-group').find('.multiselect').addClass("addFD");
                //         } else {
                //             $(`#halal`).next('.btn-group').find('.multiselect').removeClass("addFD");
                //         }
                //     }
                // });
                // $(`#halal`).multiselect('selectAll', false);
                // $(`#halal`).multiselect("deselectAll", false);
                // $(`#halal`).multiselect('updateButtonText');

                $(`#childrenHouseholdType`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Children In HH`,
                    nSelectedText: `Children In HH`,
                    allSelectedText: `Children In HH`,
                    buttonText: function(options, select) {
                        return `Children In HH`;
                    },
                    onChange: function(option, checked, select) {
                        if ($(`#childrenHouseholdType option:selected`).length > 0) {
                            $(`#childrenHouseholdType`).next('.btn-group').find('.multiselect').addClass("addFD");
                        } else {
                            $(`#childrenHouseholdType`).next('.btn-group').find('.multiselect').removeClass("addFD");
                        }
                    }
                });
                $(`#childrenHouseholdType`).multiselect('selectAll', false);
                $(`#childrenHouseholdType`).multiselect("deselectAll", false);
                $(`#childrenHouseholdType`).multiselect('updateButtonText');

                $(`#protienF`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Protien F`,
                    nSelectedText: `Protien F`,
                    allSelectedText: `Protien F`,
                    buttonText: function(options, select) {
                        return `Protien F`;
                    }
                });
                $(`#protienF`).multiselect('selectAll', false);
                $(`#protienF`).multiselect("deselectAll", false);
                $(`#protienF`).multiselect('updateButtonText');

                $(`#category_hml`).multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false,
                    nonSelectedText: `Category HML`,
                    nSelectedText: `Category HML`,
                    allSelectedText: `Category HML`,
                    buttonText: function(options, select) {
                        return `Category HML`;
                    }
                });
                $(`#category_hml`).multiselect('selectAll', false);
                $(`#category_hml`).multiselect("deselectAll", false);
                $(`#category_hml`).multiselect('updateButtonText');

                // $(".custom-tab-pane1").each(function(i,e){
                //     var status = $(this).data('status');
                //     statusArr[0].push(status);
                //     var classArr2 = []
                //     $(this).find(".row").each(function(i2,e2){
                //         classArr2 = [];
                //         $(this).find('table').addClass(`tblprofile_${i}`);
                //         classArr2.push(`tblprofile_${i}`);
                //     });
                //     classArr.push(classArr2);
                // });

                $(".custom-tab-pane1").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[0].push(status);
                });

                $(".custom-tab-pane2").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[1].push(status);
                });

                $(".custom-tab-pane3").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[2].push(status);
                });

                $(".custom-tab-pane4").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[3].push(status);
                });

                $(".custom-tab-pane5").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[4].push(status);
                    var classArr2 = []
                    $(this).find(".row").each(function(i2,e2){
                        classArr2 = [];
                        $(this).find('table').addClass(`tblprofile_${i}`);
                        classArr2.push(`tblprofile_${i}`);
                    });
                    classArr.push(classArr2);
                });

                $(".custom-tab-pane6").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[5].push(status);
                });

                $(".custom-tab-pane7").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[6].push(status);
                });

                $(".custom-tab-pane8").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[7].push(status);
                });

                $(".custom-tab-pane9").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[8].push(status);
                });

                $(".custom-tab-pane10").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[9].push(status);
                });

                $(".custom-tab-pane11").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[10].push(status);
                });

                $(".custom-tab-pane12").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[11].push(status);
                });

                $(".custom-tab-pane13").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[12].push(status);
                });

                $(".custom-tab-pane14").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[13].push(status);
                });

                $(".custom-tab-pane15").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[14].push(status);
                });

                $(".custom-tab-pane16").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[15].push(status);
                });

                $(".custom-tab-pane17").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[16].push(status);
                });

                $(".custom-tab-pane18").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[17].push(status);
                });
                $(".custom-tab-pane19").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[18].push(status);
                });

                $(".custom-tab-pane20").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[19].push(status);
                });

                $(".custom-tab-pane21").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[20].push(status);
                });

                $(".custom-tab-pane22").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[21].push(status);
                });

                $(".custom-tab-pane23").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[22].push(status);
                });

                $(".custom-tab-pane24").each(function(i, e) {
                    var status = $(this).data('status');
                    statusArr[23].push(status);
                });

                //console.log(statusArr);

            });
            $(window).on("load", function() {
                $("#outer_1").before(`<span class="nxt_head">Category Findings</span>`);
                $("#outer_16").before(`<span class="nxt_head">Other Info</span>`);
                $("#outer_19").before(`<span class="nxt_head">Trends</span>`);
                applyF();
                setTimeout(() => {
                    $(window).trigger('resize');
                }, 1000);
            });

            var im2 = function X(a)
            {
                if(a == "Thailand")
                {
                    return `<span class="setImg" style="margin-left:14px"><img src="https://www.keresearch.in/dynata/assets/images/thailand.png" style="width:30px;height:30px"></img>${a}</span>`;
                }
                else if(a == "Philippines")
                {
                    return `<span class="setImg"><img src="https://www.keresearch.in/dynata/assets/images/philippines.png" style="width:30px;height:30px"></img>${a}</span>`;
                }
                else if(a == "Indonesia")
                {
                    return `<span class="setImg"><img src="https://www.keresearch.in/dynata/assets/images/indonesia.png" style="width:30px;height:30px"></img>${a}</span>`;
                }
                else if(a == "Malaysia")
                {
                    return `<span class="setImg"><img src="https://www.keresearch.in/dynata/assets/images/malaysia.png" style="width:30px;height:30px"></img>${a}</span>`;
                }
                else if(a == "Vietnam")
                {
                    return `<span class="setImg"><img src="https://www.keresearch.in/dynata/assets/images/vietnam.png" style="width:30px;height:30px"></img>${a}</span>`;
                }
                
                else
                {
                    return `${a.split(' ').join('<br>')}`;
                }
            }

            //=================================Tab Sidebar START============================================
            function openS()
            {
                ////////debugger;
                var windowWidth = $(window).width();
                // var windowWidth2 = $("body").width();
                // //console.log(`width:${windowWidth}`);
                // //console.log(`width:${windowWidth2}`);
                // if(windowWidth<=1285)
                // {
                //     document.body.style.zoom = "90%";
                // }
                // //console.log(`width:${windowWidth}`);
                // //console.log(`width:${windowWidth2}`);
                var sidebarWidth = ((18/100)*windowWidth);
                var mainWidth = windowWidth-sidebarWidth;
                $("#mySidebar").css("width",sidebarWidth);  
                $("#mySidebar").css("min-width",sidebarWidth);
                $(".app-header-left").css("width",sidebarWidth); 
                $(".app-header-right").css("width",mainWidth);  
                $("#main").css("margin-left",sidebarWidth);
                setTimeout(() => {
                    var newWidth = $("#main").width();
                    var newWidth2 = $("#main").width();
                    var newWidth3 = $("#main").width();
                    newWidth = newWidth - 20 ;
                    newWidth2 = (100/100)*newWidth2;
                    newWidth3 = (28/100)*newWidth3;
                    $("#activetabnamedivsection").css("width",newWidth);
                    //$("#categorydivsection").css("width",newWidth3+6);
                    if(trendStatus === false)
                    {
                        $(targetedHighchartContainer).each(function(){
                            ////////debugger;
                            var chart = $(this).highcharts();
                            if (chart)
                            {
                                chart.setSize(newWidth);
                            }
                        });
                    }
                    else
                    {
                        // $(targetedHighchartContainerT).each(function() {
                        //     var chart2 = $(this).highcharts();
                        //     if (chart2) {
                        //         chart2.setSize(newWidth, null, true);
                        //     }
                        // });
                    }
                }, 800);
            }

            function closeS()
            {
                var windowWidth = $(window).width();
                var sidebarWidth = ((0/100)*windowWidth);
                
                $("#mySidebar").css("width",sidebarWidth);
                $("#mySidebar").css("min-width",sidebarWidth);
                $("#main").css("margin-left",sidebarWidth);
                setTimeout(() => {
                    var newWidth = $("#main").width();
                    var newWidth2 = $("#main").width();
                    var newWidth3 = $("#main").width();
                    newWidth = newWidth - 20 ;
                    newWidth2 = (100/100)*newWidth2;
                    newWidth3 = (28/100)*newWidth3;
                    $("#activetabnamedivsection").css("width",newWidth2-20);
                    //$("#categorydivsection").css("width",newWidth3+12);
                    if(trendStatus === false)
                    {
                        $(targetedHighchartContainer).each(function(){
                            var chart = $(this).highcharts();
                            if (chart)
                            {
                                chart.setSize(newWidth);
                            }
                        });
                    }
                    else
                    {
                        // $(targetedHighchartContainerT).each(function() {
                        //     var chart2 = $(this).highcharts();
                        //     if (chart2) {
                        //         chart2.setSize(newWidth, null, true);
                        //     }
                        // });
                    }
                }, 800);
            }

            function tabSidebar()
            {
                var sidebardataStatus = $('#openbtn').attr("data-status");
                if(sidebardataStatus==1)
                {
                    $('#openbtn').attr('data-status', '2');
                    closeS();
                }
                else
                {
                    $('#openbtn').attr('data-status', '1');
                    openS();
                }
            }
            //=================================Tab Sidebar END============================================

            //=================================Logout Start============================================
                function logout() {
                    window.stop();
                    $.ajax({
                        url: "api/logout.php",
                        type: "POST",
                        data: {
                            'action': 'logout'
                        },
                        success: function(response) {
                            if (response == "success") {
                                window.location.href = "index.php";
                            }
                        }
                    })
                }
            //=================================Logout End============================================

            //=================================Resizing Chart Start============================================
                $(window).on("resize", function() {
                    openS();
                });
            //=================================Resizing Chart END============================================
            
            //=================================Filter Form START============================================
                function countryFX(idX)
                {
                    var valX = $(`#${idX}`).val();
                    var HHILabel1 = [];
                    var HHILabel2 = [];
                    valX.forEach(function(e,i,a){
                        HHILabel1.push(HHI_filter_label[parseInt(e)-1]);
                        HHILabel2.push(HHI_profile_label[parseInt(e)-1]);
                    });

                    if (valX.length === 0) {
                        $("#city").empty();
                    } else {
                        ////////debugger;
                        let cityHTML = "";
                        let hasSix = valX.includes("6");
                        let hasOther = valX.some(num => num >= "1" && num <= "5");

                        if (hasOther) {
                            cityLabel.forEach((e, i) => {
                                cityHTML += `<option value="L${i + 1}" data-name="${e}">${e}</option>`;
                            });
                        }

                        if (hasSix) {
                            cityLabel2.forEach((e, i) => {
                                cityHTML += `<option value="V${i + 1}" data-name="${e}">${e}</option>`;
                            });
                        }
                        $("#city").empty().append(cityHTML);
                    }
                    // 
                    
                    var HHIHTML1 = ``;
                    
                    if(HHILabel1.length!=0)
                    {
                        HHILabel1.forEach(function (e, i) {
                            Object.entries(e).forEach(function ([key, value], i2) {
                                var counterX = i2 + 1;
                                if (key <= 9) {
                                    HHIHTML1 += `<option value="${key}" data-name="${value}">${value}</option>`;
                                } else {
                                    HHIHTML1 += `<option value="${key}" data-name="${value}">${value}</option>`;
                                }
                            });
                        });
                    }

                    $("#HHI").empty().append(HHIHTML1);
                    
                    // 

                    var HHIHTML2 = ``;
                    
                    if(HHILabel2.length!=0)
                    {
                        HHILabel2.forEach(function (e, i) {
                            Object.entries(e).forEach(function ([key, value], i2) {
                                var counterX = i2 + 1;
                                if (key <= 9) {
                                    HHIHTML2 += `<option value="${key}" data-name="${value}">${value}</option>`;
                                } else {
                                    HHIHTML2 += `<option value="${key}" data-name="${value}">${value}</option>`;
                                }
                            });
                        });
                    }

                    $("#HHI2").empty().append(HHIHTML2);

                    $(`#city`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `City Type`,
                        nSelectedText: `City Type`,
                        allSelectedText: `City Type`,
                        buttonText: function(options, select) {
                            return `City Type`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#city option:selected`).length > 0) {
                                $(`#city`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#city`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#city`).multiselect('selectAll', false);
                    $(`#city`).multiselect("deselectAll", false);
                    $(`#city`).multiselect('updateButtonText');
                    $("#city").multiselect('rebuild');
                    $("#city").change();

                    $(`#HHI`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Gross HHI`,
                        nSelectedText: `Gross HHI`,
                        allSelectedText: `Gross HHI`,
                        buttonText: function(options, select) {
                            return `Gross HHI`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#HHI option:selected`).length > 0) {
                                $(`#HHI`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#HHI`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#HHI`).multiselect('selectAll', false);
                    $(`#HHI`).multiselect("deselectAll", false);
                    $(`#HHI`).multiselect('updateButtonText');
                    $("#HHI").multiselect('rebuild');
                    $("#HHI").change();

                    $(`#HHI2`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Gross HHI`,
                        nSelectedText: `Gross HHI`,
                        allSelectedText: `Gross HHI`,
                        buttonText: function(options, select) {
                            return `Gross HHI`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#HHI2 option:selected`).length > 0) {
                                $(`#HHI2`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#HHI2`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#HHI2`).multiselect('selectAll', false);
                    $(`#HHI2`).multiselect("deselectAll", false);
                    $(`#HHI2`).multiselect('updateButtonText');
                    $("#HHI2").multiselect('rebuild');
                    $("#HHI2").change();


                }
            //=================================Filter Form END============================================

            //=================================Reset Filter START============================================
                function resetFilters()
                {
                    $("#city").empty();
                    $("#HHI").empty();
                    $("#HHI2").empty();
                    $("#race").empty();
                    
                    $(".splash").show();

                    $(`#quarter`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Quarter`,
                        nSelectedText: `Quarter`,
                        allSelectedText: `Quarter`,
                        buttonText: function(options, select) {
                            return `Quarter`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#quarter option:selected`).length > 0) {
                                $(`#quarter`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#quarter`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#quarter`).multiselect('selectAll', false);
                    $(`#quarter`).multiselect("deselectAll", false);
                    $(`#quarter`).multiselect('updateButtonText');

                    $(`#country`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Country`,
                        nSelectedText: `Country`,
                        allSelectedText: `Country`,
                        buttonText: function(options, select) {
                            return `Country`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#country option:selected`).length > 0) {
                                $(`#country`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#country`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#country`).multiselect('selectAll', false);
                    $(`#country`).multiselect("deselectAll", false);
                    $(`#country`).multiselect('updateButtonText');

                    $(`#region`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Region`,
                        nSelectedText: `Region`,
                        allSelectedText: `Region`,
                        buttonText: function(options, select) {
                            return `Region`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#region option:selected`).length > 0) {
                                $(`#region`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#region`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#region`).multiselect('selectAll', false);
                    $(`#region`).multiselect("deselectAll", false);
                    $(`#region`).multiselect('updateButtonText');

                    $(`#city`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `City Type`,
                        nSelectedText: `City Type`,
                        allSelectedText: `City Type`,
                        buttonText: function(options, select) {
                            return `City Type`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#city option:selected`).length > 0) {
                                $(`#city`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#city`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#city`).multiselect('selectAll', false);
                    $(`#city`).multiselect("deselectAll", false);
                    $(`#city`).multiselect('updateButtonText');
                    $("#city").multiselect('rebuild');
                    $("#city").change();

                    $(`#HHI`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Gross HHI`,
                        nSelectedText: `Gross HHI`,
                        allSelectedText: `Gross HHI`,
                        buttonText: function(options, select) {
                            return `Gross HHI`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#HHI option:selected`).length > 0) {
                                $(`#HHI`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#HHI`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#HHI`).multiselect('selectAll', false);
                    $(`#HHI`).multiselect("deselectAll", false);
                    $(`#HHI`).multiselect('updateButtonText');
                    $("#HHI").multiselect('rebuild');
                    $("#HHI").change();

                    $(`#HHI2`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Gross HHI`,
                        nSelectedText: `Gross HHI`,
                        allSelectedText: `Gross HHI`,
                        buttonText: function(options, select) {
                            return `Gross HHI`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#HHI2 option:selected`).length > 0) {
                                $(`#HHI2`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#HHI2`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#HHI2`).multiselect('selectAll', false);
                    $(`#HHI2`).multiselect("deselectAll", false);
                    $(`#HHI2`).multiselect('updateButtonText');
                    $("#HHI2").multiselect('rebuild');
                    $("#HHI2").change();

                    $(`#gender`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Gender`,
                        nSelectedText: `Gender`,
                        allSelectedText: `Gender`,
                        buttonText: function(options, select) {
                            return `Gender`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#gender option:selected`).length > 0) {
                                $(`#gender`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#gender`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#gender`).multiselect('selectAll', false);
                    $(`#gender`).multiselect("deselectAll", false);
                    $(`#gender`).multiselect('updateButtonText');

                    $(`#age`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Age`,
                        nSelectedText: `Age`,
                        allSelectedText: `Age`,
                        buttonText: function(options, select) {
                            return `Age`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#age option:selected`).length > 0) {
                                $(`#age`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#age`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#age`).multiselect('selectAll', false);
                    $(`#age`).multiselect("deselectAll", false);
                    $(`#age`).multiselect('updateButtonText');

                    // $(`#halal`).multiselect({
                    //     includeSelectAllOption: true,
                    //     enableFiltering: false,
                    //     enableFullValueFiltering: false,
                    //     nonSelectedText: `Halal diet`,
                    //     nSelectedText: `Halal diet`,
                    //     allSelectedText: `Halal diet`,
                    //     buttonText: function(options, select) {
                    //         return `Halal diet`;
                    //     },
                    //     onChange: function(option, checked, select) {
                    //         if ($(`#halal option:selected`).length > 0) {
                    //             $(`#halal`).next('.btn-group').find('.multiselect').addClass("addFD");
                    //         } else {
                    //             $(`#halal`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    //         }
                    //     }
                    // });
                    // $(`#halal`).multiselect('selectAll', false);
                    // $(`#halal`).multiselect("deselectAll", false);
                    // $(`#halal`).multiselect('updateButtonText');

                    $(`#childrenHouseholdType`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Children In HH`,
                        nSelectedText: `Children In HH`,
                        allSelectedText: `Children In HH`,
                        buttonText: function(options, select) {
                            return `Children In HH`;
                        },
                        onChange: function(option, checked, select) {
                            if ($(`#childrenHouseholdType option:selected`).length > 0) {
                                $(`#childrenHouseholdType`).next('.btn-group').find('.multiselect').addClass("addFD");
                            } else {
                                $(`#childrenHouseholdType`).next('.btn-group').find('.multiselect').removeClass("addFD");
                            }
                        }
                    });
                    $(`#childrenHouseholdType`).multiselect('selectAll', false);
                    $(`#childrenHouseholdType`).multiselect("deselectAll", false);
                    $(`#childrenHouseholdType`).multiselect('updateButtonText');

                    $(`#protienF`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Protien F`,
                        nSelectedText: `Protien F`,
                        allSelectedText: `Protien F`,
                        buttonText: function(options, select) {
                            return `Protien F`;
                        }
                    });
                    $(`#protienF`).multiselect('selectAll', false);
                    $(`#protienF`).multiselect("deselectAll", false);
                    $(`#protienF`).multiselect('updateButtonText');

                    $(`#category_hml`).multiselect({
                        includeSelectAllOption: true,
                        enableFiltering: false,
                        enableFullValueFiltering: false,
                        nonSelectedText: `Category HML`,
                        nSelectedText: `Category HML`,
                        allSelectedText: `Category HML`,
                        buttonText: function(options, select) {
                            return `Category HML`;
                        }
                    });
                    $(`#category_hml`).multiselect('selectAll', false);
                    $(`#category_hml`).multiselect("deselectAll", false);
                    $(`#category_hml`).multiselect('updateButtonText');


                    $(`#quarter`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    $(`#country`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    $(`#region`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    $(`#city`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    //$(`#race`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    $(`#HHI`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    $(`#gender`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    $(`#age`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    $(`#childrenHouseholdType`).next('.btn-group').find('.multiselect').removeClass("addFD");
                    //$(`#halal`).next('.btn-group').find('.multiselect').removeClass("addFD");

                    $("#p_s2").empty().append(`<h6 class="placeholder">Please select the respective country</h6>`);
                    $("#p_s7").empty().append(`<h6 class="placeholder">Please select the respective country</h6>`);
                    $("#p_s2_base").empty().append(`(Base=N/A)`);
                    $("#p_s7_base").empty().append(`(Base=N/A)`);

                    $(".filter_wrap_div").removeClass("customfilterselect");
                    
                    flagConstruct();
                    
                }

            //=================================Reset Filter END============================================

            //================================= Trends Swap Start============================================
                function trends(thisX)
                {
                    var getTxt = $(thisX).attr('data-value');
                    if(getTxt=="Trends")
                    {
                        $(".trends_div_chart").show();
                        $(".overall_div_chart").hide();
                        $(".table_div_chart").hide();
                        $(thisX).attr('data-value','Chart');
                        trendStatus = true;
                        $(thisX).empty().append(`<i class="fa fa-pie-chart fa-2x"></i>`);
                    }
                    else
                    {
                        $(".trends_div_chart").hide();
                        $(".overall_div_chart").show();
                        $(".table_div_chart").hide();
                        $(thisX).attr('data-value','Trends');
                        trendStatus = false;
                        $(thisX).empty().append(`<i class="fa fa-line-chart fa-2x"></i>`);
                    }
                }

                function swapTable(thisX)
                {

                    var getTxt = $(thisX).attr('data-value');
                    if(getTxt=="Tbl")
                    {
                        $(".trends_div_chart").hide();
                        $(".overall_div_chart").hide();
                        $(".table_div_chart").show();
                        $(".data_table").show();
                        $(".rightFunnel").hide();
                        $(thisX).attr('data-value','Chart');
                        tblStatus = true;
                        $("#cm_15 .rightFunnel").show();
                        $("#cm_15 .funnel-col").show();
                        $("#cm_14 .rightFunnel").show();
                        $("#cm_16 .rightFunnel").show();
                        $("#cm_16 .funnel-col").show();
                        $("#roc_c").hide();
                        $("#roc_t").show();

                        $("#fd_15 .rightFunnel").show();
                        $("#fd_15 .funnel-col").show();
                        $("#fd_14 .rightFunnel").show();
                        $("#fd_16 .rightFunnel").show();
                        $("#fd_16 .funnel-col").show();
                        $("#roc_c_fd").hide();
                        $("#roc_t_fd").show();

                        $("#y_15 .rightFunnel").show();
                        $("#y_15 .funnel-col").show();
                        $("#y_14 .rightFunnel").show();
                        $("#y_16 .rightFunnel").show();
                        $("#y_16 .funnel-col").show();
                        $("#roc_c_y").hide();
                        $("#roc_t_y").show();

                    }
                    else
                    {
                        $(".trends_div_chart").hide();
                        $(".overall_div_chart").show();
                        $(".table_div_chart").hide();
                        $(".data_table").hide();
                        $(".rightFunnel").show();
                        $(thisX).attr('data-value','Tbl');
                        tblStatus = false;
                        // $(thisX).empty().append(`<i class="fa fa-line-chart fa-2x"></i>`);
                        $("#pc_tbl").show();
                        $("#hc_tbl").show();
                        $("#roc_c").show();
                        $("#roc_t").hide();

                        $("#pc_tbl_fd").show();
                        $("#hc_tbl_fd").show();
                        $("#fd_15 .rightFunnel").show();
                        $("#fd_15 .funnel-col").show();
                        $("#fd_14 .rightFunnel").show();
                        $("#fd_16 .rightFunnel").show();
                        $("#fd_16 .funnel-col").show();
                        $("#roc_c_fd").hide();
                        $("#roc_t_fd").show();

                        $("#pc_tbl_y").show();
                        $("#hc_tbl_y").show();
                        $("#y_15 .rightFunnel").show();
                        $("#y_15 .funnel-col").show();
                        $("#y_14 .rightFunnel").show();
                        $("#y_16 .rightFunnel").show();
                        $("#y_16 .funnel-col").show();
                        $("#roc_c_y").hide();
                        $("#roc_t_y").show();
                    }
                }
            //================================= Trends Swap END============================================

            //=================================Tab Click Start============================================

            function tabClick(element)
            {
                //////////debugger;
                $(".outer_li").each(function() {
                    $(this).find("a").removeClass("outer_div");
                });

                $(`#${element} > a`).addClass('outer_div');

                $(".targetA").each(function(){
                    $(this).attr('aria-expanded', 'false');
                    $(this).attr('aria-selected', 'false');
                    $(this).parent().removeClass('mm-active');
                    $(this).parent().removeClass('active');
                    $(this).removeClass('active');
                });
                $(window).trigger('resize');
            }

            function tabClick2(element)
            {
                //debugger
                window.scrollTo(0, 0);
                const id = $(element).attr('id');
                dataOuter = $(element).attr('data-outer');
                dataInner = $(element).attr('data-inner');
                outerTextDefination = tabsDefination[dataOuter];
                outerText = outerTab[dataOuter];
                innerText = innerTab[dataOuter][dataInner];
                
                if(outerText=="Category Consumption" || outerText == "Study Introduction" || outerText == "Consumer Profiling" || outerText == "Key Health Areas" || outerText == "Dairy milk (from cows) Trends" || outerText == "Cheese Trends" || outerText == "Frozen/Chilled dessert Trends" || outerText == "Yogurt/Cultured milk/Fermented drinks Trends")
                {
                    $("#activetabnamedivsection").hide();
                    $("#categorydivsection").hide();
                }
                else
                {
                    $("#activetabnamedivsection").show();
                    $("#categorydivsection").show();
                }
                $("#activetabname").empty().append(`${outerText}`);
                if(outerTextDefination=="")
                {
                    $("#activetabnamedefination").empty();
                }
                else
                {
                    $("#activetabnamedefination").empty().append(`(${outerTextDefination})`);
                }
                
                targetedHighchartContainer = $(`#tab-eg7-${dataOuter}-${dataInner} .overall_div_chart .chart_div .card .chartC2`);
                //console.log(`#tab-eg7-${dataOuter}-${dataInner} .overall_div_chart .chart_div .card .chartC2`);
                

                // if(trendStatus==true)
                // {
                //     $("#timeField").hide();
                //     $("#weekField").show();
                //     $("#weekdayField").show();
                //     $("#dateField").show();
                //     $("#filterdefination_overall_div").show();
                //     $("#filterdefination_trend_div").hide();
                //     $(".chart_div").show();
                //     $(".tbl_div").hide();
                //     $(".chart_divT").hide();

                //     trendStatus = false;
                // }

                // if(tableStatus==true)
                // {
                //     $("#data_type").hide();
                //     $("#data_type").next().hide();
                //     $("#trends_open_div").hide();
                //     $("#trends_close_div").hide();
                //     $("#swap_zero_btn").show();
                // }
                // else
                // {
                //     $("#data_type").show();
                //     $("#data_type").next().show();
                //     $("#trends_open_div").show();
                //     $("#trends_close_div").hide();
                //     $("#swap_zero_btn").hide();
                //     if(innerText=="NPS")
                //     {
                //         $("#data_type").hide();
                //         $("#data_type").next().hide();
                //     }
                //     else
                //     {
                //         $("#data_type").show();
                //         $("#data_type").next().show();
                //     }
                // }

                $(window).trigger('resize');

                
                statusArr[dataOuter][dataInner]="active";
                //console.log(statusArr);
                //console.log(functionFlag);
                if(functionFlag[dataOuter][dataInner]===false)
                {
                    applyF();
                }
            }

            function customtabchangeFunction(e) 
            {
                //////////debugger;
                $(".fdsX").each(function(){
                    $(this).prop("checked", false);
                });
                $(e).prop("checked", true);
                var valX = $(e).val();
                if(valX=="1")
                {
                    $("#tab-eg9-2").addClass("active");
                    $("#tab-eg9-3").removeClass("active");
                    $("#tab-eg9-61").removeClass("active");
                }
                else if(valX=="2")
                {
                    $("#tab-eg9-2").removeClass("active");
                    $("#tab-eg9-3").addClass("active");
                    $("#tab-eg9-61").removeClass("active");
                }
                else if(valX=="3")
                {
                    $("#tab-eg9-2").removeClass("active");
                    $("#tab-eg9-3").removeClass("active");
                    $("#tab-eg9-61").addClass("active");
                }
                else{}
            }
            function customtabchangeFunction2(e) 
            {
                //////////debugger;
                $(".fdsX2").each(function(){
                    $(this).prop("checked", false);
                });
                $(e).prop("checked", true);
                var valX = $(e).val();

                if(valX=="4")
                {
                    $("#tab-eg9-73").addClass("active");
                    $("#tab-eg9-74").removeClass("active");
                    $("#tab-eg9-75").removeClass("active");
                }
                else if(valX=="5")
                {
                    $("#tab-eg9-73").removeClass("active");
                    $("#tab-eg9-74").addClass("active");
                    $("#tab-eg9-75").removeClass("active");
                }
                else if(valX=="6")
                {
                    $("#tab-eg9-73").removeClass("active");
                    $("#tab-eg9-74").removeClass("active");
                    $("#tab-eg9-75").addClass("active");
                }
                else{}
                
            }


            //=================================Tab Click END============================================

                // doughnutChart(doughnutData3,"pd_c0");
                // pieChart(pieData1,"pd_c10");
                // columnChart(columnData1,"pd_c3",PDC3label);
                // barChart(barData1,"pd_c8",PDC8label,30);
                // doughnutChart2(doughnut2Data7,"pd_c17_1",colorPallet[0]);
                // lineChart(lineData1,"pd_c2T");
                // stackbarChart(stackbarData1,"pd_c10T");
                // stackcolumnChart(stackcolumnData1,"pd_c6T");
                // heatChart(heatData1,"pd_c3T",PDC3label);

            //=================================Data Manipulation Start============================================
            function extractValues(array,valueArray,baseArray,countArray,valueType)
            {
                if(valueType=="Simple")
                {
                    array.forEach(function(e,i,a){
                        valueArray.push(e.percentage);
                        baseArray.push(e.bCount);
                        countArray.push(e.cCount);
                    });
                }
                else
                {
                    array.forEach(function(e,i,a){
                        var arrayV2 = [];
                        var arrayB2 = [];
                        var arrayC2 = [];
                        e.forEach(function(e2,i2,a2){
                            arrayV2.push(e2.percentage);
                            arrayB2.push(e2.bCount);
                            arrayC2.push(e2.cCount);
                        });
                        valueArray.push(arrayV2);
                        baseArray.push(arrayB2);
                        countArray.push(arrayC2);
                    });
                }
            } 
            
            function extractValues2(array,valueArray,valueArray2,baseArray,countArray,valueType)
            {
                if(valueType=="Simple")
                {
                    array.forEach(function(e,i,a){
                        valueArray.push(e.percentage);
                        valueArray2.push(e.percentage2);
                        baseArray.push(e.bCount);
                        countArray.push(e.cCount);
                    });
                }
                else
                {
                    array.forEach(function(e,i,a){
                        var arrayV2 = [];
                        var arrayV22 = [];
                        var arrayB2 = [];
                        var arrayC2 = [];
                        e.forEach(function(e2,i2,a2){
                            arrayV2.push(e2.percentage);
                            arrayV22.push(e2.percentage2);
                            arrayB2.push(e2.bCount);
                            arrayC2.push(e2.cCount);
                        });
                        valueArray.push(arrayV2);
                        valueArray2.push(arrayV22);
                        baseArray.push(arrayB2);
                        //////debugger;
                        countArray.push(arrayC2);
                    });
                }
            } 

            function customizedArray(array,valueArray,labelArray,colorLabel,chartType,nameXX)
            {
                if(chartType=="Doughnut")
                {
                    array.forEach(function(e,i,a){
                        var valueE = {
                            name: labelArray[i],
                            y: e,
                            color: (labelArray[i] == "DK/CS") ? "#808080" : 
                            (labelArray[i] == "Others") ? "#b3b3b3" : colorLabel[i]
                        };
                        valueArray.push(valueE);
                    });
                }
                else if(chartType=="StackBar")
                {
                    array.forEach(function(e,i,a){
                        var valueE = {
                            name: labelArray[i],
                            data: e,
                        };
                        valueArray.push(valueE);
                    });
                }
                else if(chartType=="Line")
                {
                    array.forEach(function(e,i,a){
                        var valueE = {
                            name: labelArray[i],
                            data: e,
                        };
                        valueArray.push(valueE);
                    });
                }
                else if(chartType=="Bar")
                {
                    array.forEach(function(e,i,a){
                        var valueE = {
                            name: labelArray[i],
                            y: e,
                            color: (labelArray[i] == "DK/CS") ? "#808080" : 
                            (labelArray[i] == "Others") ? "#b3b3b3" : colorLabel[i]
                        };
                        valueArray.push(valueE);
                    });
                    // var valueE = {
                    //     name: nameXX,
                    //     data: array,
                    // };
                    // valueArray.push(valueE);
                }
                else if(chartType=="Heat")
                {
                    const result = array.flatMap((row, rowIndex) => 
                        row.map((value, colIndex) => [rowIndex, colIndex, value])
                    );
                    valueArray.push(result);
                }
                else if(chartType=="Bubble")
                {
                    array.forEach(function(e, i) {
                        var arrX = {
                            name: labelArray[i],
                            data: [],
                            marker: {
                                fillColor: radialColors[i]
                            }
                        };
                        e.forEach(function(e2, i2) {
                            var dataPoint = {
                                x: i2,
                                y: i,
                                z: e2
                            };
                            arrX.data.push(dataPoint);
                        });
                        valueArray.push(arrX);
                    });
                }
                else
                {
                    const dataX = airportName.map((airport, index) => ({
                        'hc-key': airportDataMap[airport],
                        value: array[index],
                        name: airport
                    }));

                    valueArray.push(dataX);
                }
                
            }

            function transposeData(data) 
            {
                return data[0].map((col, i) => data.map(row => row[i]));
            }

            function processBase(arr) 
            {
                const allSame = arr.every(element => Number(element) === Number(arr[0]));
                //////////debugger;
                if (allSame) {
                    return [arr[0]];
                } else {
                    return arr;
                }
            }

            function clickableSlice(divId, dataNameX, dropdownName, optionName, types, types2)
            {
                //console.log("trigger1");
                if(types2=="fresh")
                {
                    var option = $("#"+dropdownName+" option[data-name='" + optionName + "']");
                    if (option.is(':selected') === true) 
                    {
                        option.prop('selected', false);
                    } 
                    else 
                    {
                        option.prop('selected', true);
                    }
                    $("#"+dropdownName+"").multiselect('rebuild');
                    $("#"+dropdownName+"").change();

                    if(types=="charts")
                    {
                        //////////debugger;
                        $(`[data-name="${dataNameX}"]`).each(function() {
                            var chart = $(this).highcharts();
                            if(chart) 
                            {
                                if(chart.options.chart.type=="pie")
                                {
                                    var sliceIndex = chart.series[0].data.findIndex(function(point) {
                                        return point.name === optionName;
                                    });

                                    if (sliceIndex !== -1) 
                                    {
                                        var selectedSlice = chart.series[0].data[sliceIndex];
                                        
                                        if (option.is(':selected')) 
                                        {
                                            selectedSlice.update({
                                                borderWidth: 3,
                                                borderColor: '#000000',
                                            });
                                        } 
                                        else 
                                        {
                                            selectedSlice.update({
                                                borderWidth: 1,
                                                borderColor: '#ccc',
                                            });
                                        }
                                    }
                                }
                                else
                                {
                                    var sliceIndex = chart.series[0].data.findIndex(function(point) {
                                        return point.category === optionName;
                                    });
                                    
                                    if (sliceIndex !== -1) 
                                    {
                                        var selectedSlice = chart.series[0].data[sliceIndex];
                                        
                                        if (option.is(':selected')) 
                                        {
                                            selectedSlice.update({
                                                borderWidth: 3,
                                                borderColor: '#000000',
                                            });
                                        } 
                                        else 
                                        {
                                            selectedSlice.update({
                                                borderWidth: 1,
                                                borderColor: '#ccc',
                                            });
                                        }
                                    }
                                }
                                
                            }
                        });
                    }
                    else
                    {
                        $(`[data-name="${dataNameX}"]`).each(function() {
                            if(option.is(':selected')) 
                            {
                                $(this).find(".filter_wrap_div").addClass('customfilterselect');
                            } 
                            else 
                            {
                                $(this).find(".filter_wrap_div").removeClass('customfilterselect');
                            }
                        });
                    }
                    flagConstruct();
                }
                else
                {
                    if(types=="charts")
                    {
                        //////////debugger;
                        //dataNameX.forEach(function(e,i,a){
                            $(`[data-name="${dataNameX}"]`).each(function() {
                                var chart = $(this).highcharts();
                                if(chart) 
                                {
                                    if(chart.options.chart.type=="pie")
                                    {
                                        if(optionName.length==0)
                                        {
                                            chart.series[0].data.forEach(function(slice) {
                                                slice.update({
                                                    borderWidth: 1,
                                                    borderColor: '#ccc',
                                                });
                                            });
                                        }
                                        else
                                        {
                                            optionName.forEach(function(e,i,a){
                                                var option = $("#"+dropdownName+" option[data-name='" + e + "']");
                                                var sliceIndex = chart.series[0].data.findIndex(function(point) {
                                                    return point.name === e;
                                                });
                                                if (sliceIndex !== -1) 
                                                {
                                                    var selectedSlice = chart.series[0].data[sliceIndex];
                                                    
                                                    if (option.is(':selected')) 
                                                    {
                                                        selectedSlice.update({
                                                            borderWidth: 3,
                                                            borderColor: '#000000',
                                                        });
                                                    } 
                                                    else 
                                                    {
                                                        selectedSlice.update({
                                                            borderWidth: 1,
                                                            borderColor: '#ccc',
                                                        });
                                                    }
                                                }
                                            });
                                        }
                                    }
                                    else
                                    {
                                        optionName.forEach(function(e,i,a){
                                            var option = $("#"+dropdownName+" option[data-name='" + e + "']");
                                            var sliceIndex = chart.series[0].data.findIndex(function(point) {
                                                return point.category === e;
                                            });
                                            if (sliceIndex !== -1) 
                                            {
                                                var selectedSlice = chart.series[0].data[sliceIndex];
                                                
                                                if (option.is(':selected')) 
                                                {
                                                    selectedSlice.update({
                                                        borderWidth: 3,
                                                        borderColor: '#000000',
                                                    });
                                                } 
                                                else 
                                                {
                                                    selectedSlice.update({
                                                        borderWidth: 1,
                                                        borderColor: '#ccc',
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            });
                        //});
                    }
                    else
                    {
                        // var imgElement = $(divId).find(".gender_img")
                        // if (option.is(':selected')) 
                        // {
                        //     if(optionName=='Male')
                        //     {
                        //         imgElement.addClass('male_selected_shadow');
                        //     }
                        //     else
                        //     {
                        //         imgElement.addClass('female_selected_shadow');
                        //     }
                        // } 
                        // else 
                        // {
                        //     if(optionName=='Male')
                        //     {
                        //         imgElement.removeClass('male_selected_shadow');
                        //     }
                        //     else
                        //     {
                        //         imgElement.removeClass('female_selected_shadow');
                        //     }
                        // }
                    }
                }
            }

            function clickableSlice2()
            {
                var protienFLengthY = $("#protienF option:selected").length;
                
                if(protienFLengthY != 0)
                {
                    clickableSlice("XX","protienF_chart","protienF",protienFTxt,"charts","filters");
                }
                
            }

            function formtable(value,label,id)
            {
                var nameXX = $('#' + id).closest('.card').find('.div-head').text().trim();

                var cct = ["Attribute","Percentage"];
                // var transposeValue  = transposeData(value);
                var htmlX = ``;
                htmlX += `<tr>`;
                htmlX += `<tr class="hidekro" style="display:none"><th>${nameXX}</th></tr>`;
                cct.forEach(function(e,i,a){
                    htmlX += `<th>${e}</th>`;
                });
                htmlX += `</tr>`;

                $(`#${id} > thead`).empty().append(htmlX);

                var htmlZ = ``;
                
                value.forEach(function(e,i,a){
                    htmlZ += `<tr>`;
                    htmlZ += `<td>${label[i]}</td>`;
                    htmlZ += `<td>${e}%</td>`;
                    // e.forEach(function(e2,i2,a2){
                        
                    // });
                    htmlZ += `</tr>`;
                });
                
                $(`#${id} > tbody`).empty().append(htmlZ);
            }

            function formTable2(theadL,tbodyL,value,divid,targetid,baseA)
            {   
                ////debugger;
                //console.log(value);
                var nameXX = $(`#${divid}`).find(".funnel-col").find('table')
                //console.log(nameXX);
                var htmlX = ``;
                htmlX += `<tr>`;
                // htmlX += `<tr class="hidekro" style="display:none"><th>${nameXX}</th></tr>`;
                theadL.forEach(function(e,i,a){
                    htmlX += `<th>${e}</th>`;
                });
                htmlX += `</tr>`;

                nameXX.find("thead").empty().append(htmlX);

                var htmlZ = ``;
                
                value.forEach(function(e,i,a){
                    htmlZ += `<tr>`;
                    e.forEach(function(e2,i2,a2){
                        htmlZ += `<td>${e2}%</td>`;
                    });
                    htmlZ += `</tr>`;
                });

                htmlZ += `<tr class="allbase">`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                
                nameXX.find("tbody").empty().append(htmlZ);
            }

            function formTable3(tbodyL,value,value2,divid,targetid,baseA)
            {   
                
                if(value2==undefined)
                {
                    value2 = value1;
                }
                if(divid=="cm_14")
                {
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                } 
                else if(divid=="cm_16")
                {
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                else if(divid=="cm_12")
                {
                    //////debugger;
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                else if(divid=="fd_14")
                {
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                } 
                else if(divid=="fd_16")
                {
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                else if(divid=="fd_12")
                {
                    //////debugger;
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                else if(divid=="y_14")
                {
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                } 
                else if(divid=="y_16")
                {
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                else if(divid=="y_12")
                {
                    //////debugger;
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                else
                {
                    //debugger;
                    var nameXX = $(`#${divid}`).find(`.${targetid}`).find("table");
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                
                
            }

            function formTable7(tbodyL,value,value2,divid,targetid,baseA)
            {   
                //debugger;
                var nameXX = $(`#${divid}`).find(`#${targetid}`);
                var htmlZ = ``;
                value.forEach(function(e,i,a){
                    var significantResults = getSignificanceMatrix(baseA, value2[i]);
                    htmlZ += `<tr>`;
                    htmlZ += `<td>${tbodyL[i]}</td>`;
                    e.forEach(function(e2,i2,a2){
                        htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                    });
                    htmlZ += `</tr>`;
                });
                htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                nameXX.find("tbody").empty().append(htmlZ);
                
            }

            function formTable8(theadL,tbodyL,value,value2,divid,targetid,baseA)
            {   
                if(divid=="cm_14")
                {
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlX = ``;
                    htmlX += `<tr>`;
                    htmlX += `<th></th>`;
                    theadL.forEach(function(e,i,a){
                        htmlX += `<th>${e}</th>`;
                    });
                    htmlX += `</tr>`;
                    nameXX.find("thead").empty().append(htmlX);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        ////debugger;
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                else if(divid=="fd_14")
                {
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlX = ``;
                    htmlX += `<tr>`;
                    htmlX += `<th></th>`;
                    theadL.forEach(function(e,i,a){
                        htmlX += `<th>${e}</th>`;
                    });
                    htmlX += `</tr>`;
                    nameXX.find("thead").empty().append(htmlX);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        ////debugger;
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                else if(divid=="y_14")
                {
                    var nameXX = $(`#${divid}`).find(`#${targetid}`);
                    var htmlX = ``;
                    htmlX += `<tr>`;
                    htmlX += `<th></th>`;
                    theadL.forEach(function(e,i,a){
                        htmlX += `<th>${e}</th>`;
                    });
                    htmlX += `</tr>`;
                    nameXX.find("thead").empty().append(htmlX);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        ////debugger;
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    
                    nameXX.find("tbody").empty().append(htmlZ);
                }
                else
                {
                    var nameXX = $(`#${divid}`).find(".funnel-col").find('table')
                    var htmlX = ``;
                    htmlX += `<tr>`;
                    htmlX += `<th></th>`;
                    theadL.forEach(function(e,i,a){
                        htmlX += `<th>${e}</th>`;
                    });
                    htmlX += `</tr>`;
                    nameXX.find("thead").empty().append(htmlX);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        ////debugger;
                        var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%<sup>${significantResults[i2]}</sup></td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    htmlZ += `<tr class="allbase">`;
                    htmlZ += `<td></td>`;
                    baseA.forEach(function(e2,i2,a2){
                        htmlZ += `<td>n-${e2}</td>`;
                    });
                    htmlZ += `</tr>`;
                    nameXX.find("tbody").empty().append(htmlZ);
                }
            }

            function zTestProportions(p1, n1, p2, n2) {
                const numerator = p1 - p2;
                const denominator = Math.sqrt((p1 * (1 - p1)) / n1 + (p2 * (1 - p2)) / n2);
                return numerator / denominator;
            }

            function getSignificanceMatrix(baseArray, valueArray) {
            //console.log(baseArray);
            var len = baseArray.length;
            var result = Array.from({ length: len }, () => ""); // Initialize result array

            const i = 0; // Only compare from index 0 (i.e., 1st element)
            for (var j = 1; j < len; j++) {
                var zValue = zTestProportions(
                valueArray[i],
                baseArray[i],
                valueArray[j],
                baseArray[j]
                );
                var zValue2 = zTestProportions(
                valueArray[j],
                baseArray[j],
                valueArray[i],
                baseArray[i]
                );
                if (zValue >= 1.645) {
                result[i] += String.fromCharCode(65 + j); // Add letter for significant difference
                }

                if (zValue2 >= 1.645) {
                result[j] += String.fromCharCode(65 + i);
                }
            }

            return result;
            }

            function formTable4(tbodyL,value,value2,divid,baseA)
            {   
                //debugger;
                    var nameXX = $(`#${divid}`);
                    var htmlZ = ``;
                    value.forEach(function(e,i,a){
                        //var significantResults = getSignificanceMatrix(baseA, value2[i]);
                        htmlZ += `<tr>`;
                        htmlZ += `<td>${tbodyL[i]}</td>`;
                        e.forEach(function(e2,i2,a2){
                            htmlZ += `<td>${e2}%</td>`;
                        });
                        htmlZ += `</tr>`;
                    });
                    
                    nameXX.find("tbody").empty().append(htmlZ);
                
                
            }

            function sortByFirstCountryWithLabels(data, labels) {
                // Step 1: Get the sorting indices based on data[0], descending
                const sortedIndices = [...data[0]]
                    .map((val, idx) => ({ val, idx }))
                    .sort((a, b) => b.val - a.val) // descending
                    .map(item => item.idx);

                // Step 2: Sort the data for all countries based on sortedIndices
                const sortedData = data.map(country =>
                    sortedIndices.map(i => country[i])
                );

                // Step 3: Sort the labels using the same indices
                const sortedLabels = sortedIndices.map(i => labels[i]);

                return { sortedData, sortedLabels };
            }

            function getOffset(value) {
                const r = 25;
                const circumference = 2 * Math.PI * r;
                return circumference - (value / 100) * circumference;
            }
            function createDonut(value) {
                const offset = getOffset(value).toFixed(2);
                return `
                <div class="donutZZ">
                    <svg width="50" height="50">
                    <circle class="trackZZ" cx="25" cy="25" r="20"></circle>
                    <circle class="progressZZ" cx="25" cy="25" r="20" stroke-dasharray="125" stroke-dashoffset="${offset}"></circle>
                    </svg>
                    <div class="valueZZ">${value}%</div>
                </div>
                `;
            }

            function renderDonutTable(data, rowLabels, colLabels, flagss, divId, baseA) {
                //debugger;
                const container = document.querySelector(`#${divId} .country-col .rightFunnel .chart`);
                container.innerHTML = ''; // clear previous

                const grid = document.createElement('div');
                grid.className = 'tableZZ';

                // Header row
                grid.innerHTML += `<div class="labelZZ"></div>`;
                colLabels.forEach(function(e,i,a){
                    if(i==0)
                    {
                        grid.innerHTML += `<div class="headerZZ" style="visibility:hidden"><img src="${flagss[i]}">${e}</div>`;
                    }
                    else
                    {
                        grid.innerHTML += `<div class="headerZZ"><img src="${flagss[i]}">${e}</div>`;
                    }
                    
                })
                

                // Data rows
                data.forEach((row, rowIndex) => {
                    grid.innerHTML += `<div class="labelZZ">${rowLabels[rowIndex]}</div>`;
                    row.forEach(value => {
                        grid.innerHTML += `<div class="cellZZ">${createDonut(value)}</div>`;
                    });
                });
                grid.innerHTML += `<div class="labelZZ" style="visibility:hidden">AA</div>`;
                baseA.forEach((row, rowIndex) => {
                    
                    grid.innerHTML += `<div class="cellZZ" style="font-size:0.7rem">n-${row}</div>`;
                });

                container.appendChild(grid);
            }
            //=================================Data Manipulation End============================================

            //=================================Flag Construct Start============================================

                function flagConstruct()
                {
                    statusArr = [
                        ["inactive","inactive"],
                        ["inactive","inactive"],
                        ["inactive"],
                        ["inactive","inactive","inactive","inactive","inactive","inactive","inactive"],
                        ["inactive","inactive","inactive","inactive","inactive"],
                        ["inactive","inactive","inactive","inactive"],
                        ["inactive","inactive","inactive"],
                        ["inactive","inactive","inactive","inactive"],
                        ["inactive"],
                        ["inactive"],
                        ["inactive","inactive","inactive"],
                        ["inactive"],
                        ["inactive","inactive","inactive","inactive"],
                        ["inactive","inactive","inactive","inactive"],
                        ["inactive","inactive","inactive","inactive"],
                        ["inactive","inactive","inactive"],
                        ["inactive"],
                        ["inactive"],
                        ["inactive"],
                        ["inactive"],
                        ["inactive"],
                        ["inactive"],
                        ["inactive"],
                        ["inactive"],
                    ];
                    
                    ajaxFlag = [
                        false,false,
                        false,false,
                        false,
                        false,false,false,false,false,false,false,
                        false,false,false,false,false,
                        false,false,false,false,
                        false,false,false,
                        false,false,false,false,
                        false,
                        false,
                        false,false,false,
                        false,
                        false,false,false,false,
                        false,false,false,false,
                        false,false,false,false,
                        false,false,false,
                        false,
                        false,
                        false,
                        false,
                        false,
                        false,
                        false,
                        false,
                    ];
                    
                    functionFlag = [
                        [false,false],
                        [false,false],
                        [false],
                        [false,false,false,false,false,false,false],
                        [false,false,false,false,false],
                        [false,false,false,false],
                        [false,false,false],
                        [false,false,false,false],
                        [false],
                        [false],
                        [false,false,false],
                        [false],
                        [false,false,false,false],
                        [false,false,false,false],
                        [false,false,false,false],
                        [false,false,false],
                        [false],
                        [false],
                        [false],
                        [false],
                        [false],
                        [false],
                        [false],
                        [false],
                    ];

                    dairymilkFStatus1 = false;

                    frozenFStatus1 = false;
                    frozenFStatus2 = false;
                    frozenFStatus3 = false;
                    frozenFStatus4 = false;
                    frozenFStatus5 = false;
                    frozenFStatus6 = false;
                    frozenFStatus7 = false;

                    yougurtFStatus1 = false;
                    yougurtFStatus2 = false;
                    yougurtFStatus3 = false;
                    yougurtFStatus4 = false;
                    yougurtFStatus5 = false;

                    maltFStatus1 = false;
                    maltFStatus2 = false;
                    maltFStatus3 = false;
                    maltFStatus4 = false;

                    condensedFStatus1 = false;
                    condensedFStatus2 = false;
                    condensedFStatus3 = false;

                    protienFStatus1 = false;
                    protienFStatus2 = false;
                    protienFStatus3 = false;
                    protienFStatus4 = false;

                    adultFStatus1 = false;

                    cakeFStatus1 = false;

                    sportsFStatus1 = false;
                    sportsFStatus2 = false;
                    sportsFStatus3 = false;

                    choclateFStatus1 = false;

                    biscuitFStatus1 = false;
                    biscuitFStatus2 = false;
                    biscuitFStatus3 = false;
                    biscuitFStatus4 = false;

                    chipsFStatus1 = false;
                    chipsFStatus2 = false;
                    chipsFStatus3 = false;
                    chipsFStatus4 = false;

                    barFStatus1 = false;
                    barFStatus2 = false;
                    barFStatus3 = false;
                    barFStatus4 = false;

                    breadFStatus1 = false;
                    breadFStatus2 = false;
                    breadFStatus3 = false;

                    statusArr[dataOuter][dataInner]="active";

                    applyF();
                }

            //=================================Flag Construct End============================================
            
            //=================================Apply Start============================================
                function applyF()
                {
                    $(".splash").show();
                    
                    condX2 = ``;
                    condX = ``; 
                    trendcondX = ``;
                    conX = ``;
                    filtercondX = ``;
                    trendsfiltercondX = ``;

                    dairymilkcondX = ``;
                    forzencondX = ``;
                    yougurtcondX = ``;
                    maltcondX = ``;
                    condensedcondX = ``;
                    protiencondX = ``;
                    adultcondX = ``;
                    cakecondX = ``;
                    sportscondX = ``;
                    choclatecondX = ``;
                    biscuitcondX = ``;
                    chipscondX = ``;
                    barcondX = ``;
                    breadcondX = ``;

                    quarterTxt = [];
                    countryTxt = [];
                    regionTxt = [];
                    cityTxt = [];
                    //raceTxt = [];
                    HHITxt = [];
                    genderTxt = [];
                    ageTxt = [];
                    //halalTxt = [];
                    trends1Data = [];
                    trends2Data = [];
                    trends3Data = [];
                    childrenHouseholdTypeTxt = []

                    protienFTxt = [];

                    var quarterLengthY = $("#quarter option:selected").length;
                    var countryLengthY = $("#country option:selected").length;
                    var regionLengthY = $("#region option:selected").length;
                    var cityLengthY = $("#city option:selected").length;
                    //var raceLengthY = $("#race option:selected").length;
                    var HHILengthY = $("#HHI option:selected").length;
                    var genderLengthY = $("#gender option:selected").length;
                    var ageLengthY = $("#age option:selected").length;
                    var childrenHouseholdTypeLengthY = $("#childrenHouseholdType option:selected").length;
                    //var halalLengthY = $("#halal option:selected").length;

                    var quarterVal = $("#quarter").val();
                    var countryVal = $("#country").val();
                    var regionVal = $("#region").val();
                    var cityVal = $("#city").val();
                    //var raceVal = $("#race").val();
                    var HHIVal = $("#HHI").val();
                    var genderVal = $("#gender").val();
                    var ageVal = $("#age").val();
                    var childrenHouseholdTypeVal = $("#childrenHouseholdType").val();
                    //var halalVal = $("#halal").val();

                    var selectedOptionsquarter = $("#quarter").find("option:selected");
                    selectedOptionsquarter.each(function () {
                        var dataNameValue = $(this).data("name");
                        quarterTxt.push(dataNameValue);
                    });

                    var selectedOptionscountry = $("#country").find("option:selected");
                    selectedOptionscountry.each(function () {
                        var dataNameValue = $(this).data("name");
                        countryTxt.push(dataNameValue);
                    });

                    var selectedOptionsregion = $("#region").find("option:selected");
                    selectedOptionsregion.each(function () {
                        var dataNameValue = $(this).data("name");
                        regionTxt.push(dataNameValue);
                    });

                    var selectedOptionscity = $("#city").find("option:selected");
                    selectedOptionscity.each(function () {
                        var dataNameValue = $(this).data("name");
                        cityTxt.push(dataNameValue);
                    });

                    // var selectedOptionsrace = $("#race").find("option:selected");
                    // selectedOptionsrace.each(function () {
                    //     var dataNameValue = $(this).data("name");
                    //     raceTxt.push(dataNameValue);
                    // });

                    var selectedOptionsHHI = $("#HHI").find("option:selected");
                    selectedOptionsHHI.each(function () {
                        var dataNameValue = $(this).data("name");
                        HHITxt.push(dataNameValue);
                    });

                    var selectedOptionsgender = $("#gender").find("option:selected");
                    selectedOptionsgender.each(function () {
                        var dataNameValue = $(this).data("name");
                        genderTxt.push(dataNameValue);
                    });

                    var selectedOptionsage = $("#age").find("option:selected");
                    selectedOptionsage.each(function () {
                        var dataNameValue = $(this).data("name");
                        ageTxt.push(dataNameValue);
                    });

                    var selectedOptionsCH = $("#childrenHouseholdType").find("option:selected");
                    selectedOptionsCH.each(function () {
                        var dataNameValue = $(this).data("name");
                        childrenHouseholdTypeTxt.push(dataNameValue);
                    });

                    // var selectedOptionshalal = $("#halal").find("option:selected");
                    // selectedOptionshalal.each(function () {
                    //     var dataNameValue = $(this).data("name");
                    //     halalTxt.push(dataNameValue);
                    // });

                    if((quarterLengthY == 0) && (regionLengthY == 0) && (countryLengthY == 0) && (cityLengthY == 0) && (ageLengthY == 0) && (genderLengthY == 0) && (HHILengthY == 0) && (childrenHouseholdTypeLengthY == 0) )
                    {
                        conX = 1;
                    }
                    else
                    {
                        conX = 2;
                    }

                    if(conX==2)
                    {
                        filtercondX += `<b>Applied Filters</b>: `;

                        if(quarterLengthY != 0)
                        {
                            condX += `DQUARTER IN (${quarterVal}) AND `;
                            filtercondX += `<b>Quarter</b> = (${quarterTxt.join(", ")}) || `;
                            trendsfiltercondX += `<b>Quarter</b> IN (${quarterTxt.join(", ")}) || `;
                        }

                        if(countryLengthY != 0)
                        {
                            condX += `S0 IN (${countryVal}) AND `;
                            filtercondX += `<b>Country</b> = (${countryTxt.join(", ")}) || `;
                            trendsfiltercondX += `<b>Country</b> IN (${countryTxt.join(", ")}) || `;
                        }

                        if(regionLengthY != 0)
                        {
                            condX += `1=1 AND`;
                            filtercondX += `<b>Region</b> = (${regionTxt.join(", ")}) || `;
                            trendsfiltercondX += `<b>Region</b> IN (${regionTxt.join(", ")}) || `;
                        }

                        if(cityLengthY != 0)
                        {
                            if(cityVal.includes("V1"))
                            {
                                condX += `S1 IN (601) AND `;
                            }
                            if(cityVal.includes("V2"))
                            {
                                condX += `S1 IN (602) AND `;
                            }
                            if(cityVal.includes("V3"))
                            {
                                condX += `S1 IN (603,604,605,606,607) AND `;
                            }
                            if(cityVal.includes("L1"))
                            {
                                condX += `HCITY IN (1) AND `;
                            }
                            if(cityVal.includes("L2"))
                            {
                                condX += `HCITY IN (2) AND `;
                            }
                            filtercondX += `<b>City</b> = (${cityTxt.join(", ")}) || `;
                            trendsfiltercondX += `<b>City</b> IN (${cityTxt.join(", ")}) || `;
                        }

                        if(ageLengthY != 0)
                        {
                            condX += `HAGE IN (${ageVal}) AND `;
                            condX2 += `HAGE IN (${ageVal}) AND `;
                            filtercondX += `<b>Age</b> = (${ageTxt.join(", ")}) || `;
                            trendsfiltercondX += `<b>Age</b> IN (${ageTxt.join(", ")}) || `;
                        }

                        if(genderLengthY != 0)
                        {
                            condX += `S4 IN (${genderVal}) AND `;
                            condX2 += `S4 IN (${genderVal}) AND `;
                            filtercondX += `<b>Gender</b> = (${genderTxt.join(", ")}) || `;
                            trendsfiltercondX += `<b>Gender</b> IN (${genderTxt.join(", ")}) || `;
                        }

                        if(HHILengthY != 0)
                        {   
                            ////////debugger;
                            const countryMapping = {
                                "1": { "SGD 1": [103, 104, 105], "SGD 2": [106, 107, 108] },
                                "2": { "THB 1": [203, 204, 205], "THB 2": [206, 207, 208] },
                                "3": { "PHP 1": [303, 304, 305], "PHP 2": [306, 307, 308, 309] },
                                "4": { "IDR 1": [403, 404, 405, 406], "IDR 2": [407, 408, 409, 410] },
                                "5": { "MYR 1": [503, 504, 505, 506], "MYR 2": [507, 508, 509, 510] },
                                "6": { "VND 1": [603, 604, 605], "VND 2": [606, 607, 608] }
                            };

                            let s7Values = new Set();

                            // If no country is selected, add all S7 values
                            //console.log(countryVal);
                            ////////debugger;
                            if (countryVal === null) {
                                for (const country in countryMapping) {
                                    for (const hhi of HHIVal) { // Loop through selected HHI indexes (1 or 2)
                                        if (countryMapping[country][hhi]) {
                                            countryMapping[country][hhi].forEach(value => s7Values.add(value));
                                        }
                                    }
                                }
                            } else {
                                // If countries are selected, filter accordingly
                                for (const country of countryVal) {
                                    if (countryMapping[country]) {
                                        for (const hhi of HHIVal) {
                                            if (countryMapping[country][hhi]) {
                                                countryMapping[country][hhi].forEach(value => s7Values.add(value));
                                            }
                                        }
                                    }
                                }
                            }

                            if (s7Values.size > 0) {
                                condX += `S7 IN (${[...s7Values].join(",")}) AND `;
                                condX2 += `S7 IN (${[...s7Values].join(",")}) AND `;
                            }

                            filtercondX += `<b>Gross HHI</b> = (${HHITxt.join(", ")}) || `;
                        }

                        if(childrenHouseholdTypeLengthY != 0)
                        {
                            //console.log("childrenHouseholdTypeVal");
                            //console.log(childrenHouseholdTypeVal)
                            if(childrenHouseholdTypeVal.includes("1"))
                            {
                                condX += `P2 IN (2) AND `;
                                condX2 += `P2 IN (2) AND `;
                            }
                            if(childrenHouseholdTypeVal.includes("2"))
                            {
                                condX += `P3_1 > 0 OR P3_2 > 0 AND `;
                                condX2 += `P3_1 > 0 OR P3_2 > 0 AND `;
                            }
                            if(childrenHouseholdTypeVal.includes("3"))
                            {
                                condX += `P3_3 > 0 AND `;
                                condX2 += `P3_3 > 0 AND `;
                            }
                            if(childrenHouseholdTypeVal.includes("4"))
                            {
                                condX += `P3_4 > 0 AND `;
                                condX2 += `P3_4 > 0 AND `;
                            }

                            filtercondX += `<b>Children Household</b> = (${childrenHouseholdTypeTxt.join(", ")}) || `;

                            // condX += `S7 IN (${childrenHouseholdTypeLengthY}) AND `;
                            //filtercondX += `<b>HHI</b> = (${childrenHouseholdTypeTxt.join(", ")}) || `;
                            //trendsfiltercondX += `<b>HHI</b> IN (${childrenHouseholdTypeTxt.join(", ")}) || `;
                        }

                        // if(halalLengthY != 0)
                        // {
                        //     condX += `S10 IN (${halalVal}) AND `;
                        //     filtercondX += `<b>Halal</b> = (${halalTxt.join(", ")}) || `;
                        //     trendsfiltercondX += `<b>Halal</b> IN (${halalTxt.join(", ")}) || `;
                        // }

                        // if(raceLengthY != 0)
                        // {
                        //     if(countryVal==1)
                        //     {
                        //         condX += `S2xSG IN (${raceVal}) AND `;
                        //         filtercondX += `<b>Race</b> = (${raceTxt.join(", ")}) || `;
                        //         trendsfiltercondX += `<b>Race</b> IN (${raceTxt.join(", ")}) || `;
                        //     }
                        //     else if(countryVal==5)
                        //     {
                        //         condX += `S2xMY IN (${raceVal}) AND `;
                        //         filtercondX += `<b>Race</b> = (${raceTxt.join(", ")}) || `;
                        //         trendsfiltercondX += `<b>Race</b> IN (${raceTxt.join(", ")}) || `;
                        //     }
                        //     else if((countryVal[0]==1) && (countryVal[1]==5))
                        //     {
                        //         condX += `S2xSG IN (${raceVal}) AND `;
                        //         filtercondX += `<b>Race</b> = (${raceTxt.join(", ")}) || `;
                        //         trendsfiltercondX += `<b>Race</b> IN (${raceTxt.join(", ")}) || `;

                        //         condX += `S2xMY IN (${raceVal}) AND `;
                        //         filtercondX += `<b>Race</b> = (${raceTxt.join(", ")}) || `;
                        //         trendsfiltercondX += `<b>Race</b> IN (${raceTxt.join(", ")}) || `;
                        //     }
                        // }
                    }
                    else
                    {
                        filtercondX += `<b>Applied Filters</b>: All Selected`;
                        trendsfiltercondX += `<b>Applied Filters</b>: All Selected`;
                    }
                    condX += ` 1=1`;
                    condX2 += ` 1=1`;
                    filtercondX = filtercondX.replace(/\|\| $/, '');
                    $(".paraY").empty().append(filtercondX);
                    //console.log("condX");
                    //console.log(condX);
                    //console.log("condX2");
                    //console.log(condX2);

                    var selectedOptionsprotienF = $("#protienF").find("option:selected");
                    selectedOptionsprotienF.each(function () {
                        var dataNameValue = $(this).data("name");
                        protienFTxt.push(dataNameValue);
                    });

                    var protienFLengthY = $("#protienF option:selected").length;
                    var protienFVal = $("#protienF").val();

                    if(protienFLengthY==0)
                    {
                        ////////debugger;
                        protiencondX += `1=1`;
                        dairymilkcondX += `1=1`;
                        forzencondX += `1=1`;
                        yougurtcondX += `1=1`;
                        maltcondX += `1=1`;
                        condensedcondX += `1=1`;
                        adultcondX += `1=1`;
                        cakecondX += `1=1`;
                        sportscondX += `1=1`;
                        choclatecondX += `1=1`;
                        biscuitcondX += `1=1`;
                        chipscondX += `1=1`;
                        barcondX += `1=1`;
                        breadcondX += `1=1`;
                        $('div[data-name="protienF_chart"]').each(function () {
                            $(this).closest('.card').removeClass('addFD');
                        });
                        
                    }
                    else
                    {
                        protiencondX += `PD_C0 IN (${protienFVal}) AND 1=1`;
                        dairymilkcondX += `CM_C0 IN (${protienFVal}) AND 1=1`;
                        forzencondX += `FD_C0 IN (${protienFVal}) AND 1=1`;
                        yougurtcondX += `Y_C0 IN (${protienFVal}) AND 1=1`;
                        maltcondX += `MD_C0 IN (${protienFVal}) AND 1=1`;
                        condensedcondX += `CEM_C0 IN (${protienFVal}) AND 1=1`;
                        adultcondX += `AD_C0 IN (${protienFVal}) AND 1=1`;
                        cakecondX += `CK_C0 IN (${protienFVal}) AND 1=1`;
                        sportscondX += `SD_C0 IN (${protienFVal}) AND 1=1`;
                        choclatecondX += `CL_C0 IN (${protienFVal}) AND 1=1`;
                        biscuitcondX += `BC_C0 IN (${protienFVal}) AND 1=1`;
                        chipscondX += `CC_C0 IN (${protienFVal}) AND 1=1`;
                        barcondX += `BAR_C0 IN (${protienFVal}) AND 1=1`;
                        breadcondX += `BB_C0 IN (${protienFVal}) AND 1=1`;
                        $('div[data-name="protienF_chart"]').each(function () {
                            $(this).closest('.card').addClass('addFD');
                        });
                    }

                    fetchBase();

                    statusArr.forEach(function(e,i,a){
                        e.forEach(function(e2,i2,a2){
                            if(e2=="active")
                            {
                                if(trendStatus===false)
                                {
                                    if(functionFlag[i][i2]===false)
                                    {
                                        const selectedFunction = allAjax[i][i2];
                                        functionFlag[i][i2] = true;
                                        selectedFunction();
                                    }
                                    else{}
                                }
                                else
                                {
                                    if(functionFlagT[i][i2]===false)
                                    {
                                        const selectedFunction = trendsAjax[i][i2];
                                        functionFlagT[i][i2] = true;
                                        selectedFunction();
                                    }
                                }
                            }
                            else{}
                        });
                    });
                }
            //=================================Apply End============================================

            //=================================Ajax Start============================================

                function fetchBase()
                {
                    $.ajax({
                        url: "api/base.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            overallBase = data[0];
                            $("#overallBase").empty().append(overallBase);
                        },
                        complete: function (data) {
                        }
                    })
                }

                function consumptionAjax()
                {
                    $.ajax({
                        url: "api/consumption.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var ever = data['ever'];
                            var consumed1Y = data['consumed1Y'];
                            var consumed3M = data['consumed3M'];
                            var consumed7D = data['consumed7D'];

                            var everV = [];
                            var everB = [];
                            var everC = [];
                            var everVX = [];

                            var consumed1YV = [];
                            var consumed1YB = [];
                            var consumed1YC = [];
                            var consumed1YVX = [];

                            var consumed3MV = [];
                            var consumed3MB = [];
                            var consumed3MC = [];
                            var consumed3MVX = [];

                            var consumed7DV = [];
                            var consumed7DB = [];
                            var consumed7DC = [];
                            var consumed7DVX = [];
                            
                            extractValues(ever,everV,everB,everC,"Simple");
                            extractValues(consumed1Y,consumed1YV,consumed1YB,consumed1YC,"Simple");
                            extractValues(consumed3M,consumed3MV,consumed3MB,consumed3MC,"Simple");
                            extractValues(consumed7D,consumed7DV,consumed7DB,consumed7DC,"Simple");
                            
                            $("#cheese4").empty().append(`${everV[0]}%`);
                            $("#dairymilk4").empty().append(`${everV[2]}%`);
                            $("#yogurt4").empty().append(`${everV[1]}%`);
                            $("#frozen4").empty().append(`${everV[5]}%`);
                            $("#condensed4").empty().append(`${everV[3]}%`);
                            $("#bread4").empty().append(`${everV[12]}%`);
                            $("#biscuit4").empty().append(`${everV[13]}%`);
                            $("#chips4").empty().append(`${everV[14]}%`);
                            $("#choclate4").empty().append(`${everV[10]}%`);
                            $("#cake4").empty().append(`${everV[11]}%`);
                            $("#protienb4").empty().append(`${everV[9]}%`);
                            $("#protiend4").empty().append(`${everV[7]}%`);
                            $("#sports4").empty().append(`${everV[6]}%`);
                            $("#malt4").empty().append(`${everV[4]}%`);
                            $("#adult4").empty().append(`${everV[8]}%`);

                            $("#cheese4").parent().css("width",`${everV[0]}%`);
                            $("#dairymilk4").parent().css("width",`${everV[2]}%`);
                            $("#yogurt4").parent().css("width",`${everV[1]}%`);
                            $("#frozen4").parent().css("width",`${everV[5]}%`);
                            $("#condensed4").parent().css("width",`${everV[3]}%`);
                            $("#bread4").parent().css("width",`${everV[12]}%`);
                            $("#biscuit4").parent().css("width",`${everV[13]}%`);
                            $("#chips4").parent().css("width",`${everV[14]}%`);
                            $("#choclate4").parent().css("width",`${everV[10]}%`);
                            $("#cake4").parent().css("width",`${everV[11]}%`);
                            $("#protienb4").parent().css("width",`${everV[9]}%`);
                            $("#protiend4").parent().css("width",`${everV[7]}%`);
                            $("#sports4").parent().css("width",`${everV[6]}%`);
                            $("#malt4").parent().css("width",`${everV[4]}%`);
                            $("#adult4").parent().css("width",`${everV[8]}%`);

                            $("#cheese3").empty().append(`${consumed1YV[0]}%`);
                            $("#dairymilk3").empty().append(`${consumed1YV[2]}%`);
                            $("#yogurt3").empty().append(`${consumed1YV[1]}%`);
                            $("#frozen3").empty().append(`${consumed1YV[5]}%`);
                            $("#condensed3").empty().append(`${consumed1YV[3]}%`);
                            $("#bread3").empty().append(`${consumed1YV[12]}%`);
                            $("#biscuit3").empty().append(`${consumed1YV[13]}%`);
                            $("#chips3").empty().append(`${consumed1YV[14]}%`);
                            $("#choclate3").empty().append(`${consumed1YV[10]}%`);
                            $("#cake3").empty().append(`${consumed1YV[11]}%`);
                            $("#protienb3").empty().append(`${consumed1YV[9]}%`);
                            $("#protiend3").empty().append(`${consumed1YV[7]}%`);
                            $("#sports3").empty().append(`${consumed1YV[6]}%`);
                            $("#malt3").empty().append(`${consumed1YV[4]}%`);
                            $("#adult3").empty().append(`${consumed1YV[8]}%`);

                            $("#cheese3").parent().css("width",`${consumed1YV[0]}%`);
                            $("#dairymilk3").parent().css("width",`${consumed1YV[2]}%`);
                            $("#yogurt3").parent().css("width",`${consumed1YV[1]}%`);
                            $("#frozen3").parent().css("width",`${consumed1YV[5]}%`);
                            $("#condensed3").parent().css("width",`${consumed1YV[3]}%`);
                            $("#bread3").parent().css("width",`${consumed1YV[12]}%`);
                            $("#biscuit3").parent().css("width",`${consumed1YV[13]}%`);
                            $("#chips3").parent().css("width",`${consumed1YV[14]}%`);
                            $("#choclate3").parent().css("width",`${consumed1YV[10]}%`);
                            $("#cake3").parent().css("width",`${consumed1YV[11]}%`);
                            $("#protienb3").parent().css("width",`${consumed1YV[9]}%`);
                            $("#protiend3").parent().css("width",`${consumed1YV[7]}%`);
                            $("#sports3").parent().css("width",`${consumed1YV[6]}%`);
                            $("#malt3").parent().css("width",`${consumed1YV[4]}%`);
                            $("#adult3").parent().css("width",`${consumed1YV[8]}%`);

                            $("#cheese2").empty().append(`${consumed3MV[0]}%`);
                            $("#dairymilk2").empty().append(`${consumed3MV[2]}%`);
                            $("#yogurt2").empty().append(`${consumed3MV[1]}%`);
                            $("#frozen2").empty().append(`${consumed3MV[5]}%`);
                            $("#condensed2").empty().append(`${consumed3MV[3]}%`);
                            $("#bread2").empty().append(`${consumed3MV[12]}%`);
                            $("#biscuit2").empty().append(`${consumed3MV[13]}%`);
                            $("#chips2").empty().append(`${consumed3MV[14]}%`);
                            $("#choclate2").empty().append(`${consumed3MV[10]}%`);
                            $("#cake2").empty().append(`${consumed3MV[11]}%`);
                            $("#protienb2").empty().append(`${consumed3MV[9]}%`);
                            $("#protiend2").empty().append(`${consumed3MV[7]}%`);
                            $("#sports2").empty().append(`${consumed3MV[6]}%`);
                            $("#malt2").empty().append(`${consumed3MV[4]}%`);
                            $("#adult2").empty().append(`${consumed3MV[8]}%`);

                            $("#cheese2").parent().css("width",`${consumed3MV[0]}%`);
                            $("#dairymilk2").parent().css("width",`${consumed3MV[2]}%`);
                            $("#yogurt2").parent().css("width",`${consumed3MV[1]}%`);
                            $("#frozen2").parent().css("width",`${consumed3MV[5]}%`);
                            $("#condensed2").parent().css("width",`${consumed3MV[3]}%`);
                            $("#bread2").parent().css("width",`${consumed3MV[12]}%`);
                            $("#biscuit2").parent().css("width",`${consumed3MV[13]}%`);
                            $("#chips2").parent().css("width",`${consumed3MV[14]}%`);
                            $("#choclate2").parent().css("width",`${consumed3MV[10]}%`);
                            $("#cake2").parent().css("width",`${consumed3MV[11]}%`);
                            $("#protienb2").parent().css("width",`${consumed3MV[9]}%`);
                            $("#protiend2").parent().css("width",`${consumed3MV[7]}%`);
                            $("#sports2").parent().css("width",`${consumed3MV[6]}%`);
                            $("#malt2").parent().css("width",`${consumed3MV[4]}%`);
                            $("#adult2").parent().css("width",`${consumed3MV[8]}%`);

                            $("#cheese1").empty().append(`${consumed7DV[0]}%`);
                            $("#dairymilk1").empty().append(`${consumed7DV[2]}%`);
                            $("#yogurt1").empty().append(`${consumed7DV[1]}%`);
                            $("#frozen1").empty().append(`${consumed7DV[5]}%`);
                            $("#condensed1").empty().append(`${consumed7DV[3]}%`);
                            $("#bread1").empty().append(`${consumed7DV[12]}%`);
                            $("#biscuit1").empty().append(`${consumed7DV[13]}%`);
                            $("#chips1").empty().append(`${consumed7DV[14]}%`);
                            $("#choclate1").empty().append(`${consumed7DV[10]}%`);
                            $("#cake1").empty().append(`${consumed7DV[11]}%`);
                            $("#protienb1").empty().append(`${consumed7DV[9]}%`);
                            $("#protiend1").empty().append(`${consumed7DV[7]}%`);
                            $("#sports1").empty().append(`${consumed7DV[6]}%`);
                            $("#malt1").empty().append(`${consumed7DV[4]}%`);
                            $("#adult1").empty().append(`${consumed7DV[8]}%`);

                            $("#cheese1").parent().css("width",`${consumed7DV[0]}%`);
                            $("#dairymilk1").parent().css("width",`${consumed7DV[2]}%`);
                            $("#yogurt1").parent().css("width",`${consumed7DV[1]}%`);
                            $("#frozen1").parent().css("width",`${consumed7DV[5]}%`);
                            $("#condensed1").parent().css("width",`${consumed7DV[3]}%`);
                            $("#bread1").parent().css("width",`${consumed7DV[12]}%`);
                            $("#biscuit1").parent().css("width",`${consumed7DV[13]}%`);
                            $("#chips1").parent().css("width",`${consumed7DV[14]}%`);
                            $("#choclate1").parent().css("width",`${consumed7DV[10]}%`);
                            $("#cake1").parent().css("width",`${consumed7DV[11]}%`);
                            $("#protienb1").parent().css("width",`${consumed7DV[9]}%`);
                            $("#protiend1").parent().css("width",`${consumed7DV[7]}%`);
                            $("#sports1").parent().css("width",`${consumed7DV[6]}%`);
                            $("#malt1").parent().css("width",`${consumed7DV[4]}%`);
                            $("#adult1").parent().css("width",`${consumed7DV[8]}%`);

                            $(".incidenceBase").each(function(){
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                if (overallBase < 30) {
                                    htmlB += `${overallBase}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${overallBase})`;
                                }
                                $(this).empty().append(htmlB);
                                
                                var span = $(this);
                                var htmlContent = span.html();
                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            });
                        },
                        complete: function (data) {
                            ajaxFlag[1+0] = true;
                            $(".splash").hide();
                        }
                    })
                }

                function consumptionAjax2()
                {
                    $.ajax({
                        url: "api/consumption2.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log("consumption2");
                            //console.log(data);

                            var consumed1Y = data['consumed1Y'];
                            var consumed3M = data['consumed3M'];
                            var consumed7D = data['consumed7D'];

                            var consumed1YV = [];
                            var consumed1YB = [];
                            var consumed1YC = [];
                            var consumed1YVX = [];

                            var consumed3MV = [];
                            var consumed3MB = [];
                            var consumed3MC = [];
                            var consumed3MVX = [];

                            var consumed7DV = [];
                            var consumed7DB = [];
                            var consumed7DC = [];
                            var consumed7DVX = [];
                            
                            extractValues(consumed7D,consumed7DV,consumed7DB,consumed7DC,"Simple");
                            spiderChart(consumed7DV,"ci_1",productLabel);

                            extractValues(consumed3M,consumed3MV,consumed3MB,consumed3MC,"Simple");
                            spiderChart(consumed3MV,"ci_2",productLabel);

                            extractValues(consumed1Y,consumed1YV,consumed1YB,consumed1YC,"Simple");
                            spiderChart(consumed1YV,"ci_3",productLabel);

                            
                        },
                        complete: function (data) {
                            ajaxFlag[1+0] = true;
                            $(".splash").hide();
                        }
                    })
                }

                function firstAjax() {
                    $.ajax({
                        url: "api/ajax1.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var CHF1 = data['CH_F1'];
                            var CHF1X1 = data['CH_F1x1'];
                            var CHF2 = data['CH_F2'];
                            var CHF3 = data['CH_F3'];
                            var CHF4 = data['CH_F4'];
                            var CHF5 = data['CH_F5'];
                            var CHF6 = data['CH_F6'];
                            var CHF7 = data['CH_F7'];
                            var CHF8 = data['CH_F8'];
                            var CHFC8 = data['CH_F_C8'];
                            var CHFC11 = data['CH_F_C11'];
                            var CHFC12 = data['CH_F_C12'];
                            var CHFC15 = data['CH_F_C15'];
                            var CHC16 = data['CH_C16'];
                            var CHC17 = data['CH_C17'];
                            var CHC18 = data['CH_C18'];
                            var CHC19 = data['CH_C19'];
                            var CHC20 = data['CH_C20'];

                            var S13_1 = data['S13_1'];

                            var CHF1V = [];
                            var CHF1B = [];
                            var CHF1C = [];
                            var CHF1VX = [];

                            var CHF1X1V = [];
                            var CHF1X1B = [];
                            var CHF1X1C = [];
                            var CHF1X1VX = [];

                            var CHF2V = [];
                            var CHF2B = [];
                            var CHF2C = [];
                            var CHF2VX = [];

                            var CHF3V = [];
                            var CHF3B = [];
                            var CHF3C = [];
                            var CHF3VX = [];

                            var CHF4V = [];
                            var CHF4B = [];
                            var CHF4C = [];
                            var CHF4VX = [];

                            var CHF5V = [];
                            var CHF5B = [];
                            var CHF5C = [];
                            var CHF5VX = [];

                            var CHF6V = [];
                            var CHF6B = [];
                            var CHF6C = [];
                            var CHF6VX = [];

                            var CHF7V = [];
                            var CHF7B = [];
                            var CHF7C = [];
                            var CHF7VX = [];

                            var CHF8V = [];
                            var CHF8B = [];
                            var CHF8C = [];
                            var CHF8VX = [];

                            var CHFC8V = [];
                            var CHFC8B = [];
                            var CHFC8C = [];
                            var CHFC8VX = [];

                            var CHFC11V = [];
                            var CHFC11B = [];
                            var CHFC11C = [];
                            var CHFC11VX = [];

                            var CHFC12V = [];
                            var CHFC12B = [];
                            var CHFC12C = [];
                            var CHFC12VX = [];

                            var CHFC15V = [];
                            var CHFC15B = [];
                            var CHFC15C = [];
                            var CHFC15VX = [];

                            var CHC16V = [];
                            var CHC16B = [];
                            var CHC16C = [];
                            var CHC16VX = [];

                            var CHC17V = [];
                            var CHC17B = [];
                            var CHC17C = [];
                            var CHC17VX = [];

                            var CHC18V = [];
                            var CHC18B = [];
                            var CHC18C = [];
                            var CHC18VX = [];

                            var CHC19V = [];
                            var CHC19B = [];
                            var CHC19C = [];
                            var CHC19VX = [];

                            var CHC20V = [];
                            var CHC20B = [];
                            var CHC20C = [];
                            var CHC20VX = [];

                            var S13_1V = [];
                            var S13_1B = [];
                            var S13_1C = [];
                            var S13_1VX = [];

                            extractValues(CHF1,CHF1V,CHF1B,CHF1C,"Simple");
                            customizedArray(CHF1V,CHF1VX,CHF1label,colorPallet68,"Doughnut");
                            doughnutChart2(CHF1VX,"ch_f1","Foodservice Consumption",295);
                            var baseX = processBase(CHF1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_f1_base").empty().append(htmlB);

                            var span = $('#ch_f1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CHF1X1,CHF1X1V,CHF1X1B,CHF1X1C,"Simple");
                            customizedArray(CHF1X1V,CHF1X1VX,CHF1_1label,colorPallet68,"Doughnut");
                            doughnutChart2(CHF1X1VX,"ch_f1_1","Place of consumption",295);
                            var baseX = processBase(CHF1X1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_f1_1_base").empty().append(htmlB);

                            var span = $('#ch_f1_1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHF2,CHF2V,CHF2B,CHF2C,"Simple");
                            var max = (Math.max(...CHF2V)+20);
                            customizedArray(CHF2V,CHF2VX,CHF2label,colorPallet69,"Bar");
                            columnChart(CHF2VX,"ch_f2",CHF2label,max);

                            var baseX = processBase(CHF2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_f2_base").empty().append(htmlB);

                            var span = $('#ch_f2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHF3,CHF3V,CHF3B,CHF3C,"Simple");
                            var max = (Math.max(...CHF3V)+20);
                            customizedArray(CHF3V,CHF3VX,CHF3label,colorPallet69,"Bar");
                            columnChart(CHF3VX,"ch_f3",CHF3label,max);

                            var baseX = processBase(CHF3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_f3_base").empty().append(htmlB);

                            var span = $('#ch_f3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHF4,CHF4V,CHF4B,CHF4C,"Simple");
                            customizedArray(CHF4V,CHF4VX,CHF4label,colorPallet68,"Doughnut");
                            doughnutChart2(CHF4VX,"ch_f4","Knowledge of Variety",295);
                            var baseX = processBase(CHF4B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_f4_base").empty().append(htmlB);

                            var span = $('#ch_f4_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHF5,CHF5V,CHF5B,CHF5C,"Simple");
                            var max = (Math.max(...CHF5V)+20);
                            customizedArray(CHF5V,CHF5VX,CHF5label,colorPallet69,"Bar");
                            barChart(CHF5VX,"ch_f5",CHF5label,max);

                            var baseX = processBase(CHF5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_f5_base").empty().append(htmlB);

                            var span = $('#ch_f5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHF6,CHF6V,CHF6B,CHF6C,"Simple");
                            customizedArray(CHF6V,CHF6VX,CHF6label,colorPallet68,"Doughnut");
                            doughnutChart2(CHF6VX,"ch_f6","Natural vs. Processed Cheese",295);
                            var baseX = processBase(CHF6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_f6_base").empty().append(htmlB);

                            var span = $('#ch_f6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHF7,CHF7V,CHF7B,CHF7C,"Simple");
                            // customizedArray(CHF7V,CHF7VX,CHF7label,colorPallet69,"Doughnut");
                            // doughnutChart2(CHF7VX,"ch_f7","Country of Origin",295);
                            CHF7V.forEach(function(e,i,a){
                                $(`#ch_f7_${i+1}`).empty().append(`${e}%`);
                            });
                            var baseX = processBase(CHF7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_f7_base").empty().append(htmlB);

                            var span = $('#ch_f7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHF8,CHF8V,CHF8B,CHF8C,"Simple");
                            customizedArray(CHF8V,CHF8VX,CHF8label,colorPallet68,"Doughnut");
                            doughnutChart2(CHF8VX,"ch_f8","Source of Cheese",295);
                            var baseX = processBase(CHF8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_f8_base").empty().append(htmlB);

                            var span = $('#ch_f8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            extractValues(CHFC8,CHFC8V,CHFC8B,CHFC8C,"Simple");
                            var max = (Math.max(...CHFC8V)+20);
                            customizedArray(CHFC8V,CHFC8VX,CHFC8label,colorPallet69,"Bar");
                            barChart(CHFC8VX,"ch_f_c8",CHFC8label,max);
                            //console.log("CHFC8VX");
                            //console.log(CHFC8VX);

                            var baseX = processBase(CHFC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_f_c8_base").empty().append(htmlB);

                            var span = $('#ch_f_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHFC11,CHFC11V,CHFC11B,CHFC11C,"Simple");
                            var max = (Math.max(...CHFC11V)+20);
                            customizedArray(CHFC11V,CHFC11VX,CHFC11label,colorPallet69,"Bar");
                            columnChart(CHFC11VX,"ch_f_c11",CHFC11label,max);

                            var baseX = processBase(CHFC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_f_c11_base").empty().append(htmlB);

                            var span = $('#ch_f_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHFC12,CHFC12V,CHFC12B,CHFC12C,"Simple");
                            var max = (Math.max(...CHFC12V)+20);
                            customizedArray(CHFC12V,CHFC12VX,CHFC12label,colorPallet69,"Bar");
                            columnChart(CHFC12VX,"ch_f_c12",CHFC12label,max);

                            var baseX = processBase(CHFC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_f_c12_base").empty().append(htmlB);

                            var span = $('#ch_f_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHFC15,CHFC15V,CHFC15B,CHFC15C,"Simple");
                            CHFC15V.forEach(function(e,i,a){
                                $(`#ch_f15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CHFC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_f15_base").empty().append(htmlB);

                            var span = $('#ch_f15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // common question

                            extractValues(CHC16,CHC16V,CHC16B,CHC16C,"Simple");
                            var max = (Math.max(...CHC16V)+20);
                            customizedArray(CHC16V,CHC16VX,CHC16label,colorPallet69,"Bar");
                            barChart(CHC16VX,"ch_fc16",CHC16label,max);
                            
                            var baseX = processBase(CHC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_fc16_base").empty().append(htmlB);

                            var span = $('#ch_fc16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CHC17,CHC17V,CHC17B,CHC17C,"Simple");
                            CHC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`ch_fc17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CHC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_fc17_base").empty().append(htmlB);

                            var span = $('#ch_fc17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CHC18,CHC18V,CHC18B,CHC18C,"Simple");
                            var max = (Math.max(...CHC18V)+20);
                            customizedArray(CHC18V,CHC18VX,CHC18label,colorPallet69,"Bar");
                            barChart(CHC18VX,"ch_fc18",CHC18label,max);

                            var baseX = processBase(CHC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_fc18_base").empty().append(htmlB);
                            
                            var span = $('#ch_fc18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CHC19,CHC19V,CHC19B,CHC19C,"Simple");
                            var max = (Math.max(...CHC19V)+20);
                            customizedArray(CHC19V,CHC19VX,CHC19label,colorPallet69,"Bar");
                            barChart(CHC19VX,"ch_fc19",CHC19label,max);

                            var baseX = processBase(CHC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_fc19_base").empty().append(htmlB);
                            
                            var span = $('#ch_fc19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CHC20,CHC20V,CHC20B,CHC20C,"Simple");
                            CHC20V.forEach(function(e,i,a){
                                $(`#ch_fr20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CHC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_fr20_base").empty().append(htmlB);
                            
                            var span = $('#ch_fr20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            extractValues(S13_1, S13_1V, S13_1B, S13_1C, "Simple");
                            var max = (Math.max(...S13_1V)+20);
                            customizedArray(S13_1V,S13_1VX,S13label,colorPallet69,"Bar");
                            barChart(S13_1VX,"ch_1_s13",S13label,max);
                            //barChart(S13_1VX,"ch_2_s13",S13label,max);

                            var baseX = processBase(S13_1B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_1_s13_base").empty().append(htmlB);
                            //$("#ch_2_s13_base").empty().append(htmlB);

                            var span = $('#ch_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // var span = $('#ch_2_s13_base');
                            // var htmlContent = span.html();

                            // if (htmlContent.includes('Low')) {
                            //     var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                            //     span.html(updatedContent);
                            // } else {
                            //     var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                            //     span.html(cleanedContent); 
                            // }

                        },
                        complete: function (data) {
                            ajaxFlag[1+1] = true;
                            $(".splash").hide();
                        }
                    })
                }

                function firstAjaxN() {
                    $.ajax({
                        url: "api/ajax1N.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var CHR1 =  data['CH_R1'];
                            var CHRF1 =  data['CH_RF1'];
                            var CHR2 =  data['CH_R2'];
                            var CHR3 =  data['CH_R3'];
                            var CHR4 =  data['CH_R4'];
                            var CHR5 =  data['CH_R5'];
                            var CHR6 =  data['CH_R6'];
                            var CHR7 =  data['CH_R7'];
                            var CHR8 =  data['CH_R8'];
                            var CHRC8 =  data['CH_R_C8'];
                            var CHRC11 =  data['CH_R_C11'];
                            var CHRC12 =  data['CH_R_C12'];
                            var CHRC15 =  data['CH_R_C15'];
                            var CHC16 = data['CH_C16'];
                            var CHC17 = data['CH_C17'];
                            var CHC18 = data['CH_C18'];
                            var CHC19 = data['CH_C19'];
                            var CHC20 = data['CH_C20'];

                            var S13_1 = data['S13_1'];

                            var CHR1V = [];
                            var CHR1B = [];
                            var CHR1C = [];
                            var CHR1VX = [];

                            var CHRF1V = [];
                            var CHRF1B = [];
                            var CHRF1C = [];
                            var CHRF1VX = [];

                            var CHR2V = [];
                            var CHR2B = [];
                            var CHR2C = [];
                            var CHR2VX = [];

                            var CHR3V = [];
                            var CHR3B = [];
                            var CHR3C = [];
                            var CHR3VX = [];

                            var CHR4V = [];
                            var CHR4B = [];
                            var CHR4C = [];
                            var CHR4VX = [];

                            var CHR5V = [];
                            var CHR5B = [];
                            var CHR5C = [];
                            var CHR5VX = [];

                            var CHR6V = [];
                            var CHR6B = [];
                            var CHR6C = [];
                            var CHR6VX = [];

                            var CHR7V = [];
                            var CHR7B = [];
                            var CHR7C = [];
                            var CHR7VX = [];

                            var CHR8V = [];
                            var CHR8B = [];
                            var CHR8C = [];
                            var CHR8VX = [];

                            var CHRC8V = [];
                            var CHRC8B = [];
                            var CHRC8C = [];
                            var CHRC8VX = [];

                            var CHRC11V = [];
                            var CHRC11B = [];
                            var CHRC11C = [];
                            var CHRC11VX = [];

                            var CHRC12V = [];
                            var CHRC12B = [];
                            var CHRC12C = [];
                            var CHRC12VX = [];

                            var CHRC15V = [];
                            var CHRC15B = [];
                            var CHRC15C = [];
                            var CHRC15VX = [];

                            var CHC16V = [];
                            var CHC16B = [];
                            var CHC16C = [];
                            var CHC16VX = [];

                            var CHC17V = [];
                            var CHC17B = [];
                            var CHC17C = [];
                            var CHC17VX = [];

                            var CHC18V = [];
                            var CHC18B = [];
                            var CHC18C = [];
                            var CHC18VX = [];

                            var CHC19V = [];
                            var CHC19B = [];
                            var CHC19C = [];
                            var CHC19VX = [];

                            var CHC20V = [];
                            var CHC20B = [];
                            var CHC20C = [];
                            var CHC20VX = [];

                            var S13_1V = [];
                            var S13_1B = [];
                            var S13_1C = [];
                            var S13_1VX = [];

                            extractValues(CHR1,CHR1V,CHR1B,CHR1C,"Simple");
                            customizedArray(CHR1V,CHR1VX,CHR1label,colorPallet68,"Doughnut");
                            doughnutChart2(CHR1VX,"ch_r1","Retail Consumption",295);
                            var baseX = processBase(CHR1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_r1_base").empty().append(htmlB);

                            var span = $('#ch_r1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHR2,CHR2V,CHR2B,CHR2C,"Simple");
                            var max = (Math.max(...CHR2V)+20);
                            customizedArray(CHR2V,CHR2VX,CHR2label,colorPallet69,"Bar");
                            columnChart(CHR2VX,"ch_r2",CHR2label,max);

                            var baseX = processBase(CHR2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_r2_base").empty().append(htmlB);

                            var span = $('#ch_r2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHR3,CHR3V,CHR3B,CHR3C,"Simple");
                            var max = (Math.max(...CHR3V)+20);
                            customizedArray(CHR3V,CHR3VX,CHR3label,colorPallet69,"Bar");
                            columnChart(CHR3VX,"ch_r3",CHR3label,max);

                            var baseX = processBase(CHR3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_r3_base").empty().append(htmlB);

                            var span = $('#ch_r3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHR4,CHR4V,CHR4B,CHR4C,"Simple");
                            customizedArray(CHR4V,CHR4VX,CHR4label,colorPallet68,"Doughnut");
                            doughnutChart2(CHR4VX,"ch_r4","Knowledge of Variety",295);
                            var baseX = processBase(CHR4B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_r4_base").empty().append(htmlB);

                            var span = $('#ch_r4_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                             // 

                            extractValues(CHR5,CHR5V,CHR5B,CHR5C,"Simple");
                            var max = (Math.max(...CHR5V)+20);
                            customizedArray(CHR5V,CHR5VX,CHR5label,colorPallet69,"Bar");
                            barChart(CHR5VX,"ch_r5",CHR5label,max);

                            var baseX = processBase(CHR5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_r5_base").empty().append(htmlB);

                            var span = $('#ch_r5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHR6,CHR6V,CHR6B,CHR6C,"Simple");
                            customizedArray(CHR6V,CHR6VX,CHR6label,colorPallet68,"Doughnut");
                            doughnutChart2(CHR6VX,"ch_r6","Natural vs. Processed",295);
                            var baseX = processBase(CHR6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_r6_base").empty().append(htmlB);

                            var span = $('#ch_r6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHR7,CHR7V,CHR7B,CHR7C,"Simple");
                            // customizedArray(CHR7V,CHR7VX,CHR7label,colorPallet69,"Doughnut");
                            // doughnutChart2(CHR7VX,"ch_r7","Country of origin",295);
                            
                            CHR7V.forEach(function(e,i,a){
                                $(`#ch_r7_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CHR7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_r7_base").empty().append(htmlB);

                            var span = $('#ch_r7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHR8,CHR8V,CHR8B,CHR8C,"Simple");
                            customizedArray(CHR8V,CHR8VX,CHR8label,colorPallet68,"Doughnut");
                            doughnutChart2(CHR8VX,"ch_r8","Source of Cheese",295);
                            var baseX = processBase(CHR8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_r8_base").empty().append(htmlB);

                            var span = $('#ch_r8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHRC8,CHRC8V,CHRC8B,CHRC8C,"Simple");
                            var max = (Math.max(...CHRC8V)+20);
                            customizedArray(CHRC8V,CHRC8VX,CHRC8label,colorPallet69,"Bar");
                            barChart(CHRC8VX,"ch_r_c8",CHRC8label,max);

                            var baseX = processBase(CHRC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_r_c8_base").empty().append(htmlB);

                            var span = $('#ch_r_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHRC11,CHRC11V,CHRC11B,CHRC11C,"Simple");
                            var max = (Math.max(...CHRC11V)+20);
                            customizedArray(CHRC11V,CHRC11VX,CHRC11label,colorPallet69,"Bar");
                            columnChart(CHRC11VX,"ch_r_c11",CHRC11label,max);

                            var baseX = processBase(CHRC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_r_c11_base").empty().append(htmlB);

                            var span = $('#ch_r_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHRC12,CHRC12V,CHRC12B,CHRC12C,"Simple");
                            var max = (Math.max(...CHRC12V)+20);
                            customizedArray(CHRC12V,CHRC12VX,CHRC12label,colorPallet69,"Bar");
                            columnChart(CHRC12VX,"ch_r_c12",CHRC12label,max);

                            var baseX = processBase(CHRC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_r_c12_base").empty().append(htmlB);

                            var span = $('#ch_r_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CHRC15,CHRC15V,CHRC15B,CHRC15C,"Simple");
                            CHRC15V.forEach(function(e,i,a){
                                $(`#ch_r15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CHRC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_r15_base").empty().append(htmlB);

                            var span = $('#ch_r15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // common question

                            extractValues(CHC16,CHC16V,CHC16B,CHC16C,"Simple");
                            var max = (Math.max(...CHC16V)+20);
                            customizedArray(CHC16V,CHC16VX,CHC16label,colorPallet69,"Bar");
                            
                            barChart(CHC16VX,"ch_rsc16",CHC16label,max);

                            var baseX = processBase(CHC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            
                            $("#ch_rsc16_base").empty().append(htmlB);

                            var span = $('#ch_rsc16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CHC17,CHC17V,CHC17B,CHC17C,"Simple");
                            CHC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`ch_rsc17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CHC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_rsc17_base").empty().append(htmlB);

                            var span = $('#ch_rsc17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CHC18,CHC18V,CHC18B,CHC18C,"Simple");
                            var max = (Math.max(...CHC18V)+20);
                            customizedArray(CHC18V,CHC18VX,CHC18label,colorPallet69,"Bar");
                            barChart(CHC18VX,"ch_rsc18",CHC18label,max);

                            var baseX = processBase(CHC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_rsc18_base").empty().append(htmlB);

                            var span = $('#ch_rsc18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CHC19,CHC19V,CHC19B,CHC19C,"Simple");
                            var max = (Math.max(...CHC19V)+20);
                            customizedArray(CHC19V,CHC19VX,CHC19label,colorPallet69,"Bar");
                            barChart(CHC19VX,"ch_rsc19",CHC19label,max);

                            var baseX = processBase(CHC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_rsc19_base").empty().append(htmlB);

                            var span = $('#ch_rsc19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CHC20,CHC20V,CHC20B,CHC20C,"Simple");
                            CHC20V.forEach(function(e,i,a){
                                $(`#ch_rsr20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CHC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ch_rsr20_base").empty().append(htmlB);

                            var span = $('#ch_rsr20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            extractValues(S13_1, S13_1V, S13_1B, S13_1C, "Simple");
                            var max = (Math.max(...S13_1V)+20);
                            customizedArray(S13_1V,S13_1VX,S13label,colorPallet69,"Bar");
                            barChart(S13_1VX,"ch_2_s13",S13label,max);

                            var baseX = processBase(S13_1B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ch_2_s13_base").empty().append(htmlB);

                            var span = $('#ch_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            ajaxFlag[1+2] = true;
                            $(".splash").hide();
                        }
                    })
                }

                function secondAjax() {
                    //console.log(dairymilkcondX)
                    $.ajax({
                        url: "api/ajax2.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'dairymilkcondX':dairymilkcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);
                            var CMC0 = data['CM_C0'];
                            var CMC2 = data['CM_C2'];
                            var CMC3 = data['CM_C3'];
                            var CMC4b = data['CM_C4b'];
                            var CMC5 = data['CM_C5'];
                            var CMC6 = data['CM_C6'];
                            var CMC7 = data['CM_C7'];
                            var CMC8 = data['CM_C8'];
                            var CMC9 = data['CM_C9'];
                            var CMC10 = data['CM_C10'];
                            var CMC11 = data['CM_C11'];
                            var CMC12 = data['CM_C12'];
                            var CMC15 = data['CM_C15'];
                            var CMC16 = data['CM_C16'];
                            var CMC17 = data['CM_C17'];
                            var CMC18 = data['CM_C18'];
                            var CMC19 = data['CM_C19'];
                            var CMC20 = data['CM_C20'];

                            var S13_3 = data['S13_3'];

                            var CMC0V = [];
                            var CMC0B = [];
                            var CMC0C = [];
                            var CMC0VX = [];

                            var CMC2V = [];
                            var CMC2B = [];
                            var CMC2C = [];
                            var CMC2VX = [];

                            var CMC3V = [];
                            var CMC3B = [];
                            var CMC3C = [];
                            var CMC3VX = [];

                            var CMC4bV = [];
                            var CMC4bB = [];
                            var CMC4bC = [];
                            var CMC4bVX = [];

                            var CMC5V = [];
                            var CMC5B = [];
                            var CMC5C = [];
                            var CMC5VX = [];

                            var CMC6V = [];
                            var CMC6B = [];
                            var CMC6C = [];
                            var CMC6VX = [];

                            var CMC7V = [];
                            var CMC7B = [];
                            var CMC7C = [];
                            var CMC7VX = [];

                            var CMC8V = [];
                            var CMC8B = [];
                            var CMC8C = [];
                            var CMC8VX = [];

                            var CMC9V = [];
                            var CMC9B = [];
                            var CMC9C = [];
                            var CMC9VX = [];

                            var CMC10V = [];
                            var CMC10B = [];
                            var CMC10C = [];
                            var CMC10VX = [];

                            var CMC11V = [];
                            var CMC11B = [];
                            var CMC11C = [];
                            var CMC11VX = [];

                            var CMC12V = [];
                            var CMC12B = [];
                            var CMC12C = [];
                            var CMC12VX = [];

                            var CMC13V = [];
                            var CMC13B = [];
                            var CMC13C = [];
                            var CMC13VX = [];

                            var CMC14V = [];
                            var CMC14B = [];
                            var CMC14C = [];
                            var CMC14VX = [];

                            var CMC15V = [];
                            var CMC15B = [];
                            var CMC15C = [];
                            var CMC15VX = [];

                            var CMC16V = [];
                            var CMC16B = [];
                            var CMC16C = [];
                            var CMC16VX = [];

                            var CMC17V = [];
                            var CMC17B = [];
                            var CMC17C = [];
                            var CMC17VX = [];

                            var CMC18V = [];
                            var CMC18B = [];
                            var CMC18C = [];
                            var CMC18VX = [];

                            var CMC19V = [];
                            var CMC19B = [];
                            var CMC19C = [];
                            var CMC19VX = [];

                            var CMC20V = [];
                            var CMC20B = [];
                            var CMC20C = [];
                            var CMC20VX = [];

                            var S13_3V = []; 
                            var S13_3B = []; 
                            var S13_3C = []; 
                            var S13_3VX = [];

                            if(dairymilkFStatus1==false)
                            {
                                extractValues(CMC0,CMC0V,CMC0B,CMC0C,"Simple");
                                //customizedArray(CMC0V,CMC0VX,CMC0label,colorPallet69,"Doughnut");
                                //doughnutChart2(CMC0VX,"cm1_c0","Food Service vs. Retail",295);
                                CMC0V.forEach(function(e,i,a){
                                    $(`#cm1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CMC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#cm1_c0_base").empty().append(htmlB);

                                var span = $('#cm1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                formtable(CMC0V,CMC0label,"cm1_c0TA");
                            }
                            
                            extractValues(CMC2,CMC2V,CMC2B,CMC2C,"Simple");
                            customizedArray(CMC2V,CMC2VX,CMC2label,colorPallet68,"Doughnut");
                            doughnutChart2(CMC2VX,"cm1_c2","Type of dairy milk you had","auto");

                            var baseX = processBase(CMC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c2_base").empty().append(htmlB);

                            var span = $('#cm1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC2V,CMC2label,"cm1_c2TA");

                            extractValues(CMC3,CMC3V,CMC3B,CMC3C,"Simple");
                            var max = (Math.max(...CMC3V)+20);
                            customizedArray(CMC3V,CMC3VX,CMC3label,colorPallet69,"Bar");
                            barChart(CMC3VX,"cm1_c3",CMC3label,max);

                            var baseX = processBase(CMC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c3_base").empty().append(htmlB);

                            var span = $('#cm1_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC3V,CMC3label,"cm1_c3TA");

                            extractValues(CMC4b,CMC4bV,CMC4bB,CMC4bC,"Simple");
                            customizedArray(CMC4bV,CMC4bVX,CMC4blabel,colorPallet68,"Doughnut");
                            doughnutChart2(CMC4bVX,"cm1_c4b","Consumed with hot or cold",285);
                            var baseX = processBase(CMC4bB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c4b_base").empty().append(htmlB);

                            var span = $('#cm1_c4b_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC4bV,CMC4blabel,"cm1_c4bTA");

                            extractValues(CMC5,CMC5V,CMC5B,CMC5C,"Simple");
                            customizedArray(CMC5V,CMC5VX,CMC5label,colorPallet68,"Doughnut");
                            doughnutChart(CMC5VX,"cm1_c5","Category Consumed",300);

                            var baseX = processBase(CMC5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c5_base").empty().append(htmlB);

                            var span = $('#cm1_c5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC5V,CMC5label,"cm1_c5TA");

                            extractValues(CMC6,CMC6V,CMC6B,CMC6C,"Simple");
                            customizedArray(CMC6V,CMC6VX,CMC6label,colorPallet69,"Doughnut");
                            pieChart(CMC6VX,"cm1_c6","Type of Packaging","auto");

                            var baseX = processBase(CMC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c6_base").empty().append(htmlB);

                            var span = $('#cm1_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC6V,CMC6label,"cm1_c6TA");

                            extractValues(CMC7,CMC7V,CMC7B,CMC7C,"Simple");
                            customizedArray(CMC7V,CMC7VX,CMC7label,colorPallet68,"Doughnut");
                            pieChart(CMC7VX,"cm1_c7","Type of Packaging","auto");

                            var baseX = processBase(CMC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c7_base").empty().append(htmlB);

                            var span = $('#cm1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC7V,CMC7label,"cm1_c7TA");

                            extractValues(CMC8,CMC8V,CMC8B,CMC8C,"Simple");
                            var max = (Math.max(...CMC8V)+20);
                            customizedArray(CMC8V,CMC8VX,CMC8label,colorPallet69,"Bar");
                            barChart(CMC8VX,"cm1_c8",CMC8label,max);

                            var baseX = processBase(CMC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c8_base").empty().append(htmlB);

                            var span = $('#cm1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC8V,CMC8label,"cm1_c8TA");

                            extractValues(CMC9,CMC9V,CMC9B,CMC9C,"Simple");
                            var max = (Math.max(...CMC9V)+20);
                            customizedArray(CMC9V,CMC9VX,CMC9label,colorPallet69,"Bar");
                            barChart(CMC9VX,"cm1_c9",CMC9label,max);

                            var baseX = processBase(CMC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c9_base").empty().append(htmlB);

                            var span = $('#cm1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC9V,CMC9label,"cm1_c9TA");

                            extractValues(CMC10,CMC10V,CMC10B,CMC10C,"Simple");
                            customizedArray(CMC10V,CMC10VX,CMC10label,colorPallet68,"Doughnut");
                            pieChart(CMC10VX,"cm1_c10","Way of consumption","auto");

                            var baseX = processBase(CMC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c10_base").empty().append(htmlB);

                            var span = $('#cm1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC10V,CMC10label,"cm1_c10TA");

                            extractValues(CMC11,CMC11V,CMC11B,CMC11C,"Simple");
                            var max = (Math.max(...CMC11V)+20);
                            customizedArray(CMC11V,CMC11VX,CMC11label,colorPallet69,"Bar");
                            columnChart(CMC11VX,"cm1_c11",CMC11label,max);

                            var baseX = processBase(CMC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c11_base").empty().append(htmlB);

                            var span = $('#cm1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC11V,CMC11label,"cm1_c11TA");

                            extractValues(CMC12,CMC12V,CMC12B,CMC12C,"Simple");
                            var max = (Math.max(...CMC12V)+20);
                            customizedArray(CMC12V,CMC12VX,CMC12label,colorPallet69,"Bar");
                            columnChart(CMC12VX,"cm1_c12",CMC12label,max);

                            var baseX = processBase(CMC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c12_base").empty().append(htmlB);

                            var span = $('#cm1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC12V,CMC12label,"cm1_c12TA");

                            extractValues(CMC15,CMC15V,CMC15B,CMC15C,"Simple");
                            CMC15V.forEach(function(e,i,a){
                                $(`#cm1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CMC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c15_base").empty().append(htmlB);

                            var span = $('#cm1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            formtable(CMC15V,CMC15label,"cm1_c15TA");

                            extractValues(CMC16,CMC16V,CMC16B,CMC16C,"Simple");
                            var max = (Math.max(...CMC16V)+20);
                            customizedArray(CMC16V,CMC16VX,CMC16label,colorPallet69,"Bar");
                            barChart(CMC16VX,"cm1_c16",CMC16label,max);

                            var baseX = processBase(CMC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c16_base").empty().append(htmlB);

                            var span = $('#cm1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CMC17,CMC17V,CMC17B,CMC17C,"Simple");
                            CMC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`cm1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CMC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c17_base").empty().append(htmlB);

                            var span = $('#cm1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CMC18,CMC18V,CMC18B,CMC18C,"Simple");
                            var max = (Math.max(...CMC18V)+20);
                            customizedArray(CMC18V,CMC18VX,CMC18label,colorPallet69,"Bar");
                            barChart(CMC18VX,"cm1_c18",CMC18label,max);

                            var baseX = processBase(CMC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c18_base").empty().append(htmlB);

                            var span = $('#cm1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CMC19,CMC19V,CMC19B,CMC19C,"Simple");
                            var max = (Math.max(...CMC19V)+20);
                            customizedArray(CMC19V,CMC19VX,CMC19label,colorPallet69,"Bar");
                            barChart(CMC19VX,"cm1_c19",CMC19label,max);

                            var baseX = processBase(CMC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c19_base").empty().append(htmlB);

                            var span = $('#cm1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(CMC20,CMC20V,CMC20B,CMC20C,"Simple");
                            CMC20V.forEach(function(e,i,a){
                                $(`#cm1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CMC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cm1_c20_base").empty().append(htmlB);

                            var span = $('#cm1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            ////////debugger;
                            extractValues(S13_3, S13_3V, S13_3B, S13_3C, "Simple");
                            var max = (Math.max(...S13_3V)+20);
                            customizedArray(S13_3V,S13_3VX,S13label,colorPallet69,"Bar");
                            barChart(S13_3VX,"cm_1_s13",S13label,max);

                            var baseX = processBase(S13_3B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cm_1_s13_base").empty().append(htmlB);

                            var span = $('#cm_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            var lineData1 = [
                                {
                                    "name": `${CMC0label[0]}`,
                                    "data": [43,48,65,81,11,14,22,23]
                                },
                                {
                                    "name": `${CMC0label[1]}`,
                                    "data": [24,37,29,29,32,30,23,24]
                                },
                            ];

                            var lineData2 = [
                                {
                                    "name": `${CMC4blabel[0]}`,
                                    "data": [43,48,65,81,11,14,22,23]
                                },
                                {
                                    "name": `${CMC4blabel[1]}`,
                                    "data": [24,37,29,29,32,30,23,24]
                                },
                            ];

                            var lineData3 = [
                                {
                                    "name": `${CMC5label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${CMC5label[1]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC5label[2]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC5label[3]}`,
                                    "data": [11,30,16,19,20,24,43,26]
                                },
                                {
                                    "name": `${CMC5label[4]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC5label[5]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                }
                            ];

                            var lineData4 = [
                                {
                                    "name": `${CMC2label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${CMC2label[1]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC2label[2]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC2label[3]}`,
                                    "data": [11,30,16,19,20,24,43,26]
                                },
                                {
                                    "name": `${CMC2label[4]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                }
                            ];

                            var lineData5 = [
                                {
                                    "name": `${CMC3label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${CMC3label[1]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC3label[2]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC3label[3]}`,
                                    "data": [11,30,16,19,20,24,43,26]
                                },
                                {
                                    "name": `${CMC3label[4]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                }
                            ];

                            var lineData6 = [
                                {
                                    "name": `${CMC6label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${CMC6label[1]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC6label[2]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC6label[3]}`,
                                    "data": [11,30,16,19,20,24,43,26]
                                },
                                {
                                    "name": `${CMC6label[4]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC6label[5]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                }
                            ];

                            var lineData7 = [
                                {
                                    "name": `${CMC7label[0]}`,
                                    "data": [43,48,65,81,11,14,22,23]
                                },
                                {
                                    "name": `${CMC7label[1]}`,
                                    "data": [24,37,29,29,32,30,23,24]
                                },
                            ];

                            var lineData8 = [
                                {
                                    "name": `${CMC8label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${CMC8label[1]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC8label[2]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC8label[3]}`,
                                    "data": [11,30,16,19,20,24,43,26]
                                },
                                {
                                    "name": `${CMC8label[4]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC8label[5]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                }
                            ];

                            var lineData9 = [
                                {
                                    "name": `${CMC9label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${CMC9label[1]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC9label[2]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC9label[3]}`,
                                    "data": [11,30,16,19,20,24,43,26]
                                },
                                {
                                    "name": `${CMC9label[4]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC9label[5]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC9label[6]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC9label[7]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                }
                            ];

                            var lineData10 = [
                                {
                                    "name": `${CMC10label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${CMC10label[1]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC10label[2]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC10label[3]}`,
                                    "data": [11,30,16,19,20,24,43,26]
                                },
                                {
                                    "name": `${CMC10label[4]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                }
                            ];

                            var lineData11 = [
                                {
                                    "name": `${CMC11label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${CMC11label[1]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC11label[2]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC11label[3]}`,
                                    "data": [11,30,16,19,20,24,43,26]
                                },
                                {
                                    "name": `${CMC11label[4]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${CMC11label[5]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${CMC11label[6]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                }
                            ];

                            var heatData1 = [
                                [0, 0, 10], [0, 1, 19], [0, 2, 8], [0, 3, 24], [0, 4, 67], [0, 5, 19], [0, 6, 8], [0, 7, 24],
                                [1, 0, 92], [1, 1, 58], [1, 2, 78], [1, 3, 33], [1, 4, 48], [1, 5, 19], [1, 6, 8], [1, 7, 24],
                                [2, 0, 35], [2, 1, 15], [2, 2, 23], [2, 3, 64], [2, 4, 52], [2, 5, 19], [2, 6, 8], [2, 7, 24],
                                [3, 0, 72], [3, 1, 32], [3, 2, 34], [3, 3, 19], [3, 4, 16], [3, 5, 19], [3, 6, 8], [3, 7, 24],
                                [4, 0, 38], [4, 1, 5], [4, 2, 8], [4, 3, 44], [4, 4, 22], [4, 5, 19], [4, 6, 8], [4, 7, 24],
                                [5, 0, 88], [5, 1, 32], [5, 2, 12], [5, 3, 6], [5, 4, 46], [5, 5, 19], [5, 6, 8], [5, 7, 24],
                                [6, 0, 88], [6, 1, 32], [6, 2, 12], [6, 3, 6], [6, 4, 46], [6, 5, 19], [6, 6, 8], [6, 7, 24],
                                [7, 0, 35], [7, 1, 15], [7, 2, 23], [7, 3, 64], [7, 4, 52], [7, 5, 19], [7, 6, 8], [7, 7, 24],
                            ];

                            var heatData2 = [
                                [0, 0, 10], [0, 1, 19], [0, 2, 8], [0, 3, 24], [0, 4, 67], [0, 5, 19], [0, 6, 8],
                                [1, 0, 92], [1, 1, 58], [1, 2, 78], [1, 3, 33], [1, 4, 48], [1, 5, 19], [1, 6, 8],
                                [2, 0, 35], [2, 1, 15], [2, 2, 23], [2, 3, 64], [2, 4, 52], [2, 5, 19], [2, 6, 8],
                                [3, 0, 72], [3, 1, 32], [3, 2, 34], [3, 3, 19], [3, 4, 16], [3, 5, 19], [3, 6, 8],
                                [4, 0, 38], [4, 1, 5], [4, 2, 8], [4, 3, 44], [4, 4, 22], [4, 5, 19], [4, 6, 8],
                                [5, 0, 88], [5, 1, 32], [5, 2, 12], [5, 3, 6], [5, 4, 46], [5, 5, 19], [5, 6, 8],
                                [6, 0, 88], [6, 1, 32], [6, 2, 12], [6, 3, 6], [6, 4, 46], [6, 5, 19], [6, 6, 8],
                                [7, 0, 35], [7, 1, 15], [7, 2, 23], [7, 3, 64], [7, 4, 52], [7, 5, 19], [7, 6, 8],
                            ]

                            // lineChart(lineData1,"cm1_c0T");
                            // lineChart(lineData2,"cm1_c4bT");
                            // lineChart(lineData3,"cm1_c5T");
                            // stackbarChart(lineData4,"cm1_c2T");
                            // lineChart(lineData5,"cm1_c3T");
                            // stackcolumnChart(lineData6,"cm1_c6T");
                            // lineChart(lineData7,"cm1_c7T");
                            // lineChart(lineData8,"cm1_c8T");
                            // //stackcolumnChart(lineData9,"cm1_c9T");
                            // lineChart(lineData10,"cm1_c10T");
                            // //stackcolumnChart(lineData11,"cm1_c11T");
                            // heatChart(heatData1,"cm1_c9T",CMC9label);
                            // heatChart(heatData2,"cm1_c11T",CMC11label);






                            // iske upar

                            var lineData2 = [
                                {
                                    "name": `${PDC5label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${PDC5label[1]}`,
                                    "data": [24,37,29,29,32,30,43,24]
                                },
                                {
                                    "name": `${PDC5label[2]}`,
                                    "data": [11,30,16,19,20,24,34,25]
                                },
                                {
                                    "name": `${PDC5label[3]}`,
                                    "data": [11,30,16,19,20,24,43,26]
                                }
                            ];

                            var stackbarData1 = [
                                {
                                    "name": `${PDC10label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${PDC10label[1]}`,
                                    "data": [24,37,29,29,32,30,12,24]
                                },
                                {
                                    "name": `${PDC10label[2]}`,
                                    "data": [11,30,16,19,20,24,13,25]
                                },
                                {
                                    "name": `${PDC10label[3]}`,
                                    "data": [11,30,16,19,20,24,14,26]
                                }
                            ];

                            var stackcolumnData1 = [
                                {
                                    "name": `${PDC6label[0]}`,
                                    "data": [43,48,65,81,11,14,33,23]
                                },
                                {
                                    "name": `${PDC6label[1]}`,
                                    "data": [24,37,29,29,32,30,13,24]
                                },
                                {
                                    "name": `${PDC6label[2]}`,
                                    "data": [11,30,16,19,20,24,32,25]
                                },
                                {
                                    "name": `${PDC6label[3]}`,
                                    "data": [11,30,16,19,20,24,47,26]
                                },
                                {
                                    "name": `${PDC6label[4]}`,
                                    "data": [11,30,16,19,20,24,33,27]
                                }
                            ];

                            var lineData3 = [
                                {
                                    "name": `${PDC7label[0]}`,
                                    "data": [43,48,65,81,11,14,44,23]
                                },
                                {
                                    "name": `${PDC7label[1]}`,
                                    "data": [24,37,29,29,32,30,32,24]
                                },
                            ];

                            var heatData1 = [
                                [0, 0, 10], [0, 1, 19], [0, 2, 8], [0, 3, 24], [0, 4, 67], [0, 5, 19], [0, 6, 8], [0, 7, 24],
                                [1, 0, 92], [1, 1, 58], [1, 2, 78], [1, 3, 33], [1, 4, 48], [1, 5, 19], [1, 6, 8], [1, 7, 24],
                                [2, 0, 35], [2, 1, 15], [2, 2, 23], [2, 3, 64], [2, 4, 52], [2, 5, 19], [2, 6, 8], [2, 7, 24],
                                [3, 0, 72], [3, 1, 32], [3, 2, 34], [3, 3, 19], [3, 4, 16], [3, 5, 19], [3, 6, 8], [3, 7, 24],
                                [4, 0, 38], [4, 1, 5], [4, 2, 8], [4, 3, 44], [4, 4, 22], [4, 5, 19], [4, 6, 8], [4, 7, 24],
                                [5, 0, 88], [5, 1, 32], [5, 2, 12], [5, 3, 6], [5, 4, 46], [5, 5, 19], [5, 6, 8], [5, 7, 24],
                                [6, 0, 88], [6, 1, 32], [6, 2, 12], [6, 3, 6], [6, 4, 46], [6, 5, 19], [6, 6, 8], [6, 7, 24],
                                [7, 0, 35], [7, 1, 15], [7, 2, 23], [7, 3, 64], [7, 4, 52], [7, 5, 19], [7, 6, 8], [7, 7, 24],
                            ]

                        },
                        complete: function (data) {
                            dairymilkFStatus1 = true;
                            ajaxFlag[1+3] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirdAjax() {
                    $.ajax({
                        url: "api/ajax3.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'forzencondX': forzencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var FDC0 = data['FD_C0'];
                            var FDC2 = data['FD_C2'];
                            var FDC3 = data['FD_C3'];
                            var FDC4a = data['FD_C4a'];
                            var FDC6 = data['FD_C6'];
                            var FDC7 = data['FD_C7'];
                            var FDC8 = data['FD_C8'];
                            var FDC9 = data['FD_C9'];
                            var FDC10 = data['FD_C10'];
                            var FDC11 = data['FD_C11'];
                            var FDC12 = data['FD_C12'];
                            var FDC15 = data['FD_C15'];
                            var FDC16 = data['FD_C16'];
                            var FDC17 = data['FD_C17'];
                            var FDC18 = data['FD_C18'];
                            var FDC19 = data['FD_C19'];
                            var FDC20 = data['FD_C20'];

                            var S13_6 = data['S13_6'];

                            var FDC0V = [];
                            var FDC0B = [];
                            var FDC0C = [];
                            var FDC0VX = [];

                            var FDC2V = [];
                            var FDC2B = [];
                            var FDC2C = [];
                            var FDC2VX = [];

                            var FDC3V = [];
                            var FDC3B = [];
                            var FDC3C = [];
                            var FDC3VX = [];

                            var FDC4aV = [];
                            var FDC4aB = [];
                            var FDC4aC = [];
                            var FDC4aVX = [];

                            var FDC6V = [];
                            var FDC6B = [];
                            var FDC6C = [];
                            var FDC6VX = [];

                            var FDC7V = [];
                            var FDC7B = [];
                            var FDC7C = [];
                            var FDC7VX = [];

                            var FDC8V = [];
                            var FDC8B = [];
                            var FDC8C = [];
                            var FDC8VX = [];

                            var FDC9V = [];
                            var FDC9B = [];
                            var FDC9C = [];
                            var FDC9VX = [];

                            var FDC10V = [];
                            var FDC10B = [];
                            var FDC10C = [];
                            var FDC10VX = [];

                            var FDC11V = [];
                            var FDC11B = [];
                            var FDC11C = [];
                            var FDC11VX = [];

                            var FDC12V = [];
                            var FDC12B = [];
                            var FDC12C = [];
                            var FDC12VX = [];

                            var FDC13V = [];
                            var FDC13B = [];
                            var FDC13C = [];
                            var FDC13VX = [];

                            var FDC14V = [];
                            var FDC14B = [];
                            var FDC14C = [];
                            var FDC14VX = [];

                            var FDC15V = [];
                            var FDC15B = [];
                            var FDC15C = [];
                            var FDC15VX = [];

                            var FDC16V = [];
                            var FDC16B = [];
                            var FDC16C = [];
                            var FDC16VX = [];

                            var FDC17V = [];
                            var FDC17B = [];
                            var FDC17C = [];
                            var FDC17VX = [];

                            var FDC18V = [];
                            var FDC18B = [];
                            var FDC18C = [];
                            var FDC18VX = [];

                            var FDC19V = [];
                            var FDC19B = [];
                            var FDC19C = [];
                            var FDC19VX = [];

                            var FDC20V = [];
                            var FDC20B = [];
                            var FDC20C = [];
                            var FDC20VX = [];

                            var S13_6V = [];
                            var S13_6B = [];
                            var S13_6C = [];
                            var S13_6VX = [];

                            if(frozenFStatus1==false)
                            {
                                extractValues(FDC0,FDC0V,FDC0B,FDC0C,"Simple");
                                FDC0V.forEach(function(e,i,a){
                                    $(`#fd1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(FDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#fd1_c0_base").empty().append(htmlB);

                                var span = $('#fd1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(FDC2,FDC2V,FDC2B,FDC2C,"Simple");
                            customizedArray(FDC2V,FDC2VX,FDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(FDC2VX,"fd1_c2","Type of protein","auto");

                            var baseX = processBase(FDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c2_base").empty().append(htmlB);

                            var span = $('#fd1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC3,FDC3V,FDC3B,FDC3C,"Simple");
                            var max = (Math.max(...FDC3V)+20);
                            customizedArray(FDC3V,FDC3VX,FDC3label,colorPallet69,"Bar");
                            barChart(FDC3VX,"fd1_c3",FDC3label,max);

                            var baseX = processBase(FDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c3_base").empty().append(htmlB);

                            var span = $('#fd1_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC4a,FDC4aV,FDC4aB,FDC4aC,"Simple");
                            customizedArray(FDC4aV,FDC4aVX,FDC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(FDC4aVX,"fd1_c4a","Type of protein","auto");

                            var baseX = processBase(FDC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c4a_base").empty().append(htmlB);

                            var span = $('#fd1_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC6,FDC6V,FDC6B,FDC6C,"Simple");
                            customizedArray(FDC6V,FDC6VX,FDC6label,colorPallet69,"Doughnut");
                            pieChart(FDC6VX,"fd1_c6","Type of Packaging","auto");

                            var baseX = processBase(FDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c6_base").empty().append(htmlB);

                            var span = $('#fd1_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC7,FDC7V,FDC7B,FDC7C,"Simple");
                            customizedArray(FDC7V,FDC7VX,FDC7label,colorPallet68,"Doughnut");
                            pieChart(FDC7VX,"fd1_c7","Type of Packaging","auto");

                            var baseX = processBase(FDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c7_base").empty().append(htmlB);

                            var span = $('#fd1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC8,FDC8V,FDC8B,FDC8C,"Simple");
                            var max = (Math.max(...FDC8V)+20);
                            customizedArray(FDC8V,FDC8VX,FDC8label,colorPallet69,"Bar");
                            barChart(FDC8VX,"fd1_c8",FDC8label,max);

                            var baseX = processBase(FDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c8_base").empty().append(htmlB);

                            var span = $('#fd1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC9,FDC9V,FDC9B,FDC9C,"Simple");
                            var max = (Math.max(...FDC9V)+20);
                            customizedArray(FDC9V,FDC9VX,FDC9label,colorPallet69,"Bar");
                            barChart(FDC9VX,"fd1_c9",FDC9label,max);

                            var baseX = processBase(FDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c9_base").empty().append(htmlB);

                            var span = $('#fd1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC10,FDC10V,FDC10B,FDC10C,"Simple");
                            customizedArray(FDC10V,FDC10VX,FDC10label,colorPallet68,"Doughnut");
                            pieChart(FDC10VX,"fd1_c10","Way of consumption","auto");

                            var baseX = processBase(FDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c10_base").empty().append(htmlB);

                            var span = $('#fd1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC11,FDC11V,FDC11B,FDC11C,"Simple");
                            var max = (Math.max(...FDC11V)+20);
                            customizedArray(FDC11V,FDC11VX,FDC11label,colorPallet69,"Bar");
                            columnChart(FDC11VX,"fd1_c11",FDC11label,max);

                            var baseX = processBase(FDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c11_base").empty().append(htmlB);

                            var span = $('#fd1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC12,FDC12V,FDC12B,FDC12C,"Simple");
                            var max = (Math.max(...FDC12V)+20);
                            customizedArray(FDC12V,FDC12VX,FDC12label,colorPallet69,"Bar");
                            columnChart(FDC12VX,"fd1_c12",FDC12label,max);

                            var baseX = processBase(FDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c12_base").empty().append(htmlB);

                            var span = $('#fd1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC15,FDC15V,FDC15B,FDC15C,"Simple");
                            FDC15V.forEach(function(e,i,a){
                                $(`#fd1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c15_base").empty().append(htmlB);

                            var span = $('#fd1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC16,FDC16V,FDC16B,FDC16C,"Simple");
                            var max = (Math.max(...FDC16V)+20);
                            customizedArray(FDC16V,FDC16VX,FDC16label,colorPallet69,"Bar");
                            barChart(FDC16VX,"fd1_c16",FDC16label,max);

                            var baseX = processBase(FDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c16_base").empty().append(htmlB);

                            var span = $('#fd1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC17,FDC17V,FDC17B,FDC17C,"Simple");
                            FDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`fd1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(FDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c17_base").empty().append(htmlB);

                            var span = $('#fd1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC18,FDC18V,FDC18B,FDC18C,"Simple");
                            var max = (Math.max(...FDC18V)+20);
                            customizedArray(FDC18V,FDC18VX,FDC18label,colorPallet69,"Bar");
                            barChart(FDC18VX,"fd1_c18",FDC18label,max);

                            var baseX = processBase(FDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c18_base").empty().append(htmlB);

                            var span = $('#fd1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC19,FDC19V,FDC19B,FDC19C,"Simple");
                            var max = (Math.max(...FDC19V)+20);
                            customizedArray(FDC19V,FDC19VX,FDC19label,colorPallet69,"Bar");
                            barChart(FDC19VX,"fd1_c19",FDC19label,max);

                            var baseX = processBase(FDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c19_base").empty().append(htmlB);

                            var span = $('#fd1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC20,FDC20V,FDC20B,FDC20C,"Simple");
                            FDC20V.forEach(function(e,i,a){
                                $(`#fd1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd1_c20_base").empty().append(htmlB);

                            var span = $('#fd1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_6, S13_6V, S13_6B, S13_6C, "Simple");
                            var max = (Math.max(...S13_6V)+20);
                            customizedArray(S13_6V,S13_6VX,S13label,colorPallet69,"Bar");
                            barChart(S13_6VX,"fd_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_6B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd_1_s13_base").empty().append(htmlB);

                            var span = $('#fd_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            frozenFStatus1 = true;
                            ajaxFlag[1+4] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function forthAjax() {
                    $.ajax({
                        url: "api/ajax4.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'forzencondX': forzencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var FDC0 = data['FD_C0'];
                            var FDC2 = data['FD_C2'];
                            var FDC3 = data['FD_C3'];
                            var FDC4a = data['FD_C4a'];
                            var FDC6 = data['FD_C6'];
                            var FDC7 = data['FD_C7'];
                            var FDC8 = data['FD_C8'];
                            var FDC9 = data['FD_C9'];
                            var FDC10 = data['FD_C10'];
                            var FDC11 = data['FD_C11'];
                            var FDC12 = data['FD_C12'];
                            var FDC15 = data['FD_C15'];
                            var FDC16 = data['FD_C16'];
                            var FDC17 = data['FD_C17'];
                            var FDC18 = data['FD_C18'];
                            var FDC19 = data['FD_C19'];
                            var FDC20 = data['FD_C20'];

                            var S13_6 = data['S13_6'];

                            var FDC0V = [];
                            var FDC0B = [];
                            var FDC0C = [];
                            var FDC0VX = [];

                            var FDC2V = [];
                            var FDC2B = [];
                            var FDC2C = [];
                            var FDC2VX = [];

                            var FDC3V = [];
                            var FDC3B = [];
                            var FDC3C = [];
                            var FDC3VX = [];

                            var FDC4aV = [];
                            var FDC4aB = [];
                            var FDC4aC = [];
                            var FDC4aVX = [];

                            var FDC6V = [];
                            var FDC6B = [];
                            var FDC6C = [];
                            var FDC6VX = [];

                            var FDC7V = [];
                            var FDC7B = [];
                            var FDC7C = [];
                            var FDC7VX = [];

                            var FDC8V = [];
                            var FDC8B = [];
                            var FDC8C = [];
                            var FDC8VX = [];

                            var FDC9V = [];
                            var FDC9B = [];
                            var FDC9C = [];
                            var FDC9VX = [];

                            var FDC10V = [];
                            var FDC10B = [];
                            var FDC10C = [];
                            var FDC10VX = [];

                            var FDC11V = [];
                            var FDC11B = [];
                            var FDC11C = [];
                            var FDC11VX = [];

                            var FDC12V = [];
                            var FDC12B = [];
                            var FDC12C = [];
                            var FDC12VX = [];

                            var FDC13V = [];
                            var FDC13B = [];
                            var FDC13C = [];
                            var FDC13VX = [];

                            var FDC14V = [];
                            var FDC14B = [];
                            var FDC14C = [];
                            var FDC14VX = [];

                            var FDC15V = [];
                            var FDC15B = [];
                            var FDC15C = [];
                            var FDC15VX = [];

                            var FDC16V = [];
                            var FDC16B = [];
                            var FDC16C = [];
                            var FDC16VX = [];

                            var FDC17V = [];
                            var FDC17B = [];
                            var FDC17C = [];
                            var FDC17VX = [];

                            var FDC18V = [];
                            var FDC18B = [];
                            var FDC18C = [];
                            var FDC18VX = [];

                            var FDC19V = [];
                            var FDC19B = [];
                            var FDC19C = [];
                            var FDC19VX = [];

                            var FDC20V = [];
                            var FDC20B = [];
                            var FDC20C = [];
                            var FDC20VX = [];

                            var S13_6V = [];
                            var S13_6B = [];
                            var S13_6C = [];
                            var S13_6VX = [];

                            if(frozenFStatus2==false)
                            {
                                extractValues(FDC0,FDC0V,FDC0B,FDC0C,"Simple");
                                FDC0V.forEach(function(e,i,a){
                                    $(`#fd2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(FDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#fd2_c0_base").empty().append(htmlB);

                                var span = $('#fd2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(FDC2,FDC2V,FDC2B,FDC2C,"Simple");
                            customizedArray(FDC2V,FDC2VX,FDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(FDC2VX,"fd2_c2","Type of protein","auto");

                            var baseX = processBase(FDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c2_base").empty().append(htmlB);

                            var span = $('#fd2_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC3,FDC3V,FDC3B,FDC3C,"Simple");
                            var max = (Math.max(...FDC3V)+20);
                            customizedArray(FDC3V,FDC3VX,FDC3label,colorPallet69,"Bar");
                            barChart(FDC3VX,"fd2_c3",FDC3label,max);

                            var baseX = processBase(FDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c3_base").empty().append(htmlB);

                            var span = $('#fd2_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC4a,FDC4aV,FDC4aB,FDC4aC,"Simple");
                            customizedArray(FDC4aV,FDC4aVX,FDC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(FDC4aVX,"fd2_c4a","Type of protein","auto");

                            var baseX = processBase(FDC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c4a_base").empty().append(htmlB);

                            var span = $('#fd2_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC6,FDC6V,FDC6B,FDC6C,"Simple");
                            customizedArray(FDC6V,FDC6VX,FDC6label,colorPallet69,"Doughnut");
                            pieChart(FDC6VX,"fd2_c6","Type of Packaging","auto");

                            var baseX = processBase(FDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c6_base").empty().append(htmlB);

                            var span = $('#fd2_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC7,FDC7V,FDC7B,FDC7C,"Simple");
                            customizedArray(FDC7V,FDC7VX,FDC7label,colorPallet68,"Doughnut");
                            pieChart(FDC7VX,"fd2_c7","Type of Packaging","auto");

                            var baseX = processBase(FDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c7_base").empty().append(htmlB);

                            var span = $('#fd2_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC8,FDC8V,FDC8B,FDC8C,"Simple");
                            var max = (Math.max(...FDC8V)+20);
                            customizedArray(FDC8V,FDC8VX,FDC8label,colorPallet69,"Bar");
                            barChart(FDC8VX,"fd2_c8",FDC8label,max);

                            var baseX = processBase(FDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c8_base").empty().append(htmlB);

                            var span = $('#fd2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC9,FDC9V,FDC9B,FDC9C,"Simple");
                            var max = (Math.max(...FDC9V)+20);
                            customizedArray(FDC9V,FDC9VX,FDC9label,colorPallet69,"Bar");
                            barChart(FDC9VX,"fd2_c9",FDC9label,max);

                            var baseX = processBase(FDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c9_base").empty().append(htmlB);

                            var span = $('#fd2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC10,FDC10V,FDC10B,FDC10C,"Simple");
                            customizedArray(FDC10V,FDC10VX,FDC10label,colorPallet68,"Doughnut");
                            pieChart(FDC10VX,"fd2_c10","Way of consumption","auto");

                            var baseX = processBase(FDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c10_base").empty().append(htmlB);

                            var span = $('#fd2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC11,FDC11V,FDC11B,FDC11C,"Simple");
                            var max = (Math.max(...FDC11V)+20);
                            customizedArray(FDC11V,FDC11VX,FDC11label,colorPallet69,"Bar");
                            columnChart(FDC11VX,"fd2_c11",FDC11label,max);

                            var baseX = processBase(FDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c11_base").empty().append(htmlB);

                            var span = $('#fd2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC12,FDC12V,FDC12B,FDC12C,"Simple");
                            var max = (Math.max(...FDC12V)+20);
                            customizedArray(FDC12V,FDC12VX,FDC12label,colorPallet69,"Bar");
                            columnChart(FDC12VX,"fd2_c12",FDC12label,max);

                            var baseX = processBase(FDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c12_base").empty().append(htmlB);

                            var span = $('#fd2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC15,FDC15V,FDC15B,FDC15C,"Simple");
                            FDC15V.forEach(function(e,i,a){
                                $(`#fd2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c15_base").empty().append(htmlB);

                            var span = $('#fd2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC16,FDC16V,FDC16B,FDC16C,"Simple");
                            var max = (Math.max(...FDC16V)+20);
                            customizedArray(FDC16V,FDC16VX,FDC16label,colorPallet69,"Bar");
                            barChart(FDC16VX,"fd2_c16",FDC16label,max);

                            var baseX = processBase(FDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c16_base").empty().append(htmlB);

                            var span = $('#fd2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC17,FDC17V,FDC17B,FDC17C,"Simple");
                            FDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`fd2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(FDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c17_base").empty().append(htmlB);

                            var span = $('#fd2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC18,FDC18V,FDC18B,FDC18C,"Simple");
                            var max = (Math.max(...FDC18V)+20);
                            customizedArray(FDC18V,FDC18VX,FDC18label,colorPallet69,"Bar");
                            barChart(FDC18VX,"fd2_c18",FDC18label,max);

                            var baseX = processBase(FDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c18_base").empty().append(htmlB);

                            var span = $('#fd2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC19,FDC19V,FDC19B,FDC19C,"Simple");
                            var max = (Math.max(...FDC19V)+20);
                            customizedArray(FDC19V,FDC19VX,FDC19label,colorPallet69,"Bar");
                            barChart(FDC19VX,"fd2_c19",FDC19label,max);

                            var baseX = processBase(FDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c19_base").empty().append(htmlB);

                            var span = $('#fd2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC20,FDC20V,FDC20B,FDC20C,"Simple");
                            FDC20V.forEach(function(e,i,a){
                                $(`#fd2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd2_c20_base").empty().append(htmlB);

                            var span = $('#fd2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_6, S13_6V, S13_6B, S13_6C, "Simple");
                            var max = (Math.max(...S13_6V)+20);
                            customizedArray(S13_6V,S13_6VX,S13label,colorPallet69,"Bar");
                            barChart(S13_6VX,"fd_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_6B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd_2_s13_base").empty().append(htmlB);

                            var span = $('#fd_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            frozenFStatus2 = true
                            ajaxFlag[1+5] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fifthAjax() {
                    $.ajax({
                        url: "api/ajax5.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'forzencondX': forzencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var FDC0 = data['FD_C0'];
                            var FDC2 = data['FD_C2'];
                            var FDC3 = data['FD_C3'];
                            var FDC4a = data['FD_C4a'];
                            var FDC6 = data['FD_C6'];
                            var FDC7 = data['FD_C7'];
                            var FDC8 = data['FD_C8'];
                            var FDC9 = data['FD_C9'];
                            var FDC10 = data['FD_C10'];
                            var FDC11 = data['FD_C11'];
                            var FDC12 = data['FD_C12'];
                            var FDC15 = data['FD_C15'];
                            var FDC16 = data['FD_C16'];
                            var FDC17 = data['FD_C17'];
                            var FDC18 = data['FD_C18'];
                            var FDC19 = data['FD_C19'];
                            var FDC20 = data['FD_C20'];

                            var S13_6 = data['S13_6'];

                            var FDC0V = [];
                            var FDC0B = [];
                            var FDC0C = [];
                            var FDC0VX = [];

                            var FDC2V = [];
                            var FDC2B = [];
                            var FDC2C = [];
                            var FDC2VX = [];

                            var FDC3V = [];
                            var FDC3B = [];
                            var FDC3C = [];
                            var FDC3VX = [];

                            var FDC4aV = [];
                            var FDC4aB = [];
                            var FDC4aC = [];
                            var FDC4aVX = [];

                            var FDC6V = [];
                            var FDC6B = [];
                            var FDC6C = [];
                            var FDC6VX = [];

                            var FDC7V = [];
                            var FDC7B = [];
                            var FDC7C = [];
                            var FDC7VX = [];

                            var FDC8V = [];
                            var FDC8B = [];
                            var FDC8C = [];
                            var FDC8VX = [];

                            var FDC9V = [];
                            var FDC9B = [];
                            var FDC9C = [];
                            var FDC9VX = [];

                            var FDC10V = [];
                            var FDC10B = [];
                            var FDC10C = [];
                            var FDC10VX = [];

                            var FDC11V = [];
                            var FDC11B = [];
                            var FDC11C = [];
                            var FDC11VX = [];

                            var FDC12V = [];
                            var FDC12B = [];
                            var FDC12C = [];
                            var FDC12VX = [];

                            var FDC13V = [];
                            var FDC13B = [];
                            var FDC13C = [];
                            var FDC13VX = [];

                            var FDC14V = [];
                            var FDC14B = [];
                            var FDC14C = [];
                            var FDC14VX = [];

                            var FDC15V = [];
                            var FDC15B = [];
                            var FDC15C = [];
                            var FDC15VX = [];

                            var FDC16V = [];
                            var FDC16B = [];
                            var FDC16C = [];
                            var FDC16VX = [];

                            var FDC17V = [];
                            var FDC17B = [];
                            var FDC17C = [];
                            var FDC17VX = [];

                            var FDC18V = [];
                            var FDC18B = [];
                            var FDC18C = [];
                            var FDC18VX = [];

                            var FDC19V = [];
                            var FDC19B = [];
                            var FDC19C = [];
                            var FDC19VX = [];

                            var FDC20V = [];
                            var FDC20B = [];
                            var FDC20C = [];
                            var FDC20VX = [];

                            var S13_6V = [];
                            var S13_6B = [];
                            var S13_6C = [];
                            var S13_6VX = [];

                            if(frozenFStatus3==false)
                            {
                                extractValues(FDC0,FDC0V,FDC0B,FDC0C,"Simple");
                                FDC0V.forEach(function(e,i,a){
                                    $(`#fd3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(FDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#fd3_c0_base").empty().append(htmlB);

                                var span = $('#fd3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(FDC2,FDC2V,FDC2B,FDC2C,"Simple");
                            customizedArray(FDC2V,FDC2VX,FDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(FDC2VX,"fd3_c2","Type of protein","auto");

                            var baseX = processBase(FDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c2_base").empty().append(htmlB);

                            var span = $('#fd3_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC3,FDC3V,FDC3B,FDC3C,"Simple");
                            var max = (Math.max(...FDC3V)+20);
                            customizedArray(FDC3V,FDC3VX,FDC3label,colorPallet69,"Bar");
                            barChart(FDC3VX,"fd3_c3",FDC3label,max);

                            var baseX = processBase(FDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c3_base").empty().append(htmlB);

                            var span = $('#fd3_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC4a,FDC4aV,FDC4aB,FDC4aC,"Simple");
                            customizedArray(FDC4aV,FDC4aVX,FDC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(FDC4aVX,"fd3_c4a","Type of protein","auto");

                            var baseX = processBase(FDC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c4a_base").empty().append(htmlB);

                            var span = $('#fd3_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC6,FDC6V,FDC6B,FDC6C,"Simple");
                            customizedArray(FDC6V,FDC6VX,FDC6label,colorPallet69,"Doughnut");
                            pieChart(FDC6VX,"fd3_c6","Type of Packaging","auto");

                            var baseX = processBase(FDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c6_base").empty().append(htmlB);

                            var span = $('#fd3_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC7,FDC7V,FDC7B,FDC7C,"Simple");
                            customizedArray(FDC7V,FDC7VX,FDC7label,colorPallet68,"Doughnut");
                            pieChart(FDC7VX,"fd3_c7","Type of Packaging","auto");

                            var baseX = processBase(FDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c7_base").empty().append(htmlB);

                            var span = $('#fd3_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC8,FDC8V,FDC8B,FDC8C,"Simple");
                            var max = (Math.max(...FDC8V)+20);
                            customizedArray(FDC8V,FDC8VX,FDC8label,colorPallet69,"Bar");
                            barChart(FDC8VX,"fd3_c8",FDC8label,max);

                            var baseX = processBase(FDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c8_base").empty().append(htmlB);

                            var span = $('#fd3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC9,FDC9V,FDC9B,FDC9C,"Simple");
                            var max = (Math.max(...FDC9V)+20);
                            customizedArray(FDC9V,FDC9VX,FDC9label,colorPallet69,"Bar");
                            barChart(FDC9VX,"fd3_c9",FDC9label,max);

                            var baseX = processBase(FDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c9_base").empty().append(htmlB);

                            var span = $('#fd3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC10,FDC10V,FDC10B,FDC10C,"Simple");
                            customizedArray(FDC10V,FDC10VX,FDC10label,colorPallet68,"Doughnut");
                            pieChart(FDC10VX,"fd3_c10","Way of consumption","auto");

                            var baseX = processBase(FDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c10_base").empty().append(htmlB);

                            var span = $('#fd3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC11,FDC11V,FDC11B,FDC11C,"Simple");
                            var max = (Math.max(...FDC11V)+20);
                            customizedArray(FDC11V,FDC11VX,FDC11label,colorPallet69,"Bar");
                            columnChart(FDC11VX,"fd3_c11",FDC11label,max);

                            var baseX = processBase(FDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c11_base").empty().append(htmlB);

                            var span = $('#fd3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC12,FDC12V,FDC12B,FDC12C,"Simple");
                            var max = (Math.max(...FDC12V)+20);
                            customizedArray(FDC12V,FDC12VX,FDC12label,colorPallet69,"Bar");
                            columnChart(FDC12VX,"fd3_c12",FDC12label,max);

                            var baseX = processBase(FDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c12_base").empty().append(htmlB);

                            var span = $('#fd3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC15,FDC15V,FDC15B,FDC15C,"Simple");
                            FDC15V.forEach(function(e,i,a){
                                $(`#fd3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c15_base").empty().append(htmlB);

                            var span = $('#fd3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC16,FDC16V,FDC16B,FDC16C,"Simple");
                            var max = (Math.max(...FDC16V)+20);
                            customizedArray(FDC16V,FDC16VX,FDC16label,colorPallet69,"Bar");
                            barChart(FDC16VX,"fd3_c16",FDC16label,max);

                            var baseX = processBase(FDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c16_base").empty().append(htmlB);

                            var span = $('#fd3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC17,FDC17V,FDC17B,FDC17C,"Simple");
                            FDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`fd3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(FDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c17_base").empty().append(htmlB);

                            var span = $('#fd3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC18,FDC18V,FDC18B,FDC18C,"Simple");
                            var max = (Math.max(...FDC18V)+20);
                            customizedArray(FDC18V,FDC18VX,FDC18label,colorPallet69,"Bar");
                            barChart(FDC18VX,"fd3_c18",FDC18label,max);

                            var baseX = processBase(FDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c18_base").empty().append(htmlB);

                            var span = $('#fd3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC19,FDC19V,FDC19B,FDC19C,"Simple");
                            var max = (Math.max(...FDC19V)+20);
                            customizedArray(FDC19V,FDC19VX,FDC19label,colorPallet69,"Bar");
                            barChart(FDC19VX,"fd3_c19",FDC19label,max);

                            var baseX = processBase(FDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c19_base").empty().append(htmlB);

                            var span = $('#fd3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC20,FDC20V,FDC20B,FDC20C,"Simple");
                            FDC20V.forEach(function(e,i,a){
                                $(`#fd3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd3_c20_base").empty().append(htmlB);

                            var span = $('#fd3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_6, S13_6V, S13_6B, S13_6C, "Simple");
                            var max = (Math.max(...S13_6V)+20);
                            customizedArray(S13_6V,S13_6VX,S13label,colorPallet69,"Bar");
                            barChart(S13_6VX,"fd_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_6B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd_3_s13_base").empty().append(htmlB);

                            var span = $('#fd_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            frozenFStatus3 = true;
                            ajaxFlag[1+6] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function sixthAjax() {
                    $.ajax({
                        url: "api/ajax6.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'forzencondX': forzencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var FDC0 = data['FD_C0'];
                            var FDC2 = data['FD_C2'];
                            var FDC3 = data['FD_C3'];
                            var FDC4a = data['FD_C4a'];
                            var FDC6 = data['FD_C6'];
                            var FDC7 = data['FD_C7'];
                            var FDC8 = data['FD_C8'];
                            var FDC9 = data['FD_C9'];
                            var FDC10 = data['FD_C10'];
                            var FDC11 = data['FD_C11'];
                            var FDC12 = data['FD_C12'];
                            var FDC15 = data['FD_C15'];
                            var FDC16 = data['FD_C16'];
                            var FDC17 = data['FD_C17'];
                            var FDC18 = data['FD_C18'];
                            var FDC19 = data['FD_C19'];
                            var FDC20 = data['FD_C20'];

                            var S13_6 = data['S13_6'];

                            var FDC0V = [];
                            var FDC0B = [];
                            var FDC0C = [];
                            var FDC0VX = [];

                            var FDC2V = [];
                            var FDC2B = [];
                            var FDC2C = [];
                            var FDC2VX = [];

                            var FDC3V = [];
                            var FDC3B = [];
                            var FDC3C = [];
                            var FDC3VX = [];

                            var FDC4aV = [];
                            var FDC4aB = [];
                            var FDC4aC = [];
                            var FDC4aVX = [];

                            var FDC6V = [];
                            var FDC6B = [];
                            var FDC6C = [];
                            var FDC6VX = [];

                            var FDC7V = [];
                            var FDC7B = [];
                            var FDC7C = [];
                            var FDC7VX = [];

                            var FDC8V = [];
                            var FDC8B = [];
                            var FDC8C = [];
                            var FDC8VX = [];

                            var FDC9V = [];
                            var FDC9B = [];
                            var FDC9C = [];
                            var FDC9VX = [];

                            var FDC10V = [];
                            var FDC10B = [];
                            var FDC10C = [];
                            var FDC10VX = [];

                            var FDC11V = [];
                            var FDC11B = [];
                            var FDC11C = [];
                            var FDC11VX = [];

                            var FDC12V = [];
                            var FDC12B = [];
                            var FDC12C = [];
                            var FDC12VX = [];

                            var FDC13V = [];
                            var FDC13B = [];
                            var FDC13C = [];
                            var FDC13VX = [];

                            var FDC14V = [];
                            var FDC14B = [];
                            var FDC14C = [];
                            var FDC14VX = [];

                            var FDC15V = [];
                            var FDC15B = [];
                            var FDC15C = [];
                            var FDC15VX = [];

                            var FDC16V = [];
                            var FDC16B = [];
                            var FDC16C = [];
                            var FDC16VX = [];

                            var FDC17V = [];
                            var FDC17B = [];
                            var FDC17C = [];
                            var FDC17VX = [];

                            var FDC18V = [];
                            var FDC18B = [];
                            var FDC18C = [];
                            var FDC18VX = [];

                            var FDC19V = [];
                            var FDC19B = [];
                            var FDC19C = [];
                            var FDC19VX = [];

                            var FDC20V = [];
                            var FDC20B = [];
                            var FDC20C = [];
                            var FDC20VX = [];

                            var S13_6V = [];
                            var S13_6B = [];
                            var S13_6C = [];
                            var S13_6VX = [];

                            if(frozenFStatus4==false)
                            {
                                extractValues(FDC0,FDC0V,FDC0B,FDC0C,"Simple");
                                FDC0V.forEach(function(e,i,a){
                                    $(`#fd4_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(FDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#fd4_c0_base").empty().append(htmlB);

                                var span = $('#fd4_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(FDC2,FDC2V,FDC2B,FDC2C,"Simple");
                            customizedArray(FDC2V,FDC2VX,FDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(FDC2VX,"fd4_c2","Type of protein","auto");

                            var baseX = processBase(FDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c2_base").empty().append(htmlB);

                            var span = $('#fd4_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC3,FDC3V,FDC3B,FDC3C,"Simple");
                            var max = (Math.max(...FDC3V)+20);
                            customizedArray(FDC3V,FDC3VX,FDC3label,colorPallet69,"Bar");
                            barChart(FDC3VX,"fd4_c3",FDC3label,max);

                            var baseX = processBase(FDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c3_base").empty().append(htmlB);

                            var span = $('#fd4_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC4a,FDC4aV,FDC4aB,FDC4aC,"Simple");
                            customizedArray(FDC4aV,FDC4aVX,FDC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(FDC4aVX,"fd4_c4a","Type of protein","auto");

                            var baseX = processBase(FDC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c4a_base").empty().append(htmlB);

                            var span = $('#fd4_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC6,FDC6V,FDC6B,FDC6C,"Simple");
                            customizedArray(FDC6V,FDC6VX,FDC6label,colorPallet69,"Doughnut");
                            pieChart(FDC6VX,"fd4_c6","Type of Packaging","auto");

                            var baseX = processBase(FDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c6_base").empty().append(htmlB);

                            var span = $('#fd4_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC7,FDC7V,FDC7B,FDC7C,"Simple");
                            customizedArray(FDC7V,FDC7VX,FDC7label,colorPallet68,"Doughnut");
                            pieChart(FDC7VX,"fd4_c7","Type of Packaging","auto");

                            var baseX = processBase(FDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c7_base").empty().append(htmlB);

                            var span = $('#fd4_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC8,FDC8V,FDC8B,FDC8C,"Simple");
                            var max = (Math.max(...FDC8V)+20);
                            customizedArray(FDC8V,FDC8VX,FDC8label,colorPallet69,"Bar");
                            barChart(FDC8VX,"fd4_c8",FDC8label,max);

                            var baseX = processBase(FDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c8_base").empty().append(htmlB);

                            var span = $('#fd4_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC9,FDC9V,FDC9B,FDC9C,"Simple");
                            var max = (Math.max(...FDC9V)+20);
                            customizedArray(FDC9V,FDC9VX,FDC9label,colorPallet69,"Bar");
                            barChart(FDC9VX,"fd4_c9",FDC9label,max);

                            var baseX = processBase(FDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c9_base").empty().append(htmlB);

                            var span = $('#fd4_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC10,FDC10V,FDC10B,FDC10C,"Simple");
                            customizedArray(FDC10V,FDC10VX,FDC10label,colorPallet68,"Doughnut");
                            pieChart(FDC10VX,"fd4_c10","Way of consumption","auto");

                            var baseX = processBase(FDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c10_base").empty().append(htmlB);

                            var span = $('#fd4_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC11,FDC11V,FDC11B,FDC11C,"Simple");
                            var max = (Math.max(...FDC11V)+20);
                            customizedArray(FDC11V,FDC11VX,FDC11label,colorPallet69,"Bar");
                            columnChart(FDC11VX,"fd4_c11",FDC11label,max);

                            var baseX = processBase(FDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c11_base").empty().append(htmlB);

                            var span = $('#fd4_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC12,FDC12V,FDC12B,FDC12C,"Simple");
                            var max = (Math.max(...FDC12V)+20);
                            customizedArray(FDC12V,FDC12VX,FDC12label,colorPallet69,"Bar");
                            columnChart(FDC12VX,"fd4_c12",FDC12label,max);

                            var baseX = processBase(FDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c12_base").empty().append(htmlB);

                            var span = $('#fd4_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC15,FDC15V,FDC15B,FDC15C,"Simple");
                            FDC15V.forEach(function(e,i,a){
                                $(`#fd4_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c15_base").empty().append(htmlB);

                            var span = $('#fd4_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC16,FDC16V,FDC16B,FDC16C,"Simple");
                            var max = (Math.max(...FDC16V)+20);
                            customizedArray(FDC16V,FDC16VX,FDC16label,colorPallet69,"Bar");
                            barChart(FDC16VX,"fd4_c16",FDC16label,max);

                            var baseX = processBase(FDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c16_base").empty().append(htmlB);

                            var span = $('#fd4_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC17,FDC17V,FDC17B,FDC17C,"Simple");
                            FDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`fd4_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(FDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c17_base").empty().append(htmlB);

                            var span = $('#fd4_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC18,FDC18V,FDC18B,FDC18C,"Simple");
                            var max = (Math.max(...FDC18V)+20);
                            customizedArray(FDC18V,FDC18VX,FDC18label,colorPallet69,"Bar");
                            barChart(FDC18VX,"fd4_c18",FDC18label,max);

                            var baseX = processBase(FDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c18_base").empty().append(htmlB);

                            var span = $('#fd4_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC19,FDC19V,FDC19B,FDC19C,"Simple");
                            var max = (Math.max(...FDC19V)+20);
                            customizedArray(FDC19V,FDC19VX,FDC19label,colorPallet69,"Bar");
                            barChart(FDC19VX,"fd4_c19",FDC19label,max);

                            var baseX = processBase(FDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c19_base").empty().append(htmlB);

                            var span = $('#fd4_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC20,FDC20V,FDC20B,FDC20C,"Simple");
                            FDC20V.forEach(function(e,i,a){
                                $(`#fd4_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd4_c20_base").empty().append(htmlB);

                            var span = $('#fd4_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_6, S13_6V, S13_6B, S13_6C, "Simple");
                            var max = (Math.max(...S13_6V)+20);
                            customizedArray(S13_6V,S13_6VX,S13label,colorPallet69,"Bar");
                            barChart(S13_6VX,"fd_4_s13",S13label,max);
                            
                            var baseX = processBase(S13_6B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd_4_s13_base").empty().append(htmlB);

                            var span = $('#fd_4_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            frozenFStatus4 = true
                            ajaxFlag[1+7] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function seventhAjax() {
                    $.ajax({
                        url: "api/ajax7.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'forzencondX': forzencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var FDC0 = data['FD_C0'];
                            var FDC2 = data['FD_C2'];
                            var FDC3 = data['FD_C3'];
                            var FDC4a = data['FD_C4a'];
                            var FDC6 = data['FD_C6'];
                            var FDC7 = data['FD_C7'];
                            var FDC8 = data['FD_C8'];
                            var FDC9 = data['FD_C9'];
                            var FDC10 = data['FD_C10'];
                            var FDC11 = data['FD_C11'];
                            var FDC12 = data['FD_C12'];
                            var FDC15 = data['FD_C15'];
                            var FDC16 = data['FD_C16'];
                            var FDC17 = data['FD_C17'];
                            var FDC18 = data['FD_C18'];
                            var FDC19 = data['FD_C19'];
                            var FDC20 = data['FD_C20'];

                            var S13_6 = data['S13_6'];

                            var FDC0V = [];
                            var FDC0B = [];
                            var FDC0C = [];
                            var FDC0VX = [];

                            var FDC2V = [];
                            var FDC2B = [];
                            var FDC2C = [];
                            var FDC2VX = [];

                            var FDC3V = [];
                            var FDC3B = [];
                            var FDC3C = [];
                            var FDC3VX = [];

                            var FDC4aV = [];
                            var FDC4aB = [];
                            var FDC4aC = [];
                            var FDC4aVX = [];

                            var FDC6V = [];
                            var FDC6B = [];
                            var FDC6C = [];
                            var FDC6VX = [];

                            var FDC7V = [];
                            var FDC7B = [];
                            var FDC7C = [];
                            var FDC7VX = [];

                            var FDC8V = [];
                            var FDC8B = [];
                            var FDC8C = [];
                            var FDC8VX = [];

                            var FDC9V = [];
                            var FDC9B = [];
                            var FDC9C = [];
                            var FDC9VX = [];

                            var FDC10V = [];
                            var FDC10B = [];
                            var FDC10C = [];
                            var FDC10VX = [];

                            var FDC11V = [];
                            var FDC11B = [];
                            var FDC11C = [];
                            var FDC11VX = [];

                            var FDC12V = [];
                            var FDC12B = [];
                            var FDC12C = [];
                            var FDC12VX = [];

                            var FDC13V = [];
                            var FDC13B = [];
                            var FDC13C = [];
                            var FDC13VX = [];

                            var FDC14V = [];
                            var FDC14B = [];
                            var FDC14C = [];
                            var FDC14VX = [];

                            var FDC15V = [];
                            var FDC15B = [];
                            var FDC15C = [];
                            var FDC15VX = [];

                            var FDC16V = [];
                            var FDC16B = [];
                            var FDC16C = [];
                            var FDC16VX = [];

                            var FDC17V = [];
                            var FDC17B = [];
                            var FDC17C = [];
                            var FDC17VX = [];

                            var FDC18V = [];
                            var FDC18B = [];
                            var FDC18C = [];
                            var FDC18VX = [];

                            var FDC19V = [];
                            var FDC19B = [];
                            var FDC19C = [];
                            var FDC19VX = [];

                            var FDC20V = [];
                            var FDC20B = [];
                            var FDC20C = [];
                            var FDC20VX = [];

                            var S13_6V = [];
                            var S13_6B = [];
                            var S13_6C = [];
                            var S13_6VX = [];

                            if(frozenFStatus5==false)
                            {
                                extractValues(FDC0,FDC0V,FDC0B,FDC0C,"Simple");
                                FDC0V.forEach(function(e,i,a){
                                    $(`#fd5_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(FDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#fd5_c0_base").empty().append(htmlB);

                                var span = $('#fd5_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(FDC2,FDC2V,FDC2B,FDC2C,"Simple");
                            customizedArray(FDC2V,FDC2VX,FDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(FDC2VX,"fd5_c2","Type of protein","auto");

                            var baseX = processBase(FDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c2_base").empty().append(htmlB);

                            var span = $('#fd5_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC3,FDC3V,FDC3B,FDC3C,"Simple");
                            var max = (Math.max(...FDC3V)+20);
                            customizedArray(FDC3V,FDC3VX,FDC3label,colorPallet69,"Bar");
                            barChart(FDC3VX,"fd5_c3",FDC3label,max);

                            var baseX = processBase(FDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c3_base").empty().append(htmlB);

                            var span = $('#fd5_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC4a,FDC4aV,FDC4aB,FDC4aC,"Simple");
                            customizedArray(FDC4aV,FDC4aVX,FDC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(FDC4aVX,"fd5_c4a","Type of protein","auto");

                            var baseX = processBase(FDC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c4a_base").empty().append(htmlB);

                            var span = $('#fd5_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC6,FDC6V,FDC6B,FDC6C,"Simple");
                            customizedArray(FDC6V,FDC6VX,FDC6label,colorPallet69,"Doughnut");
                            pieChart(FDC6VX,"fd5_c6","Type of Packaging","auto");

                            var baseX = processBase(FDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c6_base").empty().append(htmlB);

                            var span = $('#fd5_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC7,FDC7V,FDC7B,FDC7C,"Simple");
                            customizedArray(FDC7V,FDC7VX,FDC7label,colorPallet68,"Doughnut");
                            pieChart(FDC7VX,"fd5_c7","Type of Packaging","auto");

                            var baseX = processBase(FDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c7_base").empty().append(htmlB);

                            var span = $('#fd5_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC8,FDC8V,FDC8B,FDC8C,"Simple");
                            var max = (Math.max(...FDC8V)+20);
                            customizedArray(FDC8V,FDC8VX,FDC8label,colorPallet69,"Bar");
                            barChart(FDC8VX,"fd5_c8",FDC8label,max);

                            var baseX = processBase(FDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c8_base").empty().append(htmlB);

                            var span = $('#fd5_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC9,FDC9V,FDC9B,FDC9C,"Simple");
                            var max = (Math.max(...FDC9V)+20);
                            customizedArray(FDC9V,FDC9VX,FDC9label,colorPallet69,"Bar");
                            barChart(FDC9VX,"fd5_c9",FDC9label,max);

                            var baseX = processBase(FDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c9_base").empty().append(htmlB);

                            var span = $('#fd5_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC10,FDC10V,FDC10B,FDC10C,"Simple");
                            customizedArray(FDC10V,FDC10VX,FDC10label,colorPallet68,"Doughnut");
                            pieChart(FDC10VX,"fd5_c10","Way of consumption","auto");

                            var baseX = processBase(FDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c10_base").empty().append(htmlB);

                            var span = $('#fd5_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC11,FDC11V,FDC11B,FDC11C,"Simple");
                            var max = (Math.max(...FDC11V)+20);
                            customizedArray(FDC11V,FDC11VX,FDC11label,colorPallet69,"Bar");
                            columnChart(FDC11VX,"fd5_c11",FDC11label,max);

                            var baseX = processBase(FDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c11_base").empty().append(htmlB);

                            var span = $('#fd5_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC12,FDC12V,FDC12B,FDC12C,"Simple");
                            var max = (Math.max(...FDC12V)+20);
                            customizedArray(FDC12V,FDC12VX,FDC12label,colorPallet69,"Bar");
                            columnChart(FDC12VX,"fd5_c12",FDC12label,max);

                            var baseX = processBase(FDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c12_base").empty().append(htmlB);

                            var span = $('#fd5_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC15,FDC15V,FDC15B,FDC15C,"Simple");
                            FDC15V.forEach(function(e,i,a){
                                $(`#fd5_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c15_base").empty().append(htmlB);

                            var span = $('#fd5_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC16,FDC16V,FDC16B,FDC16C,"Simple");
                            var max = (Math.max(...FDC16V)+20);
                            customizedArray(FDC16V,FDC16VX,FDC16label,colorPallet69,"Bar");
                            barChart(FDC16VX,"fd5_c16",FDC16label,max);

                            var baseX = processBase(FDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c16_base").empty().append(htmlB);

                            var span = $('#fd5_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC17,FDC17V,FDC17B,FDC17C,"Simple");
                            FDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`fd5_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(FDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c17_base").empty().append(htmlB);

                            var span = $('#fd5_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC18,FDC18V,FDC18B,FDC18C,"Simple");
                            var max = (Math.max(...FDC18V)+20);
                            customizedArray(FDC18V,FDC18VX,FDC18label,colorPallet69,"Bar");
                            barChart(FDC18VX,"fd5_c18",FDC18label,max);

                            var baseX = processBase(FDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c18_base").empty().append(htmlB);

                            var span = $('#fd5_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC19,FDC19V,FDC19B,FDC19C,"Simple");
                            var max = (Math.max(...FDC19V)+20);
                            customizedArray(FDC19V,FDC19VX,FDC19label,colorPallet69,"Bar");
                            barChart(FDC19VX,"fd5_c19",FDC19label,max);

                            var baseX = processBase(FDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c19_base").empty().append(htmlB);

                            var span = $('#fd5_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC20,FDC20V,FDC20B,FDC20C,"Simple");
                            FDC20V.forEach(function(e,i,a){
                                $(`#fd5_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd5_c20_base").empty().append(htmlB);

                            var span = $('#fd5_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_6, S13_6V, S13_6B, S13_6C, "Simple");
                            var max = (Math.max(...S13_6V)+20);
                            customizedArray(S13_6V,S13_6VX,S13label,colorPallet69,"Bar");
                            barChart(S13_6VX,"fd_5_s13",S13label,max);
                            
                            var baseX = processBase(S13_6B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd_5_s13_base").empty().append(htmlB);

                            var span = $('#fd_5_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            frozenFStatus5 = true;
                            ajaxFlag[1+8] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function eightthAjax() {
                    $.ajax({
                        url: "api/ajax8.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'forzencondX': forzencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var FDC0 = data['FD_C0'];
                            var FDC2 = data['FD_C2'];
                            var FDC3 = data['FD_C3'];
                            var FDC4a = data['FD_C4a'];
                            var FDC6 = data['FD_C6'];
                            var FDC7 = data['FD_C7'];
                            var FDC8 = data['FD_C8'];
                            var FDC9 = data['FD_C9'];
                            var FDC10 = data['FD_C10'];
                            var FDC11 = data['FD_C11'];
                            var FDC12 = data['FD_C12'];
                            var FDC15 = data['FD_C15'];
                            var FDC16 = data['FD_C16'];
                            var FDC17 = data['FD_C17'];
                            var FDC18 = data['FD_C18'];
                            var FDC19 = data['FD_C19'];
                            var FDC20 = data['FD_C20'];

                            var S13_6 = data['S13_6'];

                            var FDC0V = [];
                            var FDC0B = [];
                            var FDC0C = [];
                            var FDC0VX = [];

                            var FDC2V = [];
                            var FDC2B = [];
                            var FDC2C = [];
                            var FDC2VX = [];

                            var FDC3V = [];
                            var FDC3B = [];
                            var FDC3C = [];
                            var FDC3VX = [];

                            var FDC4aV = [];
                            var FDC4aB = [];
                            var FDC4aC = [];
                            var FDC4aVX = [];

                            var FDC6V = [];
                            var FDC6B = [];
                            var FDC6C = [];
                            var FDC6VX = [];

                            var FDC7V = [];
                            var FDC7B = [];
                            var FDC7C = [];
                            var FDC7VX = [];

                            var FDC8V = [];
                            var FDC8B = [];
                            var FDC8C = [];
                            var FDC8VX = [];

                            var FDC9V = [];
                            var FDC9B = [];
                            var FDC9C = [];
                            var FDC9VX = [];

                            var FDC10V = [];
                            var FDC10B = [];
                            var FDC10C = [];
                            var FDC10VX = [];

                            var FDC11V = [];
                            var FDC11B = [];
                            var FDC11C = [];
                            var FDC11VX = [];

                            var FDC12V = [];
                            var FDC12B = [];
                            var FDC12C = [];
                            var FDC12VX = [];

                            var FDC13V = [];
                            var FDC13B = [];
                            var FDC13C = [];
                            var FDC13VX = [];

                            var FDC14V = [];
                            var FDC14B = [];
                            var FDC14C = [];
                            var FDC14VX = [];

                            var FDC15V = [];
                            var FDC15B = [];
                            var FDC15C = [];
                            var FDC15VX = [];

                            var FDC16V = [];
                            var FDC16B = [];
                            var FDC16C = [];
                            var FDC16VX = [];

                            var FDC17V = [];
                            var FDC17B = [];
                            var FDC17C = [];
                            var FDC17VX = [];

                            var FDC18V = [];
                            var FDC18B = [];
                            var FDC18C = [];
                            var FDC18VX = [];

                            var FDC19V = [];
                            var FDC19B = [];
                            var FDC19C = [];
                            var FDC19VX = [];

                            var FDC20V = [];
                            var FDC20B = [];
                            var FDC20C = [];
                            var FDC20VX = [];

                            var S13_6V = [];
                            var S13_6B = [];
                            var S13_6C = [];
                            var S13_6VX = [];

                            if(frozenFStatus6==false)
                            {
                                extractValues(FDC0,FDC0V,FDC0B,FDC0C,"Simple");
                                FDC0V.forEach(function(e,i,a){
                                    $(`#fd6_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(FDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#fd6_c0_base").empty().append(htmlB);

                                var span = $('#fd6_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(FDC2,FDC2V,FDC2B,FDC2C,"Simple");
                            customizedArray(FDC2V,FDC2VX,FDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(FDC2VX,"fd6_c2","Type of protein","auto");

                            var baseX = processBase(FDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c2_base").empty().append(htmlB);

                            var span = $('#fd6_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC3,FDC3V,FDC3B,FDC3C,"Simple");
                            var max = (Math.max(...FDC3V)+20);
                            customizedArray(FDC3V,FDC3VX,FDC3label,colorPallet69,"Bar");
                            barChart(FDC3VX,"fd6_c3",FDC3label,max);

                            var baseX = processBase(FDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c3_base").empty().append(htmlB);

                            var span = $('#fd6_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC4a,FDC4aV,FDC4aB,FDC4aC,"Simple");
                            customizedArray(FDC4aV,FDC4aVX,FDC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(FDC4aVX,"fd6_c4a","Type of protein","auto");

                            var baseX = processBase(FDC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c4a_base").empty().append(htmlB);

                            var span = $('#fd6_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC6,FDC6V,FDC6B,FDC6C,"Simple");
                            customizedArray(FDC6V,FDC6VX,FDC6label,colorPallet69,"Doughnut");
                            pieChart(FDC6VX,"fd6_c6","Type of Packaging","auto");

                            var baseX = processBase(FDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c6_base").empty().append(htmlB);

                            var span = $('#fd6_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC7,FDC7V,FDC7B,FDC7C,"Simple");
                            customizedArray(FDC7V,FDC7VX,FDC7label,colorPallet68,"Doughnut");
                            pieChart(FDC7VX,"fd6_c7","Type of Packaging","auto");

                            var baseX = processBase(FDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c7_base").empty().append(htmlB);

                            var span = $('#fd6_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC8,FDC8V,FDC8B,FDC8C,"Simple");
                            var max = (Math.max(...FDC8V)+20);
                            customizedArray(FDC8V,FDC8VX,FDC8label,colorPallet69,"Bar");
                            barChart(FDC8VX,"fd6_c8",FDC8label,max);

                            var baseX = processBase(FDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c8_base").empty().append(htmlB);

                            var span = $('#fd6_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC9,FDC9V,FDC9B,FDC9C,"Simple");
                            var max = (Math.max(...FDC9V)+20);
                            customizedArray(FDC9V,FDC9VX,FDC9label,colorPallet69,"Bar");
                            barChart(FDC9VX,"fd6_c9",FDC9label,max);

                            var baseX = processBase(FDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c9_base").empty().append(htmlB);

                            var span = $('#fd6_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC10,FDC10V,FDC10B,FDC10C,"Simple");
                            customizedArray(FDC10V,FDC10VX,FDC10label,colorPallet68,"Doughnut");
                            pieChart(FDC10VX,"fd6_c10","Way of consumption","auto");

                            var baseX = processBase(FDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c10_base").empty().append(htmlB);

                            var span = $('#fd6_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC11,FDC11V,FDC11B,FDC11C,"Simple");
                            var max = (Math.max(...FDC11V)+20);
                            customizedArray(FDC11V,FDC11VX,FDC11label,colorPallet69,"Bar");
                            columnChart(FDC11VX,"fd6_c11",FDC11label,max);

                            var baseX = processBase(FDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c11_base").empty().append(htmlB);

                            var span = $('#fd6_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC12,FDC12V,FDC12B,FDC12C,"Simple");
                            var max = (Math.max(...FDC12V)+20);
                            customizedArray(FDC12V,FDC12VX,FDC12label,colorPallet69,"Bar");
                            columnChart(FDC12VX,"fd6_c12",FDC12label,max);

                            var baseX = processBase(FDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c12_base").empty().append(htmlB);

                            var span = $('#fd6_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC15,FDC15V,FDC15B,FDC15C,"Simple");
                            FDC15V.forEach(function(e,i,a){
                                $(`#fd6_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c15_base").empty().append(htmlB);

                            var span = $('#fd6_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC16,FDC16V,FDC16B,FDC16C,"Simple");
                            var max = (Math.max(...FDC16V)+20);
                            customizedArray(FDC16V,FDC16VX,FDC16label,colorPallet69,"Bar");
                            barChart(FDC16VX,"fd6_c16",FDC16label,max);

                            var baseX = processBase(FDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c16_base").empty().append(htmlB);

                            var span = $('#fd6_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC17,FDC17V,FDC17B,FDC17C,"Simple");
                            FDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`fd6_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(FDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c17_base").empty().append(htmlB);

                            var span = $('#fd6_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC18,FDC18V,FDC18B,FDC18C,"Simple");
                            var max = (Math.max(...FDC18V)+20);
                            customizedArray(FDC18V,FDC18VX,FDC18label,colorPallet69,"Bar");
                            barChart(FDC18VX,"fd6_c18",FDC18label,max);

                            var baseX = processBase(FDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c18_base").empty().append(htmlB);

                            var span = $('#fd6_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC19,FDC19V,FDC19B,FDC19C,"Simple");
                            var max = (Math.max(...FDC19V)+20);
                            customizedArray(FDC19V,FDC19VX,FDC19label,colorPallet69,"Bar");
                            barChart(FDC19VX,"fd6_c19",FDC19label,max);

                            var baseX = processBase(FDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c19_base").empty().append(htmlB);

                            var span = $('#fd6_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC20,FDC20V,FDC20B,FDC20C,"Simple");
                            FDC20V.forEach(function(e,i,a){
                                $(`#fd6_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd6_c20_base").empty().append(htmlB);

                            var span = $('#fd6_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_6, S13_6V, S13_6B, S13_6C, "Simple");
                            var max = (Math.max(...S13_6V)+20);
                            customizedArray(S13_6V,S13_6VX,S13label,colorPallet69,"Bar");
                            barChart(S13_6VX,"fd_6_s13",S13label,max);
                            
                            var baseX = processBase(S13_6B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd_6_s13_base").empty().append(htmlB);

                            var span = $('#fd_6_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            frozenFStatus6 = true;
                            ajaxFlag[1+9] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function ninethAjax() {
                    $.ajax({
                        url: "api/ajax9.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'forzencondX': forzencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);

                            var FDC0 = data['FD_C0'];
                            var FDC2 = data['FD_C2'];
                            var FDC3 = data['FD_C3'];
                            var FDC4a = data['FD_C4a'];
                            var FDC6 = data['FD_C6'];
                            var FDC7 = data['FD_C7'];
                            var FDC8 = data['FD_C8'];
                            var FDC9 = data['FD_C9'];
                            var FDC10 = data['FD_C10'];
                            var FDC11 = data['FD_C11'];
                            var FDC12 = data['FD_C12'];
                            var FDC15 = data['FD_C15'];
                            var FDC16 = data['FD_C16'];
                            var FDC17 = data['FD_C17'];
                            var FDC18 = data['FD_C18'];
                            var FDC19 = data['FD_C19'];
                            var FDC20 = data['FD_C20'];

                            var S13_6 = data['S13_6'];

                            var FDC0V = [];
                            var FDC0B = [];
                            var FDC0C = [];
                            var FDC0VX = [];

                            var FDC2V = [];
                            var FDC2B = [];
                            var FDC2C = [];
                            var FDC2VX = [];

                            var FDC3V = [];
                            var FDC3B = [];
                            var FDC3C = [];
                            var FDC3VX = [];

                            var FDC4aV = [];
                            var FDC4aB = [];
                            var FDC4aC = [];
                            var FDC4aVX = [];

                            var FDC6V = [];
                            var FDC6B = [];
                            var FDC6C = [];
                            var FDC6VX = [];

                            var FDC7V = [];
                            var FDC7B = [];
                            var FDC7C = [];
                            var FDC7VX = [];

                            var FDC8V = [];
                            var FDC8B = [];
                            var FDC8C = [];
                            var FDC8VX = [];

                            var FDC9V = [];
                            var FDC9B = [];
                            var FDC9C = [];
                            var FDC9VX = [];

                            var FDC10V = [];
                            var FDC10B = [];
                            var FDC10C = [];
                            var FDC10VX = [];

                            var FDC11V = [];
                            var FDC11B = [];
                            var FDC11C = [];
                            var FDC11VX = [];

                            var FDC12V = [];
                            var FDC12B = [];
                            var FDC12C = [];
                            var FDC12VX = [];

                            var FDC13V = [];
                            var FDC13B = [];
                            var FDC13C = [];
                            var FDC13VX = [];

                            var FDC14V = [];
                            var FDC14B = [];
                            var FDC14C = [];
                            var FDC14VX = [];

                            var FDC15V = [];
                            var FDC15B = [];
                            var FDC15C = [];
                            var FDC15VX = [];

                            var FDC16V = [];
                            var FDC16B = [];
                            var FDC16C = [];
                            var FDC16VX = [];

                            var FDC17V = [];
                            var FDC17B = [];
                            var FDC17C = [];
                            var FDC17VX = [];

                            var FDC18V = [];
                            var FDC18B = [];
                            var FDC18C = [];
                            var FDC18VX = [];

                            var FDC19V = [];
                            var FDC19B = [];
                            var FDC19C = [];
                            var FDC19VX = [];

                            var FDC20V = [];
                            var FDC20B = [];
                            var FDC20C = [];
                            var FDC20VX = [];

                            var S13_6V = [];
                            var S13_6B = [];
                            var S13_6C = [];
                            var S13_6VX = [];

                            if(frozenFStatus7==false)
                            {
                                extractValues(FDC0,FDC0V,FDC0B,FDC0C,"Simple");
                                FDC0V.forEach(function(e,i,a){
                                    $(`#fd7_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(FDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#fd7_c0_base").empty().append(htmlB);

                                var span = $('#fd7_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(FDC2,FDC2V,FDC2B,FDC2C,"Simple");
                            customizedArray(FDC2V,FDC2VX,FDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(FDC2VX,"fd7_c2","Type of protein","auto");

                            var baseX = processBase(FDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c2_base").empty().append(htmlB);

                            var span = $('#fd7_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC3,FDC3V,FDC3B,FDC3C,"Simple");
                            var max = (Math.max(...FDC3V)+20);
                            customizedArray(FDC3V,FDC3VX,FDC3label,colorPallet69,"Bar");
                            barChart(FDC3VX,"fd7_c3",FDC3label,max);

                            var baseX = processBase(FDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c3_base").empty().append(htmlB);

                            var span = $('#fd7_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC4a,FDC4aV,FDC4aB,FDC4aC,"Simple");
                            customizedArray(FDC4aV,FDC4aVX,FDC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(FDC4aVX,"fd7_c4a","Type of protein","auto");

                            var baseX = processBase(FDC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c4a_base").empty().append(htmlB);

                            var span = $('#fd7_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(FDC6,FDC6V,FDC6B,FDC6C,"Simple");
                            customizedArray(FDC6V,FDC6VX,FDC6label,colorPallet69,"Doughnut");
                            pieChart(FDC6VX,"fd7_c6","Type of Packaging","auto");

                            var baseX = processBase(FDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c6_base").empty().append(htmlB);

                            var span = $('#fd7_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC7,FDC7V,FDC7B,FDC7C,"Simple");
                            customizedArray(FDC7V,FDC7VX,FDC7label,colorPallet68,"Doughnut");
                            pieChart(FDC7VX,"fd7_c7","Type of Packaging","auto");

                            var baseX = processBase(FDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c7_base").empty().append(htmlB);

                            var span = $('#fd7_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC8,FDC8V,FDC8B,FDC8C,"Simple");
                            var max = (Math.max(...FDC8V)+20);
                            customizedArray(FDC8V,FDC8VX,FDC8label,colorPallet69,"Bar");
                            barChart(FDC8VX,"fd7_c8",FDC8label,max);

                            var baseX = processBase(FDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c8_base").empty().append(htmlB);

                            var span = $('#fd7_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC9,FDC9V,FDC9B,FDC9C,"Simple");
                            var max = (Math.max(...FDC9V)+20);
                            customizedArray(FDC9V,FDC9VX,FDC9label,colorPallet69,"Bar");
                            barChart(FDC9VX,"fd7_c9",FDC9label,max);

                            var baseX = processBase(FDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c9_base").empty().append(htmlB);

                            var span = $('#fd7_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC10,FDC10V,FDC10B,FDC10C,"Simple");
                            customizedArray(FDC10V,FDC10VX,FDC10label,colorPallet68,"Doughnut");
                            pieChart(FDC10VX,"fd7_c10","Way of consumption","auto");

                            var baseX = processBase(FDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c10_base").empty().append(htmlB);

                            var span = $('#fd7_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC11,FDC11V,FDC11B,FDC11C,"Simple");
                            var max = (Math.max(...FDC11V)+20);
                            customizedArray(FDC11V,FDC11VX,FDC11label,colorPallet69,"Bar");
                            columnChart(FDC11VX,"fd7_c11",FDC11label,max);

                            var baseX = processBase(FDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c11_base").empty().append(htmlB);

                            var span = $('#fd7_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC12,FDC12V,FDC12B,FDC12C,"Simple");
                            var max = (Math.max(...FDC12V)+20);
                            customizedArray(FDC12V,FDC12VX,FDC12label,colorPallet69,"Bar");
                            columnChart(FDC12VX,"fd7_c12",FDC12label,max);

                            var baseX = processBase(FDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c12_base").empty().append(htmlB);

                            var span = $('#fd7_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC15,FDC15V,FDC15B,FDC15C,"Simple");
                            FDC15V.forEach(function(e,i,a){
                                $(`#fd7_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c15_base").empty().append(htmlB);

                            var span = $('#fd7_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC16,FDC16V,FDC16B,FDC16C,"Simple");
                            var max = (Math.max(...FDC16V)+20);
                            customizedArray(FDC16V,FDC16VX,FDC16label,colorPallet69,"Bar");
                            barChart(FDC16VX,"fd7_c16",FDC16label,max);

                            var baseX = processBase(FDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c16_base").empty().append(htmlB);

                            var span = $('#fd7_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC17,FDC17V,FDC17B,FDC17C,"Simple");
                            FDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`fd7_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(FDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c17_base").empty().append(htmlB);

                            var span = $('#fd7_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC18,FDC18V,FDC18B,FDC18C,"Simple");
                            var max = (Math.max(...FDC18V)+20);
                            customizedArray(FDC18V,FDC18VX,FDC18label,colorPallet69,"Bar");
                            barChart(FDC18VX,"fd7_c18",FDC18label,max);

                            var baseX = processBase(FDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c18_base").empty().append(htmlB);

                            var span = $('#fd7_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC19,FDC19V,FDC19B,FDC19C,"Simple");
                            var max = (Math.max(...FDC19V)+20);
                            customizedArray(FDC19V,FDC19VX,FDC19label,colorPallet69,"Bar");
                            barChart(FDC19VX,"fd7_c19",FDC19label,max);

                            var baseX = processBase(FDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c19_base").empty().append(htmlB);

                            var span = $('#fd7_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(FDC20,FDC20V,FDC20B,FDC20C,"Simple");
                            FDC20V.forEach(function(e,i,a){
                                $(`#fd7_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(FDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd7_c20_base").empty().append(htmlB);

                            var span = $('#fd7_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_6, S13_6V, S13_6B, S13_6C, "Simple");
                            var max = (Math.max(...S13_6V)+20);
                            customizedArray(S13_6V,S13_6VX,S13label,colorPallet69,"Bar");
                            barChart(S13_6VX,"fd_7_s13",S13label,max);
                            
                            var baseX = processBase(S13_6B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#fd_7_s13_base").empty().append(htmlB);

                            var span = $('#fd_7_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            frozenFStatus7 = true;
                            ajaxFlag[1+10] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function tenthAjax() {
                    $.ajax({
                        url: "api/ajax10.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'yougurtcondX': yougurtcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var YC0 = data['Y_C0'];
                            var YC2 = data['Y_C2'];
                            var YC3 = data['Y_C3'];
                            var YC4a = data['Y_C4a'];
                            var YC4d = data['Y_C4d'];
                            var YC4e = data['Y_C4e'];
                            var YC5 = data['Y_C5'];
                            var YC6 = data['Y_C6'];
                            var YC7 = data['Y_C7'];
                            var YC8 = data['Y_C8'];
                            var YC9 = data['Y_C9'];
                            var YC10 = data['Y_C10'];
                            var YC11 = data['Y_C11'];
                            var YC12 = data['Y_C12'];
                            var YC15 = data['Y_C15'];
                            var YC16 = data['Y_C16'];
                            var YC17 = data['Y_C17'];
                            var YC18 = data['Y_C18'];
                            var YC19 = data['Y_C19'];
                            var YC20 = data['Y_C20'];

                            var S13_2 = data['S13_2'];

                            var YC0V = [];
                            var YC0B = [];
                            var YC0C = [];
                            var YC0VX = [];

                            var YC2V = [];
                            var YC2B = [];
                            var YC2C = [];
                            var YC2VX = [];

                            var YC3V = [];
                            var YC3B = [];
                            var YC3C = [];
                            var YC3VX = [];

                            var YC4aV = [];
                            var YC4aB = [];
                            var YC4aC = [];
                            var YC4aVX = [];

                            var YC4dV = [];
                            var YC4dB = [];
                            var YC4dC = [];
                            var YC4dVX = [];

                            var YC4eV = [];
                            var YC4eB = [];
                            var YC4eC = [];
                            var YC4eVX = [];

                            var YC5V = [];
                            var YC5B = [];
                            var YC5C = [];
                            var YC5VX = [];

                            var YC6V = [];
                            var YC6B = [];
                            var YC6C = [];
                            var YC6VX = [];

                            var YC7V = [];
                            var YC7B = [];
                            var YC7C = [];
                            var YC7VX = [];

                            var YC8V = [];
                            var YC8B = [];
                            var YC8C = [];
                            var YC8VX = [];

                            var YC9V = [];
                            var YC9B = [];
                            var YC9C = [];
                            var YC9VX = [];

                            var YC10V = [];
                            var YC10B = [];
                            var YC10C = [];
                            var YC10VX = [];

                            var YC11V = [];
                            var YC11B = [];
                            var YC11C = [];
                            var YC11VX = [];

                            var YC12V = [];
                            var YC12B = [];
                            var YC12C = [];
                            var YC12VX = [];

                            var YC13V = [];
                            var YC13B = [];
                            var YC13C = [];
                            var YC13VX = [];

                            var YC14V = [];
                            var YC14B = [];
                            var YC14C = [];
                            var YC14VX = [];

                            var YC15V = [];
                            var YC15B = [];
                            var YC15C = [];
                            var YC15VX = [];

                            var YC16V = [];
                            var YC16B = [];
                            var YC16C = [];
                            var YC16VX = [];

                            var YC17V = [];
                            var YC17B = [];
                            var YC17C = [];
                            var YC17VX = [];

                            var YC18V = [];
                            var YC18B = [];
                            var YC18C = [];
                            var YC18VX = [];

                            var YC19V = [];
                            var YC19B = [];
                            var YC19C = [];
                            var YC19VX = [];

                            var YC20V = [];
                            var YC20B = [];
                            var YC20C = [];
                            var YC20VX = [];

                            var S13_2V = [];
                            var S13_2B = [];
                            var S13_2C = [];
                            var S13_2VX = [];

                            if(yougurtFStatus1==false)
                            {
                                extractValues(YC0,YC0V,YC0B,YC0C,"Simple");
                                YC0V.forEach(function(e,i,a){
                                    $(`#y1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(YC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y1_c0_base").empty().append(htmlB);

                                var span = $('#y1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                                // 

                                extractValues(YC2,YC2V,YC2B,YC2C,"Simple");
                                customizedArray(YC2V,YC2VX,YC2label,colorPallet68,"Doughnut");
                                doughnutChart2(YC2VX,"y1_c2","Type of protein","auto");

                                var baseX = processBase(YC2B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y1_c2_base").empty().append(htmlB);

                                var span = $('#y1_c2_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC3,YC3V,YC3B,YC3C,"Simple");
                                var max = (Math.max(...YC3V)+20);
                                customizedArray(YC3V,YC3VX,YC3label,colorPallet69,"Bar");
                                barChart(YC3VX,"y1_c3",YC3label,max);

                                var baseX = processBase(YC3B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y1_c3_base").empty().append(htmlB);

                                var span = $('#y1_c3_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4a,YC4aV,YC4aB,YC4aC,"Simple");
                                customizedArray(YC4aV,YC4aVX,YC4alabel,colorPallet68,"Doughnut");
                                doughnutChart1_1(YC4aVX,"y1_c4a","Type of protein","auto");

                                var baseX = processBase(YC4aB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y1_c4a_base").empty().append(htmlB);

                                var span = $('#y1_c4a_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4d,YC4dV,YC4dB,YC4dC,"Simple");
                                customizedArray(YC4dV,YC4dVX,YC4dlabel,colorPallet68,"Doughnut");
                                doughnutChart1_2(YC4dVX,"y1_c4d","Type of protein",280);

                                var baseX = processBase(YC4dB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y1_c4d_base").empty().append(htmlB);

                                var span = $('#y1_c4d_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4e,YC4eV,YC4eB,YC4eC,"Simple");
                                customizedArray(YC4eV,YC4eVX,YC4elabel,colorPallet68,"Doughnut");
                                doughnutChart1_3(YC4eVX,"y1_c4e","Type of protein",290);

                                var baseX = processBase(YC4eB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y1_c4e_base").empty().append(htmlB);

                                var span = $('#y1_c4e_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC5,YC5V,YC5B,YC5C,"Simple");
                                customizedArray(YC5V,YC5VX,YC5label,colorPallet68,"Doughnut");
                                doughnutChart2(YC5VX,"y1_c5","Type of protein","auto");

                                var baseX = processBase(YC5B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y1_c5_base").empty().append(htmlB);

                                var span = $('#y1_c5_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                            extractValues(YC6,YC6V,YC6B,YC6C,"Simple");
                            customizedArray(YC6V,YC6VX,YC6label,colorPallet69,"Doughnut");
                            pieChart(YC6VX,"y1_c6","Type of Packaging","auto");

                            var baseX = processBase(YC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c6_base").empty().append(htmlB);

                            var span = $('#y1_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC7,YC7V,YC7B,YC7C,"Simple");
                            customizedArray(YC7V,YC7VX,YC7label,colorPallet68,"Doughnut");
                            pieChart(YC7VX,"y1_c7","Type of Packaging","auto");

                            var baseX = processBase(YC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c7_base").empty().append(htmlB);

                            var span = $('#y1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC8,YC8V,YC8B,YC8C,"Simple");
                            var max = (Math.max(...YC8V)+20);
                            customizedArray(YC8V,YC8VX,YC8label,colorPallet69,"Bar");
                            barChart(YC8VX,"y1_c8",YC8label,max);

                            var baseX = processBase(YC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c8_base").empty().append(htmlB);

                            var span = $('#y1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC9,YC9V,YC9B,YC9C,"Simple");
                            var max = (Math.max(...YC9V)+20);
                            customizedArray(YC9V,YC9VX,YC9label,colorPallet69,"Bar");
                            barChart(YC9VX,"y1_c9",YC9label,max);

                            var baseX = processBase(YC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c9_base").empty().append(htmlB);

                            var span = $('#y1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC10,YC10V,YC10B,YC10C,"Simple");
                            customizedArray(YC10V,YC10VX,YC10label,colorPallet68,"Doughnut");
                            pieChart(YC10VX,"y1_c10","Way of consumption","auto");

                            var baseX = processBase(YC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c10_base").empty().append(htmlB);

                            var span = $('#y1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC11,YC11V,YC11B,YC11C,"Simple");
                            var max = (Math.max(...YC11V)+20);
                            customizedArray(YC11V,YC11VX,YC11label,colorPallet69,"Bar");
                            columnChart(YC11VX,"y1_c11",YC11label,max);

                            var baseX = processBase(YC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c11_base").empty().append(htmlB);

                            var span = $('#y1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC12,YC12V,YC12B,YC12C,"Simple");
                            var max = (Math.max(...YC12V)+20);
                            customizedArray(YC12V,YC12VX,YC12label,colorPallet69,"Bar");
                            columnChart(YC12VX,"y1_c12",YC12label,max);

                            var baseX = processBase(YC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c12_base").empty().append(htmlB);

                            var span = $('#y1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC15,YC15V,YC15B,YC15C,"Simple");
                            YC15V.forEach(function(e,i,a){
                                $(`#y1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c15_base").empty().append(htmlB);

                            var span = $('#y1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC16,YC16V,YC16B,YC16C,"Simple");
                            var max = (Math.max(...YC16V)+20);
                            customizedArray(YC16V,YC16VX,YC16label,colorPallet69,"Bar");
                            barChart(YC16VX,"y1_c16",YC16label,max);

                            var baseX = processBase(YC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c16_base").empty().append(htmlB);

                            var span = $('#y1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC17,YC17V,YC17B,YC17C,"Simple");
                            YC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`y1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(YC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c17_base").empty().append(htmlB);

                            var span = $('#y1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC18,YC18V,YC18B,YC18C,"Simple");
                            var max = (Math.max(...YC18V)+20);
                            customizedArray(YC18V,YC18VX,YC18label,colorPallet69,"Bar");
                            barChart(YC18VX,"y1_c18",YC18label,max);

                            var baseX = processBase(YC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c18_base").empty().append(htmlB);

                            var span = $('#y1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC19,YC19V,YC19B,YC19C,"Simple");
                            var max = (Math.max(...YC19V)+20);
                            customizedArray(YC19V,YC19VX,YC19label,colorPallet69,"Bar");
                            barChart(YC19VX,"y1_c19",YC19label,max);

                            var baseX = processBase(YC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c19_base").empty().append(htmlB);

                            var span = $('#y1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC20,YC20V,YC20B,YC20C,"Simple");
                            YC20V.forEach(function(e,i,a){
                                $(`#y1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y1_c20_base").empty().append(htmlB);

                            var span = $('#y1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_2, S13_2V, S13_2B, S13_2C, "Simple");
                            var max = (Math.max(...S13_2V)+20);
                            customizedArray(S13_2V,S13_2VX,S13label,colorPallet69,"Bar");
                            barChart(S13_2VX,"y_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_2B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y_1_s13_base").empty().append(htmlB);

                            var span = $('#y_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            yougurtFStatus1=true;
                            ajaxFlag[1+11] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function eleventhAjax() {
                    $.ajax({
                        url: "api/ajax11.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'yougurtcondX': yougurtcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var YC0 = data['Y_C0'];
                            var YC2 = data['Y_C2'];
                            var YC3 = data['Y_C3'];
                            var YC4a = data['Y_C4a'];
                            var YC4d = data['Y_C4d'];
                            var YC4e = data['Y_C4e'];
                            var YC5 = data['Y_C5'];
                            var YC6 = data['Y_C6'];
                            var YC7 = data['Y_C7'];
                            var YC8 = data['Y_C8'];
                            var YC9 = data['Y_C9'];
                            var YC10 = data['Y_C10'];
                            var YC11 = data['Y_C11'];
                            var YC12 = data['Y_C12'];
                            var YC15 = data['Y_C15'];
                            var YC16 = data['Y_C16'];
                            var YC17 = data['Y_C17'];
                            var YC18 = data['Y_C18'];
                            var YC19 = data['Y_C19'];
                            var YC20 = data['Y_C20'];

                            var S13_2 = data['S13_2'];

                            var YC0V = [];
                            var YC0B = [];
                            var YC0C = [];
                            var YC0VX = [];

                            var YC2V = [];
                            var YC2B = [];
                            var YC2C = [];
                            var YC2VX = [];

                            var YC3V = [];
                            var YC3B = [];
                            var YC3C = [];
                            var YC3VX = [];

                            var YC4aV = [];
                            var YC4aB = [];
                            var YC4aC = [];
                            var YC4aVX = [];

                            var YC4dV = [];
                            var YC4dB = [];
                            var YC4dC = [];
                            var YC4dVX = [];

                            var YC4eV = [];
                            var YC4eB = [];
                            var YC4eC = [];
                            var YC4eVX = [];

                            var YC5V = [];
                            var YC5B = [];
                            var YC5C = [];
                            var YC5VX = [];

                            var YC6V = [];
                            var YC6B = [];
                            var YC6C = [];
                            var YC6VX = [];

                            var YC7V = [];
                            var YC7B = [];
                            var YC7C = [];
                            var YC7VX = [];

                            var YC8V = [];
                            var YC8B = [];
                            var YC8C = [];
                            var YC8VX = [];

                            var YC9V = [];
                            var YC9B = [];
                            var YC9C = [];
                            var YC9VX = [];

                            var YC10V = [];
                            var YC10B = [];
                            var YC10C = [];
                            var YC10VX = [];

                            var YC11V = [];
                            var YC11B = [];
                            var YC11C = [];
                            var YC11VX = [];

                            var YC12V = [];
                            var YC12B = [];
                            var YC12C = [];
                            var YC12VX = [];

                            var YC13V = [];
                            var YC13B = [];
                            var YC13C = [];
                            var YC13VX = [];

                            var YC14V = [];
                            var YC14B = [];
                            var YC14C = [];
                            var YC14VX = [];

                            var YC15V = [];
                            var YC15B = [];
                            var YC15C = [];
                            var YC15VX = [];

                            var YC16V = [];
                            var YC16B = [];
                            var YC16C = [];
                            var YC16VX = [];

                            var YC17V = [];
                            var YC17B = [];
                            var YC17C = [];
                            var YC17VX = [];

                            var YC18V = [];
                            var YC18B = [];
                            var YC18C = [];
                            var YC18VX = [];

                            var YC19V = [];
                            var YC19B = [];
                            var YC19C = [];
                            var YC19VX = [];

                            var YC20V = [];
                            var YC20B = [];
                            var YC20C = [];
                            var YC20VX = [];

                            var S13_2V = [];
                            var S13_2B = [];
                            var S13_2C = [];
                            var S13_2VX = [];

                            if(yougurtFStatus2==false)
                            {
                                extractValues(YC0,YC0V,YC0B,YC0C,"Simple");
                                YC0V.forEach(function(e,i,a){
                                    $(`#y2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(YC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y2_c0_base").empty().append(htmlB);

                                var span = $('#y2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                                // 

                                extractValues(YC2,YC2V,YC2B,YC2C,"Simple");
                                customizedArray(YC2V,YC2VX,YC2label,colorPallet68,"Doughnut");
                                doughnutChart2(YC2VX,"y2_c2","Type of protein","auto");

                                var baseX = processBase(YC2B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y2_c2_base").empty().append(htmlB);

                                var span = $('#y2_c2_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC3,YC3V,YC3B,YC3C,"Simple");
                                var max = (Math.max(...YC3V)+20);
                                customizedArray(YC3V,YC3VX,YC3label,colorPallet69,"Bar");
                                barChart(YC3VX,"y2_c3",YC3label,max);

                                var baseX = processBase(YC3B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y2_c3_base").empty().append(htmlB);

                                var span = $('#y2_c3_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4a,YC4aV,YC4aB,YC4aC,"Simple");
                                customizedArray(YC4aV,YC4aVX,YC4alabel,colorPallet68,"Doughnut");
                                doughnutChart1_1(YC4aVX,"y2_c4a","Type of protein","auto");

                                var baseX = processBase(YC4aB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y2_c4a_base").empty().append(htmlB);

                                var span = $('#y2_c4a_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4d,YC4dV,YC4dB,YC4dC,"Simple");
                                customizedArray(YC4dV,YC4dVX,YC4dlabel,colorPallet68,"Doughnut");
                                doughnutChart1_2(YC4dVX,"y2_c4d","Type of protein",280);

                                var baseX = processBase(YC4dB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y2_c4d_base").empty().append(htmlB);

                                var span = $('#y2_c4d_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4e,YC4eV,YC4eB,YC4eC,"Simple");
                                customizedArray(YC4eV,YC4eVX,YC4elabel,colorPallet68,"Doughnut");
                                doughnutChart1_3(YC4eVX,"y2_c4e","Type of protein",290);

                                var baseX = processBase(YC4eB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y2_c4e_base").empty().append(htmlB);

                                var span = $('#y2_c4e_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC5,YC5V,YC5B,YC5C,"Simple");
                                customizedArray(YC5V,YC5VX,YC5label,colorPallet68,"Doughnut");
                                doughnutChart2(YC5VX,"y2_c5","Type of protein","auto");

                                var baseX = processBase(YC5B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y2_c5_base").empty().append(htmlB);

                                var span = $('#y2_c5_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                            extractValues(YC6,YC6V,YC6B,YC6C,"Simple");
                            customizedArray(YC6V,YC6VX,YC6label,colorPallet69,"Doughnut");
                            pieChart(YC6VX,"y2_c6","Type of Packaging","auto");

                            var baseX = processBase(YC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c6_base").empty().append(htmlB);

                            var span = $('#y2_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC7,YC7V,YC7B,YC7C,"Simple");
                            customizedArray(YC7V,YC7VX,YC7label,colorPallet68,"Doughnut");
                            pieChart(YC7VX,"y2_c7","Type of Packaging","auto");

                            var baseX = processBase(YC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c7_base").empty().append(htmlB);

                            var span = $('#y2_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC8,YC8V,YC8B,YC8C,"Simple");
                            var max = (Math.max(...YC8V)+20);
                            customizedArray(YC8V,YC8VX,YC8label,colorPallet69,"Bar");
                            barChart(YC8VX,"y2_c8",YC8label,max);

                            var baseX = processBase(YC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c8_base").empty().append(htmlB);

                            var span = $('#y2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC9,YC9V,YC9B,YC9C,"Simple");
                            var max = (Math.max(...YC9V)+20);
                            customizedArray(YC9V,YC9VX,YC9label,colorPallet69,"Bar");
                            barChart(YC9VX,"y2_c9",YC9label,max);

                            var baseX = processBase(YC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c9_base").empty().append(htmlB);

                            var span = $('#y2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC10,YC10V,YC10B,YC10C,"Simple");
                            customizedArray(YC10V,YC10VX,YC10label,colorPallet68,"Doughnut");
                            pieChart(YC10VX,"y2_c10","Way of consumption","auto");

                            var baseX = processBase(YC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c10_base").empty().append(htmlB);

                            var span = $('#y2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC11,YC11V,YC11B,YC11C,"Simple");
                            var max = (Math.max(...YC11V)+20);
                            customizedArray(YC11V,YC11VX,YC11label,colorPallet69,"Bar");
                            columnChart(YC11VX,"y2_c11",YC11label,max);

                            var baseX = processBase(YC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c11_base").empty().append(htmlB);

                            var span = $('#y2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC12,YC12V,YC12B,YC12C,"Simple");
                            var max = (Math.max(...YC12V)+20);
                            customizedArray(YC12V,YC12VX,YC12label,colorPallet69,"Bar");
                            columnChart(YC12VX,"y2_c12",YC12label,max);

                            var baseX = processBase(YC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c12_base").empty().append(htmlB);

                            var span = $('#y2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC15,YC15V,YC15B,YC15C,"Simple");
                            YC15V.forEach(function(e,i,a){
                                $(`#y2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c15_base").empty().append(htmlB);

                            var span = $('#y2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC16,YC16V,YC16B,YC16C,"Simple");
                            var max = (Math.max(...YC16V)+20);
                            customizedArray(YC16V,YC16VX,YC16label,colorPallet69,"Bar");
                            barChart(YC16VX,"y2_c16",YC16label,max);

                            var baseX = processBase(YC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c16_base").empty().append(htmlB);

                            var span = $('#y2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC17,YC17V,YC17B,YC17C,"Simple");
                            YC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`y2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(YC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c17_base").empty().append(htmlB);

                            var span = $('#y2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC18,YC18V,YC18B,YC18C,"Simple");
                            var max = (Math.max(...YC18V)+20);
                            customizedArray(YC18V,YC18VX,YC18label,colorPallet69,"Bar");
                            barChart(YC18VX,"y2_c18",YC18label,max);

                            var baseX = processBase(YC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c18_base").empty().append(htmlB);

                            var span = $('#y2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC19,YC19V,YC19B,YC19C,"Simple");
                            var max = (Math.max(...YC19V)+20);
                            customizedArray(YC19V,YC19VX,YC19label,colorPallet69,"Bar");
                            barChart(YC19VX,"y2_c19",YC19label,max);

                            var baseX = processBase(YC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c19_base").empty().append(htmlB);

                            var span = $('#y2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC20,YC20V,YC20B,YC20C,"Simple");
                            YC20V.forEach(function(e,i,a){
                                $(`#y2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y2_c20_base").empty().append(htmlB);

                            var span = $('#y2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_2, S13_2V, S13_2B, S13_2C, "Simple");
                            var max = (Math.max(...S13_2V)+20);
                            customizedArray(S13_2V,S13_2VX,S13label,colorPallet69,"Bar");
                            barChart(S13_2VX,"y_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_2B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y_2_s13_base").empty().append(htmlB);

                            var span = $('#y_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            yougurtFStatus2 = true;
                            ajaxFlag[1+12] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twelvethAjax() {
                    $.ajax({
                        url: "api/ajax12.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'yougurtcondX': yougurtcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var YC0 = data['Y_C0'];
                            var YC2 = data['Y_C2'];
                            var YC3 = data['Y_C3'];
                            var YC4a = data['Y_C4a'];
                            var YC4d = data['Y_C4d'];
                            var YC4e = data['Y_C4e'];
                            var YC5 = data['Y_C5'];
                            var YC6 = data['Y_C6'];
                            var YC7 = data['Y_C7'];
                            var YC8 = data['Y_C8'];
                            var YC9 = data['Y_C9'];
                            var YC10 = data['Y_C10'];
                            var YC11 = data['Y_C11'];
                            var YC12 = data['Y_C12'];
                            var YC15 = data['Y_C15'];
                            var YC16 = data['Y_C16'];
                            var YC17 = data['Y_C17'];
                            var YC18 = data['Y_C18'];
                            var YC19 = data['Y_C19'];
                            var YC20 = data['Y_C20'];

                            var S13_2 = data['S13_2'];

                            var YC0V = [];
                            var YC0B = [];
                            var YC0C = [];
                            var YC0VX = [];

                            var YC2V = [];
                            var YC2B = [];
                            var YC2C = [];
                            var YC2VX = [];

                            var YC3V = [];
                            var YC3B = [];
                            var YC3C = [];
                            var YC3VX = [];

                            var YC4aV = [];
                            var YC4aB = [];
                            var YC4aC = [];
                            var YC4aVX = [];

                            var YC4dV = [];
                            var YC4dB = [];
                            var YC4dC = [];
                            var YC4dVX = [];

                            var YC4eV = [];
                            var YC4eB = [];
                            var YC4eC = [];
                            var YC4eVX = [];

                            var YC5V = [];
                            var YC5B = [];
                            var YC5C = [];
                            var YC5VX = [];

                            var YC6V = [];
                            var YC6B = [];
                            var YC6C = [];
                            var YC6VX = [];

                            var YC7V = [];
                            var YC7B = [];
                            var YC7C = [];
                            var YC7VX = [];

                            var YC8V = [];
                            var YC8B = [];
                            var YC8C = [];
                            var YC8VX = [];

                            var YC9V = [];
                            var YC9B = [];
                            var YC9C = [];
                            var YC9VX = [];

                            var YC10V = [];
                            var YC10B = [];
                            var YC10C = [];
                            var YC10VX = [];

                            var YC11V = [];
                            var YC11B = [];
                            var YC11C = [];
                            var YC11VX = [];

                            var YC12V = [];
                            var YC12B = [];
                            var YC12C = [];
                            var YC12VX = [];

                            var YC13V = [];
                            var YC13B = [];
                            var YC13C = [];
                            var YC13VX = [];

                            var YC14V = [];
                            var YC14B = [];
                            var YC14C = [];
                            var YC14VX = [];

                            var YC15V = [];
                            var YC15B = [];
                            var YC15C = [];
                            var YC15VX = [];

                            var YC16V = [];
                            var YC16B = [];
                            var YC16C = [];
                            var YC16VX = [];

                            var YC17V = [];
                            var YC17B = [];
                            var YC17C = [];
                            var YC17VX = [];

                            var YC18V = [];
                            var YC18B = [];
                            var YC18C = [];
                            var YC18VX = [];

                            var YC19V = [];
                            var YC19B = [];
                            var YC19C = [];
                            var YC19VX = [];

                            var YC20V = [];
                            var YC20B = [];
                            var YC20C = [];
                            var YC20VX = [];

                            var S13_2V = [];
                            var S13_2B = [];
                            var S13_2C = [];
                            var S13_2VX = [];

                            if(yougurtFStatus3==false)
                            {
                                extractValues(YC0,YC0V,YC0B,YC0C,"Simple");
                                YC0V.forEach(function(e,i,a){
                                    $(`#y3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(YC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y3_c0_base").empty().append(htmlB);

                                var span = $('#y3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                                // 

                                extractValues(YC2,YC2V,YC2B,YC2C,"Simple");
                                customizedArray(YC2V,YC2VX,YC2label,colorPallet68,"Doughnut");
                                doughnutChart2(YC2VX,"y3_c2","Type of protein","auto");

                                var baseX = processBase(YC2B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y3_c2_base").empty().append(htmlB);

                                var span = $('#y3_c2_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC3,YC3V,YC3B,YC3C,"Simple");
                                var max = (Math.max(...YC3V)+20);
                                customizedArray(YC3V,YC3VX,YC3label,colorPallet69,"Bar");
                                barChart(YC3VX,"y3_c3",YC3label,max);

                                var baseX = processBase(YC3B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y3_c3_base").empty().append(htmlB);

                                var span = $('#y3_c3_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4a,YC4aV,YC4aB,YC4aC,"Simple");
                                customizedArray(YC4aV,YC4aVX,YC4alabel,colorPallet68,"Doughnut");
                                doughnutChart1_1(YC4aVX,"y3_c4a","Type of protein","auto");

                                var baseX = processBase(YC4aB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y3_c4a_base").empty().append(htmlB);

                                var span = $('#y3_c4a_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4d,YC4dV,YC4dB,YC4dC,"Simple");
                                customizedArray(YC4dV,YC4dVX,YC4dlabel,colorPallet68,"Doughnut");
                                doughnutChart1_2(YC4dVX,"y3_c4d","Type of protein",280);

                                var baseX = processBase(YC4dB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y3_c4d_base").empty().append(htmlB);

                                var span = $('#y3_c4d_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4e,YC4eV,YC4eB,YC4eC,"Simple");
                                customizedArray(YC4eV,YC4eVX,YC4elabel,colorPallet68,"Doughnut");
                                doughnutChart1_3(YC4eVX,"y3_c4e","Type of protein",290);

                                var baseX = processBase(YC4eB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y3_c4e_base").empty().append(htmlB);

                                var span = $('#y3_c4e_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC5,YC5V,YC5B,YC5C,"Simple");
                                customizedArray(YC5V,YC5VX,YC5label,colorPallet68,"Doughnut");
                                doughnutChart2(YC5VX,"y3_c5","Type of protein","auto");

                                var baseX = processBase(YC5B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y3_c5_base").empty().append(htmlB);

                                var span = $('#y3_c5_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                            extractValues(YC6,YC6V,YC6B,YC6C,"Simple");
                            customizedArray(YC6V,YC6VX,YC6label,colorPallet69,"Doughnut");
                            pieChart(YC6VX,"y3_c6","Type of Packaging","auto");

                            var baseX = processBase(YC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c6_base").empty().append(htmlB);

                            var span = $('#y3_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC7,YC7V,YC7B,YC7C,"Simple");
                            customizedArray(YC7V,YC7VX,YC7label,colorPallet68,"Doughnut");
                            pieChart(YC7VX,"y3_c7","Type of Packaging","auto");

                            var baseX = processBase(YC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c7_base").empty().append(htmlB);

                            var span = $('#y3_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC8,YC8V,YC8B,YC8C,"Simple");
                            var max = (Math.max(...YC8V)+20);
                            customizedArray(YC8V,YC8VX,YC8label,colorPallet69,"Bar");
                            barChart(YC8VX,"y3_c8",YC8label,max);

                            var baseX = processBase(YC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c8_base").empty().append(htmlB);

                            var span = $('#y3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC9,YC9V,YC9B,YC9C,"Simple");
                            var max = (Math.max(...YC9V)+20);
                            customizedArray(YC9V,YC9VX,YC9label,colorPallet69,"Bar");
                            barChart(YC9VX,"y3_c9",YC9label,max);

                            var baseX = processBase(YC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c9_base").empty().append(htmlB);

                            var span = $('#y3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC10,YC10V,YC10B,YC10C,"Simple");
                            customizedArray(YC10V,YC10VX,YC10label,colorPallet68,"Doughnut");
                            pieChart(YC10VX,"y3_c10","Way of consumption","auto");

                            var baseX = processBase(YC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c10_base").empty().append(htmlB);

                            var span = $('#y3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC11,YC11V,YC11B,YC11C,"Simple");
                            var max = (Math.max(...YC11V)+20);
                            customizedArray(YC11V,YC11VX,YC11label,colorPallet69,"Bar");
                            columnChart(YC11VX,"y3_c11",YC11label,max);

                            var baseX = processBase(YC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c11_base").empty().append(htmlB);

                            var span = $('#y3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC12,YC12V,YC12B,YC12C,"Simple");
                            var max = (Math.max(...YC12V)+20);
                            customizedArray(YC12V,YC12VX,YC12label,colorPallet69,"Bar");
                            columnChart(YC12VX,"y3_c12",YC12label,max);

                            var baseX = processBase(YC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c12_base").empty().append(htmlB);

                            var span = $('#y3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC15,YC15V,YC15B,YC15C,"Simple");
                            YC15V.forEach(function(e,i,a){
                                $(`#y3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c15_base").empty().append(htmlB);

                            var span = $('#y3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC16,YC16V,YC16B,YC16C,"Simple");
                            var max = (Math.max(...YC16V)+20);
                            customizedArray(YC16V,YC16VX,YC16label,colorPallet69,"Bar");
                            barChart(YC16VX,"y3_c16",YC16label,max);

                            var baseX = processBase(YC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c16_base").empty().append(htmlB);

                            var span = $('#y3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC17,YC17V,YC17B,YC17C,"Simple");
                            YC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`y3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(YC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c17_base").empty().append(htmlB);

                            var span = $('#y3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC18,YC18V,YC18B,YC18C,"Simple");
                            var max = (Math.max(...YC18V)+20);
                            customizedArray(YC18V,YC18VX,YC18label,colorPallet69,"Bar");
                            barChart(YC18VX,"y3_c18",YC18label,max);

                            var baseX = processBase(YC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c18_base").empty().append(htmlB);

                            var span = $('#y3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC19,YC19V,YC19B,YC19C,"Simple");
                            var max = (Math.max(...YC19V)+20);
                            customizedArray(YC19V,YC19VX,YC19label,colorPallet69,"Bar");
                            barChart(YC19VX,"y3_c19",YC19label,max);

                            var baseX = processBase(YC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c19_base").empty().append(htmlB);

                            var span = $('#y3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC20,YC20V,YC20B,YC20C,"Simple");
                            YC20V.forEach(function(e,i,a){
                                $(`#y3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y3_c20_base").empty().append(htmlB);

                            var span = $('#y3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_2, S13_2V, S13_2B, S13_2C, "Simple");
                            var max = (Math.max(...S13_2V)+20);
                            customizedArray(S13_2V,S13_2VX,S13label,colorPallet69,"Bar");
                            barChart(S13_2VX,"y_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_2B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y_3_s13_base").empty().append(htmlB);

                            var span = $('#y_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            yougurtFStatus3 = true;
                            ajaxFlag[1+13] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirteenthAjax() {
                    $.ajax({
                        url: "api/ajax13.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'yougurtcondX': yougurtcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var YC0 = data['Y_C0'];
                            var YC2 = data['Y_C2'];
                            var YC3 = data['Y_C3'];
                            var YC4a = data['Y_C4a'];
                            var YC4d = data['Y_C4d'];
                            var YC4e = data['Y_C4e'];
                            var YC5 = data['Y_C5'];
                            var YC6 = data['Y_C6'];
                            var YC7 = data['Y_C7'];
                            var YC8 = data['Y_C8'];
                            var YC9 = data['Y_C9'];
                            var YC10 = data['Y_C10'];
                            var YC11 = data['Y_C11'];
                            var YC12 = data['Y_C12'];
                            var YC15 = data['Y_C15'];
                            var YC16 = data['Y_C16'];
                            var YC17 = data['Y_C17'];
                            var YC18 = data['Y_C18'];
                            var YC19 = data['Y_C19'];
                            var YC20 = data['Y_C20'];

                            var S13_2 = data['S13_2'];

                            var YC0V = [];
                            var YC0B = [];
                            var YC0C = [];
                            var YC0VX = [];

                            var YC2V = [];
                            var YC2B = [];
                            var YC2C = [];
                            var YC2VX = [];

                            var YC3V = [];
                            var YC3B = [];
                            var YC3C = [];
                            var YC3VX = [];

                            var YC4aV = [];
                            var YC4aB = [];
                            var YC4aC = [];
                            var YC4aVX = [];

                            var YC4dV = [];
                            var YC4dB = [];
                            var YC4dC = [];
                            var YC4dVX = [];

                            var YC4eV = [];
                            var YC4eB = [];
                            var YC4eC = [];
                            var YC4eVX = [];

                            var YC5V = [];
                            var YC5B = [];
                            var YC5C = [];
                            var YC5VX = [];

                            var YC6V = [];
                            var YC6B = [];
                            var YC6C = [];
                            var YC6VX = [];

                            var YC7V = [];
                            var YC7B = [];
                            var YC7C = [];
                            var YC7VX = [];

                            var YC8V = [];
                            var YC8B = [];
                            var YC8C = [];
                            var YC8VX = [];

                            var YC9V = [];
                            var YC9B = [];
                            var YC9C = [];
                            var YC9VX = [];

                            var YC10V = [];
                            var YC10B = [];
                            var YC10C = [];
                            var YC10VX = [];

                            var YC11V = [];
                            var YC11B = [];
                            var YC11C = [];
                            var YC11VX = [];

                            var YC12V = [];
                            var YC12B = [];
                            var YC12C = [];
                            var YC12VX = [];

                            var YC13V = [];
                            var YC13B = [];
                            var YC13C = [];
                            var YC13VX = [];

                            var YC14V = [];
                            var YC14B = [];
                            var YC14C = [];
                            var YC14VX = [];

                            var YC15V = [];
                            var YC15B = [];
                            var YC15C = [];
                            var YC15VX = [];

                            var YC16V = [];
                            var YC16B = [];
                            var YC16C = [];
                            var YC16VX = [];

                            var YC17V = [];
                            var YC17B = [];
                            var YC17C = [];
                            var YC17VX = [];

                            var YC18V = [];
                            var YC18B = [];
                            var YC18C = [];
                            var YC18VX = [];

                            var YC19V = [];
                            var YC19B = [];
                            var YC19C = [];
                            var YC19VX = [];

                            var YC20V = [];
                            var YC20B = [];
                            var YC20C = [];
                            var YC20VX = [];

                            var S13_2V = [];
                            var S13_2B = [];
                            var S13_2C = [];
                            var S13_2VX = [];

                            if(yougurtFStatus4==false)
                            {
                                extractValues(YC0,YC0V,YC0B,YC0C,"Simple");
                                YC0V.forEach(function(e,i,a){
                                    $(`#y4_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(YC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y4_c0_base").empty().append(htmlB);

                                var span = $('#y4_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                                // 

                                extractValues(YC2,YC2V,YC2B,YC2C,"Simple");
                                customizedArray(YC2V,YC2VX,YC2label,colorPallet68,"Doughnut");
                                doughnutChart2(YC2VX,"y4_c2","Type of protein","auto");

                                var baseX = processBase(YC2B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y4_c2_base").empty().append(htmlB);

                                var span = $('#y4_c2_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC3,YC3V,YC3B,YC3C,"Simple");
                                var max = (Math.max(...YC3V)+20);
                                customizedArray(YC3V,YC3VX,YC3label,colorPallet69,"Bar");
                                barChart(YC3VX,"y4_c3",YC3label,max);

                                var baseX = processBase(YC3B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y4_c3_base").empty().append(htmlB);

                                var span = $('#y4_c3_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4a,YC4aV,YC4aB,YC4aC,"Simple");
                                customizedArray(YC4aV,YC4aVX,YC4alabel,colorPallet68,"Doughnut");
                                doughnutChart1_1(YC4aVX,"y4_c4a","Type of protein","auto");

                                var baseX = processBase(YC4aB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y4_c4a_base").empty().append(htmlB);

                                var span = $('#y4_c4a_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4d,YC4dV,YC4dB,YC4dC,"Simple");
                                customizedArray(YC4dV,YC4dVX,YC4dlabel,colorPallet68,"Doughnut");
                                doughnutChart1_2(YC4dVX,"y4_c4d","Type of protein",280);

                                var baseX = processBase(YC4dB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y4_c4d_base").empty().append(htmlB);

                                var span = $('#y4_c4d_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4e,YC4eV,YC4eB,YC4eC,"Simple");
                                customizedArray(YC4eV,YC4eVX,YC4elabel,colorPallet68,"Doughnut");
                                doughnutChart1_3(YC4eVX,"y4_c4e","Type of protein",290);

                                var baseX = processBase(YC4eB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y4_c4e_base").empty().append(htmlB);

                                var span = $('#y4_c4e_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC5,YC5V,YC5B,YC5C,"Simple");
                                customizedArray(YC5V,YC5VX,YC5label,colorPallet68,"Doughnut");
                                doughnutChart2(YC5VX,"y4_c5","Type of protein","auto");

                                var baseX = processBase(YC5B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y4_c5_base").empty().append(htmlB);

                                var span = $('#y4_c5_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                            extractValues(YC6,YC6V,YC6B,YC6C,"Simple");
                            customizedArray(YC6V,YC6VX,YC6label,colorPallet69,"Doughnut");
                            pieChart(YC6VX,"y4_c6","Type of Packaging","auto");

                            var baseX = processBase(YC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c6_base").empty().append(htmlB);

                            var span = $('#y4_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC7,YC7V,YC7B,YC7C,"Simple");
                            customizedArray(YC7V,YC7VX,YC7label,colorPallet68,"Doughnut");
                            pieChart(YC7VX,"y4_c7","Type of Packaging","auto");

                            var baseX = processBase(YC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c7_base").empty().append(htmlB);

                            var span = $('#y4_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC8,YC8V,YC8B,YC8C,"Simple");
                            var max = (Math.max(...YC8V)+20);
                            customizedArray(YC8V,YC8VX,YC8label,colorPallet69,"Bar");
                            barChart(YC8VX,"y4_c8",YC8label,max);

                            var baseX = processBase(YC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c8_base").empty().append(htmlB);

                            var span = $('#y4_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC9,YC9V,YC9B,YC9C,"Simple");
                            var max = (Math.max(...YC9V)+20);
                            customizedArray(YC9V,YC9VX,YC9label,colorPallet69,"Bar");
                            barChart(YC9VX,"y4_c9",YC9label,max);

                            var baseX = processBase(YC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c9_base").empty().append(htmlB);

                            var span = $('#y4_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC10,YC10V,YC10B,YC10C,"Simple");
                            customizedArray(YC10V,YC10VX,YC10label,colorPallet68,"Doughnut");
                            pieChart(YC10VX,"y4_c10","Way of consumption","auto");

                            var baseX = processBase(YC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c10_base").empty().append(htmlB);

                            var span = $('#y4_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC11,YC11V,YC11B,YC11C,"Simple");
                            var max = (Math.max(...YC11V)+20);
                            customizedArray(YC11V,YC11VX,YC11label,colorPallet69,"Bar");
                            columnChart(YC11VX,"y4_c11",YC11label,max);

                            var baseX = processBase(YC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c11_base").empty().append(htmlB);

                            var span = $('#y4_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC12,YC12V,YC12B,YC12C,"Simple");
                            var max = (Math.max(...YC12V)+20);
                            customizedArray(YC12V,YC12VX,YC12label,colorPallet69,"Bar");
                            columnChart(YC12VX,"y4_c12",YC12label,max);

                            var baseX = processBase(YC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c12_base").empty().append(htmlB);

                            var span = $('#y4_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC15,YC15V,YC15B,YC15C,"Simple");
                            YC15V.forEach(function(e,i,a){
                                $(`#y4_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c15_base").empty().append(htmlB);

                            var span = $('#y4_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC16,YC16V,YC16B,YC16C,"Simple");
                            var max = (Math.max(...YC16V)+20);
                            customizedArray(YC16V,YC16VX,YC16label,colorPallet69,"Bar");
                            barChart(YC16VX,"y4_c16",YC16label,max);

                            var baseX = processBase(YC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c16_base").empty().append(htmlB);

                            var span = $('#y4_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC17,YC17V,YC17B,YC17C,"Simple");
                            YC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`y4_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(YC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c17_base").empty().append(htmlB);

                            var span = $('#y4_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC18,YC18V,YC18B,YC18C,"Simple");
                            var max = (Math.max(...YC18V)+20);
                            customizedArray(YC18V,YC18VX,YC18label,colorPallet69,"Bar");
                            barChart(YC18VX,"y4_c18",YC18label,max);

                            var baseX = processBase(YC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c18_base").empty().append(htmlB);

                            var span = $('#y4_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC19,YC19V,YC19B,YC19C,"Simple");
                            var max = (Math.max(...YC19V)+20);
                            customizedArray(YC19V,YC19VX,YC19label,colorPallet69,"Bar");
                            barChart(YC19VX,"y4_c19",YC19label,max);

                            var baseX = processBase(YC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c19_base").empty().append(htmlB);

                            var span = $('#y4_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC20,YC20V,YC20B,YC20C,"Simple");
                            YC20V.forEach(function(e,i,a){
                                $(`#y4_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y4_c20_base").empty().append(htmlB);

                            var span = $('#y4_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_2, S13_2V, S13_2B, S13_2C, "Simple");
                            var max = (Math.max(...S13_2V)+20);
                            customizedArray(S13_2V,S13_2VX,S13label,colorPallet69,"Bar");
                            barChart(S13_2VX,"y_4_s13",S13label,max);
                            
                            var baseX = processBase(S13_2B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y_4_s13_base").empty().append(htmlB);

                            var span = $('#y_4_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            yougurtFStatus4 = true;
                            ajaxFlag[1+14] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fourteenthAjax() {
                    $.ajax({
                        url: "api/ajax14.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'yougurtcondX': yougurtcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var YC0 = data['Y_C0'];
                            var YC2 = data['Y_C2'];
                            var YC3 = data['Y_C3'];
                            var YC4a = data['Y_C4a'];
                            var YC4d = data['Y_C4d'];
                            var YC4e = data['Y_C4e'];
                            var YC5 = data['Y_C5'];
                            var YC6 = data['Y_C6'];
                            var YC7 = data['Y_C7'];
                            var YC8 = data['Y_C8'];
                            var YC9 = data['Y_C9'];
                            var YC10 = data['Y_C10'];
                            var YC11 = data['Y_C11'];
                            var YC12 = data['Y_C12'];
                            var YC15 = data['Y_C15'];
                            var YC16 = data['Y_C16'];
                            var YC17 = data['Y_C17'];
                            var YC18 = data['Y_C18'];
                            var YC19 = data['Y_C19'];
                            var YC20 = data['Y_C20'];

                            var S13_2 = data['S13_2'];

                            var YC0V = [];
                            var YC0B = [];
                            var YC0C = [];
                            var YC0VX = [];

                            var YC2V = [];
                            var YC2B = [];
                            var YC2C = [];
                            var YC2VX = [];

                            var YC3V = [];
                            var YC3B = [];
                            var YC3C = [];
                            var YC3VX = [];

                            var YC4aV = [];
                            var YC4aB = [];
                            var YC4aC = [];
                            var YC4aVX = [];

                            var YC4dV = [];
                            var YC4dB = [];
                            var YC4dC = [];
                            var YC4dVX = [];

                            var YC4eV = [];
                            var YC4eB = [];
                            var YC4eC = [];
                            var YC4eVX = [];

                            var YC5V = [];
                            var YC5B = [];
                            var YC5C = [];
                            var YC5VX = [];

                            var YC6V = [];
                            var YC6B = [];
                            var YC6C = [];
                            var YC6VX = [];

                            var YC7V = [];
                            var YC7B = [];
                            var YC7C = [];
                            var YC7VX = [];

                            var YC8V = [];
                            var YC8B = [];
                            var YC8C = [];
                            var YC8VX = [];

                            var YC9V = [];
                            var YC9B = [];
                            var YC9C = [];
                            var YC9VX = [];

                            var YC10V = [];
                            var YC10B = [];
                            var YC10C = [];
                            var YC10VX = [];

                            var YC11V = [];
                            var YC11B = [];
                            var YC11C = [];
                            var YC11VX = [];

                            var YC12V = [];
                            var YC12B = [];
                            var YC12C = [];
                            var YC12VX = [];

                            var YC13V = [];
                            var YC13B = [];
                            var YC13C = [];
                            var YC13VX = [];

                            var YC14V = [];
                            var YC14B = [];
                            var YC14C = [];
                            var YC14VX = [];

                            var YC15V = [];
                            var YC15B = [];
                            var YC15C = [];
                            var YC15VX = [];

                            var YC16V = [];
                            var YC16B = [];
                            var YC16C = [];
                            var YC16VX = [];

                            var YC17V = [];
                            var YC17B = [];
                            var YC17C = [];
                            var YC17VX = [];

                            var YC18V = [];
                            var YC18B = [];
                            var YC18C = [];
                            var YC18VX = [];

                            var YC19V = [];
                            var YC19B = [];
                            var YC19C = [];
                            var YC19VX = [];

                            var YC20V = [];
                            var YC20B = [];
                            var YC20C = [];
                            var YC20VX = [];

                            var S13_2V = [];
                            var S13_2B = [];
                            var S13_2C = [];
                            var S13_2VX = [];

                            if(yougurtFStatus5==false)
                            {
                                extractValues(YC0,YC0V,YC0B,YC0C,"Simple");
                                YC0V.forEach(function(e,i,a){
                                    $(`#y5_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(YC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y5_c0_base").empty().append(htmlB);

                                var span = $('#y5_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                                // 

                                extractValues(YC2,YC2V,YC2B,YC2C,"Simple");
                                customizedArray(YC2V,YC2VX,YC2label,colorPallet68,"Doughnut");
                                doughnutChart2(YC2VX,"y5_c2","Type of protein","auto");

                                var baseX = processBase(YC2B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y5_c2_base").empty().append(htmlB);

                                var span = $('#y5_c2_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC3,YC3V,YC3B,YC3C,"Simple");
                                var max = (Math.max(...YC3V)+20);
                                customizedArray(YC3V,YC3VX,YC3label,colorPallet69,"Bar");
                                barChart(YC3VX,"y5_c3",YC3label,max);

                                var baseX = processBase(YC3B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y5_c3_base").empty().append(htmlB);

                                var span = $('#y5_c3_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4a,YC4aV,YC4aB,YC4aC,"Simple");
                                customizedArray(YC4aV,YC4aVX,YC4alabel,colorPallet68,"Doughnut");
                                doughnutChart1_1(YC4aVX,"y5_c4a","Type of protein","auto");

                                var baseX = processBase(YC4aB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y5_c4a_base").empty().append(htmlB);

                                var span = $('#y5_c4a_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4d,YC4dV,YC4dB,YC4dC,"Simple");
                                customizedArray(YC4dV,YC4dVX,YC4dlabel,colorPallet68,"Doughnut");
                                doughnutChart1_2(YC4dVX,"y5_c4d","Type of protein",280);

                                var baseX = processBase(YC4dB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y5_c4d_base").empty().append(htmlB);

                                var span = $('#y5_c4d_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC4e,YC4eV,YC4eB,YC4eC,"Simple");
                                customizedArray(YC4eV,YC4eVX,YC4elabel,colorPallet68,"Doughnut");
                                doughnutChart1_3(YC4eVX,"y5_c4e","Type of protein",290);

                                var baseX = processBase(YC4eB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y5_c4e_base").empty().append(htmlB);

                                var span = $('#y5_c4e_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                                extractValues(YC5,YC5V,YC5B,YC5C,"Simple");
                                customizedArray(YC5V,YC5VX,YC5label,colorPallet68,"Doughnut");
                                doughnutChart2(YC5VX,"y5_c5","Type of protein","auto");

                                var baseX = processBase(YC5B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#y5_c5_base").empty().append(htmlB);

                                var span = $('#y5_c5_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                // 

                            extractValues(YC6,YC6V,YC6B,YC6C,"Simple");
                            customizedArray(YC6V,YC6VX,YC6label,colorPallet69,"Doughnut");
                            pieChart(YC6VX,"y5_c6","Type of Packaging","auto");

                            var baseX = processBase(YC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c6_base").empty().append(htmlB);

                            var span = $('#y5_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC7,YC7V,YC7B,YC7C,"Simple");
                            customizedArray(YC7V,YC7VX,YC7label,colorPallet68,"Doughnut");
                            pieChart(YC7VX,"y5_c7","Type of Packaging","auto");

                            var baseX = processBase(YC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c7_base").empty().append(htmlB);

                            var span = $('#y5_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC8,YC8V,YC8B,YC8C,"Simple");
                            var max = (Math.max(...YC8V)+20);
                            customizedArray(YC8V,YC8VX,YC8label,colorPallet69,"Bar");
                            barChart(YC8VX,"y5_c8",YC8label,max);

                            var baseX = processBase(YC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c8_base").empty().append(htmlB);

                            var span = $('#y5_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC9,YC9V,YC9B,YC9C,"Simple");
                            var max = (Math.max(...YC9V)+20);
                            customizedArray(YC9V,YC9VX,YC9label,colorPallet69,"Bar");
                            barChart(YC9VX,"y5_c9",YC9label,max);

                            var baseX = processBase(YC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c9_base").empty().append(htmlB);

                            var span = $('#y5_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC10,YC10V,YC10B,YC10C,"Simple");
                            customizedArray(YC10V,YC10VX,YC10label,colorPallet68,"Doughnut");
                            pieChart(YC10VX,"y5_c10","Way of consumption","auto");

                            var baseX = processBase(YC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c10_base").empty().append(htmlB);

                            var span = $('#y5_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC11,YC11V,YC11B,YC11C,"Simple");
                            var max = (Math.max(...YC11V)+20);
                            customizedArray(YC11V,YC11VX,YC11label,colorPallet69,"Bar");
                            columnChart(YC11VX,"y5_c11",YC11label,max);

                            var baseX = processBase(YC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c11_base").empty().append(htmlB);

                            var span = $('#y5_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC12,YC12V,YC12B,YC12C,"Simple");
                            var max = (Math.max(...YC12V)+20);
                            customizedArray(YC12V,YC12VX,YC12label,colorPallet69,"Bar");
                            columnChart(YC12VX,"y5_c12",YC12label,max);

                            var baseX = processBase(YC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c12_base").empty().append(htmlB);

                            var span = $('#y5_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC15,YC15V,YC15B,YC15C,"Simple");
                            YC15V.forEach(function(e,i,a){
                                $(`#y5_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c15_base").empty().append(htmlB);

                            var span = $('#y5_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC16,YC16V,YC16B,YC16C,"Simple");
                            var max = (Math.max(...YC16V)+20);
                            customizedArray(YC16V,YC16VX,YC16label,colorPallet69,"Bar");
                            barChart(YC16VX,"y5_c16",YC16label,max);

                            var baseX = processBase(YC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c16_base").empty().append(htmlB);

                            var span = $('#y5_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC17,YC17V,YC17B,YC17C,"Simple");
                            YC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`y5_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(YC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c17_base").empty().append(htmlB);

                            var span = $('#y5_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC18,YC18V,YC18B,YC18C,"Simple");
                            var max = (Math.max(...YC18V)+20);
                            customizedArray(YC18V,YC18VX,YC18label,colorPallet69,"Bar");
                            barChart(YC18VX,"y5_c18",YC18label,max);

                            var baseX = processBase(YC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c18_base").empty().append(htmlB);

                            var span = $('#y5_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC19,YC19V,YC19B,YC19C,"Simple");
                            var max = (Math.max(...YC19V)+20);
                            customizedArray(YC19V,YC19VX,YC19label,colorPallet69,"Bar");
                            barChart(YC19VX,"y5_c19",YC19label,max);

                            var baseX = processBase(YC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c19_base").empty().append(htmlB);

                            var span = $('#y5_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(YC20,YC20V,YC20B,YC20C,"Simple");
                            YC20V.forEach(function(e,i,a){
                                $(`#y5_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(YC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y5_c20_base").empty().append(htmlB);

                            var span = $('#y5_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_2, S13_2V, S13_2B, S13_2C, "Simple");
                            var max = (Math.max(...S13_2V)+20);
                            customizedArray(S13_2V,S13_2VX,S13label,colorPallet69,"Bar");
                            barChart(S13_2VX,"y_5_s13",S13label,max);
                            
                            var baseX = processBase(S13_2B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#y_5_s13_base").empty().append(htmlB);

                            var span = $('#y_5_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            yougurtFStatus5 = true;
                            ajaxFlag[1+15] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fifteenthAjax() {
                    $.ajax({
                        url: "api/ajax15.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'maltcondX':maltcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var MDC0 = data['MD_C0'];
                            var MDC1 = data['MD_C1'];
                            var MDC2 = data['MD_C2'];
                            var MDC3 = data['MD_C3'];
                            var MDC4b = data['MD_C4b'];
                            var MDC6 = data['MD_C6'];
                            var MDC7 = data['MD_C7'];
                            var MDC8 = data['MD_C8'];
                            var MDC9 = data['MD_C9'];
                            var MDC10 = data['MD_C10'];
                            var MDC11 = data['MD_C11'];
                            var MDC12 = data['MD_C12'];
                            var MDC15 = data['MD_C15'];
                            var MDC16 = data['MD_C16'];
                            var MDC17 = data['MD_C17'];
                            var MDC18 = data['MD_C18'];
                            var MDC19 = data['MD_C19'];
                            var MDC20 = data['MD_C20'];

                            var S13_5 = data['S13_5'];

                            var MDC0V = [];
                            var MDC0B = [];
                            var MDC0C = [];
                            var MDC0VX = [];

                            var MDC1V = [];
                            var MDC1B = [];
                            var MDC1C = [];
                            var MDC1VX = [];

                            var MDC2V = [];
                            var MDC2B = [];
                            var MDC2C = [];
                            var MDC2VX = [];

                            var MDC3V = [];
                            var MDC3B = [];
                            var MDC3C = [];
                            var MDC3VX = [];

                            var MDC4bV = [];
                            var MDC4bB = [];
                            var MDC4bC = [];
                            var MDC4bVX = [];

                            var MDC6V = [];
                            var MDC6B = [];
                            var MDC6C = [];
                            var MDC6VX = [];

                            var MDC7V = [];
                            var MDC7B = [];
                            var MDC7C = [];
                            var MDC7VX = [];

                            var MDC8V = [];
                            var MDC8B = [];
                            var MDC8C = [];
                            var MDC8VX = [];

                            var MDC9V = [];
                            var MDC9B = [];
                            var MDC9C = [];
                            var MDC9VX = [];

                            var MDC10V = [];
                            var MDC10B = [];
                            var MDC10C = [];
                            var MDC10VX = [];

                            var MDC11V = [];
                            var MDC11B = [];
                            var MDC11C = [];
                            var MDC11VX = [];

                            var MDC12V = [];
                            var MDC12B = [];
                            var MDC12C = [];
                            var MDC12VX = [];

                            var MDC13V = [];
                            var MDC13B = [];
                            var MDC13C = [];
                            var MDC13VX = [];

                            var MDC14V = [];
                            var MDC14B = [];
                            var MDC14C = [];
                            var MDC14VX = [];

                            var MDC15V = [];
                            var MDC15B = [];
                            var MDC15C = [];
                            var MDC15VX = [];

                            var MDC16V = [];
                            var MDC16B = [];
                            var MDC16C = [];
                            var MDC16VX = [];

                            var MDC17V = [];
                            var MDC17B = [];
                            var MDC17C = [];
                            var MDC17VX = [];

                            var MDC18V = [];
                            var MDC18B = [];
                            var MDC18C = [];
                            var MDC18VX = [];

                            var MDC19V = [];
                            var MDC19B = [];
                            var MDC19C = [];
                            var MDC19VX = [];

                            var MDC20V = [];
                            var MDC20B = [];
                            var MDC20C = [];
                            var MDC20VX = [];

                            var S13_5V = [];
                            var S13_5B = [];
                            var S13_5C = [];
                            var S13_5VX = [];

                            if(maltFStatus1==false)
                            {
                                extractValues(MDC0,MDC0V,MDC0B,MDC0C,"Simple");
                                MDC0V.forEach(function(e,i,a){
                                    $(`#md1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(MDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#md1_c0_base").empty().append(htmlB);

                                var span = $('#md1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                //formtable(MDC0V,MDC0label,"md1_c0TA");
                            }

                            // 

                            extractValues(MDC1,MDC1V,MDC1B,MDC1C,"Simple");
                            customizedArray(MDC1V,MDC1VX,MDC1label,colorPallet68,"Doughnut");
                            doughnutChart2(MDC1VX,"md1_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(MDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c1_base").empty().append(htmlB);

                            var span = $('#md1_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            
                            extractValues(MDC2,MDC2V,MDC2B,MDC2C,"Simple");
                            customizedArray(MDC2V,MDC2VX,MDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(MDC2VX,"md1_c2","Type of dairy milk you had","auto");

                            var baseX = processBase(MDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c2_base").empty().append(htmlB);

                            var span = $('#md1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC2V,MDC2label,"md1_c2TA");

                            extractValues(MDC3,MDC3V,MDC3B,MDC3C,"Simple");
                            var max = (Math.max(...MDC3V)+20);
                            customizedArray(MDC3V,MDC3VX,MDC3label,colorPallet69,"Bar");
                            barChart(MDC3VX,"md1_c3",MDC3label,max);

                            var baseX = processBase(MDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c3_base").empty().append(htmlB);

                            var span = $('#md1_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC3V,MDC3label,"md1_c3TA");

                            extractValues(MDC4b,MDC4bV,MDC4bB,MDC4bC,"Simple");
                            customizedArray(MDC4bV,MDC4bVX,MDC4blabel,colorPallet68,"Doughnut");
                            doughnutChart2(MDC4bVX,"md1_c4b","Consumed with hot or cold",285);
                            var baseX = processBase(MDC4bB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c4b_base").empty().append(htmlB);

                            var span = $('#md1_c4b_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC4bV,MDC4blabel,"md1_c4bTA");

                            extractValues(MDC6,MDC6V,MDC6B,MDC6C,"Simple");
                            customizedArray(MDC6V,MDC6VX,MDC6label,colorPallet69,"Doughnut");
                            pieChart(MDC6VX,"md1_c6","Type of Packaging","auto");

                            var baseX = processBase(MDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c6_base").empty().append(htmlB);

                            var span = $('#md1_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC6V,MDC6label,"md1_c6TA");

                            extractValues(MDC7,MDC7V,MDC7B,MDC7C,"Simple");
                            customizedArray(MDC7V,MDC7VX,MDC7label,colorPallet68,"Doughnut");
                            pieChart(MDC7VX,"md1_c7","Type of Packaging","auto");

                            var baseX = processBase(MDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c7_base").empty().append(htmlB);

                            var span = $('#md1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC7V,MDC7label,"md1_c7TA");

                            extractValues(MDC8,MDC8V,MDC8B,MDC8C,"Simple");
                            var max = (Math.max(...MDC8V)+20);
                            customizedArray(MDC8V,MDC8VX,MDC8label,colorPallet69,"Bar");
                            barChart(MDC8VX,"md1_c8",MDC8label,max);

                            var baseX = processBase(MDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c8_base").empty().append(htmlB);

                            var span = $('#md1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC8V,MDC8label,"md1_c8TA");

                            extractValues(MDC9,MDC9V,MDC9B,MDC9C,"Simple");
                            var max = (Math.max(...MDC9V)+20);
                            customizedArray(MDC9V,MDC9VX,MDC9label,colorPallet69,"Bar");
                            barChart(MDC9VX,"md1_c9",MDC9label,max);

                            var baseX = processBase(MDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c9_base").empty().append(htmlB);

                            var span = $('#md1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC9V,MDC9label,"md1_c9TA");

                            extractValues(MDC10,MDC10V,MDC10B,MDC10C,"Simple");
                            customizedArray(MDC10V,MDC10VX,MDC10label,colorPallet68,"Doughnut");
                            pieChart(MDC10VX,"md1_c10","Way of consumption","auto");

                            var baseX = processBase(MDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c10_base").empty().append(htmlB);

                            var span = $('#md1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC10V,MDC10label,"md1_c10TA");

                            extractValues(MDC11,MDC11V,MDC11B,MDC11C,"Simple");
                            var max = (Math.max(...MDC11V)+20);
                            customizedArray(MDC11V,MDC11VX,MDC11label,colorPallet69,"Bar");
                            columnChart(MDC11VX,"md1_c11",MDC11label,max);

                            var baseX = processBase(MDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c11_base").empty().append(htmlB);

                            var span = $('#md1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC11V,MDC11label,"md1_c11TA");

                            extractValues(MDC12,MDC12V,MDC12B,MDC12C,"Simple");
                            var max = (Math.max(...MDC12V)+20);
                            customizedArray(MDC12V,MDC12VX,MDC12label,colorPallet69,"Bar");
                            columnChart(MDC12VX,"md1_c12",MDC12label,max);

                            var baseX = processBase(MDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c12_base").empty().append(htmlB);

                            var span = $('#md1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC12V,MDC12label,"md1_c12TA");

                            extractValues(MDC15,MDC15V,MDC15B,MDC15C,"Simple");
                            MDC15V.forEach(function(e,i,a){
                                $(`#md1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(MDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c15_base").empty().append(htmlB);

                            var span = $('#md1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC15V,MDC15label,"md1_c15TA");

                            extractValues(MDC16,MDC16V,MDC16B,MDC16C,"Simple");
                            var max = (Math.max(...MDC16V)+20);
                            customizedArray(MDC16V,MDC16VX,MDC16label,colorPallet69,"Bar");
                            barChart(MDC16VX,"md1_c16",MDC16label,max);

                            var baseX = processBase(MDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c16_base").empty().append(htmlB);

                            var span = $('#md1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC17,MDC17V,MDC17B,MDC17C,"Simple");
                            MDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`md1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(MDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c17_base").empty().append(htmlB);

                            var span = $('#md1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC18,MDC18V,MDC18B,MDC18C,"Simple");
                            var max = (Math.max(...MDC18V)+20);
                            customizedArray(MDC18V,MDC18VX,MDC18label,colorPallet69,"Bar");
                            barChart(MDC18VX,"md1_c18",MDC18label,max);

                            var baseX = processBase(MDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c18_base").empty().append(htmlB);

                            var span = $('#md1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC19,MDC19V,MDC19B,MDC19C,"Simple");
                            var max = (Math.max(...MDC19V)+20);
                            customizedArray(MDC19V,MDC19VX,MDC19label,colorPallet69,"Bar");
                            barChart(MDC19VX,"md1_c19",MDC19label,max);

                            var baseX = processBase(MDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c19_base").empty().append(htmlB);

                            var span = $('#md1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(MDC20,MDC20V,MDC20B,MDC20C,"Simple");
                            MDC20V.forEach(function(e,i,a){
                                $(`#md1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(MDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md1_c20_base").empty().append(htmlB);

                            var span = $('#md1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_5, S13_5V, S13_5B, S13_5C, "Simple");
                            var max = (Math.max(...S13_5V)+20);
                            customizedArray(S13_5V,S13_5VX,S13label,colorPallet69,"Bar");
                            barChart(S13_5VX,"md_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_5B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#md_1_s13_base").empty().append(htmlB);

                            var span = $('#md_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            maltFStatus1 = true;
                            ajaxFlag[1+16] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }
                function sixteenthAjax() {
                    $.ajax({
                        url: "api/ajax16.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'maltcondX':maltcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var MDC0 = data['MD_C0'];
                            var MDC1 = data['MD_C1'];
                            var MDC2 = data['MD_C2'];
                            var MDC3 = data['MD_C3'];
                            var MDC4b = data['MD_C4b'];
                            var MDC6 = data['MD_C6'];
                            var MDC7 = data['MD_C7'];
                            var MDC8 = data['MD_C8'];
                            var MDC9 = data['MD_C9'];
                            var MDC10 = data['MD_C10'];
                            var MDC11 = data['MD_C11'];
                            var MDC12 = data['MD_C12'];
                            var MDC15 = data['MD_C15'];
                            var MDC16 = data['MD_C16'];
                            var MDC17 = data['MD_C17'];
                            var MDC18 = data['MD_C18'];
                            var MDC19 = data['MD_C19'];
                            var MDC20 = data['MD_C20'];

                            var S13_5 = data['S13_5'];

                            var MDC0V = [];
                            var MDC0B = [];
                            var MDC0C = [];
                            var MDC0VX = [];

                            var MDC1V = [];
                            var MDC1B = [];
                            var MDC1C = [];
                            var MDC1VX = [];

                            var MDC2V = [];
                            var MDC2B = [];
                            var MDC2C = [];
                            var MDC2VX = [];

                            var MDC3V = [];
                            var MDC3B = [];
                            var MDC3C = [];
                            var MDC3VX = [];

                            var MDC4bV = [];
                            var MDC4bB = [];
                            var MDC4bC = [];
                            var MDC4bVX = [];

                            var MDC6V = [];
                            var MDC6B = [];
                            var MDC6C = [];
                            var MDC6VX = [];

                            var MDC7V = [];
                            var MDC7B = [];
                            var MDC7C = [];
                            var MDC7VX = [];

                            var MDC8V = [];
                            var MDC8B = [];
                            var MDC8C = [];
                            var MDC8VX = [];

                            var MDC9V = [];
                            var MDC9B = [];
                            var MDC9C = [];
                            var MDC9VX = [];

                            var MDC10V = [];
                            var MDC10B = [];
                            var MDC10C = [];
                            var MDC10VX = [];

                            var MDC11V = [];
                            var MDC11B = [];
                            var MDC11C = [];
                            var MDC11VX = [];

                            var MDC12V = [];
                            var MDC12B = [];
                            var MDC12C = [];
                            var MDC12VX = [];

                            var MDC13V = [];
                            var MDC13B = [];
                            var MDC13C = [];
                            var MDC13VX = [];

                            var MDC14V = [];
                            var MDC14B = [];
                            var MDC14C = [];
                            var MDC14VX = [];

                            var MDC15V = [];
                            var MDC15B = [];
                            var MDC15C = [];
                            var MDC15VX = [];

                            var MDC16V = [];
                            var MDC16B = [];
                            var MDC16C = [];
                            var MDC16VX = [];

                            var MDC17V = [];
                            var MDC17B = [];
                            var MDC17C = [];
                            var MDC17VX = [];

                            var MDC18V = [];
                            var MDC18B = [];
                            var MDC18C = [];
                            var MDC18VX = [];

                            var MDC19V = [];
                            var MDC19B = [];
                            var MDC19C = [];
                            var MDC19VX = [];

                            var MDC20V = [];
                            var MDC20B = [];
                            var MDC20C = [];
                            var MDC20VX = [];

                            var S13_5V = [];
                            var S13_5B = [];
                            var S13_5C = [];
                            var S13_5VX = [];

                            if(maltFStatus2==false)
                            {
                                extractValues(MDC0,MDC0V,MDC0B,MDC0C,"Simple");
                                MDC0V.forEach(function(e,i,a){
                                    $(`#md2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(MDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#md2_c0_base").empty().append(htmlB);

                                var span = $('#md2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                //formtable(MDC0V,MDC0label,"md2_c0TA");
                            }

                            // 

                            extractValues(MDC1,MDC1V,MDC1B,MDC1C,"Simple");
                            customizedArray(MDC1V,MDC1VX,MDC1label,colorPallet68,"Doughnut");
                            doughnutChart2(MDC1VX,"md2_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(MDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c1_base").empty().append(htmlB);

                            var span = $('#md2_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            
                            extractValues(MDC2,MDC2V,MDC2B,MDC2C,"Simple");
                            customizedArray(MDC2V,MDC2VX,MDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(MDC2VX,"md2_c2","Type of dairy milk you had","auto");

                            var baseX = processBase(MDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c2_base").empty().append(htmlB);

                            var span = $('#md2_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC2V,MDC2label,"md2_c2TA");

                            extractValues(MDC3,MDC3V,MDC3B,MDC3C,"Simple");
                            var max = (Math.max(...MDC3V)+20);
                            customizedArray(MDC3V,MDC3VX,MDC3label,colorPallet69,"Bar");
                            barChart(MDC3VX,"md2_c3",MDC3label,max);

                            var baseX = processBase(MDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c3_base").empty().append(htmlB);

                            var span = $('#md2_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC3V,MDC3label,"md2_c3TA");

                            extractValues(MDC4b,MDC4bV,MDC4bB,MDC4bC,"Simple");
                            customizedArray(MDC4bV,MDC4bVX,MDC4blabel,colorPallet68,"Doughnut");
                            doughnutChart2(MDC4bVX,"md2_c4b","Consumed with hot or cold",285);
                            var baseX = processBase(MDC4bB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c4b_base").empty().append(htmlB);

                            var span = $('#md2_c4b_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC4bV,MDC4blabel,"md2_c4bTA");

                            extractValues(MDC6,MDC6V,MDC6B,MDC6C,"Simple");
                            customizedArray(MDC6V,MDC6VX,MDC6label,colorPallet69,"Doughnut");
                            pieChart(MDC6VX,"md2_c6","Type of Packaging","auto");

                            var baseX = processBase(MDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c6_base").empty().append(htmlB);

                            var span = $('#md2_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC6V,MDC6label,"md2_c6TA");

                            extractValues(MDC7,MDC7V,MDC7B,MDC7C,"Simple");
                            customizedArray(MDC7V,MDC7VX,MDC7label,colorPallet68,"Doughnut");
                            pieChart(MDC7VX,"md2_c7","Type of Packaging","auto");

                            var baseX = processBase(MDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c7_base").empty().append(htmlB);

                            var span = $('#md2_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC7V,MDC7label,"md2_c7TA");

                            extractValues(MDC8,MDC8V,MDC8B,MDC8C,"Simple");
                            var max = (Math.max(...MDC8V)+20);
                            customizedArray(MDC8V,MDC8VX,MDC8label,colorPallet69,"Bar");
                            barChart(MDC8VX,"md2_c8",MDC8label,max);

                            var baseX = processBase(MDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c8_base").empty().append(htmlB);

                            var span = $('#md2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC8V,MDC8label,"md2_c8TA");

                            extractValues(MDC9,MDC9V,MDC9B,MDC9C,"Simple");
                            var max = (Math.max(...MDC9V)+20);
                            customizedArray(MDC9V,MDC9VX,MDC9label,colorPallet69,"Bar");
                            barChart(MDC9VX,"md2_c9",MDC9label,max);

                            var baseX = processBase(MDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c9_base").empty().append(htmlB);

                            var span = $('#md2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC9V,MDC9label,"md2_c9TA");

                            extractValues(MDC10,MDC10V,MDC10B,MDC10C,"Simple");
                            customizedArray(MDC10V,MDC10VX,MDC10label,colorPallet68,"Doughnut");
                            pieChart(MDC10VX,"md2_c10","Way of consumption","auto");

                            var baseX = processBase(MDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c10_base").empty().append(htmlB);

                            var span = $('#md2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC10V,MDC10label,"md2_c10TA");

                            extractValues(MDC11,MDC11V,MDC11B,MDC11C,"Simple");
                            var max = (Math.max(...MDC11V)+20);
                            customizedArray(MDC11V,MDC11VX,MDC11label,colorPallet69,"Bar");
                            columnChart(MDC11VX,"md2_c11",MDC11label,max);

                            var baseX = processBase(MDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c11_base").empty().append(htmlB);

                            var span = $('#md2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC11V,MDC11label,"md2_c11TA");

                            extractValues(MDC12,MDC12V,MDC12B,MDC12C,"Simple");
                            var max = (Math.max(...MDC12V)+20);
                            customizedArray(MDC12V,MDC12VX,MDC12label,colorPallet69,"Bar");
                            columnChart(MDC12VX,"md2_c12",MDC12label,max);

                            var baseX = processBase(MDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c12_base").empty().append(htmlB);

                            var span = $('#md2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC12V,MDC12label,"md2_c12TA");

                            extractValues(MDC15,MDC15V,MDC15B,MDC15C,"Simple");
                            MDC15V.forEach(function(e,i,a){
                                $(`#md2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(MDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c15_base").empty().append(htmlB);

                            var span = $('#md2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC15V,MDC15label,"md2_c15TA");

                            extractValues(MDC16,MDC16V,MDC16B,MDC16C,"Simple");
                            var max = (Math.max(...MDC16V)+20);
                            customizedArray(MDC16V,MDC16VX,MDC16label,colorPallet69,"Bar");
                            barChart(MDC16VX,"md2_c16",MDC16label,max);

                            var baseX = processBase(MDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c16_base").empty().append(htmlB);

                            var span = $('#md2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC17,MDC17V,MDC17B,MDC17C,"Simple");
                            MDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`md2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(MDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c17_base").empty().append(htmlB);

                            var span = $('#md2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC18,MDC18V,MDC18B,MDC18C,"Simple");
                            var max = (Math.max(...MDC18V)+20);
                            customizedArray(MDC18V,MDC18VX,MDC18label,colorPallet69,"Bar");
                            barChart(MDC18VX,"md2_c18",MDC18label,max);

                            var baseX = processBase(MDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c18_base").empty().append(htmlB);

                            var span = $('#md2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC19,MDC19V,MDC19B,MDC19C,"Simple");
                            var max = (Math.max(...MDC19V)+20);
                            customizedArray(MDC19V,MDC19VX,MDC19label,colorPallet69,"Bar");
                            barChart(MDC19VX,"md2_c19",MDC19label,max);

                            var baseX = processBase(MDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c19_base").empty().append(htmlB);

                            var span = $('#md2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(MDC20,MDC20V,MDC20B,MDC20C,"Simple");
                            MDC20V.forEach(function(e,i,a){
                                $(`#md2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(MDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md2_c20_base").empty().append(htmlB);

                            var span = $('#md2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_5, S13_5V, S13_5B, S13_5C, "Simple");
                            var max = (Math.max(...S13_5V)+20);
                            customizedArray(S13_5V,S13_5VX,S13label,colorPallet69,"Bar");
                            barChart(S13_5VX,"md_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_5B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#md_2_s13_base").empty().append(htmlB);

                            var span = $('#md_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            maltFStatus2 = true;
                            ajaxFlag[1+17] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function seventeenthAjax() {
                    $.ajax({
                        url: "api/ajax17.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'maltcondX':maltcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var MDC0 = data['MD_C0'];
                            var MDC1 = data['MD_C1'];
                            var MDC2 = data['MD_C2'];
                            var MDC3 = data['MD_C3'];
                            var MDC4b = data['MD_C4b'];
                            var MDC6 = data['MD_C6'];
                            var MDC7 = data['MD_C7'];
                            var MDC8 = data['MD_C8'];
                            var MDC9 = data['MD_C9'];
                            var MDC10 = data['MD_C10'];
                            var MDC11 = data['MD_C11'];
                            var MDC12 = data['MD_C12'];
                            var MDC15 = data['MD_C15'];
                            var MDC16 = data['MD_C16'];
                            var MDC17 = data['MD_C17'];
                            var MDC18 = data['MD_C18'];
                            var MDC19 = data['MD_C19'];
                            var MDC20 = data['MD_C20'];

                            var S13_5 = data['S13_5'];

                            var MDC0V = [];
                            var MDC0B = [];
                            var MDC0C = [];
                            var MDC0VX = [];

                            var MDC1V = [];
                            var MDC1B = [];
                            var MDC1C = [];
                            var MDC1VX = [];

                            var MDC2V = [];
                            var MDC2B = [];
                            var MDC2C = [];
                            var MDC2VX = [];

                            var MDC3V = [];
                            var MDC3B = [];
                            var MDC3C = [];
                            var MDC3VX = [];

                            var MDC4bV = [];
                            var MDC4bB = [];
                            var MDC4bC = [];
                            var MDC4bVX = [];

                            var MDC6V = [];
                            var MDC6B = [];
                            var MDC6C = [];
                            var MDC6VX = [];

                            var MDC7V = [];
                            var MDC7B = [];
                            var MDC7C = [];
                            var MDC7VX = [];

                            var MDC8V = [];
                            var MDC8B = [];
                            var MDC8C = [];
                            var MDC8VX = [];

                            var MDC9V = [];
                            var MDC9B = [];
                            var MDC9C = [];
                            var MDC9VX = [];

                            var MDC10V = [];
                            var MDC10B = [];
                            var MDC10C = [];
                            var MDC10VX = [];

                            var MDC11V = [];
                            var MDC11B = [];
                            var MDC11C = [];
                            var MDC11VX = [];

                            var MDC12V = [];
                            var MDC12B = [];
                            var MDC12C = [];
                            var MDC12VX = [];

                            var MDC13V = [];
                            var MDC13B = [];
                            var MDC13C = [];
                            var MDC13VX = [];

                            var MDC14V = [];
                            var MDC14B = [];
                            var MDC14C = [];
                            var MDC14VX = [];

                            var MDC15V = [];
                            var MDC15B = [];
                            var MDC15C = [];
                            var MDC15VX = [];

                            var MDC16V = [];
                            var MDC16B = [];
                            var MDC16C = [];
                            var MDC16VX = [];

                            var MDC17V = [];
                            var MDC17B = [];
                            var MDC17C = [];
                            var MDC17VX = [];

                            var MDC18V = [];
                            var MDC18B = [];
                            var MDC18C = [];
                            var MDC18VX = [];

                            var MDC19V = [];
                            var MDC19B = [];
                            var MDC19C = [];
                            var MDC19VX = [];

                            var MDC20V = [];
                            var MDC20B = [];
                            var MDC20C = [];
                            var MDC20VX = [];

                            var S13_5V = [];
                            var S13_5B = [];
                            var S13_5C = [];
                            var S13_5VX = [];

                            if(maltFStatus3==false)
                            {
                                extractValues(MDC0,MDC0V,MDC0B,MDC0C,"Simple");
                                MDC0V.forEach(function(e,i,a){
                                    $(`#md3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(MDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#md3_c0_base").empty().append(htmlB);

                                var span = $('#md3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                //formtable(MDC0V,MDC0label,"md3_c0TA");
                            }

                            // 

                            extractValues(MDC1,MDC1V,MDC1B,MDC1C,"Simple");
                            customizedArray(MDC1V,MDC1VX,MDC1label,colorPallet68,"Doughnut");
                            doughnutChart2(MDC1VX,"md3_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(MDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c1_base").empty().append(htmlB);

                            var span = $('#md3_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            
                            extractValues(MDC2,MDC2V,MDC2B,MDC2C,"Simple");
                            customizedArray(MDC2V,MDC2VX,MDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(MDC2VX,"md3_c2","Type of dairy milk you had","auto");

                            var baseX = processBase(MDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c2_base").empty().append(htmlB);

                            var span = $('#md3_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC2V,MDC2label,"md3_c2TA");

                            extractValues(MDC3,MDC3V,MDC3B,MDC3C,"Simple");
                            var max = (Math.max(...MDC3V)+20);
                            customizedArray(MDC3V,MDC3VX,MDC3label,colorPallet69,"Bar");
                            barChart(MDC3VX,"md3_c3",MDC3label,max);

                            var baseX = processBase(MDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c3_base").empty().append(htmlB);

                            var span = $('#md3_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC3V,MDC3label,"md3_c3TA");

                            extractValues(MDC4b,MDC4bV,MDC4bB,MDC4bC,"Simple");
                            customizedArray(MDC4bV,MDC4bVX,MDC4blabel,colorPallet68,"Doughnut");
                            doughnutChart2(MDC4bVX,"md3_c4b","Consumed with hot or cold",285);
                            var baseX = processBase(MDC4bB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c4b_base").empty().append(htmlB);

                            var span = $('#md3_c4b_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC4bV,MDC4blabel,"md3_c4bTA");

                            extractValues(MDC6,MDC6V,MDC6B,MDC6C,"Simple");
                            customizedArray(MDC6V,MDC6VX,MDC6label,colorPallet69,"Doughnut");
                            pieChart(MDC6VX,"md3_c6","Type of Packaging","auto");

                            var baseX = processBase(MDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c6_base").empty().append(htmlB);

                            var span = $('#md3_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC6V,MDC6label,"md3_c6TA");

                            extractValues(MDC7,MDC7V,MDC7B,MDC7C,"Simple");
                            customizedArray(MDC7V,MDC7VX,MDC7label,colorPallet68,"Doughnut");
                            pieChart(MDC7VX,"md3_c7","Type of Packaging","auto");

                            var baseX = processBase(MDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c7_base").empty().append(htmlB);

                            var span = $('#md3_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC7V,MDC7label,"md3_c7TA");

                            extractValues(MDC8,MDC8V,MDC8B,MDC8C,"Simple");
                            var max = (Math.max(...MDC8V)+20);
                            customizedArray(MDC8V,MDC8VX,MDC8label,colorPallet69,"Bar");
                            barChart(MDC8VX,"md3_c8",MDC8label,max);

                            var baseX = processBase(MDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c8_base").empty().append(htmlB);

                            var span = $('#md3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC8V,MDC8label,"md3_c8TA");

                            extractValues(MDC9,MDC9V,MDC9B,MDC9C,"Simple");
                            var max = (Math.max(...MDC9V)+20);
                            customizedArray(MDC9V,MDC9VX,MDC9label,colorPallet69,"Bar");
                            barChart(MDC9VX,"md3_c9",MDC9label,max);

                            var baseX = processBase(MDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c9_base").empty().append(htmlB);

                            var span = $('#md3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC9V,MDC9label,"md3_c9TA");

                            extractValues(MDC10,MDC10V,MDC10B,MDC10C,"Simple");
                            customizedArray(MDC10V,MDC10VX,MDC10label,colorPallet68,"Doughnut");
                            pieChart(MDC10VX,"md3_c10","Way of consumption","auto");

                            var baseX = processBase(MDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c10_base").empty().append(htmlB);

                            var span = $('#md3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC10V,MDC10label,"md3_c10TA");

                            extractValues(MDC11,MDC11V,MDC11B,MDC11C,"Simple");
                            var max = (Math.max(...MDC11V)+20);
                            customizedArray(MDC11V,MDC11VX,MDC11label,colorPallet69,"Bar");
                            columnChart(MDC11VX,"md3_c11",MDC11label,max);

                            var baseX = processBase(MDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c11_base").empty().append(htmlB);

                            var span = $('#md3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC11V,MDC11label,"md3_c11TA");

                            extractValues(MDC12,MDC12V,MDC12B,MDC12C,"Simple");
                            var max = (Math.max(...MDC12V)+20);
                            customizedArray(MDC12V,MDC12VX,MDC12label,colorPallet69,"Bar");
                            columnChart(MDC12VX,"md3_c12",MDC12label,max);

                            var baseX = processBase(MDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c12_base").empty().append(htmlB);

                            var span = $('#md3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC12V,MDC12label,"md3_c12TA");

                            extractValues(MDC15,MDC15V,MDC15B,MDC15C,"Simple");
                            MDC15V.forEach(function(e,i,a){
                                $(`#md3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(MDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c15_base").empty().append(htmlB);

                            var span = $('#md3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC15V,MDC15label,"md3_c15TA");

                            extractValues(MDC16,MDC16V,MDC16B,MDC16C,"Simple");
                            var max = (Math.max(...MDC16V)+20);
                            customizedArray(MDC16V,MDC16VX,MDC16label,colorPallet69,"Bar");
                            barChart(MDC16VX,"md3_c16",MDC16label,max);

                            var baseX = processBase(MDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c16_base").empty().append(htmlB);

                            var span = $('#md3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC17,MDC17V,MDC17B,MDC17C,"Simple");
                            MDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`md3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(MDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c17_base").empty().append(htmlB);

                            var span = $('#md3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC18,MDC18V,MDC18B,MDC18C,"Simple");
                            var max = (Math.max(...MDC18V)+20);
                            customizedArray(MDC18V,MDC18VX,MDC18label,colorPallet69,"Bar");
                            barChart(MDC18VX,"md3_c18",MDC18label,max);

                            var baseX = processBase(MDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c18_base").empty().append(htmlB);

                            var span = $('#md3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC19,MDC19V,MDC19B,MDC19C,"Simple");
                            var max = (Math.max(...MDC19V)+20);
                            customizedArray(MDC19V,MDC19VX,MDC19label,colorPallet69,"Bar");
                            barChart(MDC19VX,"md3_c19",MDC19label,max);

                            var baseX = processBase(MDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c19_base").empty().append(htmlB);

                            var span = $('#md3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(MDC20,MDC20V,MDC20B,MDC20C,"Simple");
                            MDC20V.forEach(function(e,i,a){
                                $(`#md3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(MDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md3_c20_base").empty().append(htmlB);

                            var span = $('#md3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_5, S13_5V, S13_5B, S13_5C, "Simple");
                            var max = (Math.max(...S13_5V)+20);
                            customizedArray(S13_5V,S13_5VX,S13label,colorPallet69,"Bar");
                            barChart(S13_5VX,"md_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_5B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#md_3_s13_base").empty().append(htmlB);

                            var span = $('#md_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            maltFStatus3 = true;
                            ajaxFlag[1+18] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function eighteenthAjax() {
                    $.ajax({
                        url: "api/ajax18.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'maltcondX':maltcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var MDC0 = data['MD_C0'];
                            var MDC1 = data['MD_C1'];
                            var MDC2 = data['MD_C2'];
                            var MDC3 = data['MD_C3'];
                            var MDC4b = data['MD_C4b'];
                            var MDC6 = data['MD_C6'];
                            var MDC7 = data['MD_C7'];
                            var MDC8 = data['MD_C8'];
                            var MDC9 = data['MD_C9'];
                            var MDC10 = data['MD_C10'];
                            var MDC11 = data['MD_C11'];
                            var MDC12 = data['MD_C12'];
                            var MDC15 = data['MD_C15'];
                            var MDC16 = data['MD_C16'];
                            var MDC17 = data['MD_C17'];
                            var MDC18 = data['MD_C18'];
                            var MDC19 = data['MD_C19'];
                            var MDC20 = data['MD_C20'];

                            var S13_5 = data['S13_5'];

                            var MDC0V = [];
                            var MDC0B = [];
                            var MDC0C = [];
                            var MDC0VX = [];

                            var MDC1V = [];
                            var MDC1B = [];
                            var MDC1C = [];
                            var MDC1VX = [];

                            var MDC2V = [];
                            var MDC2B = [];
                            var MDC2C = [];
                            var MDC2VX = [];

                            var MDC3V = [];
                            var MDC3B = [];
                            var MDC3C = [];
                            var MDC3VX = [];

                            var MDC4bV = [];
                            var MDC4bB = [];
                            var MDC4bC = [];
                            var MDC4bVX = [];

                            var MDC6V = [];
                            var MDC6B = [];
                            var MDC6C = [];
                            var MDC6VX = [];

                            var MDC7V = [];
                            var MDC7B = [];
                            var MDC7C = [];
                            var MDC7VX = [];

                            var MDC8V = [];
                            var MDC8B = [];
                            var MDC8C = [];
                            var MDC8VX = [];

                            var MDC9V = [];
                            var MDC9B = [];
                            var MDC9C = [];
                            var MDC9VX = [];

                            var MDC10V = [];
                            var MDC10B = [];
                            var MDC10C = [];
                            var MDC10VX = [];

                            var MDC11V = [];
                            var MDC11B = [];
                            var MDC11C = [];
                            var MDC11VX = [];

                            var MDC12V = [];
                            var MDC12B = [];
                            var MDC12C = [];
                            var MDC12VX = [];

                            var MDC13V = [];
                            var MDC13B = [];
                            var MDC13C = [];
                            var MDC13VX = [];

                            var MDC14V = [];
                            var MDC14B = [];
                            var MDC14C = [];
                            var MDC14VX = [];

                            var MDC15V = [];
                            var MDC15B = [];
                            var MDC15C = [];
                            var MDC15VX = [];

                            var MDC16V = [];
                            var MDC16B = [];
                            var MDC16C = [];
                            var MDC16VX = [];

                            var MDC17V = [];
                            var MDC17B = [];
                            var MDC17C = [];
                            var MDC17VX = [];

                            var MDC18V = [];
                            var MDC18B = [];
                            var MDC18C = [];
                            var MDC18VX = [];

                            var MDC19V = [];
                            var MDC19B = [];
                            var MDC19C = [];
                            var MDC19VX = [];

                            var MDC20V = [];
                            var MDC20B = [];
                            var MDC20C = [];
                            var MDC20VX = [];

                            var S13_5V = [];
                            var S13_5B = [];
                            var S13_5C = [];
                            var S13_5VX = [];

                            if(maltFStatus4==false)
                            {
                                extractValues(MDC0,MDC0V,MDC0B,MDC0C,"Simple");
                                MDC0V.forEach(function(e,i,a){
                                    $(`#md4_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(MDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#md4_c0_base").empty().append(htmlB);

                                var span = $('#md4_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                //formtable(MDC0V,MDC0label,"md4_c0TA");
                            }

                            // 

                            extractValues(MDC1,MDC1V,MDC1B,MDC1C,"Simple");
                            customizedArray(MDC1V,MDC1VX,MDC1label,colorPallet68,"Doughnut");
                            doughnutChart2(MDC1VX,"md4_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(MDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c1_base").empty().append(htmlB);

                            var span = $('#md4_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            
                            extractValues(MDC2,MDC2V,MDC2B,MDC2C,"Simple");
                            customizedArray(MDC2V,MDC2VX,MDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(MDC2VX,"md4_c2","Type of dairy milk you had","auto");

                            var baseX = processBase(MDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c2_base").empty().append(htmlB);

                            var span = $('#md4_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC2V,MDC2label,"md4_c2TA");

                            extractValues(MDC3,MDC3V,MDC3B,MDC3C,"Simple");
                            var max = (Math.max(...MDC3V)+20);
                            customizedArray(MDC3V,MDC3VX,MDC3label,colorPallet69,"Bar");
                            barChart(MDC3VX,"md4_c3",MDC3label,max);

                            var baseX = processBase(MDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c3_base").empty().append(htmlB);

                            var span = $('#md4_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC3V,MDC3label,"md4_c3TA");

                            extractValues(MDC4b,MDC4bV,MDC4bB,MDC4bC,"Simple");
                            customizedArray(MDC4bV,MDC4bVX,MDC4blabel,colorPallet68,"Doughnut");
                            doughnutChart2(MDC4bVX,"md4_c4b","Consumed with hot or cold",285);
                            var baseX = processBase(MDC4bB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c4b_base").empty().append(htmlB);

                            var span = $('#md4_c4b_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC4bV,MDC4blabel,"md4_c4bTA");

                            extractValues(MDC6,MDC6V,MDC6B,MDC6C,"Simple");
                            customizedArray(MDC6V,MDC6VX,MDC6label,colorPallet69,"Doughnut");
                            pieChart(MDC6VX,"md4_c6","Type of Packaging","auto");

                            var baseX = processBase(MDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c6_base").empty().append(htmlB);

                            var span = $('#md4_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC6V,MDC6label,"md4_c6TA");

                            extractValues(MDC7,MDC7V,MDC7B,MDC7C,"Simple");
                            customizedArray(MDC7V,MDC7VX,MDC7label,colorPallet68,"Doughnut");
                            pieChart(MDC7VX,"md4_c7","Type of Packaging","auto");

                            var baseX = processBase(MDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c7_base").empty().append(htmlB);

                            var span = $('#md4_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC7V,MDC7label,"md4_c7TA");

                            extractValues(MDC8,MDC8V,MDC8B,MDC8C,"Simple");
                            var max = (Math.max(...MDC8V)+20);
                            customizedArray(MDC8V,MDC8VX,MDC8label,colorPallet69,"Bar");
                            barChart(MDC8VX,"md4_c8",MDC8label,max);

                            var baseX = processBase(MDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c8_base").empty().append(htmlB);

                            var span = $('#md4_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC8V,MDC8label,"md4_c8TA");

                            extractValues(MDC9,MDC9V,MDC9B,MDC9C,"Simple");
                            var max = (Math.max(...MDC9V)+20);
                            customizedArray(MDC9V,MDC9VX,MDC9label,colorPallet69,"Bar");
                            barChart(MDC9VX,"md4_c9",MDC9label,max);

                            var baseX = processBase(MDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c9_base").empty().append(htmlB);

                            var span = $('#md4_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC9V,MDC9label,"md4_c9TA");

                            extractValues(MDC10,MDC10V,MDC10B,MDC10C,"Simple");
                            customizedArray(MDC10V,MDC10VX,MDC10label,colorPallet68,"Doughnut");
                            pieChart(MDC10VX,"md4_c10","Way of consumption","auto");

                            var baseX = processBase(MDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c10_base").empty().append(htmlB);

                            var span = $('#md4_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC10V,MDC10label,"md4_c10TA");

                            extractValues(MDC11,MDC11V,MDC11B,MDC11C,"Simple");
                            var max = (Math.max(...MDC11V)+20);
                            customizedArray(MDC11V,MDC11VX,MDC11label,colorPallet69,"Bar");
                            columnChart(MDC11VX,"md4_c11",MDC11label,max);

                            var baseX = processBase(MDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c11_base").empty().append(htmlB);

                            var span = $('#md4_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC11V,MDC11label,"md4_c11TA");

                            extractValues(MDC12,MDC12V,MDC12B,MDC12C,"Simple");
                            var max = (Math.max(...MDC12V)+20);
                            customizedArray(MDC12V,MDC12VX,MDC12label,colorPallet69,"Bar");
                            columnChart(MDC12VX,"md4_c12",MDC12label,max);

                            var baseX = processBase(MDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c12_base").empty().append(htmlB);

                            var span = $('#md4_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC12V,MDC12label,"md4_c12TA");

                            extractValues(MDC15,MDC15V,MDC15B,MDC15C,"Simple");
                            MDC15V.forEach(function(e,i,a){
                                $(`#md4_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(MDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c15_base").empty().append(htmlB);

                            var span = $('#md4_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(MDC15V,MDC15label,"md4_c15TA");

                            extractValues(MDC16,MDC16V,MDC16B,MDC16C,"Simple");
                            var max = (Math.max(...MDC16V)+20);
                            customizedArray(MDC16V,MDC16VX,MDC16label,colorPallet69,"Bar");
                            barChart(MDC16VX,"md4_c16",MDC16label,max);

                            var baseX = processBase(MDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c16_base").empty().append(htmlB);

                            var span = $('#md4_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC17,MDC17V,MDC17B,MDC17C,"Simple");
                            MDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`md4_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(MDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c17_base").empty().append(htmlB);

                            var span = $('#md4_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC18,MDC18V,MDC18B,MDC18C,"Simple");
                            var max = (Math.max(...MDC18V)+20);
                            customizedArray(MDC18V,MDC18VX,MDC18label,colorPallet69,"Bar");
                            barChart(MDC18VX,"md4_c18",MDC18label,max);

                            var baseX = processBase(MDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c18_base").empty().append(htmlB);

                            var span = $('#md4_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(MDC19,MDC19V,MDC19B,MDC19C,"Simple");
                            var max = (Math.max(...MDC19V)+20);
                            customizedArray(MDC19V,MDC19VX,MDC19label,colorPallet69,"Bar");
                            barChart(MDC19VX,"md4_c19",MDC19label,max);

                            var baseX = processBase(MDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c19_base").empty().append(htmlB);

                            var span = $('#md4_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(MDC20,MDC20V,MDC20B,MDC20C,"Simple");
                            MDC20V.forEach(function(e,i,a){
                                $(`#md4_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(MDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#md4_c20_base").empty().append(htmlB);

                            var span = $('#md4_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_5, S13_5V, S13_5B, S13_5C, "Simple");
                            var max = (Math.max(...S13_5V)+20);
                            customizedArray(S13_5V,S13_5VX,S13label,colorPallet69,"Bar");
                            barChart(S13_5VX,"md_4_s13",S13label,max);
                            
                            var baseX = processBase(S13_5B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#md_4_s13_base").empty().append(htmlB);

                            var span = $('#md_4_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            maltFStatus4 = true;
                            ajaxFlag[1+19] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function nineteenthAjax() {
                    $.ajax({
                        url: "api/ajax19.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'condensedcondX':condensedcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var CEMC0 = data['CEM_C0'];
                            var CEMC1 = data['CEM_C1'];
                            var CEMC5 = data['CEM_C5'];
                            var CEMC8 = data['CEM_C8'];
                            var CEMC9 = data['CEM_C9'];
                            var CEMC10 = data['CEM_C10'];
                            var CEMC11 = data['CEM_C11'];
                            var CEMC12 = data['CEM_C12'];
                            var CEMC15 = data['CEM_C15'];
                            var CEMC16 = data['CEM_C16'];
                            var CEMC17 = data['CEM_C17'];
                            var CEMC18 = data['CEM_C18'];
                            var CEMC19 = data['CEM_C19'];
                            var CEMC20 = data['CEM_C20'];

                            var S13_4 = data['S13_4'];

                            var CEMC0V = [];
                            var CEMC0B = [];
                            var CEMC0C = [];
                            var CEMC0VX = [];

                            var CEMC1V = [];
                            var CEMC1B = [];
                            var CEMC1C = [];
                            var CEMC1VX = [];

                            var CEMC5V = [];
                            var CEMC5B = [];
                            var CEMC5C = [];
                            var CEMC5VX = [];

                            var CEMC8V = [];
                            var CEMC8B = [];
                            var CEMC8C = [];
                            var CEMC8VX = [];

                            var CEMC9V = [];
                            var CEMC9B = [];
                            var CEMC9C = [];
                            var CEMC9VX = [];

                            var CEMC10V = [];
                            var CEMC10B = [];
                            var CEMC10C = [];
                            var CEMC10VX = [];

                            var CEMC11V = [];
                            var CEMC11B = [];
                            var CEMC11C = [];
                            var CEMC11VX = [];

                            var CEMC12V = [];
                            var CEMC12B = [];
                            var CEMC12C = [];
                            var CEMC12VX = [];

                            var CEMC13V = [];
                            var CEMC13B = [];
                            var CEMC13C = [];
                            var CEMC13VX = [];

                            var CEMC14V = [];
                            var CEMC14B = [];
                            var CEMC14C = [];
                            var CEMC14VX = [];

                            var CEMC15V = [];
                            var CEMC15B = [];
                            var CEMC15C = [];
                            var CEMC15VX = [];

                            var CEMC16V = [];
                            var CEMC16B = [];
                            var CEMC16C = [];
                            var CEMC16VX = [];

                            var CEMC17V = [];
                            var CEMC17B = [];
                            var CEMC17C = [];
                            var CEMC17VX = [];

                            var CEMC18V = [];
                            var CEMC18B = [];
                            var CEMC18C = [];
                            var CEMC18VX = [];

                            var CEMC19V = [];
                            var CEMC19B = [];
                            var CEMC19C = [];
                            var CEMC19VX = [];

                            var CEMC20V = [];
                            var CEMC20B = [];
                            var CEMC20C = [];
                            var CEMC20VX = [];

                            var S13_4V = [];
                            var S13_4B = [];
                            var S13_4C = [];
                            var S13_4VX = [];

                            if(condensedFStatus1==false)
                            {
                                extractValues(CEMC0,CEMC0V,CEMC0B,CEMC0C,"Simple");
                                CEMC0V.forEach(function(e,i,a){
                                    $(`#cem1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CEMC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#cem1_c0_base").empty().append(htmlB);

                                var span = $('#cem1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(CEMC1,CEMC1V,CEMC1B,CEMC1C,"Simple");
                            customizedArray(CEMC1V,CEMC1VX,CEMC1label,colorPallet68,"Doughnut");
                            doughnutChart2(CEMC1VX,"cem1_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(CEMC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c1_base").empty().append(htmlB);

                            var span = $('#cem1_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CEMC5,CEMC5V,CEMC5B,CEMC5C,"Simple");
                            customizedArray(CEMC5V,CEMC5VX,CEMC5label,colorPallet68,"Doughnut");
                            doughnutChart2(CEMC5VX,"cem1_c5","Type of dairy milk you had","auto");

                            var baseX = processBase(CEMC5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c5_base").empty().append(htmlB);

                            var span = $('#cem1_c5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC8,CEMC8V,CEMC8B,CEMC8C,"Simple");
                            var max = (Math.max(...CEMC8V)+20);
                            customizedArray(CEMC8V,CEMC8VX,CEMC8label,colorPallet69,"Bar");
                            barChart(CEMC8VX,"cem1_c8",CEMC8label,max);

                            var baseX = processBase(CEMC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c8_base").empty().append(htmlB);

                            var span = $('#cem1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC8V,CEMC8label,"cem1_c8TA");

                            extractValues(CEMC9,CEMC9V,CEMC9B,CEMC9C,"Simple");
                            var max = (Math.max(...CEMC9V)+20);
                            customizedArray(CEMC9V,CEMC9VX,CEMC9label,colorPallet69,"Bar");
                            barChart(CEMC9VX,"cem1_c9",CEMC9label,max);

                            var baseX = processBase(CEMC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c9_base").empty().append(htmlB);

                            var span = $('#cem1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC9V,CEMC9label,"cem1_c9TA");

                            extractValues(CEMC10,CEMC10V,CEMC10B,CEMC10C,"Simple");
                            customizedArray(CEMC10V,CEMC10VX,CEMC10label,colorPallet68,"Doughnut");
                            pieChart(CEMC10VX,"cem1_c10","Way of consumption","auto");

                            var baseX = processBase(CEMC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c10_base").empty().append(htmlB);

                            var span = $('#cem1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC10V,CEMC10label,"cem1_c10TA");

                            extractValues(CEMC11,CEMC11V,CEMC11B,CEMC11C,"Simple");
                            var max = (Math.max(...CEMC11V)+20);
                            customizedArray(CEMC11V,CEMC11VX,CEMC11label,colorPallet69,"Bar");
                            columnChart(CEMC11VX,"cem1_c11",CEMC11label,max);

                            var baseX = processBase(CEMC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c11_base").empty().append(htmlB);

                            var span = $('#cem1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC11V,CEMC11label,"cem1_c11TA");

                            extractValues(CEMC12,CEMC12V,CEMC12B,CEMC12C,"Simple");
                            var max = (Math.max(...CEMC12V)+20);
                            customizedArray(CEMC12V,CEMC12VX,CEMC12label,colorPallet69,"Bar");
                            columnChart(CEMC12VX,"cem1_c12",CEMC12label,max);

                            var baseX = processBase(CEMC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c12_base").empty().append(htmlB);

                            var span = $('#cem1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC12V,CEMC12label,"cem1_c12TA");

                            extractValues(CEMC15,CEMC15V,CEMC15B,CEMC15C,"Simple");
                            CEMC15V.forEach(function(e,i,a){
                                $(`#cem1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CEMC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c15_base").empty().append(htmlB);

                            var span = $('#cem1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC15V,CEMC15label,"cem1_c15TA");

                            extractValues(CEMC16,CEMC16V,CEMC16B,CEMC16C,"Simple");
                            var max = (Math.max(...CEMC16V)+20);
                            customizedArray(CEMC16V,CEMC16VX,CEMC16label,colorPallet69,"Bar");
                            barChart(CEMC16VX,"cem1_c16",CEMC16label,max);

                            var baseX = processBase(CEMC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c16_base").empty().append(htmlB);

                            var span = $('#cem1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC17,CEMC17V,CEMC17B,CEMC17C,"Simple");
                            CEMC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`cem1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CEMC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c17_base").empty().append(htmlB);

                            var span = $('#cem1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC18,CEMC18V,CEMC18B,CEMC18C,"Simple");
                            var max = (Math.max(...CEMC18V)+20);
                            customizedArray(CEMC18V,CEMC18VX,CEMC18label,colorPallet69,"Bar");
                            barChart(CEMC18VX,"cem1_c18",CEMC18label,max);

                            var baseX = processBase(CEMC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c18_base").empty().append(htmlB);

                            var span = $('#cem1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC19,CEMC19V,CEMC19B,CEMC19C,"Simple");
                            var max = (Math.max(...CEMC19V)+20);
                            customizedArray(CEMC19V,CEMC19VX,CEMC19label,colorPallet69,"Bar");
                            barChart(CEMC19VX,"cem1_c19",CEMC19label,max);

                            var baseX = processBase(CEMC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c19_base").empty().append(htmlB);

                            var span = $('#cem1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(CEMC20,CEMC20V,CEMC20B,CEMC20C,"Simple");
                            CEMC20V.forEach(function(e,i,a){
                                $(`#cem1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CEMC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem1_c20_base").empty().append(htmlB);

                            var span = $('#cem1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_4, S13_4V, S13_4B, S13_4C, "Simple");
                            var max = (Math.max(...S13_4V)+20);
                            customizedArray(S13_4V,S13_4VX,S13label,colorPallet69,"Bar");
                            barChart(S13_4VX,"cem_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_4B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cem_1_s13_base").empty().append(htmlB);

                            var span = $('#cem_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            condensedFStatus1 = true;
                            ajaxFlag[1+20] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentythAjax() {
                    $.ajax({
                        url: "api/ajax20.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'condensedcondX':condensedcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var CEMC0 = data['CEM_C0'];
                            var CEMC1 = data['CEM_C1'];
                            var CEMC5 = data['CEM_C5'];
                            var CEMC8 = data['CEM_C8'];
                            var CEMC9 = data['CEM_C9'];
                            var CEMC10 = data['CEM_C10'];
                            var CEMC11 = data['CEM_C11'];
                            var CEMC12 = data['CEM_C12'];
                            var CEMC15 = data['CEM_C15'];
                            var CEMC16 = data['CEM_C16'];
                            var CEMC17 = data['CEM_C17'];
                            var CEMC18 = data['CEM_C18'];
                            var CEMC19 = data['CEM_C19'];
                            var CEMC20 = data['CEM_C20'];

                            var S13_4 = data['S13_4'];

                            var CEMC0V = [];
                            var CEMC0B = [];
                            var CEMC0C = [];
                            var CEMC0VX = [];

                            var CEMC1V = [];
                            var CEMC1B = [];
                            var CEMC1C = [];
                            var CEMC1VX = [];

                            var CEMC5V = [];
                            var CEMC5B = [];
                            var CEMC5C = [];
                            var CEMC5VX = [];

                            var CEMC8V = [];
                            var CEMC8B = [];
                            var CEMC8C = [];
                            var CEMC8VX = [];

                            var CEMC9V = [];
                            var CEMC9B = [];
                            var CEMC9C = [];
                            var CEMC9VX = [];

                            var CEMC10V = [];
                            var CEMC10B = [];
                            var CEMC10C = [];
                            var CEMC10VX = [];

                            var CEMC11V = [];
                            var CEMC11B = [];
                            var CEMC11C = [];
                            var CEMC11VX = [];

                            var CEMC12V = [];
                            var CEMC12B = [];
                            var CEMC12C = [];
                            var CEMC12VX = [];

                            var CEMC13V = [];
                            var CEMC13B = [];
                            var CEMC13C = [];
                            var CEMC13VX = [];

                            var CEMC14V = [];
                            var CEMC14B = [];
                            var CEMC14C = [];
                            var CEMC14VX = [];

                            var CEMC15V = [];
                            var CEMC15B = [];
                            var CEMC15C = [];
                            var CEMC15VX = [];

                            var CEMC16V = [];
                            var CEMC16B = [];
                            var CEMC16C = [];
                            var CEMC16VX = [];

                            var CEMC17V = [];
                            var CEMC17B = [];
                            var CEMC17C = [];
                            var CEMC17VX = [];

                            var CEMC18V = [];
                            var CEMC18B = [];
                            var CEMC18C = [];
                            var CEMC18VX = [];

                            var CEMC19V = [];
                            var CEMC19B = [];
                            var CEMC19C = [];
                            var CEMC19VX = [];

                            var CEMC20V = [];
                            var CEMC20B = [];
                            var CEMC20C = [];
                            var CEMC20VX = [];

                            var S13_4V = [];
                            var S13_4B = [];
                            var S13_4C = [];
                            var S13_4VX = [];

                            if(condensedFStatus2==false)
                            {
                                extractValues(CEMC0,CEMC0V,CEMC0B,CEMC0C,"Simple");
                                CEMC0V.forEach(function(e,i,a){
                                    $(`#cem2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CEMC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#cem2_c0_base").empty().append(htmlB);

                                var span = $('#cem2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(CEMC1,CEMC1V,CEMC1B,CEMC1C,"Simple");
                            customizedArray(CEMC1V,CEMC1VX,CEMC1label,colorPallet68,"Doughnut");
                            doughnutChart2(CEMC1VX,"cem2_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(CEMC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c1_base").empty().append(htmlB);

                            var span = $('#cem2_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CEMC5,CEMC5V,CEMC5B,CEMC5C,"Simple");
                            customizedArray(CEMC5V,CEMC5VX,CEMC5label,colorPallet68,"Doughnut");
                            doughnutChart2(CEMC5VX,"cem2_c5","Type of dairy milk you had","auto");

                            var baseX = processBase(CEMC5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c5_base").empty().append(htmlB);

                            var span = $('#cem2_c5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC8,CEMC8V,CEMC8B,CEMC8C,"Simple");
                            var max = (Math.max(...CEMC8V)+20);
                            customizedArray(CEMC8V,CEMC8VX,CEMC8label,colorPallet69,"Bar");
                            barChart(CEMC8VX,"cem2_c8",CEMC8label,max);

                            var baseX = processBase(CEMC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c8_base").empty().append(htmlB);

                            var span = $('#cem2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC8V,CEMC8label,"cem2_c8TA");

                            extractValues(CEMC9,CEMC9V,CEMC9B,CEMC9C,"Simple");
                            var max = (Math.max(...CEMC9V)+20);
                            customizedArray(CEMC9V,CEMC9VX,CEMC9label,colorPallet69,"Bar");
                            barChart(CEMC9VX,"cem2_c9",CEMC9label,max);

                            var baseX = processBase(CEMC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c9_base").empty().append(htmlB);

                            var span = $('#cem2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC9V,CEMC9label,"cem2_c9TA");

                            extractValues(CEMC10,CEMC10V,CEMC10B,CEMC10C,"Simple");
                            customizedArray(CEMC10V,CEMC10VX,CEMC10label,colorPallet68,"Doughnut");
                            pieChart(CEMC10VX,"cem2_c10","Way of consumption","auto");

                            var baseX = processBase(CEMC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c10_base").empty().append(htmlB);

                            var span = $('#cem2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC10V,CEMC10label,"cem2_c10TA");

                            extractValues(CEMC11,CEMC11V,CEMC11B,CEMC11C,"Simple");
                            var max = (Math.max(...CEMC11V)+20);
                            customizedArray(CEMC11V,CEMC11VX,CEMC11label,colorPallet69,"Bar");
                            columnChart(CEMC11VX,"cem2_c11",CEMC11label,max);

                            var baseX = processBase(CEMC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c11_base").empty().append(htmlB);

                            var span = $('#cem2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC11V,CEMC11label,"cem2_c11TA");

                            extractValues(CEMC12,CEMC12V,CEMC12B,CEMC12C,"Simple");
                            var max = (Math.max(...CEMC12V)+20);
                            customizedArray(CEMC12V,CEMC12VX,CEMC12label,colorPallet69,"Bar");
                            columnChart(CEMC12VX,"cem2_c12",CEMC12label,max);

                            var baseX = processBase(CEMC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c12_base").empty().append(htmlB);

                            var span = $('#cem2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC12V,CEMC12label,"cem2_c12TA");

                            extractValues(CEMC15,CEMC15V,CEMC15B,CEMC15C,"Simple");
                            CEMC15V.forEach(function(e,i,a){
                                $(`#cem2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CEMC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c15_base").empty().append(htmlB);

                            var span = $('#cem2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC15V,CEMC15label,"cem2_c15TA");

                            extractValues(CEMC16,CEMC16V,CEMC16B,CEMC16C,"Simple");
                            var max = (Math.max(...CEMC16V)+20);
                            customizedArray(CEMC16V,CEMC16VX,CEMC16label,colorPallet69,"Bar");
                            barChart(CEMC16VX,"cem2_c16",CEMC16label,max);

                            var baseX = processBase(CEMC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c16_base").empty().append(htmlB);

                            var span = $('#cem2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC17,CEMC17V,CEMC17B,CEMC17C,"Simple");
                            CEMC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`cem2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CEMC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c17_base").empty().append(htmlB);

                            var span = $('#cem2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC18,CEMC18V,CEMC18B,CEMC18C,"Simple");
                            var max = (Math.max(...CEMC18V)+20);
                            customizedArray(CEMC18V,CEMC18VX,CEMC18label,colorPallet69,"Bar");
                            barChart(CEMC18VX,"cem2_c18",CEMC18label,max);

                            var baseX = processBase(CEMC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c18_base").empty().append(htmlB);

                            var span = $('#cem2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC19,CEMC19V,CEMC19B,CEMC19C,"Simple");
                            var max = (Math.max(...CEMC19V)+20);
                            customizedArray(CEMC19V,CEMC19VX,CEMC19label,colorPallet69,"Bar");
                            barChart(CEMC19VX,"cem2_c19",CEMC19label,max);

                            var baseX = processBase(CEMC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c19_base").empty().append(htmlB);

                            var span = $('#cem2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(CEMC20,CEMC20V,CEMC20B,CEMC20C,"Simple");
                            CEMC20V.forEach(function(e,i,a){
                                $(`#cem2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CEMC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem2_c20_base").empty().append(htmlB);

                            var span = $('#cem2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_4, S13_4V, S13_4B, S13_4C, "Simple");
                            var max = (Math.max(...S13_4V)+20);
                            customizedArray(S13_4V,S13_4VX,S13label,colorPallet69,"Bar");
                            barChart(S13_4VX,"cem_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_4B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cem_2_s13_base").empty().append(htmlB);

                            var span = $('#cem_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            condensedFStatus2 = true;
                            ajaxFlag[1+21] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentyOnethAjax() {
                    $.ajax({
                        url: "api/ajax21.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'condensedcondX':condensedcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var CEMC0 = data['CEM_C0'];
                            var CEMC1 = data['CEM_C1'];
                            var CEMC5 = data['CEM_C5'];
                            var CEMC8 = data['CEM_C8'];
                            var CEMC9 = data['CEM_C9'];
                            var CEMC10 = data['CEM_C10'];
                            var CEMC11 = data['CEM_C11'];
                            var CEMC12 = data['CEM_C12'];
                            var CEMC15 = data['CEM_C15'];
                            var CEMC16 = data['CEM_C16'];
                            var CEMC17 = data['CEM_C17'];
                            var CEMC18 = data['CEM_C18'];
                            var CEMC19 = data['CEM_C19'];
                            var CEMC20 = data['CEM_C20'];

                            var S13_4 = data['S13_4'];

                            var CEMC0V = [];
                            var CEMC0B = [];
                            var CEMC0C = [];
                            var CEMC0VX = [];

                            var CEMC1V = [];
                            var CEMC1B = [];
                            var CEMC1C = [];
                            var CEMC1VX = [];

                            var CEMC5V = [];
                            var CEMC5B = [];
                            var CEMC5C = [];
                            var CEMC5VX = [];

                            var CEMC8V = [];
                            var CEMC8B = [];
                            var CEMC8C = [];
                            var CEMC8VX = [];

                            var CEMC9V = [];
                            var CEMC9B = [];
                            var CEMC9C = [];
                            var CEMC9VX = [];

                            var CEMC10V = [];
                            var CEMC10B = [];
                            var CEMC10C = [];
                            var CEMC10VX = [];

                            var CEMC11V = [];
                            var CEMC11B = [];
                            var CEMC11C = [];
                            var CEMC11VX = [];

                            var CEMC12V = [];
                            var CEMC12B = [];
                            var CEMC12C = [];
                            var CEMC12VX = [];

                            var CEMC13V = [];
                            var CEMC13B = [];
                            var CEMC13C = [];
                            var CEMC13VX = [];

                            var CEMC14V = [];
                            var CEMC14B = [];
                            var CEMC14C = [];
                            var CEMC14VX = [];

                            var CEMC15V = [];
                            var CEMC15B = [];
                            var CEMC15C = [];
                            var CEMC15VX = [];

                            var CEMC16V = [];
                            var CEMC16B = [];
                            var CEMC16C = [];
                            var CEMC16VX = [];

                            var CEMC17V = [];
                            var CEMC17B = [];
                            var CEMC17C = [];
                            var CEMC17VX = [];

                            var CEMC18V = [];
                            var CEMC18B = [];
                            var CEMC18C = [];
                            var CEMC18VX = [];

                            var CEMC19V = [];
                            var CEMC19B = [];
                            var CEMC19C = [];
                            var CEMC19VX = [];

                            var CEMC20V = [];
                            var CEMC20B = [];
                            var CEMC20C = [];
                            var CEMC20VX = [];

                            var S13_4V = [];
                            var S13_4B = [];
                            var S13_4C = [];
                            var S13_4VX = [];

                            if(condensedFStatus3==false)
                            {
                                extractValues(CEMC0,CEMC0V,CEMC0B,CEMC0C,"Simple");
                                CEMC0V.forEach(function(e,i,a){
                                    $(`#cem3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CEMC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#cem3_c0_base").empty().append(htmlB);

                                var span = $('#cem3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 

                            extractValues(CEMC1,CEMC1V,CEMC1B,CEMC1C,"Simple");
                            customizedArray(CEMC1V,CEMC1VX,CEMC1label,colorPallet68,"Doughnut");
                            doughnutChart2(CEMC1VX,"cem3_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(CEMC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c1_base").empty().append(htmlB);

                            var span = $('#cem3_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(CEMC5,CEMC5V,CEMC5B,CEMC5C,"Simple");
                            customizedArray(CEMC5V,CEMC5VX,CEMC5label,colorPallet68,"Doughnut");
                            doughnutChart2(CEMC5VX,"cem3_c5","Type of dairy milk you had","auto");

                            var baseX = processBase(CEMC5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c5_base").empty().append(htmlB);

                            var span = $('#cem3_c5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC8,CEMC8V,CEMC8B,CEMC8C,"Simple");
                            var max = (Math.max(...CEMC8V)+20);
                            customizedArray(CEMC8V,CEMC8VX,CEMC8label,colorPallet69,"Bar");
                            barChart(CEMC8VX,"cem3_c8",CEMC8label,max);

                            var baseX = processBase(CEMC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c8_base").empty().append(htmlB);

                            var span = $('#cem3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC8V,CEMC8label,"cem3_c8TA");

                            extractValues(CEMC9,CEMC9V,CEMC9B,CEMC9C,"Simple");
                            var max = (Math.max(...CEMC9V)+20);
                            customizedArray(CEMC9V,CEMC9VX,CEMC9label,colorPallet69,"Bar");
                            barChart(CEMC9VX,"cem3_c9",CEMC9label,max);

                            var baseX = processBase(CEMC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c9_base").empty().append(htmlB);

                            var span = $('#cem3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC9V,CEMC9label,"cem3_c9TA");

                            extractValues(CEMC10,CEMC10V,CEMC10B,CEMC10C,"Simple");
                            customizedArray(CEMC10V,CEMC10VX,CEMC10label,colorPallet68,"Doughnut");
                            pieChart(CEMC10VX,"cem3_c10","Way of consumption","auto");

                            var baseX = processBase(CEMC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c10_base").empty().append(htmlB);

                            var span = $('#cem3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC10V,CEMC10label,"cem3_c10TA");

                            extractValues(CEMC11,CEMC11V,CEMC11B,CEMC11C,"Simple");
                            var max = (Math.max(...CEMC11V)+20);
                            customizedArray(CEMC11V,CEMC11VX,CEMC11label,colorPallet69,"Bar");
                            columnChart(CEMC11VX,"cem3_c11",CEMC11label,max);

                            var baseX = processBase(CEMC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c11_base").empty().append(htmlB);

                            var span = $('#cem3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC11V,CEMC11label,"cem3_c11TA");

                            extractValues(CEMC12,CEMC12V,CEMC12B,CEMC12C,"Simple");
                            var max = (Math.max(...CEMC12V)+20);
                            customizedArray(CEMC12V,CEMC12VX,CEMC12label,colorPallet69,"Bar");
                            columnChart(CEMC12VX,"cem3_c12",CEMC12label,max);

                            var baseX = processBase(CEMC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c12_base").empty().append(htmlB);

                            var span = $('#cem3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC12V,CEMC12label,"cem3_c12TA");

                            extractValues(CEMC15,CEMC15V,CEMC15B,CEMC15C,"Simple");
                            CEMC15V.forEach(function(e,i,a){
                                $(`#cem3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CEMC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c15_base").empty().append(htmlB);

                            var span = $('#cem3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CEMC15V,CEMC15label,"cem3_c15TA");

                            extractValues(CEMC16,CEMC16V,CEMC16B,CEMC16C,"Simple");
                            var max = (Math.max(...CEMC16V)+20);
                            customizedArray(CEMC16V,CEMC16VX,CEMC16label,colorPallet69,"Bar");
                            barChart(CEMC16VX,"cem3_c16",CEMC16label,max);

                            var baseX = processBase(CEMC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c16_base").empty().append(htmlB);

                            var span = $('#cem3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC17,CEMC17V,CEMC17B,CEMC17C,"Simple");
                            CEMC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`cem3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CEMC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c17_base").empty().append(htmlB);

                            var span = $('#cem3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC18,CEMC18V,CEMC18B,CEMC18C,"Simple");
                            var max = (Math.max(...CEMC18V)+20);
                            customizedArray(CEMC18V,CEMC18VX,CEMC18label,colorPallet69,"Bar");
                            barChart(CEMC18VX,"cem3_c18",CEMC18label,max);

                            var baseX = processBase(CEMC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c18_base").empty().append(htmlB);

                            var span = $('#cem3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CEMC19,CEMC19V,CEMC19B,CEMC19C,"Simple");
                            var max = (Math.max(...CEMC19V)+20);
                            customizedArray(CEMC19V,CEMC19VX,CEMC19label,colorPallet69,"Bar");
                            barChart(CEMC19VX,"cem3_c19",CEMC19label,max);

                            var baseX = processBase(CEMC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c19_base").empty().append(htmlB);

                            var span = $('#cem3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(CEMC20,CEMC20V,CEMC20B,CEMC20C,"Simple");
                            CEMC20V.forEach(function(e,i,a){
                                $(`#cem3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CEMC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cem3_c20_base").empty().append(htmlB);

                            var span = $('#cem3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_4, S13_4V, S13_4B, S13_4C, "Simple");
                            var max = (Math.max(...S13_4V)+20);
                            customizedArray(S13_4V,S13_4VX,S13label,colorPallet69,"Bar");
                            barChart(S13_4VX,"cem_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_4B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cem_3_s13_base").empty().append(htmlB);

                            var span = $('#cem_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            condensedFStatus3 = true;
                            ajaxFlag[1+22] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentyTwothAjax() {
                    $.ajax({
                        url: "api/ajax22.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'protiencondX': protiencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);
                            var PDC0 = data['PD_C0'];
                            var PDC1 = data['PD_C1'];
                            var PDC1a = data['PD_C1a'];
                            var PDC2 = data['PD_C2'];
                            var PDC3 = data['PD_C3'];
                            var PDC5 = data['PD_C5'];
                            var PDC6 = data['PD_C6'];
                            var PDC7 = data['PD_C7'];
                            var PDC8 = data['PD_C8'];
                            var PDC9 = data['PD_C9'];
                            var PDC10 = data['PD_C10'];
                            var PDC11 = data['PD_C11'];
                            var PDC12 = data['PD_C12'];
                            var PDC15 = data['PD_C15'];
                            var PDC16 = data['PD_C16'];
                            var PDC17 = data['PD_C17'];
                            var PDC18 = data['PD_C18'];
                            var PDC19 = data['PD_C19'];
                            var PDC20 = data['PD_C20'];

                            var S13_8 = data['S13_8'];

                            var PDC0V = [];
                            var PDC0B = [];
                            var PDC0C = [];
                            var PDC0VX = [];

                            var PDC1V = [];
                            var PDC1B = [];
                            var PDC1C = [];
                            var PDC1VX = [];

                            var PDC1aV = [];
                            var PDC1aB = [];
                            var PDC1aC = [];
                            var PDC1aVX = [];

                            var PDC2V = [];
                            var PDC2B = [];
                            var PDC2C = [];
                            var PDC2VX = [];

                            var PDC3V = [];
                            var PDC3B = [];
                            var PDC3C = [];
                            var PDC3VX = [];

                            var PDC4V = [];
                            var PDC4B = [];
                            var PDC4C = [];
                            var PDC4VX = [];

                            var PDC5V = [];
                            var PDC5B = [];
                            var PDC5C = [];
                            var PDC5VX = [];

                            var PDC6V = [];
                            var PDC6B = [];
                            var PDC6C = [];
                            var PDC6VX = [];

                            var PDC7V = [];
                            var PDC7B = [];
                            var PDC7C = [];
                            var PDC7VX = [];

                            var PDC8V = [];
                            var PDC8B = [];
                            var PDC8C = [];
                            var PDC8VX = [];

                            var PDC9V = [];
                            var PDC9B = [];
                            var PDC9C = [];
                            var PDC9VX = [];

                            var PDC10V = [];
                            var PDC10B = [];
                            var PDC10C = [];
                            var PDC10VX = [];

                            var PDC11V = [];
                            var PDC11B = [];
                            var PDC11C = [];
                            var PDC11VX = [];

                            var PDC12V = [];
                            var PDC12B = [];
                            var PDC12C = [];
                            var PDC12VX = [];

                            var PDC13V = [];
                            var PDC13B = [];
                            var PDC13C = [];
                            var PDC13VX = [];

                            var PDC14V = [];
                            var PDC14B = [];
                            var PDC14C = [];
                            var PDC14VX = [];

                            var PDC15V = [];
                            var PDC15B = [];
                            var PDC15C = [];
                            var PDC15VX = [];

                            var PDC16V = [];
                            var PDC16B = [];
                            var PDC16C = [];
                            var PDC16VX = [];

                            var PDC17V = [];
                            var PDC17B = [];
                            var PDC17C = [];
                            var PDC17VX = [];

                            var PDC18V = [];
                            var PDC18B = [];
                            var PDC18C = [];
                            var PDC18VX = [];

                            var PDC19V = [];
                            var PDC19B = [];
                            var PDC19C = [];
                            var PDC19VX = [];

                            var PDC20V = [];
                            var PDC20B = [];
                            var PDC20C = [];
                            var PDC20VX = [];

                            var S13_8V = [];
                            var S13_8B = [];
                            var S13_8C = [];
                            var S13_8VX = [];

                            if(protienFStatus1==false)
                            {
                                extractValues(PDC0,PDC0V,PDC0B,PDC0C,"Simple");
                                //customizedArray(PDC0V,PDC0VX,PDC0label,colorPallet69,"Doughnut");
                                //doughnutChartF(PDC0VX,"pd1_c0","Food Service vs. Retail",280,"protienF");
                                PDC0V.forEach(function(e,i,a){
                                    $(`#pd1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(PDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#pd1_c0_base").empty().append(htmlB);

                                var span = $('#pd1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }
                            
                            extractValues(PDC1,PDC1V,PDC1B,PDC1C,"Simple");
                            customizedArray(PDC1V,PDC1VX,PDC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(PDC1VX,"pd1_c1","Category Consumed",290);

                            var baseX = processBase(PDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c1_base").empty().append(htmlB);

                            var span = $('#pd1_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC1a,PDC1aV,PDC1aB,PDC1aC,"Simple");
                            customizedArray(PDC1aV,PDC1aVX,PDC1alabel,colorPallet68,"Doughnut");
                            doughnutChart1_2(PDC1aVX,"pd1_c1a","Category Consumed",247);

                            var baseX = processBase(PDC1aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c1a_base").empty().append(htmlB);

                            var span = $('#pd1_c1a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC2,PDC2V,PDC2B,PDC2C,"Simple");
                            customizedArray(PDC2V,PDC2VX,PDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(PDC2VX,"pd1_c2","Type of protein","auto");

                            var baseX = processBase(PDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c2_base").empty().append(htmlB);

                            var span = $('#pd1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC5,PDC5V,PDC5B,PDC5C,"Simple");
                            customizedArray(PDC5V,PDC5VX,PDC5label,colorPallet68,"Doughnut");
                            doughnutChart1_3(PDC5VX,"pd1_c5","Category Consumed",300);

                            var baseX = processBase(PDC5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c5_base").empty().append(htmlB);

                            var span = $('#pd1_c5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC3,PDC3V,PDC3B,PDC3C,"Simple");
                            var max = (Math.max(...PDC3V)+20);
                            customizedArray(PDC3V,PDC3VX,PDC3label,colorPallet69,"Bar");
                            barChart(PDC3VX,"pd1_c3",PDC3label,max);

                            var baseX = processBase(PDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c3_base").empty().append(htmlB);

                            var span = $('#pd1_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC6,PDC6V,PDC6B,PDC6C,"Simple");
                            customizedArray(PDC6V,PDC6VX,PDC6label,colorPallet69,"Doughnut");
                            pieChart(PDC6VX,"pd1_c6","Type of Packaging","auto");

                            var baseX = processBase(PDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c6_base").empty().append(htmlB);

                            var span = $('#pd1_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC7,PDC7V,PDC7B,PDC7C,"Simple");
                            customizedArray(PDC7V,PDC7VX,PDC7label,colorPallet68,"Doughnut");
                            pieChart(PDC7VX,"pd1_c7","Type of Packaging","auto");

                            var baseX = processBase(PDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c7_base").empty().append(htmlB);

                            var span = $('#pd1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC8,PDC8V,PDC8B,PDC8C,"Simple");
                            var max = (Math.max(...PDC8V)+20);
                            customizedArray(PDC8V,PDC8VX,PDC8label,colorPallet69,"Bar");
                            barChart(PDC8VX,"pd1_c8",PDC8label,max);

                            var baseX = processBase(PDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c8_base").empty().append(htmlB);

                            var span = $('#pd1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC9,PDC9V,PDC9B,PDC9C,"Simple");
                            var max = (Math.max(...PDC9V)+20);
                            customizedArray(PDC9V,PDC9VX,PDC9label,colorPallet69,"Bar");
                            barChart(PDC9VX,"pd1_c9",PDC9label,max);

                            var baseX = processBase(PDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c9_base").empty().append(htmlB);

                            var span = $('#pd1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC10,PDC10V,PDC10B,PDC10C,"Simple");
                            customizedArray(PDC10V,PDC10VX,PDC10label,colorPallet68,"Doughnut");
                            pieChart(PDC10VX,"pd1_c10","Way of consumption","auto");

                            var baseX = processBase(PDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c10_base").empty().append(htmlB);

                            var span = $('#pd1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC11,PDC11V,PDC11B,PDC11C,"Simple");
                            var max = (Math.max(...PDC11V)+20);
                            customizedArray(PDC11V,PDC11VX,PDC11label,colorPallet69,"Bar");
                            columnChart(PDC11VX,"pd1_c11",PDC11label,max);

                            var baseX = processBase(PDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c11_base").empty().append(htmlB);

                            var span = $('#pd1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC16,PDC16V,PDC16B,PDC16C,"Simple");
                            var max = (Math.max(...PDC16V)+20);
                            customizedArray(PDC16V,PDC16VX,PDC16label,colorPallet69,"Bar");
                            barChart(PDC16VX,"pd1_c16",PDC16label,max);

                            var baseX = processBase(PDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c16_base").empty().append(htmlB);

                            var span = $('#pd1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC12,PDC12V,PDC12B,PDC12C,"Simple");
                            var max = (Math.max(...PDC12V)+20);
                            customizedArray(PDC12V,PDC12VX,PDC12label,colorPallet69,"Bar");
                            columnChart(PDC12VX,"pd1_c12",PDC12label,max);

                            var baseX = processBase(PDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c12_base").empty().append(htmlB);

                            var span = $('#pd1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC15,PDC15V,PDC15B,PDC15C,"Simple");
                            PDC15V.forEach(function(e,i,a){
                                $(`#pd1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(PDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c15_base").empty().append(htmlB);

                            var span = $('#pd1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC20,PDC20V,PDC20B,PDC20C,"Simple");
                            PDC20V.forEach(function(e,i,a){
                                $(`#pd1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(PDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c20_base").empty().append(htmlB);

                            var span = $('#pd1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC17,PDC17V,PDC17B,PDC17C,"Simple");
                            PDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`pd1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(PDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c17_base").empty().append(htmlB);

                            var span = $('#pd1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC18,PDC18V,PDC18B,PDC18C,"Simple");
                            var max = (Math.max(...PDC18V)+20);
                            customizedArray(PDC18V,PDC18VX,PDC18label,colorPallet69,"Bar");
                            barChart(PDC18VX,"pd1_c18",PDC18label,max);

                            var baseX = processBase(PDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c18_base").empty().append(htmlB);

                            var span = $('#pd1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC19,PDC19V,PDC19B,PDC19C,"Simple");
                            var max = (Math.max(...PDC19V)+20);
                            customizedArray(PDC19V,PDC19VX,PDC19label,colorPallet69,"Bar");
                            barChart(PDC19VX,"pd1_c19",PDC19label,max);

                            var baseX = processBase(PDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd1_c19_base").empty().append(htmlB);

                            var span = $('#pd1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_8, S13_8V, S13_8B, S13_8C, "Simple");
                            var max = (Math.max(...S13_8V)+20);
                            customizedArray(S13_8V,S13_8VX,S13label,colorPallet69,"Bar");
                            barChart(S13_8VX,"pd_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_8B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd_1_s13_base").empty().append(htmlB);

                            var span = $('#pd_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            protienFStatus1 = true;
                            ajaxFlag[1+23] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentyThreethAjax() {
                    $.ajax({
                        url: "api/ajax23.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'protiencondX': protiencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);
                            var PDC0 = data['PD_C0'];
                            var PDC1 = data['PD_C1'];
                            var PDC1a = data['PD_C1a'];
                            var PDC2 = data['PD_C2'];
                            var PDC3 = data['PD_C3'];
                            var PDC5 = data['PD_C5'];
                            var PDC6 = data['PD_C6'];
                            var PDC7 = data['PD_C7'];
                            var PDC8 = data['PD_C8'];
                            var PDC9 = data['PD_C9'];
                            var PDC10 = data['PD_C10'];
                            var PDC11 = data['PD_C11'];
                            var PDC12 = data['PD_C12'];
                            var PDC15 = data['PD_C15'];
                            var PDC16 = data['PD_C16'];
                            var PDC17 = data['PD_C17'];
                            var PDC18 = data['PD_C18'];
                            var PDC19 = data['PD_C19'];
                            var PDC20 = data['PD_C20'];

                            var S13_8 = data['S13_8'];

                            var PDC0V = [];
                            var PDC0B = [];
                            var PDC0C = [];
                            var PDC0VX = [];

                            var PDC1V = [];
                            var PDC1B = [];
                            var PDC1C = [];
                            var PDC1VX = [];

                            var PDC1aV = [];
                            var PDC1aB = [];
                            var PDC1aC = [];
                            var PDC1aVX = [];

                            var PDC2V = [];
                            var PDC2B = [];
                            var PDC2C = [];
                            var PDC2VX = [];

                            var PDC3V = [];
                            var PDC3B = [];
                            var PDC3C = [];
                            var PDC3VX = [];

                            var PDC4V = [];
                            var PDC4B = [];
                            var PDC4C = [];
                            var PDC4VX = [];

                            var PDC5V = [];
                            var PDC5B = [];
                            var PDC5C = [];
                            var PDC5VX = [];

                            var PDC6V = [];
                            var PDC6B = [];
                            var PDC6C = [];
                            var PDC6VX = [];

                            var PDC7V = [];
                            var PDC7B = [];
                            var PDC7C = [];
                            var PDC7VX = [];

                            var PDC8V = [];
                            var PDC8B = [];
                            var PDC8C = [];
                            var PDC8VX = [];

                            var PDC9V = [];
                            var PDC9B = [];
                            var PDC9C = [];
                            var PDC9VX = [];

                            var PDC10V = [];
                            var PDC10B = [];
                            var PDC10C = [];
                            var PDC10VX = [];

                            var PDC11V = [];
                            var PDC11B = [];
                            var PDC11C = [];
                            var PDC11VX = [];

                            var PDC12V = [];
                            var PDC12B = [];
                            var PDC12C = [];
                            var PDC12VX = [];

                            var PDC13V = [];
                            var PDC13B = [];
                            var PDC13C = [];
                            var PDC13VX = [];

                            var PDC14V = [];
                            var PDC14B = [];
                            var PDC14C = [];
                            var PDC14VX = [];

                            var PDC15V = [];
                            var PDC15B = [];
                            var PDC15C = [];
                            var PDC15VX = [];

                            var PDC16V = [];
                            var PDC16B = [];
                            var PDC16C = [];
                            var PDC16VX = [];

                            var PDC17V = [];
                            var PDC17B = [];
                            var PDC17C = [];
                            var PDC17VX = [];

                            var PDC18V = [];
                            var PDC18B = [];
                            var PDC18C = [];
                            var PDC18VX = [];

                            var PDC19V = [];
                            var PDC19B = [];
                            var PDC19C = [];
                            var PDC19VX = [];

                            var PDC20V = [];
                            var PDC20B = [];
                            var PDC20C = [];
                            var PDC20VX = [];

                            var S13_8V = [];
                            var S13_8B = [];
                            var S13_8C = [];
                            var S13_8VX = [];

                            if(protienFStatus2==false)
                            {
                                extractValues(PDC0,PDC0V,PDC0B,PDC0C,"Simple");
                                //customizedArray(PDC0V,PDC0VX,PDC0label,colorPallet69,"Doughnut");
                                //doughnutChartF(PDC0VX,"pd2_c0","Food Service vs. Retail",300,"protienF");
                                PDC0V.forEach(function(e,i,a){
                                    $(`#pd2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(PDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#pd2_c0_base").empty().append(htmlB);

                                var span = $('#pd2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }
                            
                            extractValues(PDC1,PDC1V,PDC1B,PDC1C,"Simple");
                            customizedArray(PDC1V,PDC1VX,PDC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(PDC1VX,"pd2_c1","Category Consumed",285);

                            var baseX = processBase(PDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c1_base").empty().append(htmlB);

                            var span = $('#pd2_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC1a,PDC1aV,PDC1aB,PDC1aC,"Simple");
                            customizedArray(PDC1aV,PDC1aVX,PDC1alabel,colorPallet68,"Doughnut");
                            doughnutChart1_2(PDC1aVX,"pd2_c1a","Category Consumed",265);

                            var baseX = processBase(PDC1aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c1a_base").empty().append(htmlB);

                            var span = $('#pd2_c1a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC2,PDC2V,PDC2B,PDC2C,"Simple");
                            customizedArray(PDC2V,PDC2VX,PDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(PDC2VX,"pd2_c2","Type of protein","auto");

                            var baseX = processBase(PDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c2_base").empty().append(htmlB);

                            var span = $('#pd2_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC5,PDC5V,PDC5B,PDC5C,"Simple");
                            customizedArray(PDC5V,PDC5VX,PDC5label,colorPallet68,"Doughnut");
                            doughnutChart1_3(PDC5VX,"pd2_c5","Category Consumed",300);

                            var baseX = processBase(PDC5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c5_base").empty().append(htmlB);

                            var span = $('#pd2_c5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC3,PDC3V,PDC3B,PDC3C,"Simple");
                            var max = (Math.max(...PDC3V)+20);
                            customizedArray(PDC3V,PDC3VX,PDC3label,colorPallet69,"Bar");
                            barChart(PDC3VX,"pd2_c3",PDC3label,max);

                            var baseX = processBase(PDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c3_base").empty().append(htmlB);

                            var span = $('#pd2_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC6,PDC6V,PDC6B,PDC6C,"Simple");
                            customizedArray(PDC6V,PDC6VX,PDC6label,colorPallet69,"Doughnut");
                            pieChart(PDC6VX,"pd2_c6","Type of Packaging","auto");

                            var baseX = processBase(PDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c6_base").empty().append(htmlB);

                            var span = $('#pd2_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC7,PDC7V,PDC7B,PDC7C,"Simple");
                            customizedArray(PDC7V,PDC7VX,PDC7label,colorPallet68,"Doughnut");
                            pieChart(PDC7VX,"pd2_c7","Type of Packaging","auto");

                            var baseX = processBase(PDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c7_base").empty().append(htmlB);

                            var span = $('#pd2_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC8,PDC8V,PDC8B,PDC8C,"Simple");
                            var max = (Math.max(...PDC8V)+20);
                            customizedArray(PDC8V,PDC8VX,PDC8label,colorPallet69,"Bar");
                            barChart(PDC8VX,"pd2_c8",PDC8label,max);

                            var baseX = processBase(PDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c8_base").empty().append(htmlB);

                            var span = $('#pd2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC9,PDC9V,PDC9B,PDC9C,"Simple");
                            var max = (Math.max(...PDC9V)+20);
                            customizedArray(PDC9V,PDC9VX,PDC9label,colorPallet69,"Bar");
                            barChart(PDC9VX,"pd2_c9",PDC9label,max);

                            var baseX = processBase(PDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c9_base").empty().append(htmlB);

                            var span = $('#pd2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC10,PDC10V,PDC10B,PDC10C,"Simple");
                            customizedArray(PDC10V,PDC10VX,PDC10label,colorPallet68,"Doughnut");
                            pieChart(PDC10VX,"pd2_c10","Way of consumption","auto");

                            var baseX = processBase(PDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c10_base").empty().append(htmlB);

                            var span = $('#pd2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC11,PDC11V,PDC11B,PDC11C,"Simple");
                            var max = (Math.max(...PDC11V)+20);
                            customizedArray(PDC11V,PDC11VX,PDC11label,colorPallet69,"Bar");
                            columnChart(PDC11VX,"pd2_c11",PDC11label,max);

                            var baseX = processBase(PDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c11_base").empty().append(htmlB);

                            var span = $('#pd2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC16,PDC16V,PDC16B,PDC16C,"Simple");
                            var max = (Math.max(...PDC16V)+20);
                            customizedArray(PDC16V,PDC16VX,PDC16label,colorPallet69,"Bar");
                            barChart(PDC16VX,"pd2_c16",PDC16label,max);

                            var baseX = processBase(PDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c16_base").empty().append(htmlB);

                            var span = $('#pd2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC12,PDC12V,PDC12B,PDC12C,"Simple");
                            var max = (Math.max(...PDC12V)+20);
                            customizedArray(PDC12V,PDC12VX,PDC12label,colorPallet69,"Bar");
                            columnChart(PDC12VX,"pd2_c12",PDC12label,max);

                            var baseX = processBase(PDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c12_base").empty().append(htmlB);

                            var span = $('#pd2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC15,PDC15V,PDC15B,PDC15C,"Simple");
                            PDC15V.forEach(function(e,i,a){
                                $(`#pd2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(PDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c15_base").empty().append(htmlB);

                            var span = $('#pd2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC20,PDC20V,PDC20B,PDC20C,"Simple");
                            PDC20V.forEach(function(e,i,a){
                                $(`#pd2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(PDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c20_base").empty().append(htmlB);

                            var span = $('#pd2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC17,PDC17V,PDC17B,PDC17C,"Simple");
                            PDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`pd2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(PDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c17_base").empty().append(htmlB);

                            var span = $('#pd2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC18,PDC18V,PDC18B,PDC18C,"Simple");
                            var max = (Math.max(...PDC18V)+20);
                            customizedArray(PDC18V,PDC18VX,PDC18label,colorPallet69,"Bar");
                            barChart(PDC18VX,"pd2_c18",PDC18label,max);

                            var baseX = processBase(PDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c18_base").empty().append(htmlB);

                            var span = $('#pd2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC19,PDC19V,PDC19B,PDC19C,"Simple");
                            var max = (Math.max(...PDC19V)+20);
                            customizedArray(PDC19V,PDC19VX,PDC19label,colorPallet69,"Bar");
                            barChart(PDC19VX,"pd2_c19",PDC19label,max);

                            var baseX = processBase(PDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd2_c19_base").empty().append(htmlB);

                            var span = $('#pd2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_8, S13_8V, S13_8B, S13_8C, "Simple");
                            var max = (Math.max(...S13_8V)+20);
                            customizedArray(S13_8V,S13_8VX,S13label,colorPallet69,"Bar");
                            barChart(S13_8VX,"pd_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_8B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd_2_s13_base").empty().append(htmlB);

                            var span = $('#pd_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            protienFStatus2 = true;
                            ajaxFlag[1+24] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentyFourthAjax() {
                    $.ajax({
                        url: "api/ajax24.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'protiencondX': protiencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);
                            var PDC0 = data['PD_C0'];
                            var PDC1 = data['PD_C1'];
                            var PDC1a = data['PD_C1a'];
                            var PDC2 = data['PD_C2'];
                            var PDC3 = data['PD_C3'];
                            var PDC5 = data['PD_C5'];
                            var PDC6 = data['PD_C6'];
                            var PDC7 = data['PD_C7'];
                            var PDC8 = data['PD_C8'];
                            var PDC9 = data['PD_C9'];
                            var PDC10 = data['PD_C10'];
                            var PDC11 = data['PD_C11'];
                            var PDC12 = data['PD_C12'];
                            var PDC15 = data['PD_C15'];
                            var PDC16 = data['PD_C16'];
                            var PDC17 = data['PD_C17'];
                            var PDC18 = data['PD_C18'];
                            var PDC19 = data['PD_C19'];
                            var PDC20 = data['PD_C20'];

                            var S13_8 = data['S13_8'];

                            var PDC0V = [];
                            var PDC0B = [];
                            var PDC0C = [];
                            var PDC0VX = [];

                            var PDC1V = [];
                            var PDC1B = [];
                            var PDC1C = [];
                            var PDC1VX = [];

                            var PDC1aV = [];
                            var PDC1aB = [];
                            var PDC1aC = [];
                            var PDC1aVX = [];

                            var PDC2V = [];
                            var PDC2B = [];
                            var PDC2C = [];
                            var PDC2VX = [];

                            var PDC3V = [];
                            var PDC3B = [];
                            var PDC3C = [];
                            var PDC3VX = [];

                            var PDC4V = [];
                            var PDC4B = [];
                            var PDC4C = [];
                            var PDC4VX = [];

                            var PDC5V = [];
                            var PDC5B = [];
                            var PDC5C = [];
                            var PDC5VX = [];

                            var PDC6V = [];
                            var PDC6B = [];
                            var PDC6C = [];
                            var PDC6VX = [];

                            var PDC7V = [];
                            var PDC7B = [];
                            var PDC7C = [];
                            var PDC7VX = [];

                            var PDC8V = [];
                            var PDC8B = [];
                            var PDC8C = [];
                            var PDC8VX = [];

                            var PDC9V = [];
                            var PDC9B = [];
                            var PDC9C = [];
                            var PDC9VX = [];

                            var PDC10V = [];
                            var PDC10B = [];
                            var PDC10C = [];
                            var PDC10VX = [];

                            var PDC11V = [];
                            var PDC11B = [];
                            var PDC11C = [];
                            var PDC11VX = [];

                            var PDC12V = [];
                            var PDC12B = [];
                            var PDC12C = [];
                            var PDC12VX = [];

                            var PDC13V = [];
                            var PDC13B = [];
                            var PDC13C = [];
                            var PDC13VX = [];

                            var PDC14V = [];
                            var PDC14B = [];
                            var PDC14C = [];
                            var PDC14VX = [];

                            var PDC15V = [];
                            var PDC15B = [];
                            var PDC15C = [];
                            var PDC15VX = [];

                            var PDC16V = [];
                            var PDC16B = [];
                            var PDC16C = [];
                            var PDC16VX = [];

                            var PDC17V = [];
                            var PDC17B = [];
                            var PDC17C = [];
                            var PDC17VX = [];

                            var PDC18V = [];
                            var PDC18B = [];
                            var PDC18C = [];
                            var PDC18VX = [];

                            var PDC19V = [];
                            var PDC19B = [];
                            var PDC19C = [];
                            var PDC19VX = [];

                            var PDC20V = [];
                            var PDC20B = [];
                            var PDC20C = [];
                            var PDC20VX = [];

                            var S13_8V = [];
                            var S13_8B = [];
                            var S13_8C = [];
                            var S13_8VX = [];

                            if(protienFStatus3==false)
                            {
                                extractValues(PDC0,PDC0V,PDC0B,PDC0C,"Simple");
                                //customizedArray(PDC0V,PDC0VX,PDC0label,colorPallet69,"Doughnut");
                                //doughnutChartF(PDC0VX,"pd3_c0","Food Service vs. Retail",300,"protienF");
                                PDC0V.forEach(function(e,i,a){
                                    $(`#pd3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(PDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#pd3_c0_base").empty().append(htmlB);

                                var span = $('#pd3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }
                            
                            extractValues(PDC1,PDC1V,PDC1B,PDC1C,"Simple");
                            customizedArray(PDC1V,PDC1VX,PDC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(PDC1VX,"pd3_c1","Category Consumed",285);

                            var baseX = processBase(PDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c1_base").empty().append(htmlB);

                            var span = $('#pd3_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC1a,PDC1aV,PDC1aB,PDC1aC,"Simple");
                            customizedArray(PDC1aV,PDC1aVX,PDC1alabel,colorPallet68,"Doughnut");
                            doughnutChart1_2(PDC1aVX,"pd3_c1a","Category Consumed",265);

                            var baseX = processBase(PDC1aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c1a_base").empty().append(htmlB);

                            var span = $('#pd3_c1a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC2,PDC2V,PDC2B,PDC2C,"Simple");
                            customizedArray(PDC2V,PDC2VX,PDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(PDC2VX,"pd3_c2","Type of protein","auto");

                            var baseX = processBase(PDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c2_base").empty().append(htmlB);

                            var span = $('#pd3_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC5,PDC5V,PDC5B,PDC5C,"Simple");
                            customizedArray(PDC5V,PDC5VX,PDC5label,colorPallet68,"Doughnut");
                            doughnutChart1_3(PDC5VX,"pd3_c5","Category Consumed",300);

                            var baseX = processBase(PDC5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c5_base").empty().append(htmlB);

                            var span = $('#pd3_c5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC3,PDC3V,PDC3B,PDC3C,"Simple");
                            var max = (Math.max(...PDC3V)+20);
                            customizedArray(PDC3V,PDC3VX,PDC3label,colorPallet69,"Bar");
                            barChart(PDC3VX,"pd3_c3",PDC3label,max);

                            var baseX = processBase(PDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c3_base").empty().append(htmlB);

                            var span = $('#pd3_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC6,PDC6V,PDC6B,PDC6C,"Simple");
                            customizedArray(PDC6V,PDC6VX,PDC6label,colorPallet69,"Doughnut");
                            pieChart(PDC6VX,"pd3_c6","Type of Packaging","auto");

                            var baseX = processBase(PDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c6_base").empty().append(htmlB);

                            var span = $('#pd3_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC7,PDC7V,PDC7B,PDC7C,"Simple");
                            customizedArray(PDC7V,PDC7VX,PDC7label,colorPallet68,"Doughnut");
                            pieChart(PDC7VX,"pd3_c7","Type of Packaging","auto");

                            var baseX = processBase(PDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c7_base").empty().append(htmlB);

                            var span = $('#pd3_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC8,PDC8V,PDC8B,PDC8C,"Simple");
                            var max = (Math.max(...PDC8V)+20);
                            customizedArray(PDC8V,PDC8VX,PDC8label,colorPallet69,"Bar");
                            barChart(PDC8VX,"pd3_c8",PDC8label,max);

                            var baseX = processBase(PDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c8_base").empty().append(htmlB);

                            var span = $('#pd3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC9,PDC9V,PDC9B,PDC9C,"Simple");
                            var max = (Math.max(...PDC9V)+20);
                            customizedArray(PDC9V,PDC9VX,PDC9label,colorPallet69,"Bar");
                            barChart(PDC9VX,"pd3_c9",PDC9label,max);

                            var baseX = processBase(PDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c9_base").empty().append(htmlB);

                            var span = $('#pd3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC10,PDC10V,PDC10B,PDC10C,"Simple");
                            customizedArray(PDC10V,PDC10VX,PDC10label,colorPallet68,"Doughnut");
                            pieChart(PDC10VX,"pd3_c10","Way of consumption","auto");

                            var baseX = processBase(PDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c10_base").empty().append(htmlB);

                            var span = $('#pd3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC11,PDC11V,PDC11B,PDC11C,"Simple");
                            var max = (Math.max(...PDC11V)+20);
                            customizedArray(PDC11V,PDC11VX,PDC11label,colorPallet69,"Bar");
                            columnChart(PDC11VX,"pd3_c11",PDC11label,max);

                            var baseX = processBase(PDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c11_base").empty().append(htmlB);

                            var span = $('#pd3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC16,PDC16V,PDC16B,PDC16C,"Simple");
                            var max = (Math.max(...PDC16V)+20);
                            customizedArray(PDC16V,PDC16VX,PDC16label,colorPallet69,"Bar");
                            barChart(PDC16VX,"pd3_c16",PDC16label,max);

                            var baseX = processBase(PDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c16_base").empty().append(htmlB);

                            var span = $('#pd3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC12,PDC12V,PDC12B,PDC12C,"Simple");
                            var max = (Math.max(...PDC12V)+20);
                            customizedArray(PDC12V,PDC12VX,PDC12label,colorPallet69,"Bar");
                            columnChart(PDC12VX,"pd3_c12",PDC12label,max);

                            var baseX = processBase(PDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c12_base").empty().append(htmlB);

                            var span = $('#pd3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC15,PDC15V,PDC15B,PDC15C,"Simple");
                            PDC15V.forEach(function(e,i,a){
                                $(`#pd3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(PDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c15_base").empty().append(htmlB);

                            var span = $('#pd3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC20,PDC20V,PDC20B,PDC20C,"Simple");
                            PDC20V.forEach(function(e,i,a){
                                $(`#pd3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(PDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c20_base").empty().append(htmlB);

                            var span = $('#pd3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC17,PDC17V,PDC17B,PDC17C,"Simple");
                            PDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`pd3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(PDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c17_base").empty().append(htmlB);

                            var span = $('#pd3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC18,PDC18V,PDC18B,PDC18C,"Simple");
                            var max = (Math.max(...PDC18V)+20);
                            customizedArray(PDC18V,PDC18VX,PDC18label,colorPallet69,"Bar");
                            barChart(PDC18VX,"pd3_c18",PDC18label,max);

                            var baseX = processBase(PDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c18_base").empty().append(htmlB);

                            var span = $('#pd3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC19,PDC19V,PDC19B,PDC19C,"Simple");
                            var max = (Math.max(...PDC19V)+20);
                            customizedArray(PDC19V,PDC19VX,PDC19label,colorPallet69,"Bar");
                            barChart(PDC19VX,"pd3_c19",PDC19label,max);

                            var baseX = processBase(PDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd3_c19_base").empty().append(htmlB);

                            var span = $('#pd3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_8, S13_8V, S13_8B, S13_8C, "Simple");
                            var max = (Math.max(...S13_8V)+20);
                            customizedArray(S13_8V,S13_8VX,S13label,colorPallet69,"Bar");
                            barChart(S13_8VX,"pd_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_8B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd_3_s13_base").empty().append(htmlB);

                            var span = $('#pd_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            protienFStatus3 = true;
                            ajaxFlag[1+25] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentyFivethAjax() {
                    $.ajax({
                        url: "api/ajax25.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'protiencondX': protiencondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);
                            var PDC0 = data['PD_C0'];
                            var PDC1 = data['PD_C1'];
                            var PDC1a = data['PD_C1a'];
                            var PDC2 = data['PD_C2'];
                            var PDC3 = data['PD_C3'];
                            var PDC5 = data['PD_C5'];
                            var PDC6 = data['PD_C6'];
                            var PDC7 = data['PD_C7'];
                            var PDC8 = data['PD_C8'];
                            var PDC9 = data['PD_C9'];
                            var PDC10 = data['PD_C10'];
                            var PDC11 = data['PD_C11'];
                            var PDC12 = data['PD_C12'];
                            var PDC15 = data['PD_C15'];
                            var PDC16 = data['PD_C16'];
                            var PDC17 = data['PD_C17'];
                            var PDC18 = data['PD_C18'];
                            var PDC19 = data['PD_C19'];
                            var PDC20 = data['PD_C20'];

                            var S13_8 = data['S13_8'];

                            var PDC0V = [];
                            var PDC0B = [];
                            var PDC0C = [];
                            var PDC0VX = [];

                            var PDC1V = [];
                            var PDC1B = [];
                            var PDC1C = [];
                            var PDC1VX = [];

                            var PDC1aV = [];
                            var PDC1aB = [];
                            var PDC1aC = [];
                            var PDC1aVX = [];

                            var PDC2V = [];
                            var PDC2B = [];
                            var PDC2C = [];
                            var PDC2VX = [];

                            var PDC3V = [];
                            var PDC3B = [];
                            var PDC3C = [];
                            var PDC3VX = [];

                            var PDC4V = [];
                            var PDC4B = [];
                            var PDC4C = [];
                            var PDC4VX = [];

                            var PDC5V = [];
                            var PDC5B = [];
                            var PDC5C = [];
                            var PDC5VX = [];

                            var PDC6V = [];
                            var PDC6B = [];
                            var PDC6C = [];
                            var PDC6VX = [];

                            var PDC7V = [];
                            var PDC7B = [];
                            var PDC7C = [];
                            var PDC7VX = [];

                            var PDC8V = [];
                            var PDC8B = [];
                            var PDC8C = [];
                            var PDC8VX = [];

                            var PDC9V = [];
                            var PDC9B = [];
                            var PDC9C = [];
                            var PDC9VX = [];

                            var PDC10V = [];
                            var PDC10B = [];
                            var PDC10C = [];
                            var PDC10VX = [];

                            var PDC11V = [];
                            var PDC11B = [];
                            var PDC11C = [];
                            var PDC11VX = [];

                            var PDC12V = [];
                            var PDC12B = [];
                            var PDC12C = [];
                            var PDC12VX = [];

                            var PDC13V = [];
                            var PDC13B = [];
                            var PDC13C = [];
                            var PDC13VX = [];

                            var PDC14V = [];
                            var PDC14B = [];
                            var PDC14C = [];
                            var PDC14VX = [];

                            var PDC15V = [];
                            var PDC15B = [];
                            var PDC15C = [];
                            var PDC15VX = [];

                            var PDC16V = [];
                            var PDC16B = [];
                            var PDC16C = [];
                            var PDC16VX = [];

                            var PDC17V = [];
                            var PDC17B = [];
                            var PDC17C = [];
                            var PDC17VX = [];

                            var PDC18V = [];
                            var PDC18B = [];
                            var PDC18C = [];
                            var PDC18VX = [];

                            var PDC19V = [];
                            var PDC19B = [];
                            var PDC19C = [];
                            var PDC19VX = [];

                            var PDC20V = [];
                            var PDC20B = [];
                            var PDC20C = [];
                            var PDC20VX = [];

                            var S13_8V = [];
                            var S13_8B = [];
                            var S13_8C = [];
                            var S13_8VX = [];

                            if(protienFStatus4==false)
                            {
                                extractValues(PDC0,PDC0V,PDC0B,PDC0C,"Simple");
                                //customizedArray(PDC0V,PDC0VX,PDC0label,colorPallet69,"Doughnut");
                                //doughnutChartF(PDC0VX,"pd4_c0","Food Service vs. Retail",300,"protienF");
                                PDC0V.forEach(function(e,i,a){
                                    $(`#pd4_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(PDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#pd4_c0_base").empty().append(htmlB);

                                var span = $('#pd4_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }
                            
                            extractValues(PDC1,PDC1V,PDC1B,PDC1C,"Simple");
                            customizedArray(PDC1V,PDC1VX,PDC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(PDC1VX,"pd4_c1","Category Consumed",285);

                            var baseX = processBase(PDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c1_base").empty().append(htmlB);

                            var span = $('#pd4_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC1a,PDC1aV,PDC1aB,PDC1aC,"Simple");
                            customizedArray(PDC1aV,PDC1aVX,PDC1alabel,colorPallet68,"Doughnut");
                            doughnutChart1_2(PDC1aVX,"pd4_c1a","Category Consumed",265);

                            var baseX = processBase(PDC1aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c1a_base").empty().append(htmlB);

                            var span = $('#pd4_c1a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC2,PDC2V,PDC2B,PDC2C,"Simple");
                            customizedArray(PDC2V,PDC2VX,PDC2label,colorPallet68,"Doughnut");
                            doughnutChart2(PDC2VX,"pd4_c2","Type of protein","auto");

                            var baseX = processBase(PDC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c2_base").empty().append(htmlB);

                            var span = $('#pd4_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC5,PDC5V,PDC5B,PDC5C,"Simple");
                            customizedArray(PDC5V,PDC5VX,PDC5label,colorPallet68,"Doughnut");
                            doughnutChart1_3(PDC5VX,"pd4_c5","Category Consumed",300);

                            var baseX = processBase(PDC5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c5_base").empty().append(htmlB);

                            var span = $('#pd4_c5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC3,PDC3V,PDC3B,PDC3C,"Simple");
                            var max = (Math.max(...PDC3V)+20);
                            customizedArray(PDC3V,PDC3VX,PDC3label,colorPallet69,"Bar");
                            barChart(PDC3VX,"pd4_c3",PDC3label,max);

                            var baseX = processBase(PDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c3_base").empty().append(htmlB);

                            var span = $('#pd4_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC6,PDC6V,PDC6B,PDC6C,"Simple");
                            customizedArray(PDC6V,PDC6VX,PDC6label,colorPallet69,"Doughnut");
                            pieChart(PDC6VX,"pd4_c6","Type of Packaging","auto");

                            var baseX = processBase(PDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c6_base").empty().append(htmlB);

                            var span = $('#pd4_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC7,PDC7V,PDC7B,PDC7C,"Simple");
                            customizedArray(PDC7V,PDC7VX,PDC7label,colorPallet68,"Doughnut");
                            pieChart(PDC7VX,"pd4_c7","Type of Packaging","auto");

                            var baseX = processBase(PDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c7_base").empty().append(htmlB);

                            var span = $('#pd4_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC8,PDC8V,PDC8B,PDC8C,"Simple");
                            var max = (Math.max(...PDC8V)+20);
                            customizedArray(PDC8V,PDC8VX,PDC8label,colorPallet69,"Bar");
                            barChart(PDC8VX,"pd4_c8",PDC8label,max);

                            var baseX = processBase(PDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c8_base").empty().append(htmlB);

                            var span = $('#pd4_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC9,PDC9V,PDC9B,PDC9C,"Simple");
                            var max = (Math.max(...PDC9V)+20);
                            customizedArray(PDC9V,PDC9VX,PDC9label,colorPallet69,"Bar");
                            barChart(PDC9VX,"pd4_c9",PDC9label,max);

                            var baseX = processBase(PDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c9_base").empty().append(htmlB);

                            var span = $('#pd4_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC10,PDC10V,PDC10B,PDC10C,"Simple");
                            customizedArray(PDC10V,PDC10VX,PDC10label,colorPallet68,"Doughnut");
                            pieChart(PDC10VX,"pd4_c10","Way of consumption","auto");

                            var baseX = processBase(PDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c10_base").empty().append(htmlB);

                            var span = $('#pd4_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC11,PDC11V,PDC11B,PDC11C,"Simple");
                            var max = (Math.max(...PDC11V)+20);
                            customizedArray(PDC11V,PDC11VX,PDC11label,colorPallet69,"Bar");
                            columnChart(PDC11VX,"pd4_c11",PDC11label,max);

                            var baseX = processBase(PDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c11_base").empty().append(htmlB);

                            var span = $('#pd4_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC16,PDC16V,PDC16B,PDC16C,"Simple");
                            var max = (Math.max(...PDC16V)+20);
                            customizedArray(PDC16V,PDC16VX,PDC16label,colorPallet69,"Bar");
                            barChart(PDC16VX,"pd4_c16",PDC16label,max);

                            var baseX = processBase(PDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c16_base").empty().append(htmlB);

                            var span = $('#pd4_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC12,PDC12V,PDC12B,PDC12C,"Simple");
                            var max = (Math.max(...PDC12V)+20);
                            customizedArray(PDC12V,PDC12VX,PDC12label,colorPallet69,"Bar");
                            columnChart(PDC12VX,"pd4_c12",PDC12label,max);

                            var baseX = processBase(PDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c12_base").empty().append(htmlB);

                            var span = $('#pd4_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC15,PDC15V,PDC15B,PDC15C,"Simple");
                            PDC15V.forEach(function(e,i,a){
                                $(`#pd4_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(PDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c15_base").empty().append(htmlB);

                            var span = $('#pd4_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC20,PDC20V,PDC20B,PDC20C,"Simple");
                            PDC20V.forEach(function(e,i,a){
                                $(`#pd4_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(PDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c20_base").empty().append(htmlB);

                            var span = $('#pd4_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC17,PDC17V,PDC17B,PDC17C,"Simple");
                            PDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`pd4_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(PDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c17_base").empty().append(htmlB);

                            var span = $('#pd4_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC18,PDC18V,PDC18B,PDC18C,"Simple");
                            var max = (Math.max(...PDC18V)+20);
                            customizedArray(PDC18V,PDC18VX,PDC18label,colorPallet69,"Bar");
                            barChart(PDC18VX,"pd4_c18",PDC18label,max);

                            var baseX = processBase(PDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c18_base").empty().append(htmlB);

                            var span = $('#pd4_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(PDC19,PDC19V,PDC19B,PDC19C,"Simple");
                            var max = (Math.max(...PDC19V)+20);
                            customizedArray(PDC19V,PDC19VX,PDC19label,colorPallet69,"Bar");
                            barChart(PDC19VX,"pd4_c19",PDC19label,max);

                            var baseX = processBase(PDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd4_c19_base").empty().append(htmlB);

                            var span = $('#pd4_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_8, S13_8V, S13_8B, S13_8C, "Simple");
                            var max = (Math.max(...S13_8V)+20);
                            customizedArray(S13_8V,S13_8VX,S13label,colorPallet69,"Bar");
                            barChart(S13_8VX,"pd_4_s13",S13label,max);
                            
                            var baseX = processBase(S13_8B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#pd_4_s13_base").empty().append(htmlB);

                            var span = $('#pd_4_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            protienFStatus4 = true;
                            ajaxFlag[1+26] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentySixthAjax() {
                    $.ajax({
                        url: "api/ajax26.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'adultcondX':adultcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var ADC0 = data['AD_C0'];
                            var ADC2 = data['AD_C2'];
                            var ADC3 = data['AD_C3'];
                            var ADC4b = data['AD_C4b'];
                            var ADC5 = data['AD_C5'];
                            var ADC6 = data['AD_C6'];
                            var ADC7 = data['AD_C7'];
                            var ADC8 = data['AD_C8'];
                            var ADC9 = data['AD_C9'];
                            var ADC10 = data['AD_C10'];
                            var ADC11 = data['AD_C11'];
                            var ADC12 = data['AD_C12'];
                            var ADC15 = data['AD_C15'];
                            var ADC16 = data['AD_C16'];
                            var ADC17 = data['AD_C17'];
                            var ADC18 = data['AD_C18'];
                            var ADC19 = data['AD_C19'];
                            var ADC20 = data['AD_C20'];

                            var S13_9 = data['S13_9'];

                            var ADC0V = [];
                            var ADC0B = [];
                            var ADC0C = [];
                            var ADC0VX = [];

                            var ADC2V = [];
                            var ADC2B = [];
                            var ADC2C = [];
                            var ADC2VX = [];

                            var ADC3V = [];
                            var ADC3B = [];
                            var ADC3C = [];
                            var ADC3VX = [];

                            var ADC4bV = [];
                            var ADC4bB = [];
                            var ADC4bC = [];
                            var ADC4bVX = [];

                            var ADC5V = [];
                            var ADC5B = [];
                            var ADC5C = [];
                            var ADC5VX = [];

                            var ADC6V = [];
                            var ADC6B = [];
                            var ADC6C = [];
                            var ADC6VX = [];

                            var ADC7V = [];
                            var ADC7B = [];
                            var ADC7C = [];
                            var ADC7VX = [];

                            var ADC8V = [];
                            var ADC8B = [];
                            var ADC8C = [];
                            var ADC8VX = [];

                            var ADC9V = [];
                            var ADC9B = [];
                            var ADC9C = [];
                            var ADC9VX = [];

                            var ADC10V = [];
                            var ADC10B = [];
                            var ADC10C = [];
                            var ADC10VX = [];

                            var ADC11V = [];
                            var ADC11B = [];
                            var ADC11C = [];
                            var ADC11VX = [];

                            var ADC12V = [];
                            var ADC12B = [];
                            var ADC12C = [];
                            var ADC12VX = [];

                            var ADC13V = [];
                            var ADC13B = [];
                            var ADC13C = [];
                            var ADC13VX = [];

                            var ADC14V = [];
                            var ADC14B = [];
                            var ADC14C = [];
                            var ADC14VX = [];

                            var ADC15V = [];
                            var ADC15B = [];
                            var ADC15C = [];
                            var ADC15VX = [];

                            var ADC16V = [];
                            var ADC16B = [];
                            var ADC16C = [];
                            var ADC16VX = [];

                            var ADC17V = [];
                            var ADC17B = [];
                            var ADC17C = [];
                            var ADC17VX = [];

                            var ADC18V = [];
                            var ADC18B = [];
                            var ADC18C = [];
                            var ADC18VX = [];

                            var ADC19V = [];
                            var ADC19B = [];
                            var ADC19C = [];
                            var ADC19VX = [];

                            var ADC20V = [];
                            var ADC20B = [];
                            var ADC20C = [];
                            var ADC20VX = [];

                            var S13_9V = [];
                            var S13_9B = [];
                            var S13_9C = [];
                            var S13_9VX = [];

                            if(adultFStatus1==false)
                            {
                                extractValues(ADC0,ADC0V,ADC0B,ADC0C,"Simple");
                                ADC0V.forEach(function(e,i,a){
                                    $(`#ad1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(ADC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#ad1_c0_base").empty().append(htmlB);

                                var span = $('#ad1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }

                                //formtable(ADC0V,ADC0label,"ad1_c0TA");
                            }

                            // 
                            
                            extractValues(ADC2,ADC2V,ADC2B,ADC2C,"Simple");
                            customizedArray(ADC2V,ADC2VX,ADC2label,colorPallet68,"Doughnut");
                            doughnutChart2(ADC2VX,"ad1_c2","Type of dairy milk you had","auto");

                            var baseX = processBase(ADC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c2_base").empty().append(htmlB);

                            var span = $('#ad1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC2V,ADC2label,"ad1_c2TA");

                            extractValues(ADC3,ADC3V,ADC3B,ADC3C,"Simple");
                            var max = (Math.max(...ADC3V)+20);
                            customizedArray(ADC3V,ADC3VX,ADC3label,colorPallet69,"Bar");
                            barChart(ADC3VX,"ad1_c3",ADC3label,max);

                            var baseX = processBase(ADC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c3_base").empty().append(htmlB);

                            var span = $('#ad1_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC3V,ADC3label,"ad1_c3TA");

                            extractValues(ADC4b,ADC4bV,ADC4bB,ADC4bC,"Simple");
                            customizedArray(ADC4bV,ADC4bVX,ADC4blabel,colorPallet68,"Doughnut");
                            doughnutChart2(ADC4bVX,"ad1_c4b","Consumed with hot or cold",285);
                            var baseX = processBase(ADC4bB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c4b_base").empty().append(htmlB);

                            var span = $('#ad1_c4b_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(ADC5,ADC5V,ADC5B,ADC5C,"Simple");
                            customizedArray(ADC5V,ADC5VX,ADC5label,colorPallet68,"Doughnut");
                            doughnutChart2(ADC5VX,"ad1_c5","Consumed with hot or cold",285);
                            var baseX = processBase(ADC5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c5_base").empty().append(htmlB);

                            var span = $('#ad1_c5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(ADC6,ADC6V,ADC6B,ADC6C,"Simple");
                            customizedArray(ADC6V,ADC6VX,ADC6label,colorPallet69,"Doughnut");
                            pieChart(ADC6VX,"ad1_c6","Type of Packaging","auto");

                            var baseX = processBase(ADC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c6_base").empty().append(htmlB);

                            var span = $('#ad1_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC6V,ADC6label,"ad1_c6TA");

                            extractValues(ADC7,ADC7V,ADC7B,ADC7C,"Simple");
                            customizedArray(ADC7V,ADC7VX,ADC7label,colorPallet68,"Doughnut");
                            pieChart(ADC7VX,"ad1_c7","Type of Packaging","auto");

                            var baseX = processBase(ADC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c7_base").empty().append(htmlB);

                            var span = $('#ad1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC7V,ADC7label,"ad1_c7TA");

                            extractValues(ADC8,ADC8V,ADC8B,ADC8C,"Simple");
                            var max = (Math.max(...ADC8V)+20);
                            customizedArray(ADC8V,ADC8VX,ADC8label,colorPallet69,"Bar");
                            barChart(ADC8VX,"ad1_c8",ADC8label,max);

                            var baseX = processBase(ADC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c8_base").empty().append(htmlB);

                            var span = $('#ad1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC8V,ADC8label,"ad1_c8TA");

                            extractValues(ADC9,ADC9V,ADC9B,ADC9C,"Simple");
                            var max = (Math.max(...ADC9V)+20);
                            customizedArray(ADC9V,ADC9VX,ADC9label,colorPallet69,"Bar");
                            barChart(ADC9VX,"ad1_c9",ADC9label,max);

                            var baseX = processBase(ADC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c9_base").empty().append(htmlB);

                            var span = $('#ad1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC9V,ADC9label,"ad1_c9TA");

                            extractValues(ADC10,ADC10V,ADC10B,ADC10C,"Simple");
                            customizedArray(ADC10V,ADC10VX,ADC10label,colorPallet68,"Doughnut");
                            pieChart(ADC10VX,"ad1_c10","Way of consumption","auto");

                            var baseX = processBase(ADC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c10_base").empty().append(htmlB);

                            var span = $('#ad1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC10V,ADC10label,"ad1_c10TA");

                            extractValues(ADC11,ADC11V,ADC11B,ADC11C,"Simple");
                            var max = (Math.max(...ADC11V)+20);
                            customizedArray(ADC11V,ADC11VX,ADC11label,colorPallet69,"Bar");
                            columnChart(ADC11VX,"ad1_c11",ADC11label,max);

                            var baseX = processBase(ADC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c11_base").empty().append(htmlB);

                            var span = $('#ad1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC11V,ADC11label,"ad1_c11TA");

                            extractValues(ADC12,ADC12V,ADC12B,ADC12C,"Simple");
                            var max = (Math.max(...ADC12V)+20);
                            customizedArray(ADC12V,ADC12VX,ADC12label,colorPallet69,"Bar");
                            columnChart(ADC12VX,"ad1_c12",ADC12label,max);

                            var baseX = processBase(ADC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c12_base").empty().append(htmlB);

                            var span = $('#ad1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC12V,ADC12label,"ad1_c12TA");

                            extractValues(ADC15,ADC15V,ADC15B,ADC15C,"Simple");
                            ADC15V.forEach(function(e,i,a){
                                $(`#ad1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(ADC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c15_base").empty().append(htmlB);

                            var span = $('#ad1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(ADC15V,ADC15label,"ad1_c15TA");

                            extractValues(ADC16,ADC16V,ADC16B,ADC16C,"Simple");
                            var max = (Math.max(...ADC16V)+20);
                            customizedArray(ADC16V,ADC16VX,ADC16label,colorPallet69,"Bar");
                            barChart(ADC16VX,"ad1_c16",ADC16label,max);

                            var baseX = processBase(ADC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c16_base").empty().append(htmlB);

                            var span = $('#ad1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(ADC17,ADC17V,ADC17B,ADC17C,"Simple");
                            ADC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`ad1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(ADC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c17_base").empty().append(htmlB);

                            var span = $('#ad1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(ADC18,ADC18V,ADC18B,ADC18C,"Simple");
                            var max = (Math.max(...ADC18V)+20);
                            customizedArray(ADC18V,ADC18VX,ADC18label,colorPallet69,"Bar");
                            barChart(ADC18VX,"ad1_c18",ADC18label,max);

                            var baseX = processBase(ADC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c18_base").empty().append(htmlB);

                            var span = $('#ad1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(ADC19,ADC19V,ADC19B,ADC19C,"Simple");
                            var max = (Math.max(...ADC19V)+20);
                            customizedArray(ADC19V,ADC19VX,ADC19label,colorPallet69,"Bar");
                            barChart(ADC19VX,"ad1_c19",ADC19label,max);

                            var baseX = processBase(ADC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c19_base").empty().append(htmlB);

                            var span = $('#ad1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(ADC20,ADC20V,ADC20B,ADC20C,"Simple");
                            ADC20V.forEach(function(e,i,a){
                                $(`#ad1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(ADC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ad1_c20_base").empty().append(htmlB);

                            var span = $('#ad1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_9, S13_9V, S13_9B, S13_9C, "Simple");
                            var max = (Math.max(...S13_9V)+20);
                            customizedArray(S13_9V,S13_9VX,S13label,colorPallet69,"Bar");
                            barChart(S13_9VX,"ad_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_9B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ad_1_s13_base").empty().append(htmlB);

                            var span = $('#ad_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            adultFStatus1 = true;
                            ajaxFlag[1+27] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentySeventhAjax() {
                    $.ajax({
                        url: "api/ajax27.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'cakecondX':cakecondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var CKC0 = data['CK_C0'];
                            var CKC2 = data['CK_C2'];
                            var CKC6 = data['CK_C6'];
                            var CKC7 = data['CK_C7'];
                            var CKC8 = data['CK_C8'];
                            var CKC9 = data['CK_C9'];
                            var CKC10 = data['CK_C10'];
                            var CKC11 = data['CK_C11'];
                            var CKC12 = data['CK_C12'];
                            var CKC15 = data['CK_C15'];
                            var CKC16 = data['CK_C16'];
                            var CKC17 = data['CK_C17'];
                            var CKC18 = data['CK_C18'];
                            var CKC19 = data['CK_C19'];
                            var CKC20 = data['CK_C20'];

                            var S13_12 = data['S13_12'];

                            var CKC0V = [];
                            var CKC0B = [];
                            var CKC0C = [];
                            var CKC0VX = [];

                            var CKC2V = [];
                            var CKC2B = [];
                            var CKC2C = [];
                            var CKC2VX = [];

                            var CKC6V = [];
                            var CKC6B = [];
                            var CKC6C = [];
                            var CKC6VX = [];

                            var CKC7V = [];
                            var CKC7B = [];
                            var CKC7C = [];
                            var CKC7VX = [];

                            var CKC8V = [];
                            var CKC8B = [];
                            var CKC8C = [];
                            var CKC8VX = [];

                            var CKC9V = [];
                            var CKC9B = [];
                            var CKC9C = [];
                            var CKC9VX = [];

                            var CKC10V = [];
                            var CKC10B = [];
                            var CKC10C = [];
                            var CKC10VX = [];

                            var CKC11V = [];
                            var CKC11B = [];
                            var CKC11C = [];
                            var CKC11VX = [];

                            var CKC12V = [];
                            var CKC12B = [];
                            var CKC12C = [];
                            var CKC12VX = [];

                            var CKC13V = [];
                            var CKC13B = [];
                            var CKC13C = [];
                            var CKC13VX = [];

                            var CKC14V = [];
                            var CKC14B = [];
                            var CKC14C = [];
                            var CKC14VX = [];

                            var CKC15V = [];
                            var CKC15B = [];
                            var CKC15C = [];
                            var CKC15VX = [];

                            var CKC16V = [];
                            var CKC16B = [];
                            var CKC16C = [];
                            var CKC16VX = [];

                            var CKC17V = [];
                            var CKC17B = [];
                            var CKC17C = [];
                            var CKC17VX = [];

                            var CKC18V = [];
                            var CKC18B = [];
                            var CKC18C = [];
                            var CKC18VX = [];

                            var CKC19V = [];
                            var CKC19B = [];
                            var CKC19C = [];
                            var CKC19VX = [];

                            var CKC20V = [];
                            var CKC20B = [];
                            var CKC20C = [];
                            var CKC20VX = [];

                            var S13_12V = [];
                            var S13_12B = [];
                            var S13_12C = [];
                            var S13_12VX = [];

                            if(cakeFStatus1==false)
                            {
                                extractValues(CKC0,CKC0V,CKC0B,CKC0C,"Simple");
                                CKC0V.forEach(function(e,i,a){
                                    $(`#ck1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CKC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#ck1_c0_base").empty().append(htmlB);

                                var span = $('#ck1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 
                            
                            extractValues(CKC2,CKC2V,CKC2B,CKC2C,"Simple");
                            customizedArray(CKC2V,CKC2VX,CKC2label,colorPallet68,"Doughnut");
                            doughnutChart2(CKC2VX,"ck1_c2","Type of dairy milk you had","auto");

                            var baseX = processBase(CKC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c2_base").empty().append(htmlB);

                            var span = $('#ck1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CKC6,CKC6V,CKC6B,CKC6C,"Simple");
                            customizedArray(CKC6V,CKC6VX,CKC6label,colorPallet69,"Doughnut");
                            pieChart(CKC6VX,"ck1_c6","Type of Packaging","auto");

                            var baseX = processBase(CKC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c6_base").empty().append(htmlB);

                            var span = $('#ck1_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CKC6V,CKC6label,"ck1_c6TA");

                            extractValues(CKC7,CKC7V,CKC7B,CKC7C,"Simple");
                            customizedArray(CKC7V,CKC7VX,CKC7label,colorPallet68,"Doughnut");
                            pieChart(CKC7VX,"ck1_c7","Type of Packaging","auto");

                            var baseX = processBase(CKC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c7_base").empty().append(htmlB);

                            var span = $('#ck1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CKC7V,CKC7label,"ck1_c7TA");

                            extractValues(CKC8,CKC8V,CKC8B,CKC8C,"Simple");
                            var max = (Math.max(...CKC8V)+20);
                            customizedArray(CKC8V,CKC8VX,CKC8label,colorPallet69,"Bar");
                            barChart(CKC8VX,"ck1_c8",CKC8label,max);

                            var baseX = processBase(CKC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c8_base").empty().append(htmlB);

                            var span = $('#ck1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CKC8V,CKC8label,"ck1_c8TA");

                            extractValues(CKC9,CKC9V,CKC9B,CKC9C,"Simple");
                            var max = (Math.max(...CKC9V)+20);
                            customizedArray(CKC9V,CKC9VX,CKC9label,colorPallet69,"Bar");
                            barChart(CKC9VX,"ck1_c9",CKC9label,max);

                            var baseX = processBase(CKC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c9_base").empty().append(htmlB);

                            var span = $('#ck1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CKC9V,CKC9label,"ck1_c9TA");

                            extractValues(CKC10,CKC10V,CKC10B,CKC10C,"Simple");
                            customizedArray(CKC10V,CKC10VX,CKC10label,colorPallet68,"Doughnut");
                            pieChart(CKC10VX,"ck1_c10","Way of consumption","auto");

                            var baseX = processBase(CKC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c10_base").empty().append(htmlB);

                            var span = $('#ck1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CKC10V,CKC10label,"ck1_c10TA");

                            extractValues(CKC11,CKC11V,CKC11B,CKC11C,"Simple");
                            var max = (Math.max(...CKC11V)+20);
                            customizedArray(CKC11V,CKC11VX,CKC11label,colorPallet69,"Bar");
                            columnChart(CKC11VX,"ck1_c11",CKC11label,max);

                            var baseX = processBase(CKC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c11_base").empty().append(htmlB);

                            var span = $('#ck1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CKC11V,CKC11label,"ck1_c11TA");

                            extractValues(CKC12,CKC12V,CKC12B,CKC12C,"Simple");
                            var max = (Math.max(...CKC12V)+20);
                            customizedArray(CKC12V,CKC12VX,CKC12label,colorPallet69,"Bar");
                            columnChart(CKC12VX,"ck1_c12",CKC12label,max);

                            var baseX = processBase(CKC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c12_base").empty().append(htmlB);

                            var span = $('#ck1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CKC12V,CKC12label,"ck1_c12TA");

                            extractValues(CKC15,CKC15V,CKC15B,CKC15C,"Simple");
                            CKC15V.forEach(function(e,i,a){
                                $(`#ck1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CKC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c15_base").empty().append(htmlB);

                            var span = $('#ck1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CKC15V,CKC15label,"ck1_c15TA");

                            extractValues(CKC16,CKC16V,CKC16B,CKC16C,"Simple");
                            var max = (Math.max(...CKC16V)+20);
                            customizedArray(CKC16V,CKC16VX,CKC16label,colorPallet69,"Bar");
                            barChart(CKC16VX,"ck1_c16",CKC16label,max);

                            var baseX = processBase(CKC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c16_base").empty().append(htmlB);

                            var span = $('#ck1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CKC17,CKC17V,CKC17B,CKC17C,"Simple");
                            CKC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`ck1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CKC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c17_base").empty().append(htmlB);

                            var span = $('#ck1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CKC18,CKC18V,CKC18B,CKC18C,"Simple");
                            var max = (Math.max(...CKC18V)+20);
                            customizedArray(CKC18V,CKC18VX,CKC18label,colorPallet69,"Bar");
                            barChart(CKC18VX,"ck1_c18",CKC18label,max);

                            var baseX = processBase(CKC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c18_base").empty().append(htmlB);

                            var span = $('#ck1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CKC19,CKC19V,CKC19B,CKC19C,"Simple");
                            var max = (Math.max(...CKC19V)+20);
                            customizedArray(CKC19V,CKC19VX,CKC19label,colorPallet69,"Bar");
                            barChart(CKC19VX,"ck1_c19",CKC19label,max);

                            var baseX = processBase(CKC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c19_base").empty().append(htmlB);

                            var span = $('#ck1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(CKC20,CKC20V,CKC20B,CKC20C,"Simple");
                            CKC20V.forEach(function(e,i,a){
                                $(`#ck1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CKC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#ck1_c20_base").empty().append(htmlB);

                            var span = $('#ck1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_12, S13_12V, S13_12B, S13_12C, "Simple");
                            var max = (Math.max(...S13_12V)+20);
                            customizedArray(S13_12V,S13_12VX,S13label,colorPallet69,"Bar");
                            barChart(S13_12VX,"ck_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_12B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#ck_1_s13_base").empty().append(htmlB);

                            var span = $('#ck_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                        },
                        complete: function (data) {
                            cakeFStatus1 = true;
                            ajaxFlag[1+28] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentyEightthAjax() {
                    $.ajax({
                        url: "api/ajax28.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'sportscondX':sportscondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var SDC0 = data['SD_C0'];
                            var SDC1 = data['SD_C1'];
                            var SDC3 = data['SD_C3'];
                            var SDC6 = data['SD_C6'];
                            var SDC7 = data['SD_C7'];
                            var SDC8 = data['SD_C8'];
                            var SDC9 = data['SD_C9'];
                            var SDC10 = data['SD_C10'];
                            var SDC11 = data['SD_C11'];
                            var SDC12 = data['SD_C12'];
                            var SDC15 = data['SD_C15'];
                            var SDC16 = data['SD_C16'];
                            var SDC17 = data['SD_C17'];
                            var SDC18 = data['SD_C18'];
                            var SDC19 = data['SD_C19'];
                            var SDC20 = data['SD_C20'];

                            var S13_7 = data['S13_7'];

                            var SDC0V = [];
                            var SDC0B = [];
                            var SDC0C = [];
                            var SDC0VX = [];

                            var SDC1V = [];
                            var SDC1B = [];
                            var SDC1C = [];
                            var SDC1VX = [];

                            var SDC3V = [];
                            var SDC3B = [];
                            var SDC3C = [];
                            var SDC3VX = [];

                            var SDC6V = [];
                            var SDC6B = [];
                            var SDC6C = [];
                            var SDC6VX = [];

                            var SDC7V = [];
                            var SDC7B = [];
                            var SDC7C = [];
                            var SDC7VX = [];

                            var SDC8V = [];
                            var SDC8B = [];
                            var SDC8C = [];
                            var SDC8VX = [];

                            var SDC9V = [];
                            var SDC9B = [];
                            var SDC9C = [];
                            var SDC9VX = [];

                            var SDC10V = [];
                            var SDC10B = [];
                            var SDC10C = [];
                            var SDC10VX = [];

                            var SDC11V = [];
                            var SDC11B = [];
                            var SDC11C = [];
                            var SDC11VX = [];

                            var SDC12V = [];
                            var SDC12B = [];
                            var SDC12C = [];
                            var SDC12VX = [];

                            var SDC13V = [];
                            var SDC13B = [];
                            var SDC13C = [];
                            var SDC13VX = [];

                            var SDC14V = [];
                            var SDC14B = [];
                            var SDC14C = [];
                            var SDC14VX = [];

                            var SDC15V = [];
                            var SDC15B = [];
                            var SDC15C = [];
                            var SDC15VX = [];

                            var SDC16V = [];
                            var SDC16B = [];
                            var SDC16C = [];
                            var SDC16VX = [];

                            var SDC17V = [];
                            var SDC17B = [];
                            var SDC17C = [];
                            var SDC17VX = [];

                            var SDC18V = [];
                            var SDC18B = [];
                            var SDC18C = [];
                            var SDC18VX = [];

                            var SDC19V = [];
                            var SDC19B = [];
                            var SDC19C = [];
                            var SDC19VX = [];

                            var SDC20V = [];
                            var SDC20B = [];
                            var SDC20C = [];
                            var SDC20VX = [];

                            var S13_7V = [];
                            var S13_7B = [];
                            var S13_7C = [];
                            var S13_7VX = [];

                            if(sportsFStatus1==false)
                            {
                                extractValues(SDC0,SDC0V,SDC0B,SDC0C,"Simple");
                                SDC0V.forEach(function(e,i,a){
                                    $(`#sd1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(SDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#sd1_c0_base").empty().append(htmlB);

                                var span = $('#sd1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 
                            
                            extractValues(SDC1,SDC1V,SDC1B,SDC1C,"Simple");
                            customizedArray(SDC1V,SDC1VX,SDC1label,colorPallet68,"Doughnut");
                            doughnutChart2(SDC1VX,"sd1_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(SDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c1_base").empty().append(htmlB);

                            var span = $('#sd1_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            
                            extractValues(SDC3,SDC3V,SDC3B,SDC3C,"Simple");
                            customizedArray(SDC3V,SDC3VX,SDC3label,colorPallet68,"Doughnut");
                            doughnutChart2(SDC3VX,"sd1_c3","Type of dairy milk you had","auto");

                            var baseX = processBase(SDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c3_base").empty().append(htmlB);

                            var span = $('#sd1_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC6,SDC6V,SDC6B,SDC6C,"Simple");
                            customizedArray(SDC6V,SDC6VX,SDC6label,colorPallet69,"Doughnut");
                            pieChart(SDC6VX,"sd1_c6","Type of Packaging","auto");

                            var baseX = processBase(SDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c6_base").empty().append(htmlB);

                            var span = $('#sd1_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC6V,SDC6label,"sd1_c6TA");

                            extractValues(SDC7,SDC7V,SDC7B,SDC7C,"Simple");
                            customizedArray(SDC7V,SDC7VX,SDC7label,colorPallet68,"Doughnut");
                            pieChart(SDC7VX,"sd1_c7","Type of Packaging","auto");

                            var baseX = processBase(SDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c7_base").empty().append(htmlB);

                            var span = $('#sd1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC7V,SDC7label,"sd1_c7TA");

                            extractValues(SDC8,SDC8V,SDC8B,SDC8C,"Simple");
                            var max = (Math.max(...SDC8V)+20);
                            customizedArray(SDC8V,SDC8VX,SDC8label,colorPallet69,"Bar");
                            barChart(SDC8VX,"sd1_c8",SDC8label,max);

                            var baseX = processBase(SDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c8_base").empty().append(htmlB);

                            var span = $('#sd1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC8V,SDC8label,"sd1_c8TA");

                            extractValues(SDC9,SDC9V,SDC9B,SDC9C,"Simple");
                            var max = (Math.max(...SDC9V)+20);
                            customizedArray(SDC9V,SDC9VX,SDC9label,colorPallet69,"Bar");
                            barChart(SDC9VX,"sd1_c9",SDC9label,max);

                            var baseX = processBase(SDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c9_base").empty().append(htmlB);

                            var span = $('#sd1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC9V,SDC9label,"sd1_c9TA");

                            extractValues(SDC10,SDC10V,SDC10B,SDC10C,"Simple");
                            customizedArray(SDC10V,SDC10VX,SDC10label,colorPallet68,"Doughnut");
                            pieChart(SDC10VX,"sd1_c10","Way of consumption","auto");

                            var baseX = processBase(SDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c10_base").empty().append(htmlB);

                            var span = $('#sd1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC10V,SDC10label,"sd1_c10TA");

                            extractValues(SDC11,SDC11V,SDC11B,SDC11C,"Simple");
                            var max = (Math.max(...SDC11V)+20);
                            customizedArray(SDC11V,SDC11VX,SDC11label,colorPallet69,"Bar");
                            columnChart(SDC11VX,"sd1_c11",SDC11label,max);

                            var baseX = processBase(SDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c11_base").empty().append(htmlB);

                            var span = $('#sd1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC11V,SDC11label,"sd1_c11TA");

                            extractValues(SDC12,SDC12V,SDC12B,SDC12C,"Simple");
                            var max = (Math.max(...SDC12V)+20);
                            customizedArray(SDC12V,SDC12VX,SDC12label,colorPallet69,"Bar");
                            columnChart(SDC12VX,"sd1_c12",SDC12label,max);

                            var baseX = processBase(SDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c12_base").empty().append(htmlB);

                            var span = $('#sd1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC12V,SDC12label,"sd1_c12TA");

                            extractValues(SDC15,SDC15V,SDC15B,SDC15C,"Simple");
                            SDC15V.forEach(function(e,i,a){
                                $(`#sd1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(SDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c15_base").empty().append(htmlB);

                            var span = $('#sd1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC15V,SDC15label,"sd1_c15TA");

                            extractValues(SDC16,SDC16V,SDC16B,SDC16C,"Simple");
                            var max = (Math.max(...SDC16V)+20);
                            customizedArray(SDC16V,SDC16VX,SDC16label,colorPallet69,"Bar");
                            barChart(SDC16VX,"sd1_c16",SDC16label,max);

                            var baseX = processBase(SDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c16_base").empty().append(htmlB);

                            var span = $('#sd1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC17,SDC17V,SDC17B,SDC17C,"Simple");
                            SDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`sd1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(SDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c17_base").empty().append(htmlB);

                            var span = $('#sd1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC18,SDC18V,SDC18B,SDC18C,"Simple");
                            var max = (Math.max(...SDC18V)+20);
                            customizedArray(SDC18V,SDC18VX,SDC18label,colorPallet69,"Bar");
                            barChart(SDC18VX,"sd1_c18",SDC18label,max);

                            var baseX = processBase(SDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c18_base").empty().append(htmlB);

                            var span = $('#sd1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC19,SDC19V,SDC19B,SDC19C,"Simple");
                            var max = (Math.max(...SDC19V)+20);
                            customizedArray(SDC19V,SDC19VX,SDC19label,colorPallet69,"Bar");
                            barChart(SDC19VX,"sd1_c19",SDC19label,max);

                            var baseX = processBase(SDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c19_base").empty().append(htmlB);

                            var span = $('#sd1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(SDC20,SDC20V,SDC20B,SDC20C,"Simple");
                            SDC20V.forEach(function(e,i,a){
                                $(`#sd1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(SDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd1_c20_base").empty().append(htmlB);

                            var span = $('#sd1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_7, S13_7V, S13_7B, S13_7C, "Simple");
                            var max = (Math.max(...S13_7V)+20);
                            customizedArray(S13_7V,S13_7VX,S13label,colorPallet69,"Bar");
                            barChart(S13_7VX,"sd_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_7B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#sd_1_s13_base").empty().append(htmlB);

                            var span = $('#sd_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            sportsFStatus1 = true;
                            ajaxFlag[1+29] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function twentyNinethAjax() {
                    $.ajax({
                        url: "api/ajax29.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'sportscondX':sportscondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            
                            var SDC0 = data['SD_C0'];
                            var SDC1 = data['SD_C1'];
                            var SDC3 = data['SD_C3'];
                            var SDC6 = data['SD_C6'];
                            var SDC7 = data['SD_C7'];
                            var SDC8 = data['SD_C8'];
                            var SDC9 = data['SD_C9'];
                            var SDC10 = data['SD_C10'];
                            var SDC11 = data['SD_C11'];
                            var SDC12 = data['SD_C12'];
                            var SDC15 = data['SD_C15'];
                            var SDC16 = data['SD_C16'];
                            var SDC17 = data['SD_C17'];
                            var SDC18 = data['SD_C18'];
                            var SDC19 = data['SD_C19'];
                            var SDC20 = data['SD_C20'];

                            var S13_7 = data['S13_7'];

                            var SDC0V = [];
                            var SDC0B = [];
                            var SDC0C = [];
                            var SDC0VX = [];

                            var SDC1V = [];
                            var SDC1B = [];
                            var SDC1C = [];
                            var SDC1VX = [];

                            var SDC3V = [];
                            var SDC3B = [];
                            var SDC3C = [];
                            var SDC3VX = [];

                            var SDC6V = [];
                            var SDC6B = [];
                            var SDC6C = [];
                            var SDC6VX = [];

                            var SDC7V = [];
                            var SDC7B = [];
                            var SDC7C = [];
                            var SDC7VX = [];

                            var SDC8V = [];
                            var SDC8B = [];
                            var SDC8C = [];
                            var SDC8VX = [];

                            var SDC9V = [];
                            var SDC9B = [];
                            var SDC9C = [];
                            var SDC9VX = [];

                            var SDC10V = [];
                            var SDC10B = [];
                            var SDC10C = [];
                            var SDC10VX = [];

                            var SDC11V = [];
                            var SDC11B = [];
                            var SDC11C = [];
                            var SDC11VX = [];

                            var SDC12V = [];
                            var SDC12B = [];
                            var SDC12C = [];
                            var SDC12VX = [];

                            var SDC13V = [];
                            var SDC13B = [];
                            var SDC13C = [];
                            var SDC13VX = [];

                            var SDC14V = [];
                            var SDC14B = [];
                            var SDC14C = [];
                            var SDC14VX = [];

                            var SDC15V = [];
                            var SDC15B = [];
                            var SDC15C = [];
                            var SDC15VX = [];

                            var SDC16V = [];
                            var SDC16B = [];
                            var SDC16C = [];
                            var SDC16VX = [];

                            var SDC17V = [];
                            var SDC17B = [];
                            var SDC17C = [];
                            var SDC17VX = [];

                            var SDC18V = [];
                            var SDC18B = [];
                            var SDC18C = [];
                            var SDC18VX = [];

                            var SDC19V = [];
                            var SDC19B = [];
                            var SDC19C = [];
                            var SDC19VX = [];

                            var SDC20V = [];
                            var SDC20B = [];
                            var SDC20C = [];
                            var SDC20VX = [];

                            var S13_7V = [];
                            var S13_7B = [];
                            var S13_7C = [];
                            var S13_7VX = [];

                            if(sportsFStatus2==false)
                            {
                                extractValues(SDC0,SDC0V,SDC0B,SDC0C,"Simple");
                                SDC0V.forEach(function(e,i,a){
                                    $(`#sd2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(SDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#sd2_c0_base").empty().append(htmlB);

                                var span = $('#sd2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 
                            
                            extractValues(SDC1,SDC1V,SDC1B,SDC1C,"Simple");
                            customizedArray(SDC1V,SDC1VX,SDC1label,colorPallet68,"Doughnut");
                            doughnutChart2(SDC1VX,"sd2_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(SDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c1_base").empty().append(htmlB);

                            var span = $('#sd2_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            
                            extractValues(SDC3,SDC3V,SDC3B,SDC3C,"Simple");
                            customizedArray(SDC3V,SDC3VX,SDC3label,colorPallet68,"Doughnut");
                            doughnutChart2(SDC3VX,"sd2_c3","Type of dairy milk you had","auto");

                            var baseX = processBase(SDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c3_base").empty().append(htmlB);

                            var span = $('#sd2_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC6,SDC6V,SDC6B,SDC6C,"Simple");
                            customizedArray(SDC6V,SDC6VX,SDC6label,colorPallet69,"Doughnut");
                            pieChart(SDC6VX,"sd2_c6","Type of Packaging","auto");

                            var baseX = processBase(SDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c6_base").empty().append(htmlB);

                            var span = $('#sd2_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC6V,SDC6label,"sd2_c6TA");

                            extractValues(SDC7,SDC7V,SDC7B,SDC7C,"Simple");
                            customizedArray(SDC7V,SDC7VX,SDC7label,colorPallet68,"Doughnut");
                            pieChart(SDC7VX,"sd2_c7","Type of Packaging","auto");

                            var baseX = processBase(SDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c7_base").empty().append(htmlB);

                            var span = $('#sd2_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC7V,SDC7label,"sd2_c7TA");

                            extractValues(SDC8,SDC8V,SDC8B,SDC8C,"Simple");
                            var max = (Math.max(...SDC8V)+20);
                            customizedArray(SDC8V,SDC8VX,SDC8label,colorPallet69,"Bar");
                            barChart(SDC8VX,"sd2_c8",SDC8label,max);

                            var baseX = processBase(SDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c8_base").empty().append(htmlB);

                            var span = $('#sd2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC8V,SDC8label,"sd2_c8TA");

                            extractValues(SDC9,SDC9V,SDC9B,SDC9C,"Simple");
                            var max = (Math.max(...SDC9V)+20);
                            customizedArray(SDC9V,SDC9VX,SDC9label,colorPallet69,"Bar");
                            barChart(SDC9VX,"sd2_c9",SDC9label,max);

                            var baseX = processBase(SDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c9_base").empty().append(htmlB);

                            var span = $('#sd2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC9V,SDC9label,"sd2_c9TA");

                            extractValues(SDC10,SDC10V,SDC10B,SDC10C,"Simple");
                            customizedArray(SDC10V,SDC10VX,SDC10label,colorPallet68,"Doughnut");
                            pieChart(SDC10VX,"sd2_c10","Way of consumption","auto");

                            var baseX = processBase(SDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c10_base").empty().append(htmlB);

                            var span = $('#sd2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC10V,SDC10label,"sd2_c10TA");

                            extractValues(SDC11,SDC11V,SDC11B,SDC11C,"Simple");
                            var max = (Math.max(...SDC11V)+20);
                            customizedArray(SDC11V,SDC11VX,SDC11label,colorPallet69,"Bar");
                            columnChart(SDC11VX,"sd2_c11",SDC11label,max);

                            var baseX = processBase(SDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c11_base").empty().append(htmlB);

                            var span = $('#sd2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC11V,SDC11label,"sd2_c11TA");

                            extractValues(SDC12,SDC12V,SDC12B,SDC12C,"Simple");
                            var max = (Math.max(...SDC12V)+20);
                            customizedArray(SDC12V,SDC12VX,SDC12label,colorPallet69,"Bar");
                            columnChart(SDC12VX,"sd2_c12",SDC12label,max);

                            var baseX = processBase(SDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c12_base").empty().append(htmlB);

                            var span = $('#sd2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC12V,SDC12label,"sd2_c12TA");

                            extractValues(SDC15,SDC15V,SDC15B,SDC15C,"Simple");
                            SDC15V.forEach(function(e,i,a){
                                $(`#sd2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(SDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c15_base").empty().append(htmlB);

                            var span = $('#sd2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC15V,SDC15label,"sd2_c15TA");

                            extractValues(SDC16,SDC16V,SDC16B,SDC16C,"Simple");
                            var max = (Math.max(...SDC16V)+20);
                            customizedArray(SDC16V,SDC16VX,SDC16label,colorPallet69,"Bar");
                            barChart(SDC16VX,"sd2_c16",SDC16label,max);

                            var baseX = processBase(SDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c16_base").empty().append(htmlB);

                            var span = $('#sd2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC17,SDC17V,SDC17B,SDC17C,"Simple");
                            SDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`sd2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(SDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c17_base").empty().append(htmlB);

                            var span = $('#sd2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC18,SDC18V,SDC18B,SDC18C,"Simple");
                            var max = (Math.max(...SDC18V)+20);
                            customizedArray(SDC18V,SDC18VX,SDC18label,colorPallet69,"Bar");
                            barChart(SDC18VX,"sd2_c18",SDC18label,max);

                            var baseX = processBase(SDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c18_base").empty().append(htmlB);

                            var span = $('#sd2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC19,SDC19V,SDC19B,SDC19C,"Simple");
                            var max = (Math.max(...SDC19V)+20);
                            customizedArray(SDC19V,SDC19VX,SDC19label,colorPallet69,"Bar");
                            barChart(SDC19VX,"sd2_c19",SDC19label,max);

                            var baseX = processBase(SDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c19_base").empty().append(htmlB);

                            var span = $('#sd2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(SDC20,SDC20V,SDC20B,SDC20C,"Simple");
                            SDC20V.forEach(function(e,i,a){
                                $(`#sd2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(SDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd2_c20_base").empty().append(htmlB);

                            var span = $('#sd2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_7, S13_7V, S13_7B, S13_7C, "Simple");
                            var max = (Math.max(...S13_7V)+20);
                            customizedArray(S13_7V,S13_7VX,S13label,colorPallet69,"Bar");
                            barChart(S13_7VX,"sd_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_7B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#sd_2_s13_base").empty().append(htmlB);

                            var span = $('#sd_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            sportsFStatus2 = true;
                            ajaxFlag[1+30] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtythAjax() {
                    $.ajax({
                        url: "api/ajax30.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'sportscondX':sportscondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            
                            var SDC0 = data['SD_C0'];
                            var SDC1 = data['SD_C1'];
                            var SDC3 = data['SD_C3'];
                            var SDC6 = data['SD_C6'];
                            var SDC7 = data['SD_C7'];
                            var SDC8 = data['SD_C8'];
                            var SDC9 = data['SD_C9'];
                            var SDC10 = data['SD_C10'];
                            var SDC11 = data['SD_C11'];
                            var SDC12 = data['SD_C12'];
                            var SDC15 = data['SD_C15'];
                            var SDC16 = data['SD_C16'];
                            var SDC17 = data['SD_C17'];
                            var SDC18 = data['SD_C18'];
                            var SDC19 = data['SD_C19'];
                            var SDC20 = data['SD_C20'];

                            var S13_7 = data['S13_7'];

                            var SDC0V = [];
                            var SDC0B = [];
                            var SDC0C = [];
                            var SDC0VX = [];

                            var SDC1V = [];
                            var SDC1B = [];
                            var SDC1C = [];
                            var SDC1VX = [];

                            var SDC3V = [];
                            var SDC3B = [];
                            var SDC3C = [];
                            var SDC3VX = [];

                            var SDC6V = [];
                            var SDC6B = [];
                            var SDC6C = [];
                            var SDC6VX = [];

                            var SDC7V = [];
                            var SDC7B = [];
                            var SDC7C = [];
                            var SDC7VX = [];

                            var SDC8V = [];
                            var SDC8B = [];
                            var SDC8C = [];
                            var SDC8VX = [];

                            var SDC9V = [];
                            var SDC9B = [];
                            var SDC9C = [];
                            var SDC9VX = [];

                            var SDC10V = [];
                            var SDC10B = [];
                            var SDC10C = [];
                            var SDC10VX = [];

                            var SDC11V = [];
                            var SDC11B = [];
                            var SDC11C = [];
                            var SDC11VX = [];

                            var SDC12V = [];
                            var SDC12B = [];
                            var SDC12C = [];
                            var SDC12VX = [];

                            var SDC13V = [];
                            var SDC13B = [];
                            var SDC13C = [];
                            var SDC13VX = [];

                            var SDC14V = [];
                            var SDC14B = [];
                            var SDC14C = [];
                            var SDC14VX = [];

                            var SDC15V = [];
                            var SDC15B = [];
                            var SDC15C = [];
                            var SDC15VX = [];

                            var SDC16V = [];
                            var SDC16B = [];
                            var SDC16C = [];
                            var SDC16VX = [];

                            var SDC17V = [];
                            var SDC17B = [];
                            var SDC17C = [];
                            var SDC17VX = [];

                            var SDC18V = [];
                            var SDC18B = [];
                            var SDC18C = [];
                            var SDC18VX = [];

                            var SDC19V = [];
                            var SDC19B = [];
                            var SDC19C = [];
                            var SDC19VX = [];

                            var SDC20V = [];
                            var SDC20B = [];
                            var SDC20C = [];
                            var SDC20VX = [];

                            var S13_7V = [];
                            var S13_7B = [];
                            var S13_7C = [];
                            var S13_7VX = [];

                            if(sportsFStatus3==false)
                            {
                                extractValues(SDC0,SDC0V,SDC0B,SDC0C,"Simple");
                                SDC0V.forEach(function(e,i,a){
                                    $(`#sd3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(SDC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#sd3_c0_base").empty().append(htmlB);

                                var span = $('#sd3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 
                            
                            extractValues(SDC1,SDC1V,SDC1B,SDC1C,"Simple");
                            customizedArray(SDC1V,SDC1VX,SDC1label,colorPallet68,"Doughnut");
                            doughnutChart2(SDC1VX,"sd3_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(SDC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c1_base").empty().append(htmlB);

                            var span = $('#sd3_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            
                            extractValues(SDC3,SDC3V,SDC3B,SDC3C,"Simple");
                            customizedArray(SDC3V,SDC3VX,SDC3label,colorPallet68,"Doughnut");
                            doughnutChart2(SDC3VX,"sd3_c3","Type of dairy milk you had","auto");

                            var baseX = processBase(SDC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c3_base").empty().append(htmlB);

                            var span = $('#sd3_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC6,SDC6V,SDC6B,SDC6C,"Simple");
                            customizedArray(SDC6V,SDC6VX,SDC6label,colorPallet69,"Doughnut");
                            pieChart(SDC6VX,"sd3_c6","Type of Packaging","auto");

                            var baseX = processBase(SDC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c6_base").empty().append(htmlB);

                            var span = $('#sd3_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC6V,SDC6label,"sd3_c6TA");

                            extractValues(SDC7,SDC7V,SDC7B,SDC7C,"Simple");
                            customizedArray(SDC7V,SDC7VX,SDC7label,colorPallet68,"Doughnut");
                            pieChart(SDC7VX,"sd3_c7","Type of Packaging","auto");

                            var baseX = processBase(SDC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c7_base").empty().append(htmlB);

                            var span = $('#sd3_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC7V,SDC7label,"sd3_c7TA");

                            extractValues(SDC8,SDC8V,SDC8B,SDC8C,"Simple");
                            var max = (Math.max(...SDC8V)+20);
                            customizedArray(SDC8V,SDC8VX,SDC8label,colorPallet69,"Bar");
                            barChart(SDC8VX,"sd3_c8",SDC8label,max);

                            var baseX = processBase(SDC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c8_base").empty().append(htmlB);

                            var span = $('#sd3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC8V,SDC8label,"sd3_c8TA");

                            extractValues(SDC9,SDC9V,SDC9B,SDC9C,"Simple");
                            var max = (Math.max(...SDC9V)+20);
                            customizedArray(SDC9V,SDC9VX,SDC9label,colorPallet69,"Bar");
                            barChart(SDC9VX,"sd3_c9",SDC9label,max);

                            var baseX = processBase(SDC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c9_base").empty().append(htmlB);

                            var span = $('#sd3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC9V,SDC9label,"sd3_c9TA");

                            extractValues(SDC10,SDC10V,SDC10B,SDC10C,"Simple");
                            customizedArray(SDC10V,SDC10VX,SDC10label,colorPallet68,"Doughnut");
                            pieChart(SDC10VX,"sd3_c10","Way of consumption","auto");

                            var baseX = processBase(SDC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c10_base").empty().append(htmlB);

                            var span = $('#sd3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC10V,SDC10label,"sd3_c10TA");

                            extractValues(SDC11,SDC11V,SDC11B,SDC11C,"Simple");
                            var max = (Math.max(...SDC11V)+20);
                            customizedArray(SDC11V,SDC11VX,SDC11label,colorPallet69,"Bar");
                            columnChart(SDC11VX,"sd3_c11",SDC11label,max);

                            var baseX = processBase(SDC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c11_base").empty().append(htmlB);

                            var span = $('#sd3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC11V,SDC11label,"sd3_c11TA");

                            extractValues(SDC12,SDC12V,SDC12B,SDC12C,"Simple");
                            var max = (Math.max(...SDC12V)+20);
                            customizedArray(SDC12V,SDC12VX,SDC12label,colorPallet69,"Bar");
                            columnChart(SDC12VX,"sd3_c12",SDC12label,max);

                            var baseX = processBase(SDC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c12_base").empty().append(htmlB);

                            var span = $('#sd3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC12V,SDC12label,"sd3_c12TA");

                            extractValues(SDC15,SDC15V,SDC15B,SDC15C,"Simple");
                            SDC15V.forEach(function(e,i,a){
                                $(`#sd3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(SDC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c15_base").empty().append(htmlB);

                            var span = $('#sd3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(SDC15V,SDC15label,"sd3_c15TA");

                            extractValues(SDC16,SDC16V,SDC16B,SDC16C,"Simple");
                            var max = (Math.max(...SDC16V)+20);
                            customizedArray(SDC16V,SDC16VX,SDC16label,colorPallet69,"Bar");
                            barChart(SDC16VX,"sd3_c16",SDC16label,max);

                            var baseX = processBase(SDC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c16_base").empty().append(htmlB);

                            var span = $('#sd3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC17,SDC17V,SDC17B,SDC17C,"Simple");
                            SDC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`sd3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(SDC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c17_base").empty().append(htmlB);

                            var span = $('#sd3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC18,SDC18V,SDC18B,SDC18C,"Simple");
                            var max = (Math.max(...SDC18V)+20);
                            customizedArray(SDC18V,SDC18VX,SDC18label,colorPallet69,"Bar");
                            barChart(SDC18VX,"sd3_c18",SDC18label,max);

                            var baseX = processBase(SDC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c18_base").empty().append(htmlB);

                            var span = $('#sd3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(SDC19,SDC19V,SDC19B,SDC19C,"Simple");
                            var max = (Math.max(...SDC19V)+20);
                            customizedArray(SDC19V,SDC19VX,SDC19label,colorPallet69,"Bar");
                            barChart(SDC19VX,"sd3_c19",SDC19label,max);

                            var baseX = processBase(SDC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c19_base").empty().append(htmlB);

                            var span = $('#sd3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(SDC20,SDC20V,SDC20B,SDC20C,"Simple");
                            SDC20V.forEach(function(e,i,a){
                                $(`#sd3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(SDC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#sd3_c20_base").empty().append(htmlB);

                            var span = $('#sd3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_7, S13_7V, S13_7B, S13_7C, "Simple");
                            var max = (Math.max(...S13_7V)+20);
                            customizedArray(S13_7V,S13_7VX,S13label,colorPallet69,"Bar");
                            barChart(S13_7VX,"sd_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_7B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#sd_3_s13_base").empty().append(htmlB);

                            var span = $('#sd_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            sportsFStatus3 = true;
                            ajaxFlag[1+31] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtyOnethAjax() {
                    $.ajax({
                        url: "api/ajax31.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'choclatecondX':choclatecondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var CLC0 = data['CL_C0'];
                            var CLC1 = data['CL_C1'];
                            var CLC4C = data['CL_C4c'];
                            var CLC7 = data['CL_C7'];
                            var CLC8 = data['CL_C8'];
                            var CLC9 = data['CL_C9'];
                            var CLC10 = data['CL_C10'];
                            var CLC11 = data['CL_C11'];
                            var CLC12 = data['CL_C12'];
                            var CLC15 = data['CL_C15'];
                            var CLC16 = data['CL_C16'];
                            var CLC17 = data['CL_C17'];
                            var CLC18 = data['CL_C18'];
                            var CLC19 = data['CL_C19'];
                            var CLC20 = data['CL_C20'];

                            var S13_11 = data['S13_11'];

                            var CLC0V = [];
                            var CLC0B = [];
                            var CLC0C = [];
                            var CLC0VX = [];

                            var CLC1V = [];
                            var CLC1B = [];
                            var CLC1C = [];
                            var CLC1VX = [];

                            var CLC4CV = [];
                            var CLC4CB = [];
                            var CLC4CC = [];
                            var CLC4CVX = [];

                            var CLC7V = [];
                            var CLC7B = [];
                            var CLC7C = [];
                            var CLC7VX = [];

                            var CLC8V = [];
                            var CLC8B = [];
                            var CLC8C = [];
                            var CLC8VX = [];

                            var CLC9V = [];
                            var CLC9B = [];
                            var CLC9C = [];
                            var CLC9VX = [];

                            var CLC10V = [];
                            var CLC10B = [];
                            var CLC10C = [];
                            var CLC10VX = [];

                            var CLC11V = [];
                            var CLC11B = [];
                            var CLC11C = [];
                            var CLC11VX = [];

                            var CLC12V = [];
                            var CLC12B = [];
                            var CLC12C = [];
                            var CLC12VX = [];

                            var CLC13V = [];
                            var CLC13B = [];
                            var CLC13C = [];
                            var CLC13VX = [];

                            var CLC14V = [];
                            var CLC14B = [];
                            var CLC14C = [];
                            var CLC14VX = [];

                            var CLC15V = [];
                            var CLC15B = [];
                            var CLC15C = [];
                            var CLC15VX = [];

                            var CLC16V = [];
                            var CLC16B = [];
                            var CLC16C = [];
                            var CLC16VX = [];

                            var CLC17V = [];
                            var CLC17B = [];
                            var CLC17C = [];
                            var CLC17VX = [];

                            var CLC18V = [];
                            var CLC18B = [];
                            var CLC18C = [];
                            var CLC18VX = [];

                            var CLC19V = [];
                            var CLC19B = [];
                            var CLC19C = [];
                            var CLC19VX = [];

                            var CLC20V = [];
                            var CLC20B = [];
                            var CLC20C = [];
                            var CLC20VX = [];

                            var S13_11V = [];
                            var S13_11B = [];
                            var S13_11C = [];
                            var S13_11VX = [];

                            if(choclateFStatus1==false)
                            {
                                extractValues(CLC0,CLC0V,CLC0B,CLC0C,"Simple");
                                CLC0V.forEach(function(e,i,a){
                                    $(`#cl1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CLC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });
                                $("#cl1_c0_base").empty().append(htmlB);

                                var span = $('#cl1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            // 
                            
                            extractValues(CLC1,CLC1V,CLC1B,CLC1C,"Simple");
                            customizedArray(CLC1V,CLC1VX,CLC1label,colorPallet68,"Doughnut");
                            doughnutChart2(CLC1VX,"cl1_c1","Type of dairy milk you had","auto");

                            var baseX = processBase(CLC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c1_base").empty().append(htmlB);

                            var span = $('#cl1_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 
                            
                            extractValues(CLC4C,CLC4CV,CLC4CB,CLC4CC,"Simple");
                            customizedArray(CLC4CV,CLC4CVX,CLC4Clabel,colorPallet68,"Doughnut");
                            doughnutChart2(CLC4CVX,"cl1_c4c","Type of dairy milk you had","auto");

                            var baseX = processBase(CLC4CB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c4c_base").empty().append(htmlB);

                            var span = $('#cl1_c4c_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CLC7,CLC7V,CLC7B,CLC7C,"Simple");
                            customizedArray(CLC7V,CLC7VX,CLC7label,colorPallet68,"Doughnut");
                            pieChart(CLC7VX,"cl1_c7","Type of Packaging","auto");

                            var baseX = processBase(CLC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c7_base").empty().append(htmlB);

                            var span = $('#cl1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CLC7V,CLC7label,"cl1_c7TA");

                            extractValues(CLC8,CLC8V,CLC8B,CLC8C,"Simple");
                            var max = (Math.max(...CLC8V)+20);
                            customizedArray(CLC8V,CLC8VX,CLC8label,colorPallet69,"Bar");
                            barChart(CLC8VX,"cl1_c8",CLC8label,max);

                            var baseX = processBase(CLC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c8_base").empty().append(htmlB);

                            var span = $('#cl1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CLC8V,CLC8label,"cl1_c8TA");

                            extractValues(CLC9,CLC9V,CLC9B,CLC9C,"Simple");
                            var max = (Math.max(...CLC9V)+20);
                            customizedArray(CLC9V,CLC9VX,CLC9label,colorPallet69,"Bar");
                            barChart(CLC9VX,"cl1_c9",CLC9label,max);

                            var baseX = processBase(CLC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c9_base").empty().append(htmlB);

                            var span = $('#cl1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CLC9V,CLC9label,"cl1_c9TA");

                            extractValues(CLC10,CLC10V,CLC10B,CLC10C,"Simple");
                            customizedArray(CLC10V,CLC10VX,CLC10label,colorPallet68,"Doughnut");
                            pieChart(CLC10VX,"cl1_c10","Way of consumption","auto");

                            var baseX = processBase(CLC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c10_base").empty().append(htmlB);

                            var span = $('#cl1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CLC10V,CLC10label,"cl1_c10TA");

                            extractValues(CLC11,CLC11V,CLC11B,CLC11C,"Simple");
                            var max = (Math.max(...CLC11V)+20);
                            customizedArray(CLC11V,CLC11VX,CLC11label,colorPallet69,"Bar");
                            columnChart(CLC11VX,"cl1_c11",CLC11label,max);

                            var baseX = processBase(CLC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c11_base").empty().append(htmlB);

                            var span = $('#cl1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CLC11V,CLC11label,"cl1_c11TA");

                            extractValues(CLC12,CLC12V,CLC12B,CLC12C,"Simple");
                            var max = (Math.max(...CLC12V)+20);
                            customizedArray(CLC12V,CLC12VX,CLC12label,colorPallet69,"Bar");
                            columnChart(CLC12VX,"cl1_c12",CLC12label,max);

                            var baseX = processBase(CLC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c12_base").empty().append(htmlB);

                            var span = $('#cl1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CLC12V,CLC12label,"cl1_c12TA");

                            extractValues(CLC15,CLC15V,CLC15B,CLC15C,"Simple");
                            CLC15V.forEach(function(e,i,a){
                                $(`#cl1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CLC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c15_base").empty().append(htmlB);

                            var span = $('#cl1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            //formtable(CLC15V,CLC15label,"cl1_c15TA");

                            extractValues(CLC16,CLC16V,CLC16B,CLC16C,"Simple");
                            var max = (Math.max(...CLC16V)+20);
                            customizedArray(CLC16V,CLC16VX,CLC16label,colorPallet69,"Bar");
                            barChart(CLC16VX,"cl1_c16",CLC16label,max);

                            var baseX = processBase(CLC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c16_base").empty().append(htmlB);

                            var span = $('#cl1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CLC17,CLC17V,CLC17B,CLC17C,"Simple");
                            CLC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`cl1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CLC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c17_base").empty().append(htmlB);

                            var span = $('#cl1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CLC18,CLC18V,CLC18B,CLC18C,"Simple");
                            var max = (Math.max(...CLC18V)+20);
                            customizedArray(CLC18V,CLC18VX,CLC18label,colorPallet69,"Bar");
                            barChart(CLC18VX,"cl1_c18",CLC18label,max);

                            var baseX = processBase(CLC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c18_base").empty().append(htmlB);

                            var span = $('#cl1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CLC19,CLC19V,CLC19B,CLC19C,"Simple");
                            var max = (Math.max(...CLC19V)+20);
                            customizedArray(CLC19V,CLC19VX,CLC19label,colorPallet69,"Bar");
                            barChart(CLC19VX,"cl1_c19",CLC19label,max);

                            var baseX = processBase(CLC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c19_base").empty().append(htmlB);

                            var span = $('#cl1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                            
                            extractValues(CLC20,CLC20V,CLC20B,CLC20C,"Simple");
                            CLC20V.forEach(function(e,i,a){
                                $(`#cl1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CLC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });
                            $("#cl1_c20_base").empty().append(htmlB);

                            var span = $('#cl1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_11, S13_11V, S13_11B, S13_11C, "Simple");
                            var max = (Math.max(...S13_11V)+20);
                            customizedArray(S13_11V,S13_11VX,S13label,colorPallet69,"Bar");
                            barChart(S13_11VX,"cl_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_11B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cl_1_s13_base").empty().append(htmlB);

                            var span = $('#cl_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            choclateFStatus1 = true;
                            ajaxFlag[1+32] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtyTwothAjax() {
                    $.ajax({
                        url: "api/ajax32.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'biscuitcondX':biscuitcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BCC0 = data['BC_C0'];
                            var BCC1 = data['BC_C1'];
                            var BCC2 = data['BC_C2'];
                            var BCC3 = data['BC_C3'];
                            var BCC7 = data['BC_C7'];
                            var BCC8 = data['BC_C8'];
                            var BCC9 = data['BC_C9'];
                            var BCC10 = data['BC_C10'];
                            var BCC11 = data['BC_C11'];
                            var BCC12 = data['BC_C12'];
                            var BCC15 = data['BC_C15'];
                            var BCC16 = data['BC_C16'];
                            var BCC17 = data['BC_C17'];
                            var BCC18 = data['BC_C18'];
                            var BCC19 = data['BC_C19'];
                            var BCC20 = data['BC_C20'];

                            var S13_14 = data['S13_14'];

                            var BCC0V = [];
                            var BCC0B = [];
                            var BCC0C = [];
                            var BCC0VX = [];

                            var BCC1V = [];
                            var BCC1B = [];
                            var BCC1C = [];
                            var BCC1VX = [];

                            var BCC2V = [];
                            var BCC2B = [];
                            var BCC2C = [];
                            var BCC2VX = [];

                            var BCC3V = [];
                            var BCC3B = [];
                            var BCC3C = [];
                            var BCC3VX = [];

                            var BCC7V = [];
                            var BCC7B = [];
                            var BCC7C = [];
                            var BCC7VX = [];

                            var BCC8V = [];
                            var BCC8B = [];
                            var BCC8C = [];
                            var BCC8VX = [];

                            var BCC9V = [];
                            var BCC9B = [];
                            var BCC9C = [];
                            var BCC9VX = [];

                            var BCC10V = [];
                            var BCC10B = [];
                            var BCC10C = [];
                            var BCC10VX = [];

                            var BCC11V = [];
                            var BCC11B = [];
                            var BCC11C = [];
                            var BCC11VX = [];

                            var BCC12V = [];
                            var BCC12B = [];
                            var BCC12C = [];
                            var BCC12VX = [];

                            var BCC13V = [];
                            var BCC13B = [];
                            var BCC13C = [];
                            var BCC13VX = [];

                            var BCC14V = [];
                            var BCC14B = [];
                            var BCC14C = [];
                            var BCC14VX = [];

                            var BCC15V = [];
                            var BCC15B = [];
                            var BCC15C = [];
                            var BCC15VX = [];

                            var BCC16V = [];
                            var BCC16B = [];
                            var BCC16C = [];
                            var BCC16VX = [];

                            var BCC17V = [];
                            var BCC17B = [];
                            var BCC17C = [];
                            var BCC17VX = [];

                            var BCC18V = [];
                            var BCC18B = [];
                            var BCC18C = [];
                            var BCC18VX = [];

                            var BCC19V = [];
                            var BCC19B = [];
                            var BCC19C = [];
                            var BCC19VX = [];

                            var BCC20V = [];
                            var BCC20B = [];
                            var BCC20C = [];
                            var BCC20VX = [];

                            var S13_14V = [];
                            var S13_14B = [];
                            var S13_14C = [];
                            var S13_14VX = [];

                            if(biscuitFStatus1==false)
                            {
                                extractValues(BCC0,BCC0V,BCC0B,BCC0C,"Simple");
                                BCC0V.forEach(function(e,i,a){
                                    $(`#bc1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BCC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bc1_c0_base").empty().append(htmlB);

                                var span = $('#bc1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BCC1,BCC1V,BCC1B,BCC1C,"Simple");
                            customizedArray(BCC1V,BCC1VX,BCC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(BCC1VX,"bc1_c1","Category Consumed",290);

                            var baseX = processBase(BCC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c1_base").empty().append(htmlB);

                            var span = $('#bc1_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC2,BCC2V,BCC2B,BCC2C,"Simple");
                            customizedArray(BCC2V,BCC2VX,BCC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BCC2VX,"bc1_c2","Type of protein","auto");

                            var baseX = processBase(BCC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c2_base").empty().append(htmlB);

                            var span = $('#bc1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC3,BCC3V,BCC3B,BCC3C,"Simple");
                            var max = (Math.max(...BCC3V)+20);
                            customizedArray(BCC3V,BCC3VX,BCC3label,colorPallet69,"Bar");
                            barChart(BCC3VX,"bc1_c3",BCC3label,max);

                            var baseX = processBase(BCC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c3_base").empty().append(htmlB);

                            var span = $('#bc1_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC7,BCC7V,BCC7B,BCC7C,"Simple");
                            customizedArray(BCC7V,BCC7VX,BCC7label,colorPallet68,"Doughnut");
                            pieChart(BCC7VX,"bc1_c7","Type of Packaging","auto");

                            var baseX = processBase(BCC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c7_base").empty().append(htmlB);

                            var span = $('#bc1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC8,BCC8V,BCC8B,BCC8C,"Simple");
                            var max = (Math.max(...BCC8V)+20);
                            customizedArray(BCC8V,BCC8VX,BCC8label,colorPallet69,"Bar");
                            barChart(BCC8VX,"bc1_c8",BCC8label,max);

                            var baseX = processBase(BCC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c8_base").empty().append(htmlB);

                            var span = $('#bc1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC9,BCC9V,BCC9B,BCC9C,"Simple");
                            var max = (Math.max(...BCC9V)+20);
                            customizedArray(BCC9V,BCC9VX,BCC9label,colorPallet69,"Bar");
                            barChart(BCC9VX,"bc1_c9",BCC9label,max);

                            var baseX = processBase(BCC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c9_base").empty().append(htmlB);

                            var span = $('#bc1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC10,BCC10V,BCC10B,BCC10C,"Simple");
                            customizedArray(BCC10V,BCC10VX,BCC10label,colorPallet68,"Doughnut");
                            pieChart(BCC10VX,"bc1_c10","Way of consumption","auto");

                            var baseX = processBase(BCC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c10_base").empty().append(htmlB);

                            var span = $('#bc1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC11,BCC11V,BCC11B,BCC11C,"Simple");
                            var max = (Math.max(...BCC11V)+20);
                            customizedArray(BCC11V,BCC11VX,BCC11label,colorPallet69,"Bar");
                            columnChart(BCC11VX,"bc1_c11",BCC11label,max);

                            var baseX = processBase(BCC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c11_base").empty().append(htmlB);

                            var span = $('#bc1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC12,BCC12V,BCC12B,BCC12C,"Simple");
                            var max = (Math.max(...BCC12V)+20);
                            customizedArray(BCC12V,BCC12VX,BCC12label,colorPallet69,"Bar");
                            columnChart(BCC12VX,"bc1_c12",BCC12label,max);

                            var baseX = processBase(BCC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c12_base").empty().append(htmlB);

                            var span = $('#bc1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC15,BCC15V,BCC15B,BCC15C,"Simple");
                            BCC15V.forEach(function(e,i,a){
                                $(`#bc1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BCC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c15_base").empty().append(htmlB);

                            var span = $('#bc1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC16,BCC16V,BCC16B,BCC16C,"Simple");
                            var max = (Math.max(...BCC16V)+20);
                            customizedArray(BCC16V,BCC16VX,BCC16label,colorPallet69,"Bar");
                            barChart(BCC16VX,"bc1_c16",BCC16label,max);

                            var baseX = processBase(BCC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c16_base").empty().append(htmlB);

                            var span = $('#bc1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC17,BCC17V,BCC17B,BCC17C,"Simple");
                            BCC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bc1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BCC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c17_base").empty().append(htmlB);

                            var span = $('#bc1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC18,BCC18V,BCC18B,BCC18C,"Simple");
                            var max = (Math.max(...BCC18V)+20);
                            customizedArray(BCC18V,BCC18VX,BCC18label,colorPallet69,"Bar");
                            barChart(BCC18VX,"bc1_c18",BCC18label,max);

                            var baseX = processBase(BCC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c18_base").empty().append(htmlB);

                            var span = $('#bc1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC19,BCC19V,BCC19B,BCC19C,"Simple");
                            var max = (Math.max(...BCC19V)+20);
                            customizedArray(BCC19V,BCC19VX,BCC19label,colorPallet69,"Bar");
                            barChart(BCC19VX,"bc1_c19",BCC19label,max);

                            var baseX = processBase(BCC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c19_base").empty().append(htmlB);

                            var span = $('#bc1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC20,BCC20V,BCC20B,BCC20C,"Simple");
                            BCC20V.forEach(function(e,i,a){
                                $(`#bc1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BCC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc1_c20_base").empty().append(htmlB);

                            var span = $('#bc1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_14, S13_14V, S13_14B, S13_14C, "Simple");
                            var max = (Math.max(...S13_14V)+20);
                            customizedArray(S13_14V,S13_14VX,S13label,colorPallet69,"Bar");
                            barChart(S13_14VX,"bc_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_14B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc_1_s13_base").empty().append(htmlB);

                            var span = $('#bc_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            
                        },
                        complete: function (data) {
                            biscuitFStatus1 = true;
                            ajaxFlag[1+33] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtyThreethAjax() {
                    $.ajax({
                        url: "api/ajax33.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'biscuitcondX':biscuitcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BCC0 = data['BC_C0'];
                            var BCC1 = data['BC_C1'];
                            var BCC2 = data['BC_C2'];
                            var BCC3 = data['BC_C3'];
                            var BCC7 = data['BC_C7'];
                            var BCC8 = data['BC_C8'];
                            var BCC9 = data['BC_C9'];
                            var BCC10 = data['BC_C10'];
                            var BCC11 = data['BC_C11'];
                            var BCC12 = data['BC_C12'];
                            var BCC15 = data['BC_C15'];
                            var BCC16 = data['BC_C16'];
                            var BCC17 = data['BC_C17'];
                            var BCC18 = data['BC_C18'];
                            var BCC19 = data['BC_C19'];
                            var BCC20 = data['BC_C20'];

                            var S13_14 = data['S13_14'];

                            var BCC0V = [];
                            var BCC0B = [];
                            var BCC0C = [];
                            var BCC0VX = [];

                            var BCC1V = [];
                            var BCC1B = [];
                            var BCC1C = [];
                            var BCC1VX = [];

                            var BCC2V = [];
                            var BCC2B = [];
                            var BCC2C = [];
                            var BCC2VX = [];

                            var BCC3V = [];
                            var BCC3B = [];
                            var BCC3C = [];
                            var BCC3VX = [];

                            var BCC7V = [];
                            var BCC7B = [];
                            var BCC7C = [];
                            var BCC7VX = [];

                            var BCC8V = [];
                            var BCC8B = [];
                            var BCC8C = [];
                            var BCC8VX = [];

                            var BCC9V = [];
                            var BCC9B = [];
                            var BCC9C = [];
                            var BCC9VX = [];

                            var BCC10V = [];
                            var BCC10B = [];
                            var BCC10C = [];
                            var BCC10VX = [];

                            var BCC11V = [];
                            var BCC11B = [];
                            var BCC11C = [];
                            var BCC11VX = [];

                            var BCC12V = [];
                            var BCC12B = [];
                            var BCC12C = [];
                            var BCC12VX = [];

                            var BCC13V = [];
                            var BCC13B = [];
                            var BCC13C = [];
                            var BCC13VX = [];

                            var BCC14V = [];
                            var BCC14B = [];
                            var BCC14C = [];
                            var BCC14VX = [];

                            var BCC15V = [];
                            var BCC15B = [];
                            var BCC15C = [];
                            var BCC15VX = [];

                            var BCC16V = [];
                            var BCC16B = [];
                            var BCC16C = [];
                            var BCC16VX = [];

                            var BCC17V = [];
                            var BCC17B = [];
                            var BCC17C = [];
                            var BCC17VX = [];

                            var BCC18V = [];
                            var BCC18B = [];
                            var BCC18C = [];
                            var BCC18VX = [];

                            var BCC19V = [];
                            var BCC19B = [];
                            var BCC19C = [];
                            var BCC19VX = [];

                            var BCC20V = [];
                            var BCC20B = [];
                            var BCC20C = [];
                            var BCC20VX = [];

                            var S13_14V = [];
                            var S13_14B = [];
                            var S13_14C = [];
                            var S13_14VX = [];

                            if(biscuitFStatus2==false)
                            {
                                extractValues(BCC0,BCC0V,BCC0B,BCC0C,"Simple");
                                BCC0V.forEach(function(e,i,a){
                                    $(`#bc2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BCC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bc2_c0_base").empty().append(htmlB);

                                var span = $('#bc2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BCC1,BCC1V,BCC1B,BCC1C,"Simple");
                            customizedArray(BCC1V,BCC1VX,BCC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(BCC1VX,"bc2_c1","Category Consumed",290);

                            var baseX = processBase(BCC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c1_base").empty().append(htmlB);

                            var span = $('#bc2_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC2,BCC2V,BCC2B,BCC2C,"Simple");
                            customizedArray(BCC2V,BCC2VX,BCC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BCC2VX,"bc2_c2","Type of protein","auto");

                            var baseX = processBase(BCC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c2_base").empty().append(htmlB);

                            var span = $('#bc2_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC3,BCC3V,BCC3B,BCC3C,"Simple");
                            var max = (Math.max(...BCC3V)+20);
                            customizedArray(BCC3V,BCC3VX,BCC3label,colorPallet69,"Bar");
                            barChart(BCC3VX,"bc2_c3",BCC3label,max);

                            var baseX = processBase(BCC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c3_base").empty().append(htmlB);

                            var span = $('#bc2_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC7,BCC7V,BCC7B,BCC7C,"Simple");
                            customizedArray(BCC7V,BCC7VX,BCC7label,colorPallet68,"Doughnut");
                            pieChart(BCC7VX,"bc2_c7","Type of Packaging","auto");

                            var baseX = processBase(BCC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c7_base").empty().append(htmlB);

                            var span = $('#bc2_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC8,BCC8V,BCC8B,BCC8C,"Simple");
                            var max = (Math.max(...BCC8V)+20);
                            customizedArray(BCC8V,BCC8VX,BCC8label,colorPallet69,"Bar");
                            barChart(BCC8VX,"bc2_c8",BCC8label,max);

                            var baseX = processBase(BCC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c8_base").empty().append(htmlB);

                            var span = $('#bc2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC9,BCC9V,BCC9B,BCC9C,"Simple");
                            var max = (Math.max(...BCC9V)+20);
                            customizedArray(BCC9V,BCC9VX,BCC9label,colorPallet69,"Bar");
                            barChart(BCC9VX,"bc2_c9",BCC9label,max);

                            var baseX = processBase(BCC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c9_base").empty().append(htmlB);

                            var span = $('#bc2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC10,BCC10V,BCC10B,BCC10C,"Simple");
                            customizedArray(BCC10V,BCC10VX,BCC10label,colorPallet68,"Doughnut");
                            pieChart(BCC10VX,"bc2_c10","Way of consumption","auto");

                            var baseX = processBase(BCC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c10_base").empty().append(htmlB);

                            var span = $('#bc2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC11,BCC11V,BCC11B,BCC11C,"Simple");
                            var max = (Math.max(...BCC11V)+20);
                            customizedArray(BCC11V,BCC11VX,BCC11label,colorPallet69,"Bar");
                            columnChart(BCC11VX,"bc2_c11",BCC11label,max);

                            var baseX = processBase(BCC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c11_base").empty().append(htmlB);

                            var span = $('#bc2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC12,BCC12V,BCC12B,BCC12C,"Simple");
                            var max = (Math.max(...BCC12V)+20);
                            customizedArray(BCC12V,BCC12VX,BCC12label,colorPallet69,"Bar");
                            columnChart(BCC12VX,"bc2_c12",BCC12label,max);

                            var baseX = processBase(BCC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c12_base").empty().append(htmlB);

                            var span = $('#bc2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC15,BCC15V,BCC15B,BCC15C,"Simple");
                            BCC15V.forEach(function(e,i,a){
                                $(`#bc2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BCC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c15_base").empty().append(htmlB);

                            var span = $('#bc2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC16,BCC16V,BCC16B,BCC16C,"Simple");
                            var max = (Math.max(...BCC16V)+20);
                            customizedArray(BCC16V,BCC16VX,BCC16label,colorPallet69,"Bar");
                            barChart(BCC16VX,"bc2_c16",BCC16label,max);

                            var baseX = processBase(BCC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c16_base").empty().append(htmlB);

                            var span = $('#bc2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC17,BCC17V,BCC17B,BCC17C,"Simple");
                            BCC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bc2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BCC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c17_base").empty().append(htmlB);

                            var span = $('#bc2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC18,BCC18V,BCC18B,BCC18C,"Simple");
                            var max = (Math.max(...BCC18V)+20);
                            customizedArray(BCC18V,BCC18VX,BCC18label,colorPallet69,"Bar");
                            barChart(BCC18VX,"bc2_c18",BCC18label,max);

                            var baseX = processBase(BCC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c18_base").empty().append(htmlB);

                            var span = $('#bc2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC19,BCC19V,BCC19B,BCC19C,"Simple");
                            var max = (Math.max(...BCC19V)+20);
                            customizedArray(BCC19V,BCC19VX,BCC19label,colorPallet69,"Bar");
                            barChart(BCC19VX,"bc2_c19",BCC19label,max);

                            var baseX = processBase(BCC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c19_base").empty().append(htmlB);

                            var span = $('#bc2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC20,BCC20V,BCC20B,BCC20C,"Simple");
                            BCC20V.forEach(function(e,i,a){
                                $(`#bc2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BCC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc2_c20_base").empty().append(htmlB);

                            var span = $('#bc2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_14, S13_14V, S13_14B, S13_14C, "Simple");
                            var max = (Math.max(...S13_14V)+20);
                            customizedArray(S13_14V,S13_14VX,S13label,colorPallet69,"Bar");
                            barChart(S13_14VX,"bc_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_14B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc_2_s13_base").empty().append(htmlB);

                            var span = $('#bc_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            biscuitFStatus2 = true;
                            ajaxFlag[1+34] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtyFourthAjax() {
                    $.ajax({
                        url: "api/ajax34.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'biscuitcondX':biscuitcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BCC0 = data['BC_C0'];
                            var BCC1 = data['BC_C1'];
                            var BCC2 = data['BC_C2'];
                            var BCC3 = data['BC_C3'];
                            var BCC7 = data['BC_C7'];
                            var BCC8 = data['BC_C8'];
                            var BCC9 = data['BC_C9'];
                            var BCC10 = data['BC_C10'];
                            var BCC11 = data['BC_C11'];
                            var BCC12 = data['BC_C12'];
                            var BCC15 = data['BC_C15'];
                            var BCC16 = data['BC_C16'];
                            var BCC17 = data['BC_C17'];
                            var BCC18 = data['BC_C18'];
                            var BCC19 = data['BC_C19'];
                            var BCC20 = data['BC_C20'];

                            var S13_14 = data['S13_14'];

                            var BCC0V = [];
                            var BCC0B = [];
                            var BCC0C = [];
                            var BCC0VX = [];

                            var BCC1V = [];
                            var BCC1B = [];
                            var BCC1C = [];
                            var BCC1VX = [];

                            var BCC2V = [];
                            var BCC2B = [];
                            var BCC2C = [];
                            var BCC2VX = [];

                            var BCC3V = [];
                            var BCC3B = [];
                            var BCC3C = [];
                            var BCC3VX = [];

                            var BCC7V = [];
                            var BCC7B = [];
                            var BCC7C = [];
                            var BCC7VX = [];

                            var BCC8V = [];
                            var BCC8B = [];
                            var BCC8C = [];
                            var BCC8VX = [];

                            var BCC9V = [];
                            var BCC9B = [];
                            var BCC9C = [];
                            var BCC9VX = [];

                            var BCC10V = [];
                            var BCC10B = [];
                            var BCC10C = [];
                            var BCC10VX = [];

                            var BCC11V = [];
                            var BCC11B = [];
                            var BCC11C = [];
                            var BCC11VX = [];

                            var BCC12V = [];
                            var BCC12B = [];
                            var BCC12C = [];
                            var BCC12VX = [];

                            var BCC13V = [];
                            var BCC13B = [];
                            var BCC13C = [];
                            var BCC13VX = [];

                            var BCC14V = [];
                            var BCC14B = [];
                            var BCC14C = [];
                            var BCC14VX = [];

                            var BCC15V = [];
                            var BCC15B = [];
                            var BCC15C = [];
                            var BCC15VX = [];

                            var BCC16V = [];
                            var BCC16B = [];
                            var BCC16C = [];
                            var BCC16VX = [];

                            var BCC17V = [];
                            var BCC17B = [];
                            var BCC17C = [];
                            var BCC17VX = [];

                            var BCC18V = [];
                            var BCC18B = [];
                            var BCC18C = [];
                            var BCC18VX = [];

                            var BCC19V = [];
                            var BCC19B = [];
                            var BCC19C = [];
                            var BCC19VX = [];

                            var BCC20V = [];
                            var BCC20B = [];
                            var BCC20C = [];
                            var BCC20VX = [];

                            var S13_14V = [];
                            var S13_14B = [];
                            var S13_14C = [];
                            var S13_14VX = [];

                            if(biscuitFStatus3==false)
                            {
                                extractValues(BCC0,BCC0V,BCC0B,BCC0C,"Simple");
                                BCC0V.forEach(function(e,i,a){
                                    $(`#bc3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BCC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bc3_c0_base").empty().append(htmlB);

                                var span = $('#bc3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BCC1,BCC1V,BCC1B,BCC1C,"Simple");
                            customizedArray(BCC1V,BCC1VX,BCC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(BCC1VX,"bc3_c1","Category Consumed",290);

                            var baseX = processBase(BCC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c1_base").empty().append(htmlB);

                            var span = $('#bc3_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC2,BCC2V,BCC2B,BCC2C,"Simple");
                            customizedArray(BCC2V,BCC2VX,BCC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BCC2VX,"bc3_c2","Type of protein","auto");

                            var baseX = processBase(BCC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c2_base").empty().append(htmlB);

                            var span = $('#bc3_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC3,BCC3V,BCC3B,BCC3C,"Simple");
                            var max = (Math.max(...BCC3V)+20);
                            customizedArray(BCC3V,BCC3VX,BCC3label,colorPallet69,"Bar");
                            barChart(BCC3VX,"bc3_c3",BCC3label,max);

                            var baseX = processBase(BCC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c3_base").empty().append(htmlB);

                            var span = $('#bc3_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC7,BCC7V,BCC7B,BCC7C,"Simple");
                            customizedArray(BCC7V,BCC7VX,BCC7label,colorPallet68,"Doughnut");
                            pieChart(BCC7VX,"bc3_c7","Type of Packaging","auto");

                            var baseX = processBase(BCC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c7_base").empty().append(htmlB);

                            var span = $('#bc3_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC8,BCC8V,BCC8B,BCC8C,"Simple");
                            var max = (Math.max(...BCC8V)+20);
                            customizedArray(BCC8V,BCC8VX,BCC8label,colorPallet69,"Bar");
                            barChart(BCC8VX,"bc3_c8",BCC8label,max);

                            var baseX = processBase(BCC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c8_base").empty().append(htmlB);

                            var span = $('#bc3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC9,BCC9V,BCC9B,BCC9C,"Simple");
                            var max = (Math.max(...BCC9V)+20);
                            customizedArray(BCC9V,BCC9VX,BCC9label,colorPallet69,"Bar");
                            barChart(BCC9VX,"bc3_c9",BCC9label,max);

                            var baseX = processBase(BCC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c9_base").empty().append(htmlB);

                            var span = $('#bc3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC10,BCC10V,BCC10B,BCC10C,"Simple");
                            customizedArray(BCC10V,BCC10VX,BCC10label,colorPallet68,"Doughnut");
                            pieChart(BCC10VX,"bc3_c10","Way of consumption","auto");

                            var baseX = processBase(BCC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c10_base").empty().append(htmlB);

                            var span = $('#bc3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC11,BCC11V,BCC11B,BCC11C,"Simple");
                            var max = (Math.max(...BCC11V)+20);
                            customizedArray(BCC11V,BCC11VX,BCC11label,colorPallet69,"Bar");
                            columnChart(BCC11VX,"bc3_c11",BCC11label,max);

                            var baseX = processBase(BCC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c11_base").empty().append(htmlB);

                            var span = $('#bc3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC12,BCC12V,BCC12B,BCC12C,"Simple");
                            var max = (Math.max(...BCC12V)+20);
                            customizedArray(BCC12V,BCC12VX,BCC12label,colorPallet69,"Bar");
                            columnChart(BCC12VX,"bc3_c12",BCC12label,max);

                            var baseX = processBase(BCC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c12_base").empty().append(htmlB);

                            var span = $('#bc3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC15,BCC15V,BCC15B,BCC15C,"Simple");
                            BCC15V.forEach(function(e,i,a){
                                $(`#bc3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BCC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c15_base").empty().append(htmlB);

                            var span = $('#bc3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC16,BCC16V,BCC16B,BCC16C,"Simple");
                            var max = (Math.max(...BCC16V)+20);
                            customizedArray(BCC16V,BCC16VX,BCC16label,colorPallet69,"Bar");
                            barChart(BCC16VX,"bc3_c16",BCC16label,max);

                            var baseX = processBase(BCC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c16_base").empty().append(htmlB);

                            var span = $('#bc3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC17,BCC17V,BCC17B,BCC17C,"Simple");
                            BCC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bc3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BCC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c17_base").empty().append(htmlB);

                            var span = $('#bc3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC18,BCC18V,BCC18B,BCC18C,"Simple");
                            var max = (Math.max(...BCC18V)+20);
                            customizedArray(BCC18V,BCC18VX,BCC18label,colorPallet69,"Bar");
                            barChart(BCC18VX,"bc3_c18",BCC18label,max);

                            var baseX = processBase(BCC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c18_base").empty().append(htmlB);

                            var span = $('#bc3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC19,BCC19V,BCC19B,BCC19C,"Simple");
                            var max = (Math.max(...BCC19V)+20);
                            customizedArray(BCC19V,BCC19VX,BCC19label,colorPallet69,"Bar");
                            barChart(BCC19VX,"bc3_c19",BCC19label,max);

                            var baseX = processBase(BCC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c19_base").empty().append(htmlB);

                            var span = $('#bc3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC20,BCC20V,BCC20B,BCC20C,"Simple");
                            BCC20V.forEach(function(e,i,a){
                                $(`#bc3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BCC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc3_c20_base").empty().append(htmlB);

                            var span = $('#bc3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_14, S13_14V, S13_14B, S13_14C, "Simple");
                            var max = (Math.max(...S13_14V)+20);
                            customizedArray(S13_14V,S13_14VX,S13label,colorPallet69,"Bar");
                            barChart(S13_14VX,"bc_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_14B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc_3_s13_base").empty().append(htmlB);

                            var span = $('#bc_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            biscuitFStatus3 = true;
                            ajaxFlag[1+35] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtyFivethAjax() {
                    $.ajax({
                        url: "api/ajax35.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'biscuitcondX':biscuitcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BCC0 = data['BC_C0'];
                            var BCC1 = data['BC_C1'];
                            var BCC2 = data['BC_C2'];
                            var BCC3 = data['BC_C3'];
                            var BCC7 = data['BC_C7'];
                            var BCC8 = data['BC_C8'];
                            var BCC9 = data['BC_C9'];
                            var BCC10 = data['BC_C10'];
                            var BCC11 = data['BC_C11'];
                            var BCC12 = data['BC_C12'];
                            var BCC15 = data['BC_C15'];
                            var BCC16 = data['BC_C16'];
                            var BCC17 = data['BC_C17'];
                            var BCC18 = data['BC_C18'];
                            var BCC19 = data['BC_C19'];
                            var BCC20 = data['BC_C20'];

                            var S13_14 = data['S13_14'];

                            var BCC0V = [];
                            var BCC0B = [];
                            var BCC0C = [];
                            var BCC0VX = [];

                            var BCC1V = [];
                            var BCC1B = [];
                            var BCC1C = [];
                            var BCC1VX = [];

                            var BCC2V = [];
                            var BCC2B = [];
                            var BCC2C = [];
                            var BCC2VX = [];

                            var BCC3V = [];
                            var BCC3B = [];
                            var BCC3C = [];
                            var BCC3VX = [];

                            var BCC7V = [];
                            var BCC7B = [];
                            var BCC7C = [];
                            var BCC7VX = [];

                            var BCC8V = [];
                            var BCC8B = [];
                            var BCC8C = [];
                            var BCC8VX = [];

                            var BCC9V = [];
                            var BCC9B = [];
                            var BCC9C = [];
                            var BCC9VX = [];

                            var BCC10V = [];
                            var BCC10B = [];
                            var BCC10C = [];
                            var BCC10VX = [];

                            var BCC11V = [];
                            var BCC11B = [];
                            var BCC11C = [];
                            var BCC11VX = [];

                            var BCC12V = [];
                            var BCC12B = [];
                            var BCC12C = [];
                            var BCC12VX = [];

                            var BCC13V = [];
                            var BCC13B = [];
                            var BCC13C = [];
                            var BCC13VX = [];

                            var BCC14V = [];
                            var BCC14B = [];
                            var BCC14C = [];
                            var BCC14VX = [];

                            var BCC15V = [];
                            var BCC15B = [];
                            var BCC15C = [];
                            var BCC15VX = [];

                            var BCC16V = [];
                            var BCC16B = [];
                            var BCC16C = [];
                            var BCC16VX = [];

                            var BCC17V = [];
                            var BCC17B = [];
                            var BCC17C = [];
                            var BCC17VX = [];

                            var BCC18V = [];
                            var BCC18B = [];
                            var BCC18C = [];
                            var BCC18VX = [];

                            var BCC19V = [];
                            var BCC19B = [];
                            var BCC19C = [];
                            var BCC19VX = [];

                            var BCC20V = [];
                            var BCC20B = [];
                            var BCC20C = [];
                            var BCC20VX = [];

                            var S13_14V = [];
                            var S13_14B = [];
                            var S13_14C = [];
                            var S13_14VX = [];

                            if(biscuitFStatus4==false)
                            {
                                extractValues(BCC0,BCC0V,BCC0B,BCC0C,"Simple");
                                BCC0V.forEach(function(e,i,a){
                                    $(`#bc4_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BCC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bc4_c0_base").empty().append(htmlB);

                                var span = $('#bc4_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BCC1,BCC1V,BCC1B,BCC1C,"Simple");
                            customizedArray(BCC1V,BCC1VX,BCC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(BCC1VX,"bc4_c1","Category Consumed",290);

                            var baseX = processBase(BCC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c1_base").empty().append(htmlB);

                            var span = $('#bc4_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC2,BCC2V,BCC2B,BCC2C,"Simple");
                            customizedArray(BCC2V,BCC2VX,BCC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BCC2VX,"bc4_c2","Type of protein","auto");

                            var baseX = processBase(BCC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c2_base").empty().append(htmlB);

                            var span = $('#bc4_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC3,BCC3V,BCC3B,BCC3C,"Simple");
                            var max = (Math.max(...BCC3V)+20);
                            customizedArray(BCC3V,BCC3VX,BCC3label,colorPallet69,"Bar");
                            barChart(BCC3VX,"bc4_c3",BCC3label,max);

                            var baseX = processBase(BCC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c3_base").empty().append(htmlB);

                            var span = $('#bc4_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC7,BCC7V,BCC7B,BCC7C,"Simple");
                            customizedArray(BCC7V,BCC7VX,BCC7label,colorPallet68,"Doughnut");
                            pieChart(BCC7VX,"bc4_c7","Type of Packaging","auto");

                            var baseX = processBase(BCC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c7_base").empty().append(htmlB);

                            var span = $('#bc4_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC8,BCC8V,BCC8B,BCC8C,"Simple");
                            var max = (Math.max(...BCC8V)+20);
                            customizedArray(BCC8V,BCC8VX,BCC8label,colorPallet69,"Bar");
                            barChart(BCC8VX,"bc4_c8",BCC8label,max);

                            var baseX = processBase(BCC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c8_base").empty().append(htmlB);

                            var span = $('#bc4_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC9,BCC9V,BCC9B,BCC9C,"Simple");
                            var max = (Math.max(...BCC9V)+20);
                            customizedArray(BCC9V,BCC9VX,BCC9label,colorPallet69,"Bar");
                            barChart(BCC9VX,"bc4_c9",BCC9label,max);

                            var baseX = processBase(BCC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c9_base").empty().append(htmlB);

                            var span = $('#bc4_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC10,BCC10V,BCC10B,BCC10C,"Simple");
                            customizedArray(BCC10V,BCC10VX,BCC10label,colorPallet68,"Doughnut");
                            pieChart(BCC10VX,"bc4_c10","Way of consumption","auto");

                            var baseX = processBase(BCC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c10_base").empty().append(htmlB);

                            var span = $('#bc4_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC11,BCC11V,BCC11B,BCC11C,"Simple");
                            var max = (Math.max(...BCC11V)+20);
                            customizedArray(BCC11V,BCC11VX,BCC11label,colorPallet69,"Bar");
                            columnChart(BCC11VX,"bc4_c11",BCC11label,max);

                            var baseX = processBase(BCC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c11_base").empty().append(htmlB);

                            var span = $('#bc4_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC12,BCC12V,BCC12B,BCC12C,"Simple");
                            var max = (Math.max(...BCC12V)+20);
                            customizedArray(BCC12V,BCC12VX,BCC12label,colorPallet69,"Bar");
                            columnChart(BCC12VX,"bc4_c12",BCC12label,max);

                            var baseX = processBase(BCC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c12_base").empty().append(htmlB);

                            var span = $('#bc4_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC15,BCC15V,BCC15B,BCC15C,"Simple");
                            BCC15V.forEach(function(e,i,a){
                                $(`#bc4_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BCC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c15_base").empty().append(htmlB);

                            var span = $('#bc4_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC16,BCC16V,BCC16B,BCC16C,"Simple");
                            var max = (Math.max(...BCC16V)+20);
                            customizedArray(BCC16V,BCC16VX,BCC16label,colorPallet69,"Bar");
                            barChart(BCC16VX,"bc4_c16",BCC16label,max);

                            var baseX = processBase(BCC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c16_base").empty().append(htmlB);

                            var span = $('#bc4_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC17,BCC17V,BCC17B,BCC17C,"Simple");
                            BCC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bc4_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BCC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c17_base").empty().append(htmlB);

                            var span = $('#bc4_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC18,BCC18V,BCC18B,BCC18C,"Simple");
                            var max = (Math.max(...BCC18V)+20);
                            customizedArray(BCC18V,BCC18VX,BCC18label,colorPallet69,"Bar");
                            barChart(BCC18VX,"bc4_c18",BCC18label,max);

                            var baseX = processBase(BCC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c18_base").empty().append(htmlB);

                            var span = $('#bc4_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC19,BCC19V,BCC19B,BCC19C,"Simple");
                            var max = (Math.max(...BCC19V)+20);
                            customizedArray(BCC19V,BCC19VX,BCC19label,colorPallet69,"Bar");
                            barChart(BCC19VX,"bc4_c19",BCC19label,max);

                            var baseX = processBase(BCC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c19_base").empty().append(htmlB);

                            var span = $('#bc4_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BCC20,BCC20V,BCC20B,BCC20C,"Simple");
                            BCC20V.forEach(function(e,i,a){
                                $(`#bc4_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BCC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc4_c20_base").empty().append(htmlB);

                            var span = $('#bc4_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_14, S13_14V, S13_14B, S13_14C, "Simple");
                            var max = (Math.max(...S13_14V)+20);
                            customizedArray(S13_14V,S13_14VX,S13label,colorPallet69,"Bar");
                            barChart(S13_14VX,"bc_4_s13",S13label,max);
                            
                            var baseX = processBase(S13_14B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bc_4_s13_base").empty().append(htmlB);

                            var span = $('#bc_4_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            biscuitFStatus4 = true;
                            ajaxFlag[1+36] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtySixthAjax() {
                    ////////debugger;
                    //console.log("chipscondX");
                    //console.log(chipscondX)
                    $.ajax({
                        url: "api/ajax36.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'chipscondX':chipscondX
                        },
                        success: function(response) {
                            var data  = JSON.parse(response);
                            //console.log("ajax36");
                            //console.log(data);
                            var CCC0 = data['CC_C0'];
                            var CCC1 = data['CC_C1'];
                            var CCC2 = data['CC_C2'];
                            var CCC7 = data['CC_C7'];
                            var CCC8 = data['CC_C8'];
                            var CCC9 = data['CC_C9'];
                            var CCC10 = data['CC_C10'];
                            var CCC11 = data['CC_C11'];
                            var CCC12 = data['CC_C12'];
                            var CCC15 = data['CC_C15'];
                            var CCC16 = data['CC_C16'];
                            var CCC17 = data['CC_C17'];
                            var CCC18 = data['CC_C18'];
                            var CCC19 = data['CC_C19'];
                            var CCC20 = data['CC_C20'];

                            var CCC0V = [];
                            var CCC0B = [];
                            var CCC0C = [];
                            var CCC0VX = [];

                            var CCC1V = [];
                            var CCC1B = [];
                            var CCC1C = [];
                            var CCC1VX = [];

                            var CCC2V = [];
                            var CCC2B = [];
                            var CCC2C = [];
                            var CCC2VX = [];

                            var CCC7V = [];
                            var CCC7B = [];
                            var CCC7C = [];
                            var CCC7VX = [];

                            var CCC8V = [];
                            var CCC8B = [];
                            var CCC8C = [];
                            var CCC8VX = [];

                            var CCC9V = [];
                            var CCC9B = [];
                            var CCC9C = [];
                            var CCC9VX = [];

                            var CCC10V = [];
                            var CCC10B = [];
                            var CCC10C = [];
                            var CCC10VX = [];

                            var CCC11V = [];
                            var CCC11B = [];
                            var CCC11C = [];
                            var CCC11VX = [];

                            var CCC12V = [];
                            var CCC12B = [];
                            var CCC12C = [];
                            var CCC12VX = [];

                            var CCC13V = [];
                            var CCC13B = [];
                            var CCC13C = [];
                            var CCC13VX = [];

                            var CCC14V = [];
                            var CCC14B = [];
                            var CCC14C = [];
                            var CCC14VX = [];

                            var CCC15V = [];
                            var CCC15B = [];
                            var CCC15C = [];
                            var CCC15VX = [];

                            var CCC16V = [];
                            var CCC16B = [];
                            var CCC16C = [];
                            var CCC16VX = [];

                            var CCC17V = [];
                            var CCC17B = [];
                            var CCC17C = [];
                            var CCC17VX = [];

                            var CCC18V = [];
                            var CCC18B = [];
                            var CCC18C = [];
                            var CCC18VX = [];

                            var CCC19V = [];
                            var CCC19B = [];
                            var CCC19C = [];
                            var CCC19VX = [];

                            var CCC20V = [];
                            var CCC20B = [];
                            var CCC20C = [];
                            var CCC20VX = [];

                            var S13_15V = [];
                            var S13_15B = [];
                            var S13_15C = [];
                            var S13_15VX = [];

                            var S13_15 = data['S13_15'];

                            if(chipsFStatus1==false)
                            {
                                extractValues(CCC0,CCC0V,CCC0B,CCC0C,"Simple");
                                CCC0V.forEach(function(e,i,a){
                                    $(`#cc1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CCC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#cc1_c0_base").empty().append(htmlB);

                                var span = $('#cc1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            //console.log("CCC1");
                            //console.log(CCC1);
                            extractValues(CCC1,CCC1V,CCC1B,CCC1C,"Simple");
                            //console.log("CCC1V");
                            //console.log(CCC1V);
                            customizedArray(CCC1V,CCC1VX,CCC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(CCC1VX,"cc1_c1","Category Consumed",290);
                            
                            var baseX = processBase(CCC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c1_base").empty().append(htmlB);

                            var span = $('#cc1_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC2,CCC2V,CCC2B,CCC2C,"Simple");
                            customizedArray(CCC2V,CCC2VX,CCC2label,colorPallet68,"Doughnut");
                            doughnutChart2(CCC2VX,"cc1_c2","Type of protein","auto");

                            var baseX = processBase(CCC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c2_base").empty().append(htmlB);

                            var span = $('#cc1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC7,CCC7V,CCC7B,CCC7C,"Simple");
                            customizedArray(CCC7V,CCC7VX,CCC7label,colorPallet68,"Doughnut");
                            pieChart(CCC7VX,"cc1_c7","Type of Packaging","auto");

                            var baseX = processBase(CCC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c7_base").empty().append(htmlB);

                            var span = $('#cc1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC8,CCC8V,CCC8B,CCC8C,"Simple");
                            var max = (Math.max(...CCC8V)+20);
                            customizedArray(CCC8V,CCC8VX,CCC8label,colorPallet69,"Bar");
                            barChart(CCC8VX,"cc1_c8",CCC8label,max);

                            var baseX = processBase(CCC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c8_base").empty().append(htmlB);

                            var span = $('#cc1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC9,CCC9V,CCC9B,CCC9C,"Simple");
                            var max = (Math.max(...CCC9V)+20);
                            customizedArray(CCC9V,CCC9VX,CCC9label,colorPallet69,"Bar");
                            barChart(CCC9VX,"cc1_c9",CCC9label,max);

                            var baseX = processBase(CCC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c9_base").empty().append(htmlB);

                            var span = $('#cc1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC10,CCC10V,CCC10B,CCC10C,"Simple");
                            customizedArray(CCC10V,CCC10VX,CCC10label,colorPallet68,"Doughnut");
                            pieChart(CCC10VX,"cc1_c10","Way of consumption","auto");

                            var baseX = processBase(CCC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c10_base").empty().append(htmlB);

                            var span = $('#cc1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC11,CCC11V,CCC11B,CCC11C,"Simple");
                            var max = (Math.max(...CCC11V)+20);
                            customizedArray(CCC11V,CCC11VX,CCC11label,colorPallet69,"Bar");
                            columnChart(CCC11VX,"cc1_c11",CCC11label,max);

                            var baseX = processBase(CCC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c11_base").empty().append(htmlB);

                            var span = $('#cc1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC12,CCC12V,CCC12B,CCC12C,"Simple");
                            var max = (Math.max(...CCC12V)+20);
                            customizedArray(CCC12V,CCC12VX,CCC12label,colorPallet69,"Bar");
                            columnChart(CCC12VX,"cc1_c12",CCC12label,max);

                            var baseX = processBase(CCC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c12_base").empty().append(htmlB);

                            var span = $('#cc1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC15,CCC15V,CCC15B,CCC15C,"Simple");
                            CCC15V.forEach(function(e,i,a){
                                $(`#cc1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CCC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c15_base").empty().append(htmlB);

                            var span = $('#cc1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC16,CCC16V,CCC16B,CCC16C,"Simple");
                            var max = (Math.max(...CCC16V)+20);
                            customizedArray(CCC16V,CCC16VX,CCC16label,colorPallet69,"Bar");
                            barChart(CCC16VX,"cc1_c16",CCC16label,max);

                            var baseX = processBase(CCC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c16_base").empty().append(htmlB);

                            var span = $('#cc1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC17,CCC17V,CCC17B,CCC17C,"Simple");
                            CCC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`cc1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CCC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c17_base").empty().append(htmlB);

                            var span = $('#cc1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC18,CCC18V,CCC18B,CCC18C,"Simple");
                            var max = (Math.max(...CCC18V)+20);
                            customizedArray(CCC18V,CCC18VX,CCC18label,colorPallet69,"Bar");
                            barChart(CCC18VX,"cc1_c18",CCC18label,max);

                            var baseX = processBase(CCC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c18_base").empty().append(htmlB);

                            var span = $('#cc1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC19,CCC19V,CCC19B,CCC19C,"Simple");
                            var max = (Math.max(...CCC19V)+20);
                            customizedArray(CCC19V,CCC19VX,CCC19label,colorPallet69,"Bar");
                            barChart(CCC19VX,"cc1_c19",CCC19label,max);

                            var baseX = processBase(CCC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c19_base").empty().append(htmlB);

                            var span = $('#cc1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC20,CCC20V,CCC20B,CCC20C,"Simple");
                            CCC20V.forEach(function(e,i,a){
                                $(`#cc1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CCC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc1_c20_base").empty().append(htmlB);

                            var span = $('#cc1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_15, S13_15V, S13_15B, S13_15C, "Simple");
                            var max = (Math.max(...S13_15V)+20);
                            customizedArray(S13_15V,S13_15VX,S13label,colorPallet69,"Bar");
                            barChart(S13_15VX,"cc_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_15B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc_1_s13_base").empty().append(htmlB);

                            var span = $('#cc_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            chipsFStatus1 = true;
                            ajaxFlag[1+37] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtySeventhAjax() {
                    $.ajax({
                        url: "api/ajax37.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'chipscondX':chipscondX
                        },
                        success: function(response) {
                            var data  = JSON.parse(response);

                            var CCC0 = data['CC_C0'];
                            var CCC1 = data['CC_C1'];
                            var CCC2 = data['CC_C2'];
                            var CCC7 = data['CC_C7'];
                            var CCC8 = data['CC_C8'];
                            var CCC9 = data['CC_C9'];
                            var CCC10 = data['CC_C10'];
                            var CCC11 = data['CC_C11'];
                            var CCC12 = data['CC_C12'];
                            var CCC15 = data['CC_C15'];
                            var CCC16 = data['CC_C16'];
                            var CCC17 = data['CC_C17'];
                            var CCC18 = data['CC_C18'];
                            var CCC19 = data['CC_C19'];
                            var CCC20 = data['CC_C20'];

                            var CCC0V = [];
                            var CCC0B = [];
                            var CCC0C = [];
                            var CCC0VX = [];

                            var CCC1V = [];
                            var CCC1B = [];
                            var CCC1C = [];
                            var CCC1VX = [];

                            var CCC2V = [];
                            var CCC2B = [];
                            var CCC2C = [];
                            var CCC2VX = [];

                            var CCC7V = [];
                            var CCC7B = [];
                            var CCC7C = [];
                            var CCC7VX = [];

                            var CCC8V = [];
                            var CCC8B = [];
                            var CCC8C = [];
                            var CCC8VX = [];

                            var CCC9V = [];
                            var CCC9B = [];
                            var CCC9C = [];
                            var CCC9VX = [];

                            var CCC10V = [];
                            var CCC10B = [];
                            var CCC10C = [];
                            var CCC10VX = [];

                            var CCC11V = [];
                            var CCC11B = [];
                            var CCC11C = [];
                            var CCC11VX = [];

                            var CCC12V = [];
                            var CCC12B = [];
                            var CCC12C = [];
                            var CCC12VX = [];

                            var CCC13V = [];
                            var CCC13B = [];
                            var CCC13C = [];
                            var CCC13VX = [];

                            var CCC14V = [];
                            var CCC14B = [];
                            var CCC14C = [];
                            var CCC14VX = [];

                            var CCC15V = [];
                            var CCC15B = [];
                            var CCC15C = [];
                            var CCC15VX = [];

                            var CCC16V = [];
                            var CCC16B = [];
                            var CCC16C = [];
                            var CCC16VX = [];

                            var CCC17V = [];
                            var CCC17B = [];
                            var CCC17C = [];
                            var CCC17VX = [];

                            var CCC18V = [];
                            var CCC18B = [];
                            var CCC18C = [];
                            var CCC18VX = [];

                            var CCC19V = [];
                            var CCC19B = [];
                            var CCC19C = [];
                            var CCC19VX = [];

                            var CCC20V = [];
                            var CCC20B = [];
                            var CCC20C = [];
                            var CCC20VX = [];

                            var S13_15V = [];
                            var S13_15B = [];
                            var S13_15C = [];
                            var S13_15VX = [];

                            var S13_15 = data['S13_15'];

                            if(chipsFStatus2==false)
                            {
                                extractValues(CCC0,CCC0V,CCC0B,CCC0C,"Simple");
                                CCC0V.forEach(function(e,i,a){
                                    $(`#cc2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CCC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#cc2_c0_base").empty().append(htmlB);

                                var span = $('#cc2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(CCC1,CCC1V,CCC1B,CCC1C,"Simple");
                            customizedArray(CCC1V,CCC1VX,CCC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(CCC1VX,"cc2_c1","Category Consumed",290);

                            var baseX = processBase(CCC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c1_base").empty().append(htmlB);

                            var span = $('#cc2_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC2,CCC2V,CCC2B,CCC2C,"Simple");
                            customizedArray(CCC2V,CCC2VX,CCC2label,colorPallet68,"Doughnut");
                            doughnutChart2(CCC2VX,"cc2_c2","Type of protein","auto");

                            var baseX = processBase(CCC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c2_base").empty().append(htmlB);

                            var span = $('#cc2_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC7,CCC7V,CCC7B,CCC7C,"Simple");
                            customizedArray(CCC7V,CCC7VX,CCC7label,colorPallet68,"Doughnut");
                            pieChart(CCC7VX,"cc2_c7","Type of Packaging","auto");

                            var baseX = processBase(CCC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c7_base").empty().append(htmlB);

                            var span = $('#cc2_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC8,CCC8V,CCC8B,CCC8C,"Simple");
                            var max = (Math.max(...CCC8V)+20);
                            customizedArray(CCC8V,CCC8VX,CCC8label,colorPallet69,"Bar");
                            barChart(CCC8VX,"cc2_c8",CCC8label,max);

                            var baseX = processBase(CCC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c8_base").empty().append(htmlB);

                            var span = $('#cc2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC9,CCC9V,CCC9B,CCC9C,"Simple");
                            var max = (Math.max(...CCC9V)+20);
                            customizedArray(CCC9V,CCC9VX,CCC9label,colorPallet69,"Bar");
                            barChart(CCC9VX,"cc2_c9",CCC9label,max);

                            var baseX = processBase(CCC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c9_base").empty().append(htmlB);

                            var span = $('#cc2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC10,CCC10V,CCC10B,CCC10C,"Simple");
                            customizedArray(CCC10V,CCC10VX,CCC10label,colorPallet68,"Doughnut");
                            pieChart(CCC10VX,"cc2_c10","Way of consumption","auto");

                            var baseX = processBase(CCC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c10_base").empty().append(htmlB);

                            var span = $('#cc2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC11,CCC11V,CCC11B,CCC11C,"Simple");
                            var max = (Math.max(...CCC11V)+20);
                            customizedArray(CCC11V,CCC11VX,CCC11label,colorPallet69,"Bar");
                            columnChart(CCC11VX,"cc2_c11",CCC11label,max);

                            var baseX = processBase(CCC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c11_base").empty().append(htmlB);

                            var span = $('#cc2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC12,CCC12V,CCC12B,CCC12C,"Simple");
                            var max = (Math.max(...CCC12V)+20);
                            customizedArray(CCC12V,CCC12VX,CCC12label,colorPallet69,"Bar");
                            columnChart(CCC12VX,"cc2_c12",CCC12label,max);

                            var baseX = processBase(CCC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c12_base").empty().append(htmlB);

                            var span = $('#cc2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC15,CCC15V,CCC15B,CCC15C,"Simple");
                            CCC15V.forEach(function(e,i,a){
                                $(`#cc2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CCC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c15_base").empty().append(htmlB);

                            var span = $('#cc2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC16,CCC16V,CCC16B,CCC16C,"Simple");
                            var max = (Math.max(...CCC16V)+20);
                            customizedArray(CCC16V,CCC16VX,CCC16label,colorPallet69,"Bar");
                            barChart(CCC16VX,"cc2_c16",CCC16label,max);

                            var baseX = processBase(CCC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c16_base").empty().append(htmlB);

                            var span = $('#cc2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC17,CCC17V,CCC17B,CCC17C,"Simple");
                            CCC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`cc2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CCC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c17_base").empty().append(htmlB);

                            var span = $('#cc2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC18,CCC18V,CCC18B,CCC18C,"Simple");
                            var max = (Math.max(...CCC18V)+20);
                            customizedArray(CCC18V,CCC18VX,CCC18label,colorPallet69,"Bar");
                            barChart(CCC18VX,"cc2_c18",CCC18label,max);

                            var baseX = processBase(CCC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c18_base").empty().append(htmlB);

                            var span = $('#cc2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC19,CCC19V,CCC19B,CCC19C,"Simple");
                            var max = (Math.max(...CCC19V)+20);
                            customizedArray(CCC19V,CCC19VX,CCC19label,colorPallet69,"Bar");
                            barChart(CCC19VX,"cc2_c19",CCC19label,max);

                            var baseX = processBase(CCC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c19_base").empty().append(htmlB);

                            var span = $('#cc2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC20,CCC20V,CCC20B,CCC20C,"Simple");
                            CCC20V.forEach(function(e,i,a){
                                $(`#cc2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CCC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc2_c20_base").empty().append(htmlB);

                            var span = $('#cc2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_15, S13_15V, S13_15B, S13_15C, "Simple");
                            var max = (Math.max(...S13_15V)+20);
                            customizedArray(S13_15V,S13_15VX,S13label,colorPallet69,"Bar");
                            barChart(S13_15VX,"cc_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_15B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc_2_s13_base").empty().append(htmlB);

                            var span = $('#cc_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            chipsFStatus2 = true;
                            ajaxFlag[1+38] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtyEightthAjax() {
                    $.ajax({
                        url: "api/ajax38.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'chipscondX':chipscondX
                        },
                        success: function(response) {
                            var data  = JSON.parse(response);

                            var CCC0 = data['CC_C0'];
                            var CCC1 = data['CC_C1'];
                            var CCC2 = data['CC_C2'];
                            var CCC7 = data['CC_C7'];
                            var CCC8 = data['CC_C8'];
                            var CCC9 = data['CC_C9'];
                            var CCC10 = data['CC_C10'];
                            var CCC11 = data['CC_C11'];
                            var CCC12 = data['CC_C12'];
                            var CCC15 = data['CC_C15'];
                            var CCC16 = data['CC_C16'];
                            var CCC17 = data['CC_C17'];
                            var CCC18 = data['CC_C18'];
                            var CCC19 = data['CC_C19'];
                            var CCC20 = data['CC_C20'];

                            var CCC0V = [];
                            var CCC0B = [];
                            var CCC0C = [];
                            var CCC0VX = [];

                            var CCC1V = [];
                            var CCC1B = [];
                            var CCC1C = [];
                            var CCC1VX = [];

                            var CCC2V = [];
                            var CCC2B = [];
                            var CCC2C = [];
                            var CCC2VX = [];

                            var CCC7V = [];
                            var CCC7B = [];
                            var CCC7C = [];
                            var CCC7VX = [];

                            var CCC8V = [];
                            var CCC8B = [];
                            var CCC8C = [];
                            var CCC8VX = [];

                            var CCC9V = [];
                            var CCC9B = [];
                            var CCC9C = [];
                            var CCC9VX = [];

                            var CCC10V = [];
                            var CCC10B = [];
                            var CCC10C = [];
                            var CCC10VX = [];

                            var CCC11V = [];
                            var CCC11B = [];
                            var CCC11C = [];
                            var CCC11VX = [];

                            var CCC12V = [];
                            var CCC12B = [];
                            var CCC12C = [];
                            var CCC12VX = [];

                            var CCC13V = [];
                            var CCC13B = [];
                            var CCC13C = [];
                            var CCC13VX = [];

                            var CCC14V = [];
                            var CCC14B = [];
                            var CCC14C = [];
                            var CCC14VX = [];

                            var CCC15V = [];
                            var CCC15B = [];
                            var CCC15C = [];
                            var CCC15VX = [];

                            var CCC16V = [];
                            var CCC16B = [];
                            var CCC16C = [];
                            var CCC16VX = [];

                            var CCC17V = [];
                            var CCC17B = [];
                            var CCC17C = [];
                            var CCC17VX = [];

                            var CCC18V = [];
                            var CCC18B = [];
                            var CCC18C = [];
                            var CCC18VX = [];

                            var CCC19V = [];
                            var CCC19B = [];
                            var CCC19C = [];
                            var CCC19VX = [];

                            var CCC20V = [];
                            var CCC20B = [];
                            var CCC20C = [];
                            var CCC20VX = [];

                            var S13_15V = [];
                            var S13_15B = [];
                            var S13_15C = [];
                            var S13_15VX = [];

                            var S13_15 = data['S13_15'];

                            if(chipsFStatus3==false)
                            {
                                extractValues(CCC0,CCC0V,CCC0B,CCC0C,"Simple");
                                CCC0V.forEach(function(e,i,a){
                                    $(`#cc3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CCC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#cc3_c0_base").empty().append(htmlB);

                                var span = $('#cc3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(CCC1,CCC1V,CCC1B,CCC1C,"Simple");
                            customizedArray(CCC1V,CCC1VX,CCC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(CCC1VX,"cc3_c1","Category Consumed",290);

                            var baseX = processBase(CCC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c1_base").empty().append(htmlB);

                            var span = $('#cc3_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC2,CCC2V,CCC2B,CCC2C,"Simple");
                            customizedArray(CCC2V,CCC2VX,CCC2label,colorPallet68,"Doughnut");
                            doughnutChart2(CCC2VX,"cc3_c2","Type of protein","auto");

                            var baseX = processBase(CCC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c2_base").empty().append(htmlB);

                            var span = $('#cc3_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC7,CCC7V,CCC7B,CCC7C,"Simple");
                            customizedArray(CCC7V,CCC7VX,CCC7label,colorPallet68,"Doughnut");
                            pieChart(CCC7VX,"cc3_c7","Type of Packaging","auto");

                            var baseX = processBase(CCC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c7_base").empty().append(htmlB);

                            var span = $('#cc3_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC8,CCC8V,CCC8B,CCC8C,"Simple");
                            var max = (Math.max(...CCC8V)+20);
                            customizedArray(CCC8V,CCC8VX,CCC8label,colorPallet69,"Bar");
                            barChart(CCC8VX,"cc3_c8",CCC8label,max);

                            var baseX = processBase(CCC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c8_base").empty().append(htmlB);

                            var span = $('#cc3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC9,CCC9V,CCC9B,CCC9C,"Simple");
                            var max = (Math.max(...CCC9V)+20);
                            customizedArray(CCC9V,CCC9VX,CCC9label,colorPallet69,"Bar");
                            barChart(CCC9VX,"cc3_c9",CCC9label,max);

                            var baseX = processBase(CCC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c9_base").empty().append(htmlB);

                            var span = $('#cc3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC10,CCC10V,CCC10B,CCC10C,"Simple");
                            customizedArray(CCC10V,CCC10VX,CCC10label,colorPallet68,"Doughnut");
                            pieChart(CCC10VX,"cc3_c10","Way of consumption","auto");

                            var baseX = processBase(CCC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c10_base").empty().append(htmlB);

                            var span = $('#cc3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC11,CCC11V,CCC11B,CCC11C,"Simple");
                            var max = (Math.max(...CCC11V)+20);
                            customizedArray(CCC11V,CCC11VX,CCC11label,colorPallet69,"Bar");
                            columnChart(CCC11VX,"cc3_c11",CCC11label,max);

                            var baseX = processBase(CCC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c11_base").empty().append(htmlB);

                            var span = $('#cc3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC12,CCC12V,CCC12B,CCC12C,"Simple");
                            var max = (Math.max(...CCC12V)+20);
                            customizedArray(CCC12V,CCC12VX,CCC12label,colorPallet69,"Bar");
                            columnChart(CCC12VX,"cc3_c12",CCC12label,max);

                            var baseX = processBase(CCC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c12_base").empty().append(htmlB);

                            var span = $('#cc3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC15,CCC15V,CCC15B,CCC15C,"Simple");
                            CCC15V.forEach(function(e,i,a){
                                $(`#cc3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CCC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c15_base").empty().append(htmlB);

                            var span = $('#cc3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC16,CCC16V,CCC16B,CCC16C,"Simple");
                            var max = (Math.max(...CCC16V)+20);
                            customizedArray(CCC16V,CCC16VX,CCC16label,colorPallet69,"Bar");
                            barChart(CCC16VX,"cc3_c16",CCC16label,max);

                            var baseX = processBase(CCC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c16_base").empty().append(htmlB);

                            var span = $('#cc3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC17,CCC17V,CCC17B,CCC17C,"Simple");
                            CCC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`cc3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CCC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c17_base").empty().append(htmlB);

                            var span = $('#cc3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC18,CCC18V,CCC18B,CCC18C,"Simple");
                            var max = (Math.max(...CCC18V)+20);
                            customizedArray(CCC18V,CCC18VX,CCC18label,colorPallet69,"Bar");
                            barChart(CCC18VX,"cc3_c18",CCC18label,max);

                            var baseX = processBase(CCC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c18_base").empty().append(htmlB);

                            var span = $('#cc3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC19,CCC19V,CCC19B,CCC19C,"Simple");
                            var max = (Math.max(...CCC19V)+20);
                            customizedArray(CCC19V,CCC19VX,CCC19label,colorPallet69,"Bar");
                            barChart(CCC19VX,"cc3_c19",CCC19label,max);

                            var baseX = processBase(CCC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c19_base").empty().append(htmlB);

                            var span = $('#cc3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC20,CCC20V,CCC20B,CCC20C,"Simple");
                            CCC20V.forEach(function(e,i,a){
                                $(`#cc3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CCC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc3_c20_base").empty().append(htmlB);

                            var span = $('#cc3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_15, S13_15V, S13_15B, S13_15C, "Simple");
                            var max = (Math.max(...S13_15V)+20);
                            customizedArray(S13_15V,S13_15VX,S13label,colorPallet69,"Bar");
                            barChart(S13_15VX,"cc_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_15B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc_3_s13_base").empty().append(htmlB);

                            var span = $('#cc_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            chipsFStatus3 = true;
                            ajaxFlag[1+39] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function thirtyNinethAjax() {
                    $.ajax({
                        url: "api/ajax39.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'chipscondX':chipscondX
                        },
                        success: function(response) {
                            var data  = JSON.parse(response);

                            var CCC0 = data['CC_C0'];
                            var CCC1 = data['CC_C1'];
                            var CCC2 = data['CC_C2'];
                            var CCC7 = data['CC_C7'];
                            var CCC8 = data['CC_C8'];
                            var CCC9 = data['CC_C9'];
                            var CCC10 = data['CC_C10'];
                            var CCC11 = data['CC_C11'];
                            var CCC12 = data['CC_C12'];
                            var CCC15 = data['CC_C15'];
                            var CCC16 = data['CC_C16'];
                            var CCC17 = data['CC_C17'];
                            var CCC18 = data['CC_C18'];
                            var CCC19 = data['CC_C19'];
                            var CCC20 = data['CC_C20'];

                            var CCC0V = [];
                            var CCC0B = [];
                            var CCC0C = [];
                            var CCC0VX = [];

                            var CCC1V = [];
                            var CCC1B = [];
                            var CCC1C = [];
                            var CCC1VX = [];

                            var CCC2V = [];
                            var CCC2B = [];
                            var CCC2C = [];
                            var CCC2VX = [];

                            var CCC7V = [];
                            var CCC7B = [];
                            var CCC7C = [];
                            var CCC7VX = [];

                            var CCC8V = [];
                            var CCC8B = [];
                            var CCC8C = [];
                            var CCC8VX = [];

                            var CCC9V = [];
                            var CCC9B = [];
                            var CCC9C = [];
                            var CCC9VX = [];

                            var CCC10V = [];
                            var CCC10B = [];
                            var CCC10C = [];
                            var CCC10VX = [];

                            var CCC11V = [];
                            var CCC11B = [];
                            var CCC11C = [];
                            var CCC11VX = [];

                            var CCC12V = [];
                            var CCC12B = [];
                            var CCC12C = [];
                            var CCC12VX = [];

                            var CCC13V = [];
                            var CCC13B = [];
                            var CCC13C = [];
                            var CCC13VX = [];

                            var CCC14V = [];
                            var CCC14B = [];
                            var CCC14C = [];
                            var CCC14VX = [];

                            var CCC15V = [];
                            var CCC15B = [];
                            var CCC15C = [];
                            var CCC15VX = [];

                            var CCC16V = [];
                            var CCC16B = [];
                            var CCC16C = [];
                            var CCC16VX = [];

                            var CCC17V = [];
                            var CCC17B = [];
                            var CCC17C = [];
                            var CCC17VX = [];

                            var CCC18V = [];
                            var CCC18B = [];
                            var CCC18C = [];
                            var CCC18VX = [];

                            var CCC19V = [];
                            var CCC19B = [];
                            var CCC19C = [];
                            var CCC19VX = [];

                            var CCC20V = [];
                            var CCC20B = [];
                            var CCC20C = [];
                            var CCC20VX = [];

                            var S13_15V = [];
                            var S13_15B = [];
                            var S13_15C = [];
                            var S13_15VX = [];

                            var S13_15 = data['S13_15'];

                            if(chipsFStatus4==false)
                            {
                                extractValues(CCC0,CCC0V,CCC0B,CCC0C,"Simple");
                                CCC0V.forEach(function(e,i,a){
                                    $(`#cc4_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(CCC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#cc4_c0_base").empty().append(htmlB);

                                var span = $('#cc4_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(CCC1,CCC1V,CCC1B,CCC1C,"Simple");
                            customizedArray(CCC1V,CCC1VX,CCC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(CCC1VX,"cc4_c1","Category Consumed",290);

                            var baseX = processBase(CCC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c1_base").empty().append(htmlB);

                            var span = $('#cc4_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC2,CCC2V,CCC2B,CCC2C,"Simple");
                            customizedArray(CCC2V,CCC2VX,CCC2label,colorPallet68,"Doughnut");
                            doughnutChart2(CCC2VX,"cc4_c2","Type of protein","auto");

                            var baseX = processBase(CCC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c2_base").empty().append(htmlB);

                            var span = $('#cc4_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC7,CCC7V,CCC7B,CCC7C,"Simple");
                            customizedArray(CCC7V,CCC7VX,CCC7label,colorPallet68,"Doughnut");
                            pieChart(CCC7VX,"cc4_c7","Type of Packaging","auto");

                            var baseX = processBase(CCC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c7_base").empty().append(htmlB);

                            var span = $('#cc4_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC8,CCC8V,CCC8B,CCC8C,"Simple");
                            var max = (Math.max(...CCC8V)+20);
                            customizedArray(CCC8V,CCC8VX,CCC8label,colorPallet69,"Bar");
                            barChart(CCC8VX,"cc4_c8",CCC8label,max);

                            var baseX = processBase(CCC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c8_base").empty().append(htmlB);

                            var span = $('#cc4_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC9,CCC9V,CCC9B,CCC9C,"Simple");
                            var max = (Math.max(...CCC9V)+20);
                            customizedArray(CCC9V,CCC9VX,CCC9label,colorPallet69,"Bar");
                            barChart(CCC9VX,"cc4_c9",CCC9label,max);

                            var baseX = processBase(CCC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c9_base").empty().append(htmlB);

                            var span = $('#cc4_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC10,CCC10V,CCC10B,CCC10C,"Simple");
                            customizedArray(CCC10V,CCC10VX,CCC10label,colorPallet68,"Doughnut");
                            pieChart(CCC10VX,"cc4_c10","Way of consumption","auto");

                            var baseX = processBase(CCC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c10_base").empty().append(htmlB);

                            var span = $('#cc4_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC11,CCC11V,CCC11B,CCC11C,"Simple");
                            var max = (Math.max(...CCC11V)+20);
                            customizedArray(CCC11V,CCC11VX,CCC11label,colorPallet69,"Bar");
                            columnChart(CCC11VX,"cc4_c11",CCC11label,max);

                            var baseX = processBase(CCC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c11_base").empty().append(htmlB);

                            var span = $('#cc4_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC12,CCC12V,CCC12B,CCC12C,"Simple");
                            var max = (Math.max(...CCC12V)+20);
                            customizedArray(CCC12V,CCC12VX,CCC12label,colorPallet69,"Bar");
                            columnChart(CCC12VX,"cc4_c12",CCC12label,max);

                            var baseX = processBase(CCC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c12_base").empty().append(htmlB);

                            var span = $('#cc4_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC15,CCC15V,CCC15B,CCC15C,"Simple");
                            CCC15V.forEach(function(e,i,a){
                                $(`#cc4_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CCC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c15_base").empty().append(htmlB);

                            var span = $('#cc4_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC16,CCC16V,CCC16B,CCC16C,"Simple");
                            var max = (Math.max(...CCC16V)+20);
                            customizedArray(CCC16V,CCC16VX,CCC16label,colorPallet69,"Bar");
                            barChart(CCC16VX,"cc4_c16",CCC16label,max);

                            var baseX = processBase(CCC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c16_base").empty().append(htmlB);

                            var span = $('#cc4_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC17,CCC17V,CCC17B,CCC17C,"Simple");
                            CCC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`cc4_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(CCC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c17_base").empty().append(htmlB);

                            var span = $('#cc4_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC18,CCC18V,CCC18B,CCC18C,"Simple");
                            var max = (Math.max(...CCC18V)+20);
                            customizedArray(CCC18V,CCC18VX,CCC18label,colorPallet69,"Bar");
                            barChart(CCC18VX,"cc4_c18",CCC18label,max);

                            var baseX = processBase(CCC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c18_base").empty().append(htmlB);

                            var span = $('#cc4_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC19,CCC19V,CCC19B,CCC19C,"Simple");
                            var max = (Math.max(...CCC19V)+20);
                            customizedArray(CCC19V,CCC19VX,CCC19label,colorPallet69,"Bar");
                            barChart(CCC19VX,"cc4_c19",CCC19label,max);

                            var baseX = processBase(CCC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c19_base").empty().append(htmlB);

                            var span = $('#cc4_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(CCC20,CCC20V,CCC20B,CCC20C,"Simple");
                            CCC20V.forEach(function(e,i,a){
                                $(`#cc4_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(CCC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc4_c20_base").empty().append(htmlB);

                            var span = $('#cc4_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_15, S13_15V, S13_15B, S13_15C, "Simple");
                            var max = (Math.max(...S13_15V)+20);
                            customizedArray(S13_15V,S13_15VX,S13label,colorPallet69,"Bar");
                            barChart(S13_15VX,"cc_4_s13",S13label,max);
                            
                            var baseX = processBase(S13_15B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#cc_4_s13_base").empty().append(htmlB);

                            var span = $('#cc_4_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            chipsFStatus4 = true;
                            ajaxFlag[1+40] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fortythAjax() {
                    $.ajax({
                        url: "api/ajax40.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'barcondX':barcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BARC0 = data['BAR_C0'];
                            var BARC2 = data['BAR_C2'];
                            var BARC3 = data['BAR_C3'];
                            var BARC4a = data['BAR_C4a'];
                            var BARC7 = data['BAR_C7'];
                            var BARC8 = data['BAR_C8'];
                            var BARC9 = data['BAR_C9'];
                            var BARC10 = data['BAR_C10'];
                            var BARC11 = data['BAR_C11'];
                            var BARC12 = data['BAR_C12'];
                            var BARC15 = data['BAR_C15'];
                            var BARC16 = data['BAR_C16'];
                            var BARC17 = data['BAR_C17'];
                            var BARC18 = data['BAR_C18'];
                            var BARC19 = data['BAR_C19'];
                            var BARC20 = data['BAR_C20'];

                            var S13_10 = data['S13_10'];

                            var BARC0V = [];
                            var BARC0B = [];
                            var BARC0C = [];
                            var BARC0VX = [];

                            var BARC2V = [];
                            var BARC2B = [];
                            var BARC2C = [];
                            var BARC2VX = [];

                            var BARC3V = [];
                            var BARC3B = [];
                            var BARC3C = [];
                            var BARC3VX = [];

                            var BARC4aV = [];
                            var BARC4aB = [];
                            var BARC4aC = [];
                            var BARC4aVX = [];

                            var BARC7V = [];
                            var BARC7B = [];
                            var BARC7C = [];
                            var BARC7VX = [];

                            var BARC8V = [];
                            var BARC8B = [];
                            var BARC8C = [];
                            var BARC8VX = [];

                            var BARC9V = [];
                            var BARC9B = [];
                            var BARC9C = [];
                            var BARC9VX = [];

                            var BARC10V = [];
                            var BARC10B = [];
                            var BARC10C = [];
                            var BARC10VX = [];

                            var BARC11V = [];
                            var BARC11B = [];
                            var BARC11C = [];
                            var BARC11VX = [];

                            var BARC12V = [];
                            var BARC12B = [];
                            var BARC12C = [];
                            var BARC12VX = [];

                            var BARC13V = [];
                            var BARC13B = [];
                            var BARC13C = [];
                            var BARC13VX = [];

                            var BARC14V = [];
                            var BARC14B = [];
                            var BARC14C = [];
                            var BARC14VX = [];

                            var BARC15V = [];
                            var BARC15B = [];
                            var BARC15C = [];
                            var BARC15VX = [];

                            var BARC16V = [];
                            var BARC16B = [];
                            var BARC16C = [];
                            var BARC16VX = [];

                            var BARC17V = [];
                            var BARC17B = [];
                            var BARC17C = [];
                            var BARC17VX = [];

                            var BARC18V = [];
                            var BARC18B = [];
                            var BARC18C = [];
                            var BARC18VX = [];

                            var BARC19V = [];
                            var BARC19B = [];
                            var BARC19C = [];
                            var BARC19VX = [];

                            var BARC20V = [];
                            var BARC20B = [];
                            var BARC20C = [];
                            var BARC20VX = [];

                            var S13_10V = [];
                            var S13_10B = [];
                            var S13_10C = [];
                            var S13_10VX = [];

                            if(barFStatus1==false)
                            {
                                extractValues(BARC0,BARC0V,BARC0B,BARC0C,"Simple");
                                BARC0V.forEach(function(e,i,a){
                                    $(`#bar1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BARC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bar1_c0_base").empty().append(htmlB);

                                var span = $('#bar1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BARC2,BARC2V,BARC2B,BARC2C,"Simple");
                            customizedArray(BARC2V,BARC2VX,BARC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BARC2VX,"bar1_c2","Type of protein","auto");

                            var baseX = processBase(BARC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c2_base").empty().append(htmlB);

                            var span = $('#bar1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC3,BARC3V,BARC3B,BARC3C,"Simple");
                            customizedArray(BARC3V,BARC3VX,BARC3label,colorPallet68,"Doughnut");
                            doughnutChart2(BARC3VX,"bar1_c3","Type of protein","auto");

                            var baseX = processBase(BARC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c3_base").empty().append(htmlB);

                            var span = $('#bar1_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(BARC4a,BARC4aV,BARC4aB,BARC4aC,"Simple");
                            customizedArray(BARC4aV,BARC4aVX,BARC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(BARC4aVX,"bar1_c4a","Type of protein","auto");

                            var baseX = processBase(BARC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c4a_base").empty().append(htmlB);

                            var span = $('#bar1_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC7,BARC7V,BARC7B,BARC7C,"Simple");
                            customizedArray(BARC7V,BARC7VX,BARC7label,colorPallet68,"Doughnut");
                            pieChart(BARC7VX,"bar1_c7","Type of Packaging","auto");

                            var baseX = processBase(BARC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c7_base").empty().append(htmlB);

                            var span = $('#bar1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC8,BARC8V,BARC8B,BARC8C,"Simple");
                            var max = (Math.max(...BARC8V)+20);
                            customizedArray(BARC8V,BARC8VX,BARC8label,colorPallet69,"Bar");
                            barChart(BARC8VX,"bar1_c8",BARC8label,max);

                            var baseX = processBase(BARC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c8_base").empty().append(htmlB);

                            var span = $('#bar1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC9,BARC9V,BARC9B,BARC9C,"Simple");
                            var max = (Math.max(...BARC9V)+20);
                            customizedArray(BARC9V,BARC9VX,BARC9label,colorPallet69,"Bar");
                            barChart(BARC9VX,"bar1_c9",BARC9label,max);

                            var baseX = processBase(BARC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c9_base").empty().append(htmlB);

                            var span = $('#bar1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC10,BARC10V,BARC10B,BARC10C,"Simple");
                            customizedArray(BARC10V,BARC10VX,BARC10label,colorPallet68,"Doughnut");
                            pieChart(BARC10VX,"bar1_c10","Way of consumption","auto");

                            var baseX = processBase(BARC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c10_base").empty().append(htmlB);

                            var span = $('#bar1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC11,BARC11V,BARC11B,BARC11C,"Simple");
                            var max = (Math.max(...BARC11V)+20);
                            customizedArray(BARC11V,BARC11VX,BARC11label,colorPallet69,"Bar");
                            columnChart(BARC11VX,"bar1_c11",BARC11label,max);

                            var baseX = processBase(BARC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c11_base").empty().append(htmlB);

                            var span = $('#bar1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC16,BARC16V,BARC16B,BARC16C,"Simple");
                            var max = (Math.max(...BARC16V)+20);
                            customizedArray(BARC16V,BARC16VX,BARC16label,colorPallet69,"Bar");
                            barChart(BARC16VX,"bar1_c16",BARC16label,max);

                            var baseX = processBase(BARC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c16_base").empty().append(htmlB);

                            var span = $('#bar1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC12,BARC12V,BARC12B,BARC12C,"Simple");
                            var max = (Math.max(...BARC12V)+20);
                            customizedArray(BARC12V,BARC12VX,BARC12label,colorPallet69,"Bar");
                            columnChart(BARC12VX,"bar1_c12",BARC12label,max);

                            var baseX = processBase(BARC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c12_base").empty().append(htmlB);

                            var span = $('#bar1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC15,BARC15V,BARC15B,BARC15C,"Simple");
                            BARC15V.forEach(function(e,i,a){
                                $(`#bar1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BARC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c15_base").empty().append(htmlB);

                            var span = $('#bar1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC20,BARC20V,BARC20B,BARC20C,"Simple");
                            BARC20V.forEach(function(e,i,a){
                                $(`#bar1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BARC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c20_base").empty().append(htmlB);

                            var span = $('#bar1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC17,BARC17V,BARC17B,BARC17C,"Simple");
                            BARC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bar1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BARC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c17_base").empty().append(htmlB);

                            var span = $('#bar1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC18,BARC18V,BARC18B,BARC18C,"Simple");
                            var max = (Math.max(...BARC18V)+20);
                            customizedArray(BARC18V,BARC18VX,BARC18label,colorPallet69,"Bar");
                            barChart(BARC18VX,"bar1_c18",BARC18label,max);

                            var baseX = processBase(BARC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c18_base").empty().append(htmlB);

                            var span = $('#bar1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC19,BARC19V,BARC19B,BARC19C,"Simple");
                            var max = (Math.max(...BARC19V)+20);
                            customizedArray(BARC19V,BARC19VX,BARC19label,colorPallet69,"Bar");
                            barChart(BARC19VX,"bar1_c19",BARC19label,max);

                            var baseX = processBase(BARC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar1_c19_base").empty().append(htmlB);

                            var span = $('#bar1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_10, S13_10V, S13_10B, S13_10C, "Simple");
                            var max = (Math.max(...S13_10V)+20);
                            customizedArray(S13_10V,S13_10VX,S13label,colorPallet69,"Bar");
                            barChart(S13_10VX,"bar_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_10B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar_1_s13_base").empty().append(htmlB);

                            var span = $('#bar_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            barFStatus1 = true;
                            ajaxFlag[1+41] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fortyOnethAjax() {
                    $.ajax({
                        url: "api/ajax41.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'barcondX':barcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BARC0 = data['BAR_C0'];
                            var BARC2 = data['BAR_C2'];
                            var BARC3 = data['BAR_C3'];
                            var BARC4a = data['BAR_C4a'];
                            var BARC7 = data['BAR_C7'];
                            var BARC8 = data['BAR_C8'];
                            var BARC9 = data['BAR_C9'];
                            var BARC10 = data['BAR_C10'];
                            var BARC11 = data['BAR_C11'];
                            var BARC12 = data['BAR_C12'];
                            var BARC15 = data['BAR_C15'];
                            var BARC16 = data['BAR_C16'];
                            var BARC17 = data['BAR_C17'];
                            var BARC18 = data['BAR_C18'];
                            var BARC19 = data['BAR_C19'];
                            var BARC20 = data['BAR_C20'];

                            var S13_10 = data['S13_10'];

                            var BARC0V = [];
                            var BARC0B = [];
                            var BARC0C = [];
                            var BARC0VX = [];

                            var BARC2V = [];
                            var BARC2B = [];
                            var BARC2C = [];
                            var BARC2VX = [];

                            var BARC3V = [];
                            var BARC3B = [];
                            var BARC3C = [];
                            var BARC3VX = [];

                            var BARC4aV = [];
                            var BARC4aB = [];
                            var BARC4aC = [];
                            var BARC4aVX = [];

                            var BARC7V = [];
                            var BARC7B = [];
                            var BARC7C = [];
                            var BARC7VX = [];

                            var BARC8V = [];
                            var BARC8B = [];
                            var BARC8C = [];
                            var BARC8VX = [];

                            var BARC9V = [];
                            var BARC9B = [];
                            var BARC9C = [];
                            var BARC9VX = [];

                            var BARC10V = [];
                            var BARC10B = [];
                            var BARC10C = [];
                            var BARC10VX = [];

                            var BARC11V = [];
                            var BARC11B = [];
                            var BARC11C = [];
                            var BARC11VX = [];

                            var BARC12V = [];
                            var BARC12B = [];
                            var BARC12C = [];
                            var BARC12VX = [];

                            var BARC13V = [];
                            var BARC13B = [];
                            var BARC13C = [];
                            var BARC13VX = [];

                            var BARC14V = [];
                            var BARC14B = [];
                            var BARC14C = [];
                            var BARC14VX = [];

                            var BARC15V = [];
                            var BARC15B = [];
                            var BARC15C = [];
                            var BARC15VX = [];

                            var BARC16V = [];
                            var BARC16B = [];
                            var BARC16C = [];
                            var BARC16VX = [];

                            var BARC17V = [];
                            var BARC17B = [];
                            var BARC17C = [];
                            var BARC17VX = [];

                            var BARC18V = [];
                            var BARC18B = [];
                            var BARC18C = [];
                            var BARC18VX = [];

                            var BARC19V = [];
                            var BARC19B = [];
                            var BARC19C = [];
                            var BARC19VX = [];

                            var BARC20V = [];
                            var BARC20B = [];
                            var BARC20C = [];
                            var BARC20VX = [];

                            var S13_10V = [];
                            var S13_10B = [];
                            var S13_10C = [];
                            var S13_10VX = [];

                            if(barFStatus2==false)
                            {
                                extractValues(BARC0,BARC0V,BARC0B,BARC0C,"Simple");
                                BARC0V.forEach(function(e,i,a){
                                    $(`#bar2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BARC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bar2_c0_base").empty().append(htmlB);

                                var span = $('#bar2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BARC2,BARC2V,BARC2B,BARC2C,"Simple");
                            customizedArray(BARC2V,BARC2VX,BARC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BARC2VX,"bar2_c2","Type of protein","auto");

                            var baseX = processBase(BARC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c2_base").empty().append(htmlB);

                            var span = $('#bar2_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC3,BARC3V,BARC3B,BARC3C,"Simple");
                            customizedArray(BARC3V,BARC3VX,BARC3label,colorPallet68,"Doughnut");
                            doughnutChart2(BARC3VX,"bar2_c3","Type of protein","auto");

                            var baseX = processBase(BARC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c3_base").empty().append(htmlB);

                            var span = $('#bar2_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(BARC4a,BARC4aV,BARC4aB,BARC4aC,"Simple");
                            customizedArray(BARC4aV,BARC4aVX,BARC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(BARC4aVX,"bar2_c4a","Type of protein","auto");

                            var baseX = processBase(BARC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c4a_base").empty().append(htmlB);

                            var span = $('#bar2_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC7,BARC7V,BARC7B,BARC7C,"Simple");
                            customizedArray(BARC7V,BARC7VX,BARC7label,colorPallet68,"Doughnut");
                            pieChart(BARC7VX,"bar2_c7","Type of Packaging","auto");

                            var baseX = processBase(BARC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c7_base").empty().append(htmlB);

                            var span = $('#bar2_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC8,BARC8V,BARC8B,BARC8C,"Simple");
                            var max = (Math.max(...BARC8V)+20);
                            customizedArray(BARC8V,BARC8VX,BARC8label,colorPallet69,"Bar");
                            barChart(BARC8VX,"bar2_c8",BARC8label,max);

                            var baseX = processBase(BARC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c8_base").empty().append(htmlB);

                            var span = $('#bar2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC9,BARC9V,BARC9B,BARC9C,"Simple");
                            var max = (Math.max(...BARC9V)+20);
                            customizedArray(BARC9V,BARC9VX,BARC9label,colorPallet69,"Bar");
                            barChart(BARC9VX,"bar2_c9",BARC9label,max);

                            var baseX = processBase(BARC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c9_base").empty().append(htmlB);

                            var span = $('#bar2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC10,BARC10V,BARC10B,BARC10C,"Simple");
                            customizedArray(BARC10V,BARC10VX,BARC10label,colorPallet68,"Doughnut");
                            pieChart(BARC10VX,"bar2_c10","Way of consumption","auto");

                            var baseX = processBase(BARC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c10_base").empty().append(htmlB);

                            var span = $('#bar2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC11,BARC11V,BARC11B,BARC11C,"Simple");
                            var max = (Math.max(...BARC11V)+20);
                            customizedArray(BARC11V,BARC11VX,BARC11label,colorPallet69,"Bar");
                            columnChart(BARC11VX,"bar2_c11",BARC11label,max);

                            var baseX = processBase(BARC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c11_base").empty().append(htmlB);

                            var span = $('#bar2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC16,BARC16V,BARC16B,BARC16C,"Simple");
                            var max = (Math.max(...BARC16V)+20);
                            customizedArray(BARC16V,BARC16VX,BARC16label,colorPallet69,"Bar");
                            barChart(BARC16VX,"bar2_c16",BARC16label,max);

                            var baseX = processBase(BARC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c16_base").empty().append(htmlB);

                            var span = $('#bar2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC12,BARC12V,BARC12B,BARC12C,"Simple");
                            var max = (Math.max(...BARC12V)+20);
                            customizedArray(BARC12V,BARC12VX,BARC12label,colorPallet69,"Bar");
                            columnChart(BARC12VX,"bar2_c12",BARC12label,max);

                            var baseX = processBase(BARC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c12_base").empty().append(htmlB);

                            var span = $('#bar2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC15,BARC15V,BARC15B,BARC15C,"Simple");
                            BARC15V.forEach(function(e,i,a){
                                $(`#bar2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BARC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c15_base").empty().append(htmlB);

                            var span = $('#bar2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC20,BARC20V,BARC20B,BARC20C,"Simple");
                            BARC20V.forEach(function(e,i,a){
                                $(`#bar2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BARC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c20_base").empty().append(htmlB);

                            var span = $('#bar2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC17,BARC17V,BARC17B,BARC17C,"Simple");
                            BARC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bar2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BARC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c17_base").empty().append(htmlB);

                            var span = $('#bar2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC18,BARC18V,BARC18B,BARC18C,"Simple");
                            var max = (Math.max(...BARC18V)+20);
                            customizedArray(BARC18V,BARC18VX,BARC18label,colorPallet69,"Bar");
                            barChart(BARC18VX,"bar2_c18",BARC18label,max);

                            var baseX = processBase(BARC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c18_base").empty().append(htmlB);

                            var span = $('#bar2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC19,BARC19V,BARC19B,BARC19C,"Simple");
                            var max = (Math.max(...BARC19V)+20);
                            customizedArray(BARC19V,BARC19VX,BARC19label,colorPallet69,"Bar");
                            barChart(BARC19VX,"bar2_c19",BARC19label,max);

                            var baseX = processBase(BARC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar2_c19_base").empty().append(htmlB);

                            var span = $('#bar2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_10, S13_10V, S13_10B, S13_10C, "Simple");
                            var max = (Math.max(...S13_10V)+20);
                            customizedArray(S13_10V,S13_10VX,S13label,colorPallet69,"Bar");
                            barChart(S13_10VX,"bar_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_10B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar_2_s13_base").empty().append(htmlB);

                            var span = $('#bar_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            barFStatus2 = true;
                            ajaxFlag[1+42] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fortyTwothAjax() {
                    $.ajax({
                        url: "api/ajax42.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'barcondX':barcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BARC0 = data['BAR_C0'];
                            var BARC2 = data['BAR_C2'];
                            var BARC3 = data['BAR_C3'];
                            var BARC4a = data['BAR_C4a'];
                            var BARC7 = data['BAR_C7'];
                            var BARC8 = data['BAR_C8'];
                            var BARC9 = data['BAR_C9'];
                            var BARC10 = data['BAR_C10'];
                            var BARC11 = data['BAR_C11'];
                            var BARC12 = data['BAR_C12'];
                            var BARC15 = data['BAR_C15'];
                            var BARC16 = data['BAR_C16'];
                            var BARC17 = data['BAR_C17'];
                            var BARC18 = data['BAR_C18'];
                            var BARC19 = data['BAR_C19'];
                            var BARC20 = data['BAR_C20'];

                            var S13_10 = data['S13_10'];

                            var BARC0V = [];
                            var BARC0B = [];
                            var BARC0C = [];
                            var BARC0VX = [];

                            var BARC2V = [];
                            var BARC2B = [];
                            var BARC2C = [];
                            var BARC2VX = [];

                            var BARC3V = [];
                            var BARC3B = [];
                            var BARC3C = [];
                            var BARC3VX = [];

                            var BARC4aV = [];
                            var BARC4aB = [];
                            var BARC4aC = [];
                            var BARC4aVX = [];

                            var BARC7V = [];
                            var BARC7B = [];
                            var BARC7C = [];
                            var BARC7VX = [];

                            var BARC8V = [];
                            var BARC8B = [];
                            var BARC8C = [];
                            var BARC8VX = [];

                            var BARC9V = [];
                            var BARC9B = [];
                            var BARC9C = [];
                            var BARC9VX = [];

                            var BARC10V = [];
                            var BARC10B = [];
                            var BARC10C = [];
                            var BARC10VX = [];

                            var BARC11V = [];
                            var BARC11B = [];
                            var BARC11C = [];
                            var BARC11VX = [];

                            var BARC12V = [];
                            var BARC12B = [];
                            var BARC12C = [];
                            var BARC12VX = [];

                            var BARC13V = [];
                            var BARC13B = [];
                            var BARC13C = [];
                            var BARC13VX = [];

                            var BARC14V = [];
                            var BARC14B = [];
                            var BARC14C = [];
                            var BARC14VX = [];

                            var BARC15V = [];
                            var BARC15B = [];
                            var BARC15C = [];
                            var BARC15VX = [];

                            var BARC16V = [];
                            var BARC16B = [];
                            var BARC16C = [];
                            var BARC16VX = [];

                            var BARC17V = [];
                            var BARC17B = [];
                            var BARC17C = [];
                            var BARC17VX = [];

                            var BARC18V = [];
                            var BARC18B = [];
                            var BARC18C = [];
                            var BARC18VX = [];

                            var BARC19V = [];
                            var BARC19B = [];
                            var BARC19C = [];
                            var BARC19VX = [];

                            var BARC20V = [];
                            var BARC20B = [];
                            var BARC20C = [];
                            var BARC20VX = [];

                            var S13_10V = [];
                            var S13_10B = [];
                            var S13_10C = [];
                            var S13_10VX = [];

                            if(barFStatus3==false)
                            {
                                extractValues(BARC0,BARC0V,BARC0B,BARC0C,"Simple");
                                BARC0V.forEach(function(e,i,a){
                                    $(`#bar3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BARC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bar3_c0_base").empty().append(htmlB);

                                var span = $('#bar3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BARC2,BARC2V,BARC2B,BARC2C,"Simple");
                            customizedArray(BARC2V,BARC2VX,BARC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BARC2VX,"bar3_c2","Type of protein","auto");

                            var baseX = processBase(BARC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c2_base").empty().append(htmlB);

                            var span = $('#bar3_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC3,BARC3V,BARC3B,BARC3C,"Simple");
                            customizedArray(BARC3V,BARC3VX,BARC3label,colorPallet68,"Doughnut");
                            doughnutChart2(BARC3VX,"bar3_c3","Type of protein","auto");

                            var baseX = processBase(BARC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c3_base").empty().append(htmlB);

                            var span = $('#bar3_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(BARC4a,BARC4aV,BARC4aB,BARC4aC,"Simple");
                            customizedArray(BARC4aV,BARC4aVX,BARC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(BARC4aVX,"bar3_c4a","Type of protein","auto");

                            var baseX = processBase(BARC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c4a_base").empty().append(htmlB);

                            var span = $('#bar3_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC7,BARC7V,BARC7B,BARC7C,"Simple");
                            customizedArray(BARC7V,BARC7VX,BARC7label,colorPallet68,"Doughnut");
                            pieChart(BARC7VX,"bar3_c7","Type of Packaging","auto");

                            var baseX = processBase(BARC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c7_base").empty().append(htmlB);

                            var span = $('#bar3_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC8,BARC8V,BARC8B,BARC8C,"Simple");
                            var max = (Math.max(...BARC8V)+20);
                            customizedArray(BARC8V,BARC8VX,BARC8label,colorPallet69,"Bar");
                            barChart(BARC8VX,"bar3_c8",BARC8label,max);

                            var baseX = processBase(BARC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c8_base").empty().append(htmlB);

                            var span = $('#bar3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC9,BARC9V,BARC9B,BARC9C,"Simple");
                            var max = (Math.max(...BARC9V)+20);
                            customizedArray(BARC9V,BARC9VX,BARC9label,colorPallet69,"Bar");
                            barChart(BARC9VX,"bar3_c9",BARC9label,max);

                            var baseX = processBase(BARC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c9_base").empty().append(htmlB);

                            var span = $('#bar3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC10,BARC10V,BARC10B,BARC10C,"Simple");
                            customizedArray(BARC10V,BARC10VX,BARC10label,colorPallet68,"Doughnut");
                            pieChart(BARC10VX,"bar3_c10","Way of consumption","auto");

                            var baseX = processBase(BARC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c10_base").empty().append(htmlB);

                            var span = $('#bar3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC11,BARC11V,BARC11B,BARC11C,"Simple");
                            var max = (Math.max(...BARC11V)+20);
                            customizedArray(BARC11V,BARC11VX,BARC11label,colorPallet69,"Bar");
                            columnChart(BARC11VX,"bar3_c11",BARC11label,max);

                            var baseX = processBase(BARC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c11_base").empty().append(htmlB);

                            var span = $('#bar3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC16,BARC16V,BARC16B,BARC16C,"Simple");
                            var max = (Math.max(...BARC16V)+20);
                            customizedArray(BARC16V,BARC16VX,BARC16label,colorPallet69,"Bar");
                            barChart(BARC16VX,"bar3_c16",BARC16label,max);

                            var baseX = processBase(BARC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c16_base").empty().append(htmlB);

                            var span = $('#bar3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC12,BARC12V,BARC12B,BARC12C,"Simple");
                            var max = (Math.max(...BARC12V)+20);
                            customizedArray(BARC12V,BARC12VX,BARC12label,colorPallet69,"Bar");
                            columnChart(BARC12VX,"bar3_c12",BARC12label,max);

                            var baseX = processBase(BARC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c12_base").empty().append(htmlB);

                            var span = $('#bar3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC15,BARC15V,BARC15B,BARC15C,"Simple");
                            BARC15V.forEach(function(e,i,a){
                                $(`#bar3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BARC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c15_base").empty().append(htmlB);

                            var span = $('#bar3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC20,BARC20V,BARC20B,BARC20C,"Simple");
                            BARC20V.forEach(function(e,i,a){
                                $(`#bar3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BARC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c20_base").empty().append(htmlB);

                            var span = $('#bar3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC17,BARC17V,BARC17B,BARC17C,"Simple");
                            BARC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bar3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BARC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c17_base").empty().append(htmlB);

                            var span = $('#bar3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC18,BARC18V,BARC18B,BARC18C,"Simple");
                            var max = (Math.max(...BARC18V)+20);
                            customizedArray(BARC18V,BARC18VX,BARC18label,colorPallet69,"Bar");
                            barChart(BARC18VX,"bar3_c18",BARC18label,max);

                            var baseX = processBase(BARC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c18_base").empty().append(htmlB);

                            var span = $('#bar3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC19,BARC19V,BARC19B,BARC19C,"Simple");
                            var max = (Math.max(...BARC19V)+20);
                            customizedArray(BARC19V,BARC19VX,BARC19label,colorPallet69,"Bar");
                            barChart(BARC19VX,"bar3_c19",BARC19label,max);

                            var baseX = processBase(BARC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar3_c19_base").empty().append(htmlB);

                            var span = $('#bar3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_10, S13_10V, S13_10B, S13_10C, "Simple");
                            var max = (Math.max(...S13_10V)+20);
                            customizedArray(S13_10V,S13_10VX,S13label,colorPallet69,"Bar");
                            barChart(S13_10VX,"bar_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_10B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar_3_s13_base").empty().append(htmlB);

                            var span = $('#bar_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            barFStatus3 = true;
                            ajaxFlag[1+43] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fortyThreethAjax() {
                    $.ajax({
                        url: "api/ajax43.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'barcondX':barcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BARC0 = data['BAR_C0'];
                            var BARC2 = data['BAR_C2'];
                            var BARC3 = data['BAR_C3'];
                            var BARC4a = data['BAR_C4a'];
                            var BARC7 = data['BAR_C7'];
                            var BARC8 = data['BAR_C8'];
                            var BARC9 = data['BAR_C9'];
                            var BARC10 = data['BAR_C10'];
                            var BARC11 = data['BAR_C11'];
                            var BARC12 = data['BAR_C12'];
                            var BARC15 = data['BAR_C15'];
                            var BARC16 = data['BAR_C16'];
                            var BARC17 = data['BAR_C17'];
                            var BARC18 = data['BAR_C18'];
                            var BARC19 = data['BAR_C19'];
                            var BARC20 = data['BAR_C20'];

                            var S13_10 = data['S13_10'];

                            var BARC0V = [];
                            var BARC0B = [];
                            var BARC0C = [];
                            var BARC0VX = [];

                            var BARC2V = [];
                            var BARC2B = [];
                            var BARC2C = [];
                            var BARC2VX = [];

                            var BARC3V = [];
                            var BARC3B = [];
                            var BARC3C = [];
                            var BARC3VX = [];

                            var BARC4aV = [];
                            var BARC4aB = [];
                            var BARC4aC = [];
                            var BARC4aVX = [];

                            var BARC7V = [];
                            var BARC7B = [];
                            var BARC7C = [];
                            var BARC7VX = [];

                            var BARC8V = [];
                            var BARC8B = [];
                            var BARC8C = [];
                            var BARC8VX = [];

                            var BARC9V = [];
                            var BARC9B = [];
                            var BARC9C = [];
                            var BARC9VX = [];

                            var BARC10V = [];
                            var BARC10B = [];
                            var BARC10C = [];
                            var BARC10VX = [];

                            var BARC11V = [];
                            var BARC11B = [];
                            var BARC11C = [];
                            var BARC11VX = [];

                            var BARC12V = [];
                            var BARC12B = [];
                            var BARC12C = [];
                            var BARC12VX = [];

                            var BARC13V = [];
                            var BARC13B = [];
                            var BARC13C = [];
                            var BARC13VX = [];

                            var BARC14V = [];
                            var BARC14B = [];
                            var BARC14C = [];
                            var BARC14VX = [];

                            var BARC15V = [];
                            var BARC15B = [];
                            var BARC15C = [];
                            var BARC15VX = [];

                            var BARC16V = [];
                            var BARC16B = [];
                            var BARC16C = [];
                            var BARC16VX = [];

                            var BARC17V = [];
                            var BARC17B = [];
                            var BARC17C = [];
                            var BARC17VX = [];

                            var BARC18V = [];
                            var BARC18B = [];
                            var BARC18C = [];
                            var BARC18VX = [];

                            var BARC19V = [];
                            var BARC19B = [];
                            var BARC19C = [];
                            var BARC19VX = [];

                            var BARC20V = [];
                            var BARC20B = [];
                            var BARC20C = [];
                            var BARC20VX = [];

                            var S13_10V = [];
                            var S13_10B = [];
                            var S13_10C = [];
                            var S13_10VX = [];

                            if(barFStatus4==false)
                            {
                                extractValues(BARC0,BARC0V,BARC0B,BARC0C,"Simple");
                                BARC0V.forEach(function(e,i,a){
                                    $(`#bar4_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BARC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bar4_c0_base").empty().append(htmlB);

                                var span = $('#bar4_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BARC2,BARC2V,BARC2B,BARC2C,"Simple");
                            customizedArray(BARC2V,BARC2VX,BARC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BARC2VX,"bar4_c2","Type of protein","auto");

                            var baseX = processBase(BARC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c2_base").empty().append(htmlB);

                            var span = $('#bar4_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC3,BARC3V,BARC3B,BARC3C,"Simple");
                            customizedArray(BARC3V,BARC3VX,BARC3label,colorPallet68,"Doughnut");
                            doughnutChart2(BARC3VX,"bar4_c3","Type of protein","auto");

                            var baseX = processBase(BARC3B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c3_base").empty().append(htmlB);

                            var span = $('#bar4_c3_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(BARC4a,BARC4aV,BARC4aB,BARC4aC,"Simple");
                            customizedArray(BARC4aV,BARC4aVX,BARC4alabel,colorPallet68,"Doughnut");
                            doughnutChart2(BARC4aVX,"bar4_c4a","Type of protein","auto");

                            var baseX = processBase(BARC4aB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c4a_base").empty().append(htmlB);

                            var span = $('#bar4_c4a_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC7,BARC7V,BARC7B,BARC7C,"Simple");
                            customizedArray(BARC7V,BARC7VX,BARC7label,colorPallet68,"Doughnut");
                            pieChart(BARC7VX,"bar4_c7","Type of Packaging","auto");

                            var baseX = processBase(BARC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c7_base").empty().append(htmlB);

                            var span = $('#bar4_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC8,BARC8V,BARC8B,BARC8C,"Simple");
                            var max = (Math.max(...BARC8V)+20);
                            customizedArray(BARC8V,BARC8VX,BARC8label,colorPallet69,"Bar");
                            barChart(BARC8VX,"bar4_c8",BARC8label,max);

                            var baseX = processBase(BARC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c8_base").empty().append(htmlB);

                            var span = $('#bar4_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC9,BARC9V,BARC9B,BARC9C,"Simple");
                            var max = (Math.max(...BARC9V)+20);
                            customizedArray(BARC9V,BARC9VX,BARC9label,colorPallet69,"Bar");
                            barChart(BARC9VX,"bar4_c9",BARC9label,max);

                            var baseX = processBase(BARC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c9_base").empty().append(htmlB);

                            var span = $('#bar4_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC10,BARC10V,BARC10B,BARC10C,"Simple");
                            customizedArray(BARC10V,BARC10VX,BARC10label,colorPallet68,"Doughnut");
                            pieChart(BARC10VX,"bar4_c10","Way of consumption","auto");

                            var baseX = processBase(BARC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c10_base").empty().append(htmlB);

                            var span = $('#bar4_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC11,BARC11V,BARC11B,BARC11C,"Simple");
                            var max = (Math.max(...BARC11V)+20);
                            customizedArray(BARC11V,BARC11VX,BARC11label,colorPallet69,"Bar");
                            columnChart(BARC11VX,"bar4_c11",BARC11label,max);

                            var baseX = processBase(BARC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c11_base").empty().append(htmlB);

                            var span = $('#bar4_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC16,BARC16V,BARC16B,BARC16C,"Simple");
                            var max = (Math.max(...BARC16V)+20);
                            customizedArray(BARC16V,BARC16VX,BARC16label,colorPallet69,"Bar");
                            barChart(BARC16VX,"bar4_c16",BARC16label,max);

                            var baseX = processBase(BARC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c16_base").empty().append(htmlB);

                            var span = $('#bar4_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC12,BARC12V,BARC12B,BARC12C,"Simple");
                            var max = (Math.max(...BARC12V)+20);
                            customizedArray(BARC12V,BARC12VX,BARC12label,colorPallet69,"Bar");
                            columnChart(BARC12VX,"bar4_c12",BARC12label,max);

                            var baseX = processBase(BARC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c12_base").empty().append(htmlB);

                            var span = $('#bar4_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC15,BARC15V,BARC15B,BARC15C,"Simple");
                            BARC15V.forEach(function(e,i,a){
                                $(`#bar4_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BARC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c15_base").empty().append(htmlB);

                            var span = $('#bar4_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC20,BARC20V,BARC20B,BARC20C,"Simple");
                            BARC20V.forEach(function(e,i,a){
                                $(`#bar4_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BARC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c20_base").empty().append(htmlB);

                            var span = $('#bar4_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC17,BARC17V,BARC17B,BARC17C,"Simple");
                            BARC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bar4_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BARC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c17_base").empty().append(htmlB);

                            var span = $('#bar4_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC18,BARC18V,BARC18B,BARC18C,"Simple");
                            var max = (Math.max(...BARC18V)+20);
                            customizedArray(BARC18V,BARC18VX,BARC18label,colorPallet69,"Bar");
                            barChart(BARC18VX,"bar4_c18",BARC18label,max);

                            var baseX = processBase(BARC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c18_base").empty().append(htmlB);

                            var span = $('#bar4_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BARC19,BARC19V,BARC19B,BARC19C,"Simple");
                            var max = (Math.max(...BARC19V)+20);
                            customizedArray(BARC19V,BARC19VX,BARC19label,colorPallet69,"Bar");
                            barChart(BARC19VX,"bar4_c19",BARC19label,max);

                            var baseX = processBase(BARC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar4_c19_base").empty().append(htmlB);

                            var span = $('#bar4_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_10, S13_10V, S13_10B, S13_10C, "Simple");
                            var max = (Math.max(...S13_10V)+20);
                            customizedArray(S13_10V,S13_10VX,S13label,colorPallet69,"Bar");
                            barChart(S13_10VX,"bar_4_s13",S13label,max);
                            
                            var baseX = processBase(S13_10B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bar_4_s13_base").empty().append(htmlB);

                            var span = $('#bar_4_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            barFStatus4 = true;
                            ajaxFlag[1+44] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fortyFourthAjax() {
                    $.ajax({
                        url: "api/ajax44.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'breadcondX':breadcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BBC0 = data['BB_C0'];
                            var BBC1 = data['BB_C1'];
                            var BBC2 = data['BB_C2'];
                            var BBC6 = data['BB_C6'];
                            var BBC7 = data['BB_C7'];
                            var BBC8 = data['BB_C8'];
                            var BBC9 = data['BB_C9'];
                            var BBC10 = data['BB_C10'];
                            var BBC11 = data['BB_C11'];
                            var BBC12 = data['BB_C12'];
                            var BBC15 = data['BB_C15'];
                            var BBC16 = data['BB_C16'];
                            var BBC17 = data['BB_C17'];
                            var BBC18 = data['BB_C18'];
                            var BBC19 = data['BB_C19'];
                            var BBC20 = data['BB_C20'];

                            var S13_13 = data['S13_13'];

                            var BBC0V = [];
                            var BBC0B = [];
                            var BBC0C = [];
                            var BBC0VX = [];

                            var BBC1V = [];
                            var BBC1B = [];
                            var BBC1C = [];
                            var BBC1VX = [];

                            var BBC2V = [];
                            var BBC2B = [];
                            var BBC2C = [];
                            var BBC2VX = [];

                            var BBC6V = [];
                            var BBC6B = [];
                            var BBC6C = [];
                            var BBC6VX = [];

                            var BBC7V = [];
                            var BBC7B = [];
                            var BBC7C = [];
                            var BBC7VX = [];

                            var BBC8V = [];
                            var BBC8B = [];
                            var BBC8C = [];
                            var BBC8VX = [];

                            var BBC9V = [];
                            var BBC9B = [];
                            var BBC9C = [];
                            var BBC9VX = [];

                            var BBC10V = [];
                            var BBC10B = [];
                            var BBC10C = [];
                            var BBC10VX = [];

                            var BBC11V = [];
                            var BBC11B = [];
                            var BBC11C = [];
                            var BBC11VX = [];

                            var BBC12V = [];
                            var BBC12B = [];
                            var BBC12C = [];
                            var BBC12VX = [];

                            var BBC13V = [];
                            var BBC13B = [];
                            var BBC13C = [];
                            var BBC13VX = [];

                            var BBC14V = [];
                            var BBC14B = [];
                            var BBC14C = [];
                            var BBC14VX = [];

                            var BBC15V = [];
                            var BBC15B = [];
                            var BBC15C = [];
                            var BBC15VX = [];

                            var BBC16V = [];
                            var BBC16B = [];
                            var BBC16C = [];
                            var BBC16VX = [];

                            var BBC17V = [];
                            var BBC17B = [];
                            var BBC17C = [];
                            var BBC17VX = [];

                            var BBC18V = [];
                            var BBC18B = [];
                            var BBC18C = [];
                            var BBC18VX = [];

                            var BBC19V = [];
                            var BBC19B = [];
                            var BBC19C = [];
                            var BBC19VX = [];

                            var BBC20V = [];
                            var BBC20B = [];
                            var BBC20C = [];
                            var BBC20VX = [];

                            var S13_13V = [];
                            var S13_13B = [];
                            var S13_13C = [];
                            var S13_13VX = [];

                            if(breadFStatus1==false)
                            {
                                extractValues(BBC0,BBC0V,BBC0B,BBC0C,"Simple");
                                BBC0V.forEach(function(e,i,a){
                                    $(`#bb1_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BBC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bb1_c0_base").empty().append(htmlB);

                                var span = $('#bb1_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BBC1,BBC1V,BBC1B,BBC1C,"Simple");
                            customizedArray(BBC1V,BBC1VX,BBC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(BBC1VX,"bb1_c1","Category Consumed",290);

                            var baseX = processBase(BBC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c1_base").empty().append(htmlB);

                            var span = $('#bb1_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(BBC2,BBC2V,BBC2B,BBC2C,"Simple");
                            customizedArray(BBC2V,BBC2VX,BBC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BBC2VX,"bb1_c2","Type of protein","auto");

                            var baseX = processBase(BBC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c2_base").empty().append(htmlB);

                            var span = $('#bb1_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC6,BBC6V,BBC6B,BBC6C,"Simple");
                            customizedArray(BBC6V,BBC6VX,BBC6label,colorPallet69,"Doughnut");
                            pieChart(BBC6VX,"bb1_c6","Type of Packaging","auto");

                            var baseX = processBase(BBC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c6_base").empty().append(htmlB);

                            var span = $('#bb1_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC7,BBC7V,BBC7B,BBC7C,"Simple");
                            customizedArray(BBC7V,BBC7VX,BBC7label,colorPallet68,"Doughnut");
                            pieChart(BBC7VX,"bb1_c7","Type of Packaging","auto");

                            var baseX = processBase(BBC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c7_base").empty().append(htmlB);

                            var span = $('#bb1_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC8,BBC8V,BBC8B,BBC8C,"Simple");
                            var max = (Math.max(...BBC8V)+20);
                            customizedArray(BBC8V,BBC8VX,BBC8label,colorPallet69,"Bar");
                            barChart(BBC8VX,"bb1_c8",BBC8label,max);

                            var baseX = processBase(BBC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c8_base").empty().append(htmlB);

                            var span = $('#bb1_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC9,BBC9V,BBC9B,BBC9C,"Simple");
                            var max = (Math.max(...BBC9V)+20);
                            customizedArray(BBC9V,BBC9VX,BBC9label,colorPallet69,"Bar");
                            barChart(BBC9VX,"bb1_c9",BBC9label,max);

                            var baseX = processBase(BBC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c9_base").empty().append(htmlB);

                            var span = $('#bb1_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC10,BBC10V,BBC10B,BBC10C,"Simple");
                            customizedArray(BBC10V,BBC10VX,BBC10label,colorPallet68,"Doughnut");
                            pieChart(BBC10VX,"bb1_c10","Way of consumption","auto");

                            var baseX = processBase(BBC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c10_base").empty().append(htmlB);

                            var span = $('#bb1_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC11,BBC11V,BBC11B,BBC11C,"Simple");
                            var max = (Math.max(...BBC11V)+20);
                            customizedArray(BBC11V,BBC11VX,BBC11label,colorPallet69,"Bar");
                            columnChart(BBC11VX,"bb1_c11",BBC11label,max);

                            var baseX = processBase(BBC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c11_base").empty().append(htmlB);

                            var span = $('#bb1_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC16,BBC16V,BBC16B,BBC16C,"Simple");
                            var max = (Math.max(...BBC16V)+20);
                            customizedArray(BBC16V,BBC16VX,BBC16label,colorPallet69,"Bar");
                            barChart(BBC16VX,"bb1_c16",BBC16label,max);

                            var baseX = processBase(BBC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c16_base").empty().append(htmlB);

                            var span = $('#bb1_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC12,BBC12V,BBC12B,BBC12C,"Simple");
                            var max = (Math.max(...BBC12V)+20);
                            customizedArray(BBC12V,BBC12VX,BBC12label,colorPallet69,"Bar");
                            columnChart(BBC12VX,"bb1_c12",BBC12label,max);

                            var baseX = processBase(BBC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c12_base").empty().append(htmlB);

                            var span = $('#bb1_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC15,BBC15V,BBC15B,BBC15C,"Simple");
                            BBC15V.forEach(function(e,i,a){
                                $(`#bb1_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BBC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c15_base").empty().append(htmlB);

                            var span = $('#bb1_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC20,BBC20V,BBC20B,BBC20C,"Simple");
                            BBC20V.forEach(function(e,i,a){
                                $(`#bb1_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BBC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c20_base").empty().append(htmlB);

                            var span = $('#bb1_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC17,BBC17V,BBC17B,BBC17C,"Simple");
                            BBC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bb1_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BBC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c17_base").empty().append(htmlB);

                            var span = $('#bb1_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC18,BBC18V,BBC18B,BBC18C,"Simple");
                            var max = (Math.max(...BBC18V)+20);
                            customizedArray(BBC18V,BBC18VX,BBC18label,colorPallet69,"Bar");
                            barChart(BBC18VX,"bb1_c18",BBC18label,max);

                            var baseX = processBase(BBC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c18_base").empty().append(htmlB);

                            var span = $('#bb1_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC19,BBC19V,BBC19B,BBC19C,"Simple");
                            var max = (Math.max(...BBC19V)+20);
                            customizedArray(BBC19V,BBC19VX,BBC19label,colorPallet69,"Bar");
                            barChart(BBC19VX,"bb1_c19",BBC19label,max);

                            var baseX = processBase(BBC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb1_c19_base").empty().append(htmlB);

                            var span = $('#bb1_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_13, S13_13V, S13_13B, S13_13C, "Simple");
                            var max = (Math.max(...S13_13V)+20);
                            customizedArray(S13_13V,S13_13VX,S13label,colorPallet69,"Bar");
                            barChart(S13_13VX,"bb_1_s13",S13label,max);
                            
                            var baseX = processBase(S13_13B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb_1_s13_base").empty().append(htmlB);

                            var span = $('#bb_1_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            breadFStatus1 = true;
                            ajaxFlag[1+45] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fortyFivethAjax() {
                    $.ajax({
                        url: "api/ajax45.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'breadcondX':breadcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BBC0 = data['BB_C0'];
                            var BBC1 = data['BB_C1'];
                            var BBC2 = data['BB_C2'];
                            var BBC6 = data['BB_C6'];
                            var BBC7 = data['BB_C7'];
                            var BBC8 = data['BB_C8'];
                            var BBC9 = data['BB_C9'];
                            var BBC10 = data['BB_C10'];
                            var BBC11 = data['BB_C11'];
                            var BBC12 = data['BB_C12'];
                            var BBC15 = data['BB_C15'];
                            var BBC16 = data['BB_C16'];
                            var BBC17 = data['BB_C17'];
                            var BBC18 = data['BB_C18'];
                            var BBC19 = data['BB_C19'];
                            var BBC20 = data['BB_C20'];

                            var S13_13 = data['S13_13'];

                            var BBC0V = [];
                            var BBC0B = [];
                            var BBC0C = [];
                            var BBC0VX = [];

                            var BBC1V = [];
                            var BBC1B = [];
                            var BBC1C = [];
                            var BBC1VX = [];

                            var BBC2V = [];
                            var BBC2B = [];
                            var BBC2C = [];
                            var BBC2VX = [];

                            var BBC6V = [];
                            var BBC6B = [];
                            var BBC6C = [];
                            var BBC6VX = [];

                            var BBC7V = [];
                            var BBC7B = [];
                            var BBC7C = [];
                            var BBC7VX = [];

                            var BBC8V = [];
                            var BBC8B = [];
                            var BBC8C = [];
                            var BBC8VX = [];

                            var BBC9V = [];
                            var BBC9B = [];
                            var BBC9C = [];
                            var BBC9VX = [];

                            var BBC10V = [];
                            var BBC10B = [];
                            var BBC10C = [];
                            var BBC10VX = [];

                            var BBC11V = [];
                            var BBC11B = [];
                            var BBC11C = [];
                            var BBC11VX = [];

                            var BBC12V = [];
                            var BBC12B = [];
                            var BBC12C = [];
                            var BBC12VX = [];

                            var BBC13V = [];
                            var BBC13B = [];
                            var BBC13C = [];
                            var BBC13VX = [];

                            var BBC14V = [];
                            var BBC14B = [];
                            var BBC14C = [];
                            var BBC14VX = [];

                            var BBC15V = [];
                            var BBC15B = [];
                            var BBC15C = [];
                            var BBC15VX = [];

                            var BBC16V = [];
                            var BBC16B = [];
                            var BBC16C = [];
                            var BBC16VX = [];

                            var BBC17V = [];
                            var BBC17B = [];
                            var BBC17C = [];
                            var BBC17VX = [];

                            var BBC18V = [];
                            var BBC18B = [];
                            var BBC18C = [];
                            var BBC18VX = [];

                            var BBC19V = [];
                            var BBC19B = [];
                            var BBC19C = [];
                            var BBC19VX = [];

                            var BBC20V = [];
                            var BBC20B = [];
                            var BBC20C = [];
                            var BBC20VX = [];

                            var S13_13V = [];
                            var S13_13B = [];
                            var S13_13C = [];
                            var S13_13VX = [];

                            if(breadFStatus2==false)
                            {
                                extractValues(BBC0,BBC0V,BBC0B,BBC0C,"Simple");
                                BBC0V.forEach(function(e,i,a){
                                    $(`#bb2_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BBC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bb2_c0_base").empty().append(htmlB);

                                var span = $('#bb2_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BBC1,BBC1V,BBC1B,BBC1C,"Simple");
                            customizedArray(BBC1V,BBC1VX,BBC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(BBC1VX,"bb2_c1","Category Consumed",290);

                            var baseX = processBase(BBC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c1_base").empty().append(htmlB);

                            var span = $('#bb2_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(BBC2,BBC2V,BBC2B,BBC2C,"Simple");
                            customizedArray(BBC2V,BBC2VX,BBC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BBC2VX,"bb2_c2","Type of protein","auto");

                            var baseX = processBase(BBC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c2_base").empty().append(htmlB);

                            var span = $('#bb2_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC6,BBC6V,BBC6B,BBC6C,"Simple");
                            customizedArray(BBC6V,BBC6VX,BBC6label,colorPallet69,"Doughnut");
                            pieChart(BBC6VX,"bb2_c6","Type of Packaging","auto");

                            var baseX = processBase(BBC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c6_base").empty().append(htmlB);

                            var span = $('#bb2_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC7,BBC7V,BBC7B,BBC7C,"Simple");
                            customizedArray(BBC7V,BBC7VX,BBC7label,colorPallet68,"Doughnut");
                            pieChart(BBC7VX,"bb2_c7","Type of Packaging","auto");

                            var baseX = processBase(BBC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c7_base").empty().append(htmlB);

                            var span = $('#bb2_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC8,BBC8V,BBC8B,BBC8C,"Simple");
                            var max = (Math.max(...BBC8V)+20);
                            customizedArray(BBC8V,BBC8VX,BBC8label,colorPallet69,"Bar");
                            barChart(BBC8VX,"bb2_c8",BBC8label,max);

                            var baseX = processBase(BBC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c8_base").empty().append(htmlB);

                            var span = $('#bb2_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC9,BBC9V,BBC9B,BBC9C,"Simple");
                            var max = (Math.max(...BBC9V)+20);
                            customizedArray(BBC9V,BBC9VX,BBC9label,colorPallet69,"Bar");
                            barChart(BBC9VX,"bb2_c9",BBC9label,max);

                            var baseX = processBase(BBC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c9_base").empty().append(htmlB);

                            var span = $('#bb2_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC10,BBC10V,BBC10B,BBC10C,"Simple");
                            customizedArray(BBC10V,BBC10VX,BBC10label,colorPallet68,"Doughnut");
                            pieChart(BBC10VX,"bb2_c10","Way of consumption","auto");

                            var baseX = processBase(BBC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c10_base").empty().append(htmlB);

                            var span = $('#bb2_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC11,BBC11V,BBC11B,BBC11C,"Simple");
                            var max = (Math.max(...BBC11V)+20);
                            customizedArray(BBC11V,BBC11VX,BBC11label,colorPallet69,"Bar");
                            columnChart(BBC11VX,"bb2_c11",BBC11label,max);

                            var baseX = processBase(BBC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c11_base").empty().append(htmlB);

                            var span = $('#bb2_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC16,BBC16V,BBC16B,BBC16C,"Simple");
                            var max = (Math.max(...BBC16V)+20);
                            customizedArray(BBC16V,BBC16VX,BBC16label,colorPallet69,"Bar");
                            barChart(BBC16VX,"bb2_c16",BBC16label,max);

                            var baseX = processBase(BBC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c16_base").empty().append(htmlB);

                            var span = $('#bb2_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC12,BBC12V,BBC12B,BBC12C,"Simple");
                            var max = (Math.max(...BBC12V)+20);
                            customizedArray(BBC12V,BBC12VX,BBC12label,colorPallet69,"Bar");
                            columnChart(BBC12VX,"bb2_c12",BBC12label,max);

                            var baseX = processBase(BBC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c12_base").empty().append(htmlB);

                            var span = $('#bb2_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC15,BBC15V,BBC15B,BBC15C,"Simple");
                            BBC15V.forEach(function(e,i,a){
                                $(`#bb2_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BBC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c15_base").empty().append(htmlB);

                            var span = $('#bb2_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC20,BBC20V,BBC20B,BBC20C,"Simple");
                            BBC20V.forEach(function(e,i,a){
                                $(`#bb2_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BBC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c20_base").empty().append(htmlB);

                            var span = $('#bb2_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC17,BBC17V,BBC17B,BBC17C,"Simple");
                            BBC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bb2_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BBC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c17_base").empty().append(htmlB);

                            var span = $('#bb2_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC18,BBC18V,BBC18B,BBC18C,"Simple");
                            var max = (Math.max(...BBC18V)+20);
                            customizedArray(BBC18V,BBC18VX,BBC18label,colorPallet69,"Bar");
                            barChart(BBC18VX,"bb2_c18",BBC18label,max);

                            var baseX = processBase(BBC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c18_base").empty().append(htmlB);

                            var span = $('#bb2_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC19,BBC19V,BBC19B,BBC19C,"Simple");
                            var max = (Math.max(...BBC19V)+20);
                            customizedArray(BBC19V,BBC19VX,BBC19label,colorPallet69,"Bar");
                            barChart(BBC19VX,"bb2_c19",BBC19label,max);

                            var baseX = processBase(BBC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb2_c19_base").empty().append(htmlB);

                            var span = $('#bb2_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_13, S13_13V, S13_13B, S13_13C, "Simple");
                            var max = (Math.max(...S13_13V)+20);
                            customizedArray(S13_13V,S13_13VX,S13label,colorPallet69,"Bar");
                            barChart(S13_13VX,"bb_2_s13",S13label,max);
                            
                            var baseX = processBase(S13_13B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb_2_s13_base").empty().append(htmlB);

                            var span = $('#bb_2_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            breadFStatus2 = true;
                            ajaxFlag[1+46] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function fortySixthAjax() {
                    $.ajax({
                        url: "api/ajax46.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                            'breadcondX':breadcondX
                        },
                        success: function(response) {
                            var data = JSON.parse(response);

                            var BBC0 = data['BB_C0'];
                            var BBC1 = data['BB_C1'];
                            var BBC2 = data['BB_C2'];
                            var BBC6 = data['BB_C6'];
                            var BBC7 = data['BB_C7'];
                            var BBC8 = data['BB_C8'];
                            var BBC9 = data['BB_C9'];
                            var BBC10 = data['BB_C10'];
                            var BBC11 = data['BB_C11'];
                            var BBC12 = data['BB_C12'];
                            var BBC15 = data['BB_C15'];
                            var BBC16 = data['BB_C16'];
                            var BBC17 = data['BB_C17'];
                            var BBC18 = data['BB_C18'];
                            var BBC19 = data['BB_C19'];
                            var BBC20 = data['BB_C20'];

                            var S13_13 = data['S13_13'];

                            var BBC0V = [];
                            var BBC0B = [];
                            var BBC0C = [];
                            var BBC0VX = [];

                            var BBC1V = [];
                            var BBC1B = [];
                            var BBC1C = [];
                            var BBC1VX = [];

                            var BBC2V = [];
                            var BBC2B = [];
                            var BBC2C = [];
                            var BBC2VX = [];

                            var BBC6V = [];
                            var BBC6B = [];
                            var BBC6C = [];
                            var BBC6VX = [];

                            var BBC7V = [];
                            var BBC7B = [];
                            var BBC7C = [];
                            var BBC7VX = [];

                            var BBC8V = [];
                            var BBC8B = [];
                            var BBC8C = [];
                            var BBC8VX = [];

                            var BBC9V = [];
                            var BBC9B = [];
                            var BBC9C = [];
                            var BBC9VX = [];

                            var BBC10V = [];
                            var BBC10B = [];
                            var BBC10C = [];
                            var BBC10VX = [];

                            var BBC11V = [];
                            var BBC11B = [];
                            var BBC11C = [];
                            var BBC11VX = [];

                            var BBC12V = [];
                            var BBC12B = [];
                            var BBC12C = [];
                            var BBC12VX = [];

                            var BBC13V = [];
                            var BBC13B = [];
                            var BBC13C = [];
                            var BBC13VX = [];

                            var BBC14V = [];
                            var BBC14B = [];
                            var BBC14C = [];
                            var BBC14VX = [];

                            var BBC15V = [];
                            var BBC15B = [];
                            var BBC15C = [];
                            var BBC15VX = [];

                            var BBC16V = [];
                            var BBC16B = [];
                            var BBC16C = [];
                            var BBC16VX = [];

                            var BBC17V = [];
                            var BBC17B = [];
                            var BBC17C = [];
                            var BBC17VX = [];

                            var BBC18V = [];
                            var BBC18B = [];
                            var BBC18C = [];
                            var BBC18VX = [];

                            var BBC19V = [];
                            var BBC19B = [];
                            var BBC19C = [];
                            var BBC19VX = [];

                            var BBC20V = [];
                            var BBC20B = [];
                            var BBC20C = [];
                            var BBC20VX = [];

                            var S13_13V = [];
                            var S13_13B = [];
                            var S13_13C = [];
                            var S13_13VX = [];

                            if(breadFStatus3==false)
                            {
                                extractValues(BBC0,BBC0V,BBC0B,BBC0C,"Simple");
                                BBC0V.forEach(function(e,i,a){
                                    $(`#bb3_c0_${i+1}`).empty().append(`${e}%`);
                                });
                                var baseX = processBase(BBC0B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#bb3_c0_base").empty().append(htmlB);

                                var span = $('#bb3_c0_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(BBC1,BBC1V,BBC1B,BBC1C,"Simple");
                            customizedArray(BBC1V,BBC1VX,BBC1label,colorPallet68,"Doughnut");
                            doughnutChart1_1(BBC1VX,"bb3_c1","Category Consumed",290);

                            var baseX = processBase(BBC1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c1_base").empty().append(htmlB);

                            var span = $('#bb3_c1_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(BBC2,BBC2V,BBC2B,BBC2C,"Simple");
                            customizedArray(BBC2V,BBC2VX,BBC2label,colorPallet68,"Doughnut");
                            doughnutChart2(BBC2VX,"bb3_c2","Type of protein","auto");

                            var baseX = processBase(BBC2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c2_base").empty().append(htmlB);

                            var span = $('#bb3_c2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC6,BBC6V,BBC6B,BBC6C,"Simple");
                            customizedArray(BBC6V,BBC6VX,BBC6label,colorPallet69,"Doughnut");
                            pieChart(BBC6VX,"bb3_c6","Type of Packaging","auto");

                            var baseX = processBase(BBC6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c6_base").empty().append(htmlB);

                            var span = $('#bb3_c6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC7,BBC7V,BBC7B,BBC7C,"Simple");
                            customizedArray(BBC7V,BBC7VX,BBC7label,colorPallet68,"Doughnut");
                            pieChart(BBC7VX,"bb3_c7","Type of Packaging","auto");

                            var baseX = processBase(BBC7B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c7_base").empty().append(htmlB);

                            var span = $('#bb3_c7_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC8,BBC8V,BBC8B,BBC8C,"Simple");
                            var max = (Math.max(...BBC8V)+20);
                            customizedArray(BBC8V,BBC8VX,BBC8label,colorPallet69,"Bar");
                            barChart(BBC8VX,"bb3_c8",BBC8label,max);

                            var baseX = processBase(BBC8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c8_base").empty().append(htmlB);

                            var span = $('#bb3_c8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC9,BBC9V,BBC9B,BBC9C,"Simple");
                            var max = (Math.max(...BBC9V)+20);
                            customizedArray(BBC9V,BBC9VX,BBC9label,colorPallet69,"Bar");
                            barChart(BBC9VX,"bb3_c9",BBC9label,max);

                            var baseX = processBase(BBC9B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c9_base").empty().append(htmlB);

                            var span = $('#bb3_c9_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC10,BBC10V,BBC10B,BBC10C,"Simple");
                            customizedArray(BBC10V,BBC10VX,BBC10label,colorPallet68,"Doughnut");
                            pieChart(BBC10VX,"bb3_c10","Way of consumption","auto");

                            var baseX = processBase(BBC10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c10_base").empty().append(htmlB);

                            var span = $('#bb3_c10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC11,BBC11V,BBC11B,BBC11C,"Simple");
                            var max = (Math.max(...BBC11V)+20);
                            customizedArray(BBC11V,BBC11VX,BBC11label,colorPallet69,"Bar");
                            columnChart(BBC11VX,"bb3_c11",BBC11label,max);

                            var baseX = processBase(BBC11B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c11_base").empty().append(htmlB);

                            var span = $('#bb3_c11_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC16,BBC16V,BBC16B,BBC16C,"Simple");
                            var max = (Math.max(...BBC16V)+20);
                            customizedArray(BBC16V,BBC16VX,BBC16label,colorPallet69,"Bar");
                            barChart(BBC16VX,"bb3_c16",BBC16label,max);

                            var baseX = processBase(BBC16B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c16_base").empty().append(htmlB);

                            var span = $('#bb3_c16_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC12,BBC12V,BBC12B,BBC12C,"Simple");
                            var max = (Math.max(...BBC12V)+20);
                            customizedArray(BBC12V,BBC12VX,BBC12label,colorPallet69,"Bar");
                            columnChart(BBC12VX,"bb3_c12",BBC12label,max);

                            var baseX = processBase(BBC12B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c12_base").empty().append(htmlB);

                            var span = $('#bb3_c12_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC15,BBC15V,BBC15B,BBC15C,"Simple");
                            BBC15V.forEach(function(e,i,a){
                                $(`#bb3_c15_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BBC15B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c15_base").empty().append(htmlB);

                            var span = $('#bb3_c15_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC20,BBC20V,BBC20B,BBC20C,"Simple");
                            BBC20V.forEach(function(e,i,a){
                                $(`#bb3_c20_${i+1}`).empty().append(`${e}%`);
                            });

                            var baseX = processBase(BBC20B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c20_base").empty().append(htmlB);

                            var span = $('#bb3_c20_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC17,BBC17V,BBC17B,BBC17C,"Simple");
                            BBC17V.forEach(function(e,i,a){
                                doughnutChart3(e,`bb3_c17_${i+1}`,colorPallet69[i])
                            });

                            var baseX = processBase(BBC17B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c17_base").empty().append(htmlB);

                            var span = $('#bb3_c17_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC18,BBC18V,BBC18B,BBC18C,"Simple");
                            var max = (Math.max(...BBC18V)+20);
                            customizedArray(BBC18V,BBC18VX,BBC18label,colorPallet69,"Bar");
                            barChart(BBC18VX,"bb3_c18",BBC18label,max);

                            var baseX = processBase(BBC18B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c18_base").empty().append(htmlB);

                            var span = $('#bb3_c18_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            extractValues(BBC19,BBC19V,BBC19B,BBC19C,"Simple");
                            var max = (Math.max(...BBC19V)+20);
                            customizedArray(BBC19V,BBC19VX,BBC19label,colorPallet69,"Bar");
                            barChart(BBC19VX,"bb3_c19",BBC19label,max);

                            var baseX = processBase(BBC19B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb3_c19_base").empty().append(htmlB);

                            var span = $('#bb3_c19_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S13_13, S13_13V, S13_13B, S13_13C, "Simple");
                            var max = (Math.max(...S13_13V)+20);
                            customizedArray(S13_13V,S13_13VX,S13label,colorPallet69,"Bar");
                            barChart(S13_13VX,"bb_3_s13",S13label,max);
                            
                            var baseX = processBase(S13_13B);
                            var htmlB = ``;
                            htmlB += `(Those who consumed category in past 3 months (screener)=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#bb_3_s13_base").empty().append(htmlB);

                            var span = $('#bb_3_s13_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
                        },
                        complete: function (data) {
                            breadFStatus3 = true;
                            ajaxFlag[1+47] = true;
                            $(".splash").hide();
                            clickableSlice2();
                        }
                    });
                }

                function introAjax() {
                    $.ajax({
                        url: "api/introajax.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                        },
                        success: function(response) {
                            
                        },
                        complete: function (data) {
                            ajaxFlag[1+48] = true;
                            $(".splash").hide();
                        }
                    })
                }

                function profileAjax() {
                    //////////debugger;
                    allOptions = []
                    var countryValX = $("#country").val();
                    if(countryValX==null)
                    {
                        countryValX = [0];
                        allOptions = [0];
                    }
                    else
                    {
                        $("#HHI2 option").each(function() {
                            allOptions.push($(this).val()); // Store all option values
                        });
                    }
                    //console.log("allOptions");
                    //console.log(allOptions);
                    $.ajax({
                        url: "api/profileajax.php",
                        type: "POST",
                        data: {
                            'condX' : condX,
                            'conX' : conX,
                            'tblX' : tblX,
                            'countryValX' : countryValX,
                            'allOptions' : allOptions
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);
                            var HAGE = data['HAGE'];
                            var HAGE2 = data['HAGE2'];
                            var S4 = data['S4'];
                            var P5 = data['P5'];
                            var S2xSG = data['S2xSG'];
                            var P2 = data['P2'];
                            var S7 = data['S7'];
                            var S8 = data['S8'];
                            var S10 = data['S10'];
                            var raceP = data['race'];
                            var S1 = data['S1'];
                            var P6 = data['P6'];
                            var childrenCombine = data['children_combine'];

                            var HAGEV = [];
                            var HAGEB = [];
                            var HAGEC = [];
                            var HAGEVX = [];

                            var HAGE2V = [];
                            var HAGE2B = [];
                            var HAGE2C = [];
                            var HAGE2VX = [];

                            var S1V = [];
                            var S1B = [];
                            var S1C = [];
                            var S1VX = [];

                            var S4V = [];
                            var S4B = [];
                            var S4C = [];
                            var S4VX = [];

                            var S5V = [];
                            var S5B = [];
                            var S5C = [];
                            var S5VX = [];

                            var P5V = [];
                            var P5B = [];
                            var P5C = [];
                            var P5VX = [];

                            var S2xSGV = [];
                            var S2xSGB = [];
                            var S2xSGC = [];
                            var S2xSGVX = [];

                            var P2V = [];
                            var P2B = [];
                            var P2C = [];
                            var P2VX = [];

                            var S7V = [];
                            var S7B = [];
                            var S7C = [];
                            var S7VX = [];

                            var S8V = [];
                            var S8B = [];
                            var S8C = [];
                            var S8VX = [];

                            var S10V = [];
                            var S10B = [];
                            var S10C = [];
                            var S10VX = [];

                            var raceV = [];
                            var raceB = [];
                            var raceC = [];
                            var raceVX = [];

                            var P6V = [];
                            var P6B = [];
                            var P6C = [];
                            var P6VX = [];

                            var childrenCombineV = [];
                            var childrenCombineB = [];
                            var childrenCombineC = [];
                            var childrenCombineVX = [];

                            extractValues(HAGE,HAGEV,HAGEB,HAGEC,"Simple");
                            var max = (Math.max(...HAGEV)+20);
                            customizedArray(HAGEV,HAGEVX,ageLabelXXX,colorPallet2,"Bar");
                            barChart2(HAGEVX,"p_s5",ageLabelXXX,max,colorPallet69);

                            var baseX = processBase(HAGEB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#p_s5_base").empty().append(htmlB);

                            var span = $('#p_s5_base');
                            var htmlContent = span.html();
                            //console.log(htmlContent);
                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(HAGE2,HAGE2V,HAGE2B,HAGE2C,"Simple");
                            var max = (Math.max(...HAGE2V)+20);
                            customizedArray(HAGE2V,HAGE2VX,ageLabel2,colorPallet2,"Bar");
                            barChart2(HAGE2VX,"p_s52",ageLabel2,max,colorPallet69);

                            var baseX = processBase(HAGE2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#p_s52_base").empty().append(htmlB);

                            var span = $('#p_s52_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S4,S4V,S4B,S4C,"Simple");
                            var max = (Math.max(...S4V)+20);
                            customizedArray(S4V,S4VX,genderLabel,colorPallet2,"Bar");
                            barChart2(S4VX,"p_s4",genderLabel,max,colorPallet69);

                            var baseX = processBase(S4B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#p_s4_base").empty().append(htmlB);

                            var span = $('#p_s4_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(P5,P5V,P5B,P5C,"Simple");
                            customizedArray(P5V,P5VX,occupationLabel,colorPallet2,"Doughnut");
                            doughnutChart1_1(P5VX,"p_p5","Occupation",295);

                            var baseX = processBase(P5B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#p_p5_base").empty().append(htmlB);

                            var span = $('#p_p5_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(P6,P6V,P6B,P6C,"Simple");
                            customizedArray(P6V,P6VX,wfhLabel,colorPallet2,"Doughnut");
                            doughnutChart2(P6VX,"p_p6","Work from Home",295);

                            var baseX = processBase(P6B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#p_p6_base").empty().append(htmlB);

                            var span = $('#p_p6_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }
 
                            //

                            extractValues(childrenCombine,childrenCombineV,childrenCombineB,childrenCombineC,"Simple");
                            var max = (Math.max(...childrenCombineV)+20);
                            customizedArray(childrenCombineV,childrenCombineVX,childrenLabel2,colorPallet2,"Bar");
                            barChart2(childrenCombineVX,"p_p23",childrenLabel2,max,colorPallet69,295);

                            var baseX = processBase(childrenCombineB);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#p_s23_base").empty().append(htmlB);

                            var span = $('#p_s23_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(P2,P2V,P2B,P2C,"Simple");
                            customizedArray(P2V,P2VX,childrenLabel,colorPallet3,"Doughnut");
                            doughnutChart2(P2VX,"p_p2","Children Household",220);

                            var baseX = processBase(P2B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#p_p2_base").empty().append(htmlB);

                            var span = $('#p_p2_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S8,S8V,S8B,S8C,"Simple");
                            var max = (Math.max(...S8V)+20);
                            customizedArray(S8V,S8VX,dietLabel,colorPallet2,"Bar");
                            barChart2(S8VX,"p_s8",dietLabel,max,colorPallet69);

                            var baseX = processBase(S8B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#p_s8_base").empty().append(htmlB);

                            var span = $('#p_s8_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            extractValues(S10,S10V,S10B,S10C,"Simple");
                            var max = (Math.max(...S10V)+20);
                            customizedArray(S10V,S10VX,halalLabel,colorPallet2,"Bar");
                            barChart2(S10VX,"p_s10",halalLabel,max,colorPallet69);

                            var baseX = processBase(S10B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            $("#p_s10_base").empty().append(htmlB);

                            var span = $('#p_s10_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                            // 

                            if(countryValX[0]=="1")
                            {
                                extractValues(raceP,raceV,raceB,raceC,"Simple");
                                customizedArray(raceV,raceVX,raceLabel[0],colorPallet2,"Doughnut");
                                doughnutChart1_1(raceVX,"p_s2","Race",240);

                                var baseX = processBase(raceB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#p_s2_base").empty().append(htmlB);

                                var span = $('#p_s2_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }
                            else if(countryValX[0]=="5")
                            {
                                extractValues(raceP,raceV,raceB,raceC,"Simple");
                                customizedArray(raceV,raceVX,raceLabel[4],colorPallet2,"Doughnut");
                                doughnutChart1_1(raceVX,"p_s2","Race",240);

                                var baseX = processBase(raceB);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#p_s2_base").empty().append(htmlB);

                                var span = $('#p_s2_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }
                            else{}

                            if(countryValX[0]!="0")
                            {
                                extractValues(S7,S7V,S7B,S7C,"Simple");
                                customizedArray(S7V,S7VX,HHI_profile_label2[parseInt(countryValX[0]-1)],colorPallet2,"Doughnut");
                                doughnutChart2(S7VX,"p_s7","HHI",295);

                                var baseX = processBase(S7B);
                                var htmlB = ``;
                                htmlB += `(Base=`;
                                baseX.forEach(function (e, i, a) {
                                    if (e < 30) {
                                        htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                    } else {
                                        htmlB += `${e})`;
                                    }
                                });

                                $("#p_s7_base").empty().append(htmlB);

                                var span = $('#p_s7_base');
                                var htmlContent = span.html();

                                if (htmlContent.includes('Low')) {
                                    var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                    span.html(updatedContent);
                                } else {
                                    var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                    span.html(cleanedContent); 
                                }
                            }

                            extractValues(S1,S1V,S1B,S1C,"Country");
                            var meanX = Object.assign(S1V.map(function(element,index){
                                return {
                                    ['name']:`${cityLabel[index]}`,
                                    ['data']:element,
                                    ['color']:colorPallet2[index]
                                };
                            }));
                            //console.log(meanX);
                            barChart3(meanX,"p_s1",countryLabel3,max,colorPallet69);
                            var baseX = processBase(S1B);
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            baseX.forEach(function (e, i, a) {
                                if (e < 30) {
                                    htmlB += `${e}<span class="lowerBase">*</span>, Low Base)`;
                                } else {
                                    htmlB += `${e})`;
                                }
                            });

                            //$("#p_s1_base").empty().append(htmlB);
                            
                        },
                        complete: function (data) {
                            ajaxFlag[1+49] = true;
                            $(".splash").hide();
                        }
                    })
                }


                function healthAjax() {
                    $.ajax({
                        url: "api/healthAjax.php",
                        type: "POST",
                        data: {
                            'condX': condX,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            //console.log(data);
                            var P7 = data['P7'];

                            var P7V = [];
                            var P7B = [];
                            var P7C = [];
                            var P7VX = [];

                            extractValues(P7,P7V,P7B,P7C,"Simple");
                            var max = (Math.max(...P7V)+20);
                            customizedArray(P7V,P7VX,P7label,colorPallet69,"Bar");
                            columnChart(P7VX,"p7_div",P7label,max);

                            //////////debugger;
                            var baseX = processBase(P7B);
                            
                            var htmlB = ``;
                            htmlB += `(Base=`;
                            
                            if (baseX[0] < 30) {
                                htmlB += `${baseX[0]}<span class="lowerBase">*</span>, Low Base)`;
                            } else {
                                htmlB += `${baseX[0]})`;
                            }
                          

                            $("#p7_div_base").empty().append(htmlB);

                            var span = $('#p7_div_base');
                            var htmlContent = span.html();

                            if (htmlContent.includes('Low')) {
                                var updatedContent = htmlContent.replace(/(\d+)/g, '<span class="lowerBase">$1</span>');
                                span.html(updatedContent);
                            } else {
                                var cleanedContent = htmlContent.replace(/<span class="lowerBase">(\d+)<\/span>/g, '$1');
                                span.html(cleanedContent); 
                            }

                        },
                        complete: function (data) {
                            ajaxFlag[1+50] = true;
                            $(".splash").hide();
                        }
                    })
                }

                // trends

                function fortySeventhAjax() {
                    //////debugger;
                    $.ajax({
                        url: "api/ajax47.php",
                        type: "POST",
                        data: {
                            'condX': condX2,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            trends1Data = data;
                            console.log("ajax47.php");
                            console.log(data);
                            
                            var consumptioncountryLevel = data['ConsumptionCountry'];
                            var consumptionquarterLevel = data['ConsumptionQuarter'];

                            var frequencyconsumptioncountryLevel = data['S13_3Country'];
                            var frequencyconsumptionquarterLevel = data['S13_3Quarter'];

                            var subcategorycountryLevel = data['CM_C2Country'];
                            var subcategoryquarterLevel = data['CM_C2Quarter'];

                            var howconsumedcountryLevel = data['CM_C5Country'];
                            var howconsumedquarterLevel = data['CM_C5Quarter'];

                            var accompaniedcountryLevel = data['CM_C10Country'];
                            var accompaniedquarterLevel = data['CM_C10Quarter'];

                            var tempraturecountryLevel = data['CM_C4bCountry'];
                            var tempraturequarterLevel = data['CM_C4bQuarter'];

                            var packaging_sizecountryLevel = data['CM_C7Country'];
                            var packaging_sizequarterLevel = data['CM_C7Quarter'];

                            var packaging_typecountryLevel = data['CM_C6Country'];
                            var packaging_typequarterLevel = data['CM_C6Quarter'];

                            var time_consumptioncountryLevel = data['CM_C8Country'];
                            var time_consumptionquarterLevel = data['CM_C8Quarter'];

                            var place_consumptioncountryLevel = data['CM_C9Country'];
                            var place_consumptionquarterLevel = data['CM_C9Quarter'];

                            var consumedalonecountryLevel = data['CM_C11Country'];
                            var consumedalonequarterLevel = data['CM_C11Quarter'];

                            var reasonconsumptioncountryLevel = data['CM_C12Country'];
                            var reasonconsumptionquarterLevel = data['CM_C12Quarter'];

                            var changepersonalconsumptioncountryLevel = data['CM_C15Country'];
                            var changepersonalconsumptionquarterLevel = data['CM_C15Quarter'];

                            var purchasehouseholdcountryLevel = data['CM_C17Country'];
                            var purchasehouseholdquarterLevel = data['CM_C17Quarter'];

                            var purchasehouseholdcountryLevel2 = data['CM_C17_1Country'];
                            var purchasehouseholdquarterLevel2 = data['CM_C17_1Quarter'];

                            var whopurchasecountryLevel = data['CM_C18Country'];
                            var whopurchasequarterLevel = data['CM_C18Quarter'];

                            var purchasechannelcountryLevel = data['CM_C19Country'];
                            var purchasechannelquarterLevel = data['CM_C19Quarter'];

                            var changehouseholdconsumptioncountryLevel = data['CM_C20Country'];
                            var changehouseholdconsumptionquarterLevel = data['CM_C20Quarter'];

                            var householdconsumptioncountryLevel = data['CM_C16Country'];
                            var householdconsumptionquarterLevel = data['CM_C16Quarter'];

                            var agecountryLevel = data['HAGE'];
                            var educationcountryLevel = data['P4'];
                            var dietarycountryLevel = data['S10'];
                            var occupationcountryLevel = data['P5'];
                            var incomecountryLevel = data['S7'];
                            var relationcountryLevel = data['P1'];
                            

                            // Quarter

                                // Slide 1

                                var finalconsumptionTrendData = [];

                                var consumptioneverDataQuarter = [];
                                var consumptionconsumed1YDataQuarter = [];
                                var consumptionconsumed3MDataQuarter = [];
                                var consumptionconsumed7DDataQuarter = [];

                                var finalconsumptionTrendData2 = [];

                                var consumptioneverDataQuarter2 = [];
                                var consumptionconsumed1YDataQuarter2 = [];
                                var consumptionconsumed3MDataQuarter2 = [];
                                var consumptionconsumed7DDataQuarter2 = [];

                                const consumptionquarterData = {};

                                quarterLabel.forEach(quarter => {
                                    if (consumptionquarterLevel[quarter]) {
                                        consumptionquarterData[quarter] = consumptionquarterLevel[quarter];
                                    }
                                });

                                for (let consumptionquarter in consumptionquarterData) {
                                    consumptioneverDataQuarter.push(consumptionquarterData[consumptionquarter].ever[0].percentage);
                                    consumptionconsumed1YDataQuarter.push(consumptionquarterData[consumptionquarter].consumed1Y[0].percentage);
                                    consumptionconsumed3MDataQuarter.push(consumptionquarterData[consumptionquarter].consumed3M[0].percentage);
                                    consumptionconsumed7DDataQuarter.push(consumptionquarterData[consumptionquarter].consumed7D[0].percentage);

                                    consumptioneverDataQuarter2.push(consumptionquarterData[consumptionquarter].ever[0].percentage2);
                                    consumptionconsumed1YDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed1Y[0].percentage2);
                                    consumptionconsumed3MDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed3M[0].percentage2);
                                    consumptionconsumed7DDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed7D[0].percentage2);
                                }

                                var consumptionquarterbCounts = {};
                                var consumptionquarters = Object.keys(consumptionquarterData);

                                consumptionquarters.forEach((quarter, index) => {
                                    consumptionquarterbCounts[index] = consumptionquarterLevel[quarter].ever[0].bCount;
                                });

                                const consumptionquarterflatArray = Object.values(consumptionquarterbCounts);
                                console.log(consumptionquarterflatArray);
                                finalconsumptionTrendData.push(consumptioneverDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed1YDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed3MDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed7DDataQuarter);

                                finalconsumptionTrendData2.push(consumptioneverDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed1YDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed3MDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed7DDataQuarter2);

                                formTable8(quarterLabel,tab1label,finalconsumptionTrendData,finalconsumptionTrendData2,"cm_1","consumtion_funnel",consumptionquarterflatArray);

                                var aHTML = ``;
                                consumptionquarterflatArray.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e}</span>`;
                                });
                                $("#cm_1").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 2

                                var finalfrequencyconsumptionTrendData = [];

                                var frequencyconsumptionquarterData = [];

                                var frequencyconsumptionquarterV = [];
                                var frequencyconsumptionquarterV2 = [];
                                var frequencyconsumptionquarterB = [];
                                var frequencyconsumptionquarterC = [];
                                var frequencyconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (frequencyconsumptionquarterLevel[e]) {
                                        frequencyconsumptionquarterData.push(frequencyconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(frequencyconsumptionquarterData,frequencyconsumptionquarterV,frequencyconsumptionquarterV2,frequencyconsumptionquarterB,frequencyconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(frequencyconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(frequencyconsumptionquarterV2)
                                var quarterBase = frequencyconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,S13label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_2","frequency_consumtion",quarterBase);

                                var aHTML = ``;
                                frequencyconsumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#cm_2").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 3

                                var finalsubcategoryTrendData = [];

                                var subcategoryquarterData = [];

                                var subcategoryquarterV = [];
                                var subcategoryquarterV2 = [];
                                var subcategoryquarterB = [];
                                var subcategoryquarterC = [];
                                var subcategoryquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (subcategoryquarterLevel[e]) {
                                        subcategoryquarterData.push(subcategoryquarterLevel[e]);
                                    }
                                })

                                extractValues2(subcategoryquarterData,subcategoryquarterV,subcategoryquarterV2,subcategoryquarterB,subcategoryquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(subcategoryquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(subcategoryquarterV2)
                                var quarterBase = subcategoryquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC2label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_3","subcategory",quarterBase);

                                var aHTML = ``;
                                subcategoryquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#cm_3").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 4

                                var finalhowconsumedTrendData = [];

                                var howconsumedquarterData = [];

                                var howconsumedquarterV = [];
                                var howconsumedquarterV2 = [];
                                var howconsumedquarterB = [];
                                var howconsumedquarterC = [];
                                var howconsumedquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (howconsumedquarterLevel[e]) {
                                        howconsumedquarterData.push(howconsumedquarterLevel[e]);
                                    }
                                })

                                extractValues2(howconsumedquarterData,howconsumedquarterV,howconsumedquarterV2,howconsumedquarterB,howconsumedquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(howconsumedquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(howconsumedquarterV2)
                                var quarterBase = howconsumedquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC5label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_4","howconsumed",quarterBase);

                                var aHTML = ``;
                                howconsumedquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#cm_4").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 5

                                var finalaccompaniedTrendData = [];

                                var accompaniedquarterData = [];

                                var accompaniedquarterV = [];
                                var accompaniedquarterV2 = [];
                                var accompaniedquarterB = [];
                                var accompaniedquarterC = [];
                                var accompaniedquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (accompaniedquarterLevel[e]) {
                                        accompaniedquarterData.push(accompaniedquarterLevel[e]);
                                    }
                                })

                                extractValues2(accompaniedquarterData,accompaniedquarterV,accompaniedquarterV2,accompaniedquarterB,accompaniedquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(accompaniedquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(accompaniedquarterV2)
                                var quarterBase = accompaniedquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC10label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_5","accompanied",quarterBase);

                                var aHTML = ``;
                                accompaniedquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#cm_5").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 6

                                var finaltempratureTrendData = [];

                                var tempraturequarterData = [];

                                var tempraturequarterV = [];
                                var tempraturequarterV2 = [];
                                var tempraturequarterB = [];
                                var tempraturequarterC = [];
                                var tempraturequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (tempraturequarterLevel[e]) {
                                        tempraturequarterData.push(tempraturequarterLevel[e]);
                                    }
                                })

                                extractValues2(tempraturequarterData,tempraturequarterV,tempraturequarterV2,tempraturequarterB,tempraturequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(tempraturequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(tempraturequarterV2)
                                var quarterBase = tempraturequarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC4blabel,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_6","temprature",quarterBase);

                                var aHTML = ``;
                                tempraturequarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#cm_6").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 7

                                var finalpackaging_sizeTrendData = [];

                                var packaging_sizequarterData = [];

                                var packaging_sizequarterV = [];
                                var packaging_sizequarterV2 = [];
                                var packaging_sizequarterB = [];
                                var packaging_sizequarterC = [];
                                var packaging_sizequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (packaging_sizequarterLevel[e]) {
                                        packaging_sizequarterData.push(packaging_sizequarterLevel[e]);
                                    }
                                })

                                extractValues2(packaging_sizequarterData,packaging_sizequarterV,packaging_sizequarterV2,packaging_sizequarterB,packaging_sizequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(packaging_sizequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(packaging_sizequarterV2)
                                var quarterBase = packaging_sizequarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC7label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_7","packaging_size",quarterBase);
                                var aHTML = ``;
                                packaging_sizequarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#cm_7").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 8

                                var finalpackaging_typeTrendData = [];

                                var packaging_typequarterData = [];

                                var packaging_typequarterV = [];
                                var packaging_typequarterV2 = [];
                                var packaging_typequarterB = [];
                                var packaging_typequarterC = [];
                                var packaging_typequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (packaging_typequarterLevel[e]) {
                                        packaging_typequarterData.push(packaging_typequarterLevel[e]);
                                    }
                                })

                                extractValues2(packaging_typequarterData,packaging_typequarterV,packaging_typequarterV2,packaging_typequarterB,packaging_typequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(packaging_typequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(packaging_typequarterV2)
                                var quarterBase = packaging_typequarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC6label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_8","packaging_type",quarterBase);

                                var aHTML = ``;
                                packaging_typequarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#cm_8").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 9

                                var finaltime_consumptionTrendData = [];

                                var time_consumptionquarterData = [];

                                var time_consumptionquarterV = [];
                                var time_consumptionquarterV2 = [];
                                var time_consumptionquarterB = [];
                                var time_consumptionquarterC = [];
                                var time_consumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (time_consumptionquarterLevel[e]) {
                                        time_consumptionquarterData.push(time_consumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(time_consumptionquarterData,time_consumptionquarterV,time_consumptionquarterV2,time_consumptionquarterB,time_consumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(time_consumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(time_consumptionquarterV2)
                                var quarterBase = time_consumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC8label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_9","time_consumption",quarterBase);

                                var aHTML = ``;
                                time_consumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#cm_9").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 10

                                var finalplace_consumptionTrendData = [];

                                var place_consumptionquarterData = [];

                                var place_consumptionquarterV = [];
                                var place_consumptionquarterV2 = [];
                                var place_consumptionquarterB = [];
                                var place_consumptionquarterC = [];
                                var place_consumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (place_consumptionquarterLevel[e]) {
                                        place_consumptionquarterData.push(place_consumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(place_consumptionquarterData,place_consumptionquarterV,place_consumptionquarterV2,place_consumptionquarterB,place_consumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(place_consumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(place_consumptionquarterV2)
                                var quarterBase = place_consumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC9label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_10","place_consumption",quarterBase);
                                

                                var aHTML = ``;
                                place_consumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#cm_10").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 11

                                var finalconsumedalonequarterData = [];
                                var consumedalonequarterData = [];
                                var consumedalonequarterV = [];
                                var consumedalonequarterV2 = [];
                                var consumedalonequarterB = [];
                                var consumedalonequarterC = [];
                                var consumedalonequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (consumedalonequarterLevel[e]) {
                                        consumedalonequarterData.push(consumedalonequarterLevel[e]);
                                    }
                                })

                                extractValues2(consumedalonequarterData,consumedalonequarterV,consumedalonequarterV2,consumedalonequarterB,consumedalonequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(consumedalonequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(consumedalonequarterV2)
                                var sum1 = transposefrequencycounsumptionquarterData[3].map((val, i) => val + transposefrequencycounsumptionquarterData[4][i]);
                                transposefrequencycounsumptionquarterData.splice(3, 2);
                                transposefrequencycounsumptionquarterData.splice(3, 0, sum1);
                                var sum3 = transposefrequencycounsumptionquarterData2[3].map((val, i) => val + transposefrequencycounsumptionquarterData2[4][i]);
                                transposefrequencycounsumptionquarterData2.splice(3, 2);
                                transposefrequencycounsumptionquarterData2.splice(3, 0, sum3);
                                var sum2 = transposefrequencycounsumptionquarterData[4].map((val, i) => val + transposefrequencycounsumptionquarterData[5][i]);
                                transposefrequencycounsumptionquarterData.splice(4, 2);
                                transposefrequencycounsumptionquarterData.push(sum2);
                                var sum4 = transposefrequencycounsumptionquarterData2[4].map((val, i) => val + transposefrequencycounsumptionquarterData2[5][i]);
                                transposefrequencycounsumptionquarterData2.splice(4, 2);
                                transposefrequencycounsumptionquarterData2.push(sum4);
                                var transposefrequencycounsumptionquarterDataBase = transposeData(consumedalonequarterB);
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                console.log("transposefrequencycounsumptionquarterDataBase[0]");
                                console.log(transposefrequencycounsumptionquarterDataBase[0])
                                formTable8(quarterLabel,CMC11label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_11","data_table",transposefrequencycounsumptionquarterDataBase[0]);

                                // Slide 12

                                var finalchangepersonalconsumptionquarterData = [];
                                var changepersonalconsumptionquarterData = [];
                                var changepersonalconsumptionquarterV = [];
                                var changepersonalconsumptionquarterV2 = [];
                                var changepersonalconsumptionquarterB = [];
                                var changepersonalconsumptionquarterC = [];
                                var changepersonalconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (changepersonalconsumptionquarterLevel[e]) {
                                        changepersonalconsumptionquarterData.push(changepersonalconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(changepersonalconsumptionquarterData,changepersonalconsumptionquarterV,changepersonalconsumptionquarterV2,changepersonalconsumptionquarterB,changepersonalconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(changepersonalconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(changepersonalconsumptionquarterV2)
                                var quarterBase = changepersonalconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC20label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_14","pc_tbl2",quarterBase);

                                // 

                                var finalchangehouseholdconsumptionquarterData = [];
                                var changehouseholdconsumptionquarterData = [];
                                var changehouseholdconsumptionquarterV = [];
                                var changehouseholdconsumptionquarterV2 = [];
                                var changehouseholdconsumptionquarterB = [];
                                var changehouseholdconsumptionquarterC = [];
                                var changehouseholdconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (changehouseholdconsumptionquarterLevel[e]) {
                                        changehouseholdconsumptionquarterData.push(changehouseholdconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(changehouseholdconsumptionquarterData,changehouseholdconsumptionquarterV,changehouseholdconsumptionquarterV2,changehouseholdconsumptionquarterB,changehouseholdconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(changehouseholdconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(changehouseholdconsumptionquarterV2)
                                var quarterBase = changehouseholdconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC20label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_14","hc_tbl2",quarterBase);

                                // Slide 13

                                var finalpurchasehousehold1quarterData = [];
                                var purchasehousehold1quarterData = [];
                                var purchasehousehold1quarterV = [];
                                var purchasehousehold1quarterV2 = [];
                                var purchasehousehold1quarterB = [];
                                var purchasehousehold1quarterC = [];
                                var purchasehousehold1quarterVX = [];

                                var finalpurchasehousehold2quarterData = [];
                                var purchasehousehold2quarterData = [];
                                var purchasehousehold2quarterV = [];
                                var purchasehousehold2quarterV2 = [];
                                var purchasehousehold2quarterB = [];
                                var purchasehousehold2quarterC = [];
                                var purchasehousehold2quarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (purchasechannelquarterLevel[e]) {
                                        purchasehousehold1quarterData.push(purchasechannelquarterLevel[e]);
                                    }
                                })

                                quarterLabel.forEach(function(e,i,a){
                                    if (purchasehouseholdquarterLevel2[e]) {
                                        purchasehousehold2quarterData.push(purchasehouseholdquarterLevel2[e]);
                                    }
                                });

                                function colorizeTableByColumn(tableId) {
                                    const table = document.getElementById(tableId);
                                    if (!table) return;

                                    const rows = Array.from(table.querySelectorAll("tbody tr"));
                                    const numCols = rows[0].querySelectorAll("td").length;

                                    // Convert hex to RGB
                                    function hexToRgb(hex) {
                                        const bigint = parseInt(hex.replace('#', ''), 16);
                                        return {
                                        r: (bigint >> 16) & 255,
                                        g: (bigint >> 8) & 255,
                                        b: bigint & 255,
                                        };
                                    }

                                    // Interpolate between two RGB values
                                    function interpolateColor(color1, color2, factor) {
                                        return {
                                        r: Math.round(color1.r + (color2.r - color1.r) * factor),
                                        g: Math.round(color1.g + (color2.g - color1.g) * factor),
                                        b: Math.round(color1.b + (color2.b - color1.b) * factor),
                                        };
                                    }

                                    // Custom gradient: red → white → green
                                    function getColorByRank(percent) {
                                        const red = hexToRgb("#ff4d4d");
                                        const white = hexToRgb("#ffffff");
                                        const green = hexToRgb("#4caf50");

                                        let rgb;
                                        if (percent < 0.5) {
                                        rgb = interpolateColor(red, white, percent * 2); // 0 to 0.5 → red to white
                                        } else {
                                        rgb = interpolateColor(white, green, (percent - 0.5) * 2); // 0.5 to 1 → white to green
                                        }

                                        return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
                                    }

                                    // Loop through each column (excluding label column)
                                    for (let colIndex = 1; colIndex < numCols; colIndex++) {
                                        const values = [];

                                        // Collect values with index
                                        rows.forEach((row, rowIndex) => {
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        const val = parseFloat(cell.innerText.replace('%', ''));
                                        if (!isNaN(val)) values.push({ rowIndex, value: val });
                                        });

                                        const sorted = [...values].sort((a, b) => b.value - a.value);
                                        const total = sorted.length;

                                        sorted.forEach((item, i) => {
                                        const rankPercent = 1 - (i / (total - 1)); // highest = 1, lowest = 0
                                        const row = rows[item.rowIndex];
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        cell.style.backgroundColor = getColorByRank(rankPercent);
                                        cell.style.color = "#000";
                                        });
                                    }
                                }

                                function colorizeTableByColumn2(tableId) {
                                    ////debugger;
                                    const table = document.getElementById(tableId);
                                    if (!table) return;

                                    const rows = Array.from(table.querySelectorAll("tbody tr"));
                                    const numCols = rows[0].querySelectorAll("td").length;

                                    // Convert hex to RGB
                                    function hexToRgb2(hex) {
                                        const bigint = parseInt(hex.replace('#', ''), 16);
                                        return {
                                        r: (bigint >> 16) & 255,
                                        g: (bigint >> 8) & 255,
                                        b: bigint & 255,
                                        };
                                    }

                                    // Interpolate between two RGB values
                                    function interpolateColor2(color1, color2, factor) {
                                        return {
                                        r: Math.round(color1.r + (color2.r - color1.r) * factor),
                                        g: Math.round(color1.g + (color2.g - color1.g) * factor),
                                        b: Math.round(color1.b + (color2.b - color1.b) * factor),
                                        };
                                    }

                                    // Custom gradient: red → white → green
                                    function getColorByRank2(percent) {
                                        const red = hexToRgb2("#ff4d4d");
                                        const white = hexToRgb2("#ffffff");
                                        const green = hexToRgb2("#4caf50");

                                        let rgb;
                                        if (percent < 0.5) {
                                        rgb = interpolateColor2(red, white, percent * 2); // 0 to 0.5 → red to white
                                        } else {
                                        rgb = interpolateColor2(white, green, (percent - 0.5) * 2); // 0.5 to 1 → white to green
                                        }

                                        return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
                                    }

                                    // Loop through each column (excluding label column)
                                    for (let colIndex = 0; colIndex < numCols; colIndex++) {
                                        const values = [];

                                        // Collect values with index
                                        rows.forEach((row, rowIndex) => {
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        const val = parseFloat(cell.innerText.replace('%', ''));
                                        if (!isNaN(val)) values.push({ rowIndex, value: val });
                                        });

                                        const sorted = [...values].sort((a, b) => b.value - a.value);
                                        const total = sorted.length;

                                        sorted.forEach((item, i) => {
                                        const rankPercent = 1 - (i / (total - 1)); // highest = 1, lowest = 0
                                        const row = rows[item.rowIndex];
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        cell.style.backgroundColor = getColorByRank2(rankPercent);
                                        cell.style.color = "#000";
                                        });
                                    }
                                }

                                extractValues2(purchasehousehold1quarterData,purchasehousehold1quarterV,purchasehousehold1quarterV2,purchasehousehold1quarterB,purchasehousehold1quarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(purchasehousehold1quarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(purchasehousehold1quarterV2)
                                var transposefrequencycounsumptionquarterDataBase = transposeData(purchasehousehold1quarterB)
                                
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                formTable2(quarterLabel,CMC19label2,transposefrequencycounsumptionquarterData,"cm_15","purchase_behaviour_chart2_cm2",transposefrequencycounsumptionquarterDataBase[0]);
                                colorizeTableByColumn2("purchase_behaviour_chart2_cm2");
                                
                                extractValues2(purchasehousehold2quarterData,purchasehousehold2quarterV,purchasehousehold2quarterV2,purchasehousehold2quarterB,purchasehousehold2quarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(purchasehousehold2quarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(purchasehousehold2quarterV2)
                                var transposefrequencycounsumptionquarterDataBase = transposeData(purchasehousehold2quarterB)
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptionquarterData,purchasehousehold2quarterVX,["Yes"],colorPallet,"StackBar");
                                stackcolumnChart2(purchasehousehold2quarterVX,"purchase_behaviour_chart_cm2",quarterLabel,transposefrequencycounsumptionquarterDataBase[0],"100")

                                // Slide 15

                                var finalhouseholdconsumptionquarterLevelquarterData = [];
                                var householdconsumptionquarterLevelquarterData = [];
                                var householdconsumptionquarterLevelquarterV = [];
                                var householdconsumptionquarterLevelquarterV2 = [];
                                var householdconsumptionquarterLevelquarterB = [];
                                var householdconsumptionquarterLevelquarterC = [];
                                var householdconsumptionquarterLevelquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (householdconsumptionquarterLevel[e]) {
                                        householdconsumptionquarterLevelquarterData.push(householdconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(householdconsumptionquarterLevelquarterData,householdconsumptionquarterLevelquarterV,householdconsumptionquarterLevelquarterV2,householdconsumptionquarterLevelquarterB,householdconsumptionquarterLevelquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(householdconsumptionquarterLevelquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(householdconsumptionquarterLevelquarterV2)
                                var quarterBase = householdconsumptionquarterLevelquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC16label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"cm_16","household_consumption_chart_cm",quarterBase);

                            // Country

                                // Slide 1

                                var consumptionDataCountryTable = [];

                                var consumptioneverDataCountry = [];
                                var consumptionconsumed1YDataCountry = [];
                                var consumptionconsumed3MDataCountry = [];
                                var consumptionconsumed7DDataCountry = [];

                                var consumptionDataCountryTable2 = [];

                                var consumptioneverDataCountry2 = [];
                                var consumptionconsumed1YDataCountry2 = [];
                                var consumptionconsumed3MDataCountry2 = [];
                                var consumptionconsumed7DDataCountry2 = [];

                                var consumptioncountryData = {};



                                countryLabel4.forEach(country => {
                                    if (consumptioncountryLevel[country]) {
                                        consumptioncountryData[country] = consumptioncountryLevel[country];
                                    }
                                });

                                for (let consumptioncountry in consumptioncountryData) {
                                    consumptioneverDataCountry.push(consumptioncountryData[consumptioncountry].ever[0].percentage);
                                    consumptionconsumed1YDataCountry.push(consumptioncountryData[consumptioncountry].consumed1Y[0].percentage);
                                    consumptionconsumed3MDataCountry.push(consumptioncountryData[consumptioncountry].consumed3M[0].percentage);
                                    consumptionconsumed7DDataCountry.push(consumptioncountryData[consumptioncountry].consumed7D[0].percentage);

                                    consumptioneverDataCountry2.push(consumptioncountryData[consumptioncountry].ever[0].percentage2);
                                    consumptionconsumed1YDataCountry2.push(consumptioncountryData[consumptioncountry].consumed1Y[0].percentage2);
                                    consumptionconsumed3MDataCountry2.push(consumptioncountryData[consumptioncountry].consumed3M[0].percentage2);
                                    consumptionconsumed7DDataCountry2.push(consumptioncountryData[consumptioncountry].consumed7D[0].percentage2);
                                }2

                                var consumptioncountrybCounts = {};
                                var consumptioncountries = Object.keys(consumptioncountryData);

                                consumptioncountries.forEach((country, index) => {
                                    consumptioncountrybCounts[index] = consumptioncountryLevel[country].ever[0].bCount;
                                });

                                const consumptioncountryflatArray = Object.values(consumptioncountrybCounts);

                                $("#cm_1").find(".country-col").find(".base-note").each(function(i,e){
                                    $(this).empty().append(`n-${consumptioncountryflatArray[i]}`);
                                });
                                $("#cm_1").find(".country-col").find(".full").each(function(i,e){
                                    $(this).empty().append(consumptioneverDataCountry[i]+"%");
                                })
                                $("#cm_1").find(".country-col").find(".mid").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed1YDataCountry[i]+"%");
                                })
                                $("#cm_1").find(".country-col").find(".lighter").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed3MDataCountry[i]+"%");
                                })
                                $("#cm_1").find(".country-col").find(".lightest").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed7DDataCountry[i]+"%");
                                })

                                consumptionDataCountryTable.push(consumptioneverDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed1YDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed3MDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed7DDataCountry);

                                consumptionDataCountryTable2.push(consumptioneverDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed1YDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed3MDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed7DDataCountry2);

                                formTable3(tab1label,consumptionDataCountryTable,consumptionDataCountryTable2,"cm_1","data_table",consumptioncountryflatArray);

                                // Slide 2

                                var finalfrequencyconsumptioncountryData = [];

                                var frequencyconsumptioncountryData = [];

                                var frequencyconsumptioncountryV = [];
                                var frequencyconsumptioncountryV2 = [];
                                var frequencyconsumptioncountryB = [];
                                var frequencyconsumptioncountryC = [];
                                var frequencyconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (frequencyconsumptioncountryLevel[e]) {
                                        frequencyconsumptioncountryData.push(frequencyconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(frequencyconsumptioncountryData,frequencyconsumptioncountryV,frequencyconsumptioncountryV2,frequencyconsumptioncountryB,frequencyconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(frequencyconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(frequencyconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(frequencyconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,frequencyconsumptioncountryVX,S13label2,colorPalletX4,"StackBar");
                                stackcolumnChart3(frequencyconsumptioncountryVX,"frequency_counsumption_chart_cm",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX4)
                                formTable3(S13label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_2","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 3

                                var finalsubcategorycountryData = [];

                                var subcategorycountryData = [];

                                var subcategorycountryV = [];
                                var subcategorycountryV2 = [];
                                var subcategorycountryB = [];
                                var subcategorycountryC = [];
                                var subcategorycountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (subcategorycountryLevel[e]) {
                                        subcategorycountryData.push(subcategorycountryLevel[e]);
                                    }
                                })

                                extractValues2(subcategorycountryData,subcategorycountryV,subcategorycountryV2,subcategorycountryB,subcategorycountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(subcategorycountryV, CMC2label);
                                var sortingResult2 = sortByFirstCountryWithLabels(subcategorycountryV2, CMC2label);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(subcategorycountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,subcategorycountryVX,sortingResult.sortedLabels,colorPallet99,"StackBar");
                                stackcolumnChart3(subcategorycountryVX,"subcategory_chart_cm",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX4)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_3","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 4

                                var finalhowconsumedcountryData = [];

                                var howconsumedcountryData = [];

                                var howconsumedcountryV = [];
                                var howconsumedcountryV2 = [];
                                var howconsumedcountryB = [];
                                var howconsumedcountryC = [];
                                var howconsumedcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (howconsumedcountryLevel[e]) {
                                        howconsumedcountryData.push(howconsumedcountryLevel[e]);
                                    }
                                })

                                extractValues2(howconsumedcountryData,howconsumedcountryV,howconsumedcountryV2,howconsumedcountryB,howconsumedcountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(howconsumedcountryV, CMC5label2);
                                var sortingResult2 = sortByFirstCountryWithLabels(howconsumedcountryV2, CMC5label2);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(howconsumedcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,howconsumedcountryVX,sortingResult.sortedLabels,colorPalletX3,"StackBar");
                                stackcolumnChart3(howconsumedcountryVX,"howconsumed_chart_cm",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX3)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_4","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 5

                                var finalaccompaniedcountryData = [];

                                var accompaniedcountryData = [];

                                var accompaniedcountryV = [];
                                var accompaniedcountryV2 = [];
                                var accompaniedcountryB = [];
                                var accompaniedcountryC = [];
                                var accompaniedcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (accompaniedcountryLevel[e]) {
                                        accompaniedcountryData.push(accompaniedcountryLevel[e]);
                                    }
                                })

                                extractValues2(accompaniedcountryData,accompaniedcountryV,accompaniedcountryV2,accompaniedcountryB,accompaniedcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(accompaniedcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(accompaniedcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(accompaniedcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,accompaniedcountryVX,CMC10label,colorPalletX3,"StackBar");
                                stackcolumnChart3(accompaniedcountryVX,"accompanied_chart_cm",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX3)
                                formTable3(CMC10label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_5","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 6

                                var finaltempraturecountryData = [];

                                var tempraturecountryData = [];

                                var tempraturecountryV = [];
                                var tempraturecountryV2 = [];
                                var tempraturecountryB = [];
                                var tempraturecountryC = [];
                                var tempraturecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (tempraturecountryLevel[e]) {
                                        tempraturecountryData.push(tempraturecountryLevel[e]);
                                    }
                                })

                                extractValues2(tempraturecountryData,tempraturecountryV,tempraturecountryV2,tempraturecountryB,tempraturecountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(tempraturecountryV, CMC4blabel);
                                var sortingResult2 = sortByFirstCountryWithLabels(tempraturecountryV2, CMC4blabel);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(tempraturecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,tempraturecountryVX,sortingResult.sortedLabels,colorPalletX1,"StackBar");
                                stackcolumnChart3(tempraturecountryVX,"temprature_chart_cm",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX1)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_6","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 7

                                var finalpackaging_sizecountryData = [];

                                var packaging_sizecountryData = [];

                                var packaging_sizecountryV = [];
                                var packaging_sizecountryV2 = [];
                                var packaging_sizecountryB = [];
                                var packaging_sizecountryC = [];
                                var packaging_sizecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (packaging_sizecountryLevel[e]) {
                                        packaging_sizecountryData.push(packaging_sizecountryLevel[e]);
                                    }
                                })

                                extractValues2(packaging_sizecountryData,packaging_sizecountryV,packaging_sizecountryV2,packaging_sizecountryB,packaging_sizecountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(packaging_sizecountryV, CMC7label2);
                                var sortingResult2 = sortByFirstCountryWithLabels(packaging_sizecountryV2, CMC7label2);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(packaging_sizecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,packaging_sizecountryVX,sortingResult.sortedLabels,colorPalletX1,"StackBar");
                                stackcolumnChart3(packaging_sizecountryVX,"packaging_size_chart_cm",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX1)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_7","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 8

                                var finalpackaging_typecountryData = [];

                                var packaging_typecountryData = [];

                                var packaging_typecountryV = [];
                                var packaging_typecountryV2 = [];
                                var packaging_typecountryB = [];
                                var packaging_typecountryC = [];
                                var packaging_typecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (packaging_typecountryLevel[e]) {
                                        packaging_typecountryData.push(packaging_typecountryLevel[e]);
                                    }
                                })

                                extractValues2(packaging_typecountryData,packaging_typecountryV,packaging_typecountryV2,packaging_typecountryB,packaging_typecountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(packaging_typecountryV, CMC6label);
                                var sortingResult2 = sortByFirstCountryWithLabels(packaging_typecountryV2, CMC6label);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(packaging_typecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,packaging_typecountryVX,sortingResult.sortedLabels,colorPalletX5,"StackBar");
                                stackcolumnChart3(packaging_typecountryVX,"packaging_type_chart_cm",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX5)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_8","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 9
                                var finaltime_consumptioncountryData = [];

                                var time_consumptioncountryData = [];

                                var time_consumptioncountryV = [];
                                var time_consumptioncountryV2 = [];
                                var time_consumptioncountryB = [];
                                var time_consumptioncountryC = [];
                                var time_consumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (time_consumptioncountryLevel[e]) {
                                        time_consumptioncountryData.push(time_consumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(time_consumptioncountryData,time_consumptioncountryV,time_consumptioncountryV2,time_consumptioncountryB,time_consumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(time_consumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(time_consumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(time_consumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                renderDonutTable(transposefrequencycounsumptioncountryData, CMC8label, countryLabel4,flaggXX,"cm_9",transposefrequencycounsumptioncountryDataBase[0]);
                                formTable3(CMC8label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_9","data_table",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // Slide 10

                                var finalplace_consumptioncountryData = [];
                                var place_consumptioncountryData = [];
                                var place_consumptioncountryV = [];
                                var place_consumptioncountryV2 = [];
                                var place_consumptioncountryB = [];
                                var place_consumptioncountryC = [];
                                var place_consumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (place_consumptioncountryLevel[e]) {
                                        place_consumptioncountryData.push(place_consumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(place_consumptioncountryData,place_consumptioncountryV,place_consumptioncountryV2,place_consumptioncountryB,place_consumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(place_consumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(place_consumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(place_consumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,place_consumptioncountryVX,CMC9label,colorPalletX5,"StackBar");
                                stackcolumnChart3(place_consumptioncountryVX,"place_consumption_chart_cm",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX5)
                                formTable3(CMC9label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_10","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 11

                                var finalconsumedalonecountryData = [];
                                var consumedalonecountryData = [];
                                var consumedalonecountryV = [];
                                var consumedalonecountryV2 = [];
                                var consumedalonecountryB = [];
                                var consumedalonecountryC = [];
                                var consumedalonecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (consumedalonecountryLevel[e]) {
                                        consumedalonecountryData.push(consumedalonecountryLevel[e]);
                                    }
                                })

                                extractValues2(consumedalonecountryData,consumedalonecountryV,consumedalonecountryV2,consumedalonecountryB,consumedalonecountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(consumedalonecountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(consumedalonecountryV2)
                                var sum1 = transposefrequencycounsumptioncountryData[3].map((val, i) => val + transposefrequencycounsumptioncountryData[4][i]);
                                transposefrequencycounsumptioncountryData.splice(3, 2);
                                transposefrequencycounsumptioncountryData.splice(3, 0, sum1);
                                var sum3 = transposefrequencycounsumptioncountryData2[3].map((val, i) => val + transposefrequencycounsumptioncountryData2[4][i]);
                                transposefrequencycounsumptioncountryData2.splice(3, 2);
                                transposefrequencycounsumptioncountryData2.splice(3, 0, sum3);
                                var sum2 = transposefrequencycounsumptioncountryData[4].map((val, i) => val + transposefrequencycounsumptioncountryData[5][i]);
                                transposefrequencycounsumptioncountryData.splice(4, 2);
                                transposefrequencycounsumptioncountryData.push(sum2);
                                var sum4 = transposefrequencycounsumptioncountryData2[4].map((val, i) => val + transposefrequencycounsumptioncountryData2[5][i]);
                                transposefrequencycounsumptioncountryData2.splice(4, 2);
                                transposefrequencycounsumptioncountryData2.push(sum4);
                                var transposefrequencycounsumptioncountryDataBase = transposeData(consumedalonecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                renderDonutTable(transposefrequencycounsumptioncountryData, CMC11label2, countryLabel4,flaggXX,"cm_11",transposefrequencycounsumptioncountryDataBase[0]);
                                formTable3(CMC11label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_11","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 12

                                var finalchangepersonalconsumptioncountryData = [];
                                var changepersonalconsumptioncountryData = [];
                                var changepersonalconsumptioncountryV = [];
                                var changepersonalconsumptioncountryV2 = [];
                                var changepersonalconsumptioncountryB = [];
                                var changepersonalconsumptioncountryC = [];
                                var changepersonalconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (changepersonalconsumptioncountryLevel[e]) {
                                        changepersonalconsumptioncountryData.push(changepersonalconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(changepersonalconsumptioncountryData,changepersonalconsumptioncountryV,changepersonalconsumptioncountryV2,changepersonalconsumptioncountryB,changepersonalconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(changepersonalconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(changepersonalconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(changepersonalconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(CMC20label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_14","pc_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                var finalchangehouseholdconsumptioncountryData = [];
                                var changehouseholdconsumptioncountryData = [];
                                var changehouseholdconsumptioncountryV = [];
                                var changehouseholdconsumptioncountryV2 = [];
                                var changehouseholdconsumptioncountryB = [];
                                var changehouseholdconsumptioncountryC = [];
                                var changehouseholdconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (changehouseholdconsumptioncountryLevel[e]) {
                                        changehouseholdconsumptioncountryData.push(changehouseholdconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(changehouseholdconsumptioncountryData,changehouseholdconsumptioncountryV,changehouseholdconsumptioncountryV2,changehouseholdconsumptioncountryB,changehouseholdconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(changehouseholdconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(changehouseholdconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(changehouseholdconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(CMC20label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_14","hc_tbl",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 13

                                var finalpurchasehousehold1countryData = [];
                                var purchasehousehold1countryData = [];
                                var purchasehousehold1countryV = [];
                                var purchasehousehold1countryV2 = [];
                                var purchasehousehold1countryB = [];
                                var purchasehousehold1countryC = [];
                                var purchasehousehold1countryVX = [];

                                var finalpurchasehousehold2countryData = [];
                                var purchasehousehold2countryData = [];
                                var purchasehousehold2countryV = [];
                                var purchasehousehold2countryV2 = [];
                                var purchasehousehold2countryB = [];
                                var purchasehousehold2countryC = [];
                                var purchasehousehold2countryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (purchasechannelcountryLevel[e]) {
                                        purchasehousehold1countryData.push(purchasechannelcountryLevel[e]);
                                    }
                                })

                                countryLabel4.forEach(function(e,i,a){
                                    if (purchasehouseholdcountryLevel2[e]) {
                                        purchasehousehold2countryData.push(purchasehouseholdcountryLevel2[e]);
                                    }
                                });

                                function colorizeTableByColumn(tableId) {
                                    const table = document.getElementById(tableId);
                                    if (!table) return;

                                    const rows = Array.from(table.querySelectorAll("tbody tr"));
                                    const numCols = rows[0].querySelectorAll("td").length;

                                    // Convert hex to RGB
                                    function hexToRgb(hex) {
                                        const bigint = parseInt(hex.replace('#', ''), 16);
                                        return {
                                        r: (bigint >> 16) & 255,
                                        g: (bigint >> 8) & 255,
                                        b: bigint & 255,
                                        };
                                    }

                                    // Interpolate between two RGB values
                                    function interpolateColor(color1, color2, factor) {
                                        return {
                                        r: Math.round(color1.r + (color2.r - color1.r) * factor),
                                        g: Math.round(color1.g + (color2.g - color1.g) * factor),
                                        b: Math.round(color1.b + (color2.b - color1.b) * factor),
                                        };
                                    }

                                    // Custom gradient: red → white → green
                                    function getColorByRank(percent) {
                                        const red = hexToRgb("#ff4d4d");
                                        const white = hexToRgb("#ffffff");
                                        const green = hexToRgb("#4caf50");

                                        let rgb;
                                        if (percent < 0.5) {
                                        rgb = interpolateColor(red, white, percent * 2); // 0 to 0.5 → red to white
                                        } else {
                                        rgb = interpolateColor(white, green, (percent - 0.5) * 2); // 0.5 to 1 → white to green
                                        }

                                        return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
                                    }

                                    // Loop through each column (excluding label column)
                                    for (let colIndex = 1; colIndex < numCols; colIndex++) {
                                        const values = [];

                                        // Collect values with index
                                        rows.forEach((row, rowIndex) => {
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        const val = parseFloat(cell.innerText.replace('%', ''));
                                        if (!isNaN(val)) values.push({ rowIndex, value: val });
                                        });

                                        const sorted = [...values].sort((a, b) => b.value - a.value);
                                        const total = sorted.length;

                                        sorted.forEach((item, i) => {
                                        const rankPercent = 1 - (i / (total - 1)); // highest = 1, lowest = 0
                                        const row = rows[item.rowIndex];
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        cell.style.backgroundColor = getColorByRank(rankPercent);
                                        cell.style.color = "#000";
                                        });
                                    }
                                }

                                extractValues2(purchasehousehold1countryData,purchasehousehold1countryV,purchasehousehold1countryV2,purchasehousehold1countryB,purchasehousehold1countryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(purchasehousehold1countryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(purchasehousehold1countryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(purchasehousehold1countryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);

                                formTable4(CMC19label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"purchase_behaviour_chart2_cm",transposefrequencycounsumptioncountryDataBase[0]);
                                colorizeTableByColumn("purchase_behaviour_chart2_cm");
                                htmlZ = ``;
                                htmlZ += `<tr class="allbase">`;
                                htmlZ += `<td></td>`;
                                transposefrequencycounsumptioncountryDataBase[0].forEach(function(e2,i2,a2){
                                    htmlZ += `<td>n-${e2}</td>`;
                                });
                                htmlZ += `</tr>`;
                                $("#purchase_behaviour_chart2_cm > tbody").append(htmlZ);
                                
                                extractValues2(purchasehousehold2countryData,purchasehousehold2countryV,purchasehousehold2countryV2,purchasehousehold2countryB,purchasehousehold2countryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(purchasehousehold2countryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(purchasehousehold2countryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(purchasehousehold2countryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,purchasehousehold2countryVX,["Yes"],colorPallet,"StackBar");
                                stackcolumnChart2(purchasehousehold2countryVX,"purchase_behaviour_chart_cm",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],"100")

                                // Slide 14

                                var finalreasonconsumptioncountryData = [];
                                var reasonconsumptioncountryData = [];
                                var reasonconsumptioncountryV = [];
                                var reasonconsumptioncountryV2 = [];
                                var reasonconsumptioncountryB = [];
                                var reasonconsumptioncountryC = [];
                                var reasonconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (reasonconsumptioncountryLevel[e]) {
                                        reasonconsumptioncountryData.push(reasonconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(reasonconsumptioncountryData,reasonconsumptioncountryV,reasonconsumptioncountryV2,reasonconsumptioncountryB,reasonconsumptioncountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(reasonconsumptioncountryV, CMC12label2);
                                var sortingResult2 = sortByFirstCountryWithLabels(reasonconsumptioncountryV2, CMC12label2);
                                
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(reasonconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_12","roc_tt",transposefrequencycounsumptioncountryDataBase[0]);

                                customizedArray(transposefrequencycounsumptioncountryData,reasonconsumptioncountryVX,sortingResult.sortedLabels,colorPallet,"StackBar");
                                
                                function transformToModelWise(input) {
                                    const result = [];
                                    for (let i = 0; i < 7; i++) {
                                        const modelData = {
                                        name: `Model ${i + 1}`,
                                        data: input.map(item => item.data[i])
                                        };
                                        result.push(modelData);
                                    }
                                    return result;
                                }

                                const modelWise = transformToModelWise(reasonconsumptioncountryVX);
                                console.log("modelWise");
                                console.log(modelWise);
                                console.log("reasonconsumptioncountryVX");
                                console.log(reasonconsumptioncountryVX);
                                
                                function generateColors(dataArray) {
                                    const indexed = dataArray.map((value, index) => ({ value, index }));
                                    indexed.sort((a, b) => b.value - a.value);
                                    
                                    const topIndexes = new Set(indexed.slice(0, 4).map(item => item.index));

                                    return dataArray.map((_, index) => topIndexes.has(index) ? '#4D6893' : '#7C985E');
                                }
                                modelWise.forEach(model => {
                                    model.color = 'transparent';
                                    model.colors = generateColors(model.data);
                                });


                                barChart88([modelWise[0]],"reason_consumption_1",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][0],"SouthEast Asia",flagg2[0]);
                                barChart89([modelWise[1]],"reason_consumption_2",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][1],"Singapore",flagg2[0]);
                                barChart89([modelWise[2]],"reason_consumption_3",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][2],"Thailand",flagg2[1]);
                                barChart89([modelWise[3]],"reason_consumption_4",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][3],"Malaysia",flagg2[2]);
                                barChart89([modelWise[4]],"reason_consumption_5",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][4],"Indonesia",flagg2[3]);
                                barChart89([modelWise[5]],"reason_consumption_6",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][5],"Philippines",flagg2[4]);
                                barChart89([modelWise[6]],"reason_consumption_7",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][6],"Vietnam",flagg2[5]);

                                // Slide 15

                                var finalhouseholdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryV = [];
                                var householdconsumptioncountryLevelcountryV2 = [];
                                var householdconsumptioncountryLevelcountryB = [];
                                var householdconsumptioncountryLevelcountryC = [];
                                var householdconsumptioncountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (householdconsumptioncountryLevel[e]) {
                                        householdconsumptioncountryLevelcountryData.push(householdconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(householdconsumptioncountryLevelcountryData,householdconsumptioncountryLevelcountryV,householdconsumptioncountryLevelcountryV2,householdconsumptioncountryLevelcountryB,householdconsumptioncountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(householdconsumptioncountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(householdconsumptioncountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(householdconsumptioncountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(CMC16label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_16","household_consumption_chart_cm",transposefrequencycounsumptioncountryDataBase[0]);


                                // agecountryLevel

                                var finalagecountryLevelcountryData = [];
                                var agecountryLevelcountryData = [];
                                var agecountryLevelcountryV = [];
                                var agecountryLevelcountryV2 = [];
                                var agecountryLevelcountryB = [];
                                var agecountryLevelcountryC = [];
                                var agecountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (agecountryLevel[e]) {
                                        agecountryLevelcountryData.push(agecountryLevel[e]);
                                    }
                                })

                                extractValues2(agecountryLevelcountryData,agecountryLevelcountryV,agecountryLevelcountryV2,agecountryLevelcountryB,agecountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(agecountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(agecountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(agecountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(ageLabelXXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_18","age_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // educationcountryLevel

                                var finaleducationcountryLevelcountryData = [];
                                var educationcountryLevelcountryData = [];
                                var educationcountryLevelcountryV = [];
                                var educationcountryLevelcountryV2 = [];
                                var educationcountryLevelcountryB = [];
                                var educationcountryLevelcountryC = [];
                                var educationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (educationcountryLevel[e]) {
                                        educationcountryLevelcountryData.push(educationcountryLevel[e]);
                                    }
                                })

                                extractValues2(educationcountryLevelcountryData,educationcountryLevelcountryV,educationcountryLevelcountryV2,educationcountryLevelcountryB,educationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(educationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(educationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(educationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(educationXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_18","education_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // dietarycountryLevel

                                var finaldietarycountryLevelcountryData = [];
                                var dietarycountryLevelcountryData = [];
                                var dietarycountryLevelcountryV = [];
                                var dietarycountryLevelcountryV2 = [];
                                var dietarycountryLevelcountryB = [];
                                var dietarycountryLevelcountryC = [];
                                var dietarycountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (dietarycountryLevel[e]) {
                                        dietarycountryLevelcountryData.push(dietarycountryLevel[e]);
                                    }
                                })

                                extractValues2(dietarycountryLevelcountryData,dietarycountryLevelcountryV,dietarycountryLevelcountryV2,dietarycountryLevelcountryB,dietarycountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(dietarycountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(dietarycountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(dietarycountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(halalLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_18","dietary_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // occupationcountryLevel

                                var finaloccupationcountryLevelcountryData = [];
                                var occupationcountryLevelcountryData = [];
                                var occupationcountryLevelcountryV = [];
                                var occupationcountryLevelcountryV2 = [];
                                var occupationcountryLevelcountryB = [];
                                var occupationcountryLevelcountryC = [];
                                var occupationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (occupationcountryLevel[e]) {
                                        occupationcountryLevelcountryData.push(occupationcountryLevel[e]);
                                    }
                                })

                                extractValues2(occupationcountryLevelcountryData,occupationcountryLevelcountryV,occupationcountryLevelcountryV2,occupationcountryLevelcountryB,occupationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(occupationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(occupationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(occupationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(occupationLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_19","occupation_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // incomecountryLevel

                                var finalincomecountryLevelcountryData = [];
                                var incomecountryLevelcountryData = [];
                                var incomecountryLevelcountryV = [];
                                var incomecountryLevelcountryV2 = [];
                                var incomecountryLevelcountryB = [];
                                var incomecountryLevelcountryC = [];
                                var incomecountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (incomecountryLevel[e]) {
                                        incomecountryLevelcountryData.push(incomecountryLevel[e]);
                                    }
                                })

                                extractValues2(incomecountryLevelcountryData,incomecountryLevelcountryV,incomecountryLevelcountryV2,incomecountryLevelcountryB,incomecountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(incomecountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(incomecountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(incomecountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(incomeLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_19","householdincome_tbl",transposefrequencycounsumptioncountryDataBase[0]);

                                // relationshipcountryLevel

                                var finalrelationcountryLevelcountryData = [];
                                var relationcountryLevelcountryData = [];
                                var relationcountryLevelcountryV = [];
                                var relationcountryLevelcountryV2 = [];
                                var relationcountryLevelcountryB = [];
                                var relationcountryLevelcountryC = [];
                                var relationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (relationcountryLevel[e]) {
                                        relationcountryLevelcountryData.push(relationcountryLevel[e]);
                                    }
                                })

                                extractValues2(relationcountryLevelcountryData,relationcountryLevelcountryV,relationcountryLevelcountryV2,relationcountryLevelcountryB,relationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(relationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(relationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(relationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(relationXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_20","relationship_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // People living in household

                                var finalhouseholdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryV = [];
                                var householdconsumptioncountryLevelcountryV2 = [];
                                var householdconsumptioncountryLevelcountryB = [];
                                var householdconsumptioncountryLevelcountryC = [];
                                var householdconsumptioncountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (householdconsumptioncountryLevel[e]) {
                                        householdconsumptioncountryLevelcountryData.push(householdconsumptioncountryLevel[e]);
                                    }
                                })
                                ////debugger;
                                extractValues2(householdconsumptioncountryLevelcountryData,householdconsumptioncountryLevelcountryV,householdconsumptioncountryLevelcountryV2,householdconsumptioncountryLevelcountryB,householdconsumptioncountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(householdconsumptioncountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(householdconsumptioncountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(householdconsumptioncountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(CMC16label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"cm_20","livinghousehold_tbl",transposefrequencycounsumptioncountryDataBase[0]);

                        },
                        complete: function (data) {
                            ajaxFlag[1+51] = true;
                            $(".splash").hide();
                        }
                    })
                }
                function fortyEighthAjax() {
                    $.ajax({
                        url: "api/ajax48.php",
                        type: "POST",
                        data: {
                            'condX': condX2,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            trends2Data = data;
                            console.log("ajax48.php");
                            console.log(data);

                            var consumptioncountryLevel = data['ConsumptionCountry'];
                            var consumptionquarterLevel = data['ConsumptionQuarter'];

                            var frequencyconsumptioncountryLevel = data['S13_1Country'];
                            var frequencyconsumptionquarterLevel = data['S13_1Quarter'];

                            var foodtime_consumptioncountryLevel = data['CH_F_C8Country'];
                            var foodtime_consumptionquarterLevel = data['CH_F_C8Quarter'];

                            var foodconsumedalonecountryLevel = data['CH_F_C11Country'];
                            var foodconsumedalonequarterLevel = data['CH_F_C11Quarter'];

                            var foodreasonconsumptioncountryLevel = data['CH_F_C12Country'];
                            var foodreasonconsumptionquarterLevel = data['CH_F_C12Quarter'];

                            var retailtime_consumptioncountryLevel = data['CH_R_C8Country'];
                            var retailtime_consumptionquarterLevel = data['CH_R_C8Quarter'];

                            var retailconsumedalonecountryLevel = data['CH_R_C11Country'];
                            var retailconsumedalonequarterLevel = data['CH_R_C11Quarter'];

                            var retailreasonconsumptioncountryLevel = data['CH_R_C12Country'];
                            var retailreasonconsumptionquarterLevel = data['CH_R_C12Quarter'];

                            var purchasechannelcountryLevel = data['CH_C19Country'];
                            var purchasechannelquarterLevel = data['CH_C19Quarter'];

                            var agecountryLevel = data['HAGE'];
                            var educationcountryLevel = data['P4'];
                            var dietarycountryLevel = data['S10'];
                            var occupationcountryLevel = data['P5'];
                            var incomecountryLevel = data['S7'];
                            var relationcountryLevel = data['P1'];

                            // Quarter

                                // Slide 1

                                var finalconsumptionTrendData = [];

                                var consumptioneverDataQuarter = [];
                                var consumptionconsumed1YDataQuarter = [];
                                var consumptionconsumed3MDataQuarter = [];
                                var consumptionconsumed7DDataQuarter = [];

                                var finalconsumptionTrendData2 = [];

                                var consumptioneverDataQuarter2 = [];
                                var consumptionconsumed1YDataQuarter2 = [];
                                var consumptionconsumed3MDataQuarter2 = [];
                                var consumptionconsumed7DDataQuarter2 = [];

                                const consumptionquarterData = {};

                                quarterLabel.forEach(quarter => {
                                    if (consumptionquarterLevel[quarter]) {
                                        consumptionquarterData[quarter] = consumptionquarterLevel[quarter];
                                    }
                                });

                                for (let consumptionquarter in consumptionquarterData) {
                                    consumptioneverDataQuarter.push(consumptionquarterData[consumptionquarter].ever[0].percentage);
                                    consumptionconsumed1YDataQuarter.push(consumptionquarterData[consumptionquarter].consumed1Y[0].percentage);
                                    consumptionconsumed3MDataQuarter.push(consumptionquarterData[consumptionquarter].consumed3M[0].percentage);
                                    consumptionconsumed7DDataQuarter.push(consumptionquarterData[consumptionquarter].consumed7D[0].percentage);

                                    consumptioneverDataQuarter2.push(consumptionquarterData[consumptionquarter].ever[0].percentage2);
                                    consumptionconsumed1YDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed1Y[0].percentage2);
                                    consumptionconsumed3MDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed3M[0].percentage2);
                                    consumptionconsumed7DDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed7D[0].percentage2);
                                }

                                var consumptionquarterbCounts = {};
                                var consumptionquarters = Object.keys(consumptionquarterData);

                                consumptionquarters.forEach((quarter, index) => {
                                    consumptionquarterbCounts[index] = consumptionquarterLevel[quarter].ever[0].bCount;
                                });

                                const consumptionquarterflatArray = Object.values(consumptionquarterbCounts);
                                
                                finalconsumptionTrendData.push(consumptioneverDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed1YDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed3MDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed7DDataQuarter);

                                finalconsumptionTrendData2.push(consumptioneverDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed1YDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed3MDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed7DDataQuarter2);

                                formTable8(quarterLabel,tab1label,finalconsumptionTrendData,finalconsumptionTrendData2,"ch_1","consumtion_funnel",consumptionquarterflatArray);

                                var aHTML = ``;
                                consumptionquarterflatArray.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e}</span>`;
                                });
                                $("#ch_1").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 2

                                var finalfrequencyconsumptionTrendData = [];

                                var frequencyconsumptionquarterData = [];

                                var frequencyconsumptionquarterV = [];
                                var frequencyconsumptionquarterV2 = [];
                                var frequencyconsumptionquarterB = [];
                                var frequencyconsumptionquarterC = [];
                                var frequencyconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (frequencyconsumptionquarterLevel[e]) {
                                        frequencyconsumptionquarterData.push(frequencyconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(frequencyconsumptionquarterData,frequencyconsumptionquarterV,frequencyconsumptionquarterV2,frequencyconsumptionquarterB,frequencyconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(frequencyconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(frequencyconsumptionquarterV2)
                                var quarterBase = frequencyconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,S13label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"ch_2","frequency_consumtion",quarterBase);

                                var aHTML = ``;
                                frequencyconsumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#ch_2").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 9

                                var finalfoodtime_consumptionTrendData = [];

                                var foodtime_consumptionquarterData = [];

                                var foodtime_consumptionquarterV = [];
                                var foodtime_consumptionquarterV2 = [];
                                var foodtime_consumptionquarterB = [];
                                var foodtime_consumptionquarterC = [];
                                var foodtime_consumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (foodtime_consumptionquarterLevel[e]) {
                                        foodtime_consumptionquarterData.push(foodtime_consumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(foodtime_consumptionquarterData,foodtime_consumptionquarterV,foodtime_consumptionquarterV2,foodtime_consumptionquarterB,foodtime_consumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(foodtime_consumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(foodtime_consumptionquarterV2)
                                var quarterBase = foodtime_consumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC8label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"ch_9","foodtime_consumption",quarterBase);

                                var aHTML = ``;
                                foodtime_consumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#ch_9").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 11

                                var foodfinalconsumedalonequarterData = [];
                                var foodconsumedalonequarterData = [];
                                var foodconsumedalonequarterV = [];
                                var foodconsumedalonequarterV2 = [];
                                var foodconsumedalonequarterB = [];
                                var foodconsumedalonequarterC = [];
                                var foodconsumedalonequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (foodconsumedalonequarterLevel[e]) {
                                        foodconsumedalonequarterData.push(foodconsumedalonequarterLevel[e]);
                                    }
                                })

                                extractValues2(foodconsumedalonequarterData,foodconsumedalonequarterV,foodconsumedalonequarterV2,foodconsumedalonequarterB,foodconsumedalonequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(foodconsumedalonequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(foodconsumedalonequarterV2)
                                var sum1 = transposefrequencycounsumptionquarterData[3].map((val, i) => val + transposefrequencycounsumptionquarterData[4][i]);
                                transposefrequencycounsumptionquarterData.splice(3, 2);
                                transposefrequencycounsumptionquarterData.splice(3, 0, sum1);
                                var sum3 = transposefrequencycounsumptionquarterData2[3].map((val, i) => val + transposefrequencycounsumptionquarterData2[4][i]);
                                transposefrequencycounsumptionquarterData2.splice(3, 2);
                                transposefrequencycounsumptionquarterData2.splice(3, 0, sum3);
                                var sum2 = transposefrequencycounsumptionquarterData[4].map((val, i) => val + transposefrequencycounsumptionquarterData[5][i]);
                                transposefrequencycounsumptionquarterData.splice(4, 2);
                                transposefrequencycounsumptionquarterData.push(sum2);
                                var sum4 = transposefrequencycounsumptionquarterData2[4].map((val, i) => val + transposefrequencycounsumptionquarterData2[5][i]);
                                transposefrequencycounsumptionquarterData2.splice(4, 2);
                                transposefrequencycounsumptionquarterData2.push(sum4);
                                var transposefrequencycounsumptionquarterDataBase = transposeData(foodconsumedalonequarterB);
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                console.log("transposefrequencycounsumptionquarterDataBase[0]");
                                console.log(transposefrequencycounsumptionquarterDataBase[0])
                                formTable8(quarterLabel,CMC11label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"ch_11","data_table",transposefrequencycounsumptionquarterDataBase[0]);


                            // Country

                                // Slide 1

                                var consumptionDataCountryTable = [];

                                var consumptioneverDataCountry = [];
                                var consumptionconsumed1YDataCountry = [];
                                var consumptionconsumed3MDataCountry = [];
                                var consumptionconsumed7DDataCountry = [];

                                var consumptionDataCountryTable2 = [];

                                var consumptioneverDataCountry2 = [];
                                var consumptionconsumed1YDataCountry2 = [];
                                var consumptionconsumed3MDataCountry2 = [];
                                var consumptionconsumed7DDataCountry2 = [];

                                var consumptioncountryData = {};



                                countryLabel4.forEach(country => {
                                    if (consumptioncountryLevel[country]) {
                                        consumptioncountryData[country] = consumptioncountryLevel[country];
                                    }
                                });

                                for (let consumptioncountry in consumptioncountryData) {
                                    consumptioneverDataCountry.push(consumptioncountryData[consumptioncountry].ever[0].percentage);
                                    consumptionconsumed1YDataCountry.push(consumptioncountryData[consumptioncountry].consumed1Y[0].percentage);
                                    consumptionconsumed3MDataCountry.push(consumptioncountryData[consumptioncountry].consumed3M[0].percentage);
                                    consumptionconsumed7DDataCountry.push(consumptioncountryData[consumptioncountry].consumed7D[0].percentage);

                                    consumptioneverDataCountry2.push(consumptioncountryData[consumptioncountry].ever[0].percentage2);
                                    consumptionconsumed1YDataCountry2.push(consumptioncountryData[consumptioncountry].consumed1Y[0].percentage2);
                                    consumptionconsumed3MDataCountry2.push(consumptioncountryData[consumptioncountry].consumed3M[0].percentage2);
                                    consumptionconsumed7DDataCountry2.push(consumptioncountryData[consumptioncountry].consumed7D[0].percentage2);
                                }2

                                var consumptioncountrybCounts = {};
                                var consumptioncountries = Object.keys(consumptioncountryData);

                                consumptioncountries.forEach((country, index) => {
                                    consumptioncountrybCounts[index] = consumptioncountryLevel[country].ever[0].bCount;
                                });

                                const consumptioncountryflatArray = Object.values(consumptioncountrybCounts);

                                $("#ch_1").find(".country-col").find(".base-note").each(function(i,e){
                                    $(this).empty().append(`n-${consumptioncountryflatArray[i]}`);
                                });
                                $("#ch_1").find(".country-col").find(".full").each(function(i,e){
                                    $(this).empty().append(consumptioneverDataCountry[i]+"%");
                                })
                                $("#ch_1").find(".country-col").find(".mid").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed1YDataCountry[i]+"%");
                                })
                                $("#ch_1").find(".country-col").find(".lighter").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed3MDataCountry[i]+"%");
                                })
                                $("#ch_1").find(".country-col").find(".lightest").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed7DDataCountry[i]+"%");
                                })

                                consumptionDataCountryTable.push(consumptioneverDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed1YDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed3MDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed7DDataCountry);

                                consumptionDataCountryTable2.push(consumptioneverDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed1YDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed3MDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed7DDataCountry2);

                                formTable3(tab1label,consumptionDataCountryTable,consumptionDataCountryTable2,"ch_1","data_table",consumptioncountryflatArray);

                                // Slide 2

                                var finalfrequencyconsumptioncountryData = [];

                                var frequencyconsumptioncountryData = [];

                                var frequencyconsumptioncountryV = [];
                                var frequencyconsumptioncountryV2 = [];
                                var frequencyconsumptioncountryB = [];
                                var frequencyconsumptioncountryC = [];
                                var frequencyconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (frequencyconsumptioncountryLevel[e]) {
                                        frequencyconsumptioncountryData.push(frequencyconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(frequencyconsumptioncountryData,frequencyconsumptioncountryV,frequencyconsumptioncountryV2,frequencyconsumptioncountryB,frequencyconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(frequencyconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(frequencyconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(frequencyconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,frequencyconsumptioncountryVX,S13label2,colorPalletX4,"StackBar");
                                stackcolumnChart3(frequencyconsumptioncountryVX,"frequency_counsumption_chart_ch",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX4)
                                formTable3(S13label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_2","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 9
                                
                                var finalfoodtime_consumptioncountryData = [];

                                var foodtime_consumptioncountryData = [];

                                var foodtime_consumptioncountryV = [];
                                var foodtime_consumptioncountryV2 = [];
                                var foodtime_consumptioncountryB = [];
                                var foodtime_consumptioncountryC = [];
                                var foodtime_consumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (foodtime_consumptioncountryLevel[e]) {
                                        foodtime_consumptioncountryData.push(foodtime_consumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(foodtime_consumptioncountryData,foodtime_consumptioncountryV,foodtime_consumptioncountryV2,foodtime_consumptioncountryB,foodtime_consumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(foodtime_consumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(foodtime_consumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(foodtime_consumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                renderDonutTable(transposefrequencycounsumptioncountryData, CMC8label, countryLabel4,flaggXX,"ch_9",transposefrequencycounsumptioncountryDataBase[0]);
                                formTable3(CMC8label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_9","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 11

                                var foodfinalconsumedalonecountryData = [];
                                var foodconsumedalonecountryData = [];
                                var foodconsumedalonecountryV = [];
                                var foodconsumedalonecountryV2 = [];
                                var foodconsumedalonecountryB = [];
                                var foodconsumedalonecountryC = [];
                                var foodconsumedalonecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (foodconsumedalonecountryLevel[e]) {
                                        foodconsumedalonecountryData.push(foodconsumedalonecountryLevel[e]);
                                    }
                                })

                                extractValues2(foodconsumedalonecountryData,foodconsumedalonecountryV,foodconsumedalonecountryV2,foodconsumedalonecountryB,foodconsumedalonecountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(foodconsumedalonecountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(foodconsumedalonecountryV2)
                                var sum1 = transposefrequencycounsumptioncountryData[3].map((val, i) => val + transposefrequencycounsumptioncountryData[4][i]);
                                transposefrequencycounsumptioncountryData.splice(3, 2);
                                transposefrequencycounsumptioncountryData.splice(3, 0, sum1);
                                var sum3 = transposefrequencycounsumptioncountryData2[3].map((val, i) => val + transposefrequencycounsumptioncountryData2[4][i]);
                                transposefrequencycounsumptioncountryData2.splice(3, 2);
                                transposefrequencycounsumptioncountryData2.splice(3, 0, sum3);
                                var sum2 = transposefrequencycounsumptioncountryData[4].map((val, i) => val + transposefrequencycounsumptioncountryData[5][i]);
                                transposefrequencycounsumptioncountryData.splice(4, 2);
                                transposefrequencycounsumptioncountryData.push(sum2);
                                var sum4 = transposefrequencycounsumptioncountryData2[4].map((val, i) => val + transposefrequencycounsumptioncountryData2[5][i]);
                                transposefrequencycounsumptioncountryData2.splice(4, 2);
                                transposefrequencycounsumptioncountryData2.push(sum4);
                                var transposefrequencycounsumptioncountryDataBase = transposeData(foodconsumedalonecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                renderDonutTable(transposefrequencycounsumptioncountryData, CMC11label2, countryLabel4,flaggXX,"ch_11",transposefrequencycounsumptioncountryDataBase[0]);
                                formTable3(CMC11label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_11","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 14

                                var foodfinalreasonconsumptioncountryData = [];
                                var foodreasonconsumptioncountryData = [];
                                var foodreasonconsumptioncountryV = [];
                                var foodreasonconsumptioncountryV2 = [];
                                var foodreasonconsumptioncountryB = [];
                                var foodreasonconsumptioncountryC = [];
                                var foodreasonconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (foodreasonconsumptioncountryLevel[e]) {
                                        foodreasonconsumptioncountryData.push(foodreasonconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(foodreasonconsumptioncountryData,foodreasonconsumptioncountryV,foodreasonconsumptioncountryV2,foodreasonconsumptioncountryB,foodreasonconsumptioncountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(foodreasonconsumptioncountryV, CMC12label);
                                var sortingResult2 = sortByFirstCountryWithLabels(foodreasonconsumptioncountryV2, CMC12label);
                                
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(foodreasonconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_12","roc_tt_ch_food",transposefrequencycounsumptioncountryDataBase[0]);

                                customizedArray(transposefrequencycounsumptioncountryData,foodreasonconsumptioncountryVX,sortingResult.sortedLabels,colorPallet,"StackBar");
                                
                                function transformToModelWise(input) {
                                    const result = [];
                                    for (let i = 0; i < 7; i++) {
                                        const modelData = {
                                        name: `Model ${i + 1}`,
                                        data: input.map(item => item.data[i])
                                        };
                                        result.push(modelData);
                                    }
                                    return result;
                                }

                                const modelWise = transformToModelWise(foodreasonconsumptioncountryVX);

                                
                                function generateColors(dataArray) {
                                    const indexed = dataArray.map((value, index) => ({ value, index }));
                                    indexed.sort((a, b) => b.value - a.value);
                                    
                                    const topIndexes = new Set(indexed.slice(0, 4).map(item => item.index));

                                    return dataArray.map((_, index) => topIndexes.has(index) ? '#4D6893' : '#7C985E');
                                }
                                modelWise.forEach(model => {
                                    model.color = 'transparent';
                                    model.colors = generateColors(model.data);
                                });


                                barChart88([modelWise[0]],"reason_consumption_1_ch_food",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][0],"SouthEast Asia",flagg2[0]);
                                barChart89([modelWise[1]],"reason_consumption_2_ch_food",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][1],"Singapore",flagg2[0]);
                                barChart89([modelWise[2]],"reason_consumption_3_ch_food",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][2],"Thailand",flagg2[1]);
                                barChart89([modelWise[3]],"reason_consumption_4_ch_food",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][3],"Malaysia",flagg2[2]);
                                barChart89([modelWise[4]],"reason_consumption_5_ch_food",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][4],"Indonesia",flagg2[3]);
                                barChart89([modelWise[5]],"reason_consumption_6_ch_food",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][5],"Philippines",flagg2[4]);
                                barChart89([modelWise[6]],"reason_consumption_7_ch_food",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][6],"Vietnam",flagg2[5]);

                                // agecountryLevel

                                var finalagecountryLevelcountryData = [];
                                var agecountryLevelcountryData = [];
                                var agecountryLevelcountryV = [];
                                var agecountryLevelcountryV2 = [];
                                var agecountryLevelcountryB = [];
                                var agecountryLevelcountryC = [];
                                var agecountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (agecountryLevel[e]) {
                                        agecountryLevelcountryData.push(agecountryLevel[e]);
                                    }
                                })

                                extractValues2(agecountryLevelcountryData,agecountryLevelcountryV,agecountryLevelcountryV2,agecountryLevelcountryB,agecountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(agecountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(agecountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(agecountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(ageLabelXXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_18","age_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // educationcountryLevel

                                var finaleducationcountryLevelcountryData = [];
                                var educationcountryLevelcountryData = [];
                                var educationcountryLevelcountryV = [];
                                var educationcountryLevelcountryV2 = [];
                                var educationcountryLevelcountryB = [];
                                var educationcountryLevelcountryC = [];
                                var educationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (educationcountryLevel[e]) {
                                        educationcountryLevelcountryData.push(educationcountryLevel[e]);
                                    }
                                })

                                extractValues2(educationcountryLevelcountryData,educationcountryLevelcountryV,educationcountryLevelcountryV2,educationcountryLevelcountryB,educationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(educationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(educationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(educationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(educationXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_18","education_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // dietarycountryLevel

                                var finaldietarycountryLevelcountryData = [];
                                var dietarycountryLevelcountryData = [];
                                var dietarycountryLevelcountryV = [];
                                var dietarycountryLevelcountryV2 = [];
                                var dietarycountryLevelcountryB = [];
                                var dietarycountryLevelcountryC = [];
                                var dietarycountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (dietarycountryLevel[e]) {
                                        dietarycountryLevelcountryData.push(dietarycountryLevel[e]);
                                    }
                                })

                                extractValues2(dietarycountryLevelcountryData,dietarycountryLevelcountryV,dietarycountryLevelcountryV2,dietarycountryLevelcountryB,dietarycountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(dietarycountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(dietarycountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(dietarycountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(halalLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_18","dietary_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // occupationcountryLevel

                                var finaloccupationcountryLevelcountryData = [];
                                var occupationcountryLevelcountryData = [];
                                var occupationcountryLevelcountryV = [];
                                var occupationcountryLevelcountryV2 = [];
                                var occupationcountryLevelcountryB = [];
                                var occupationcountryLevelcountryC = [];
                                var occupationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (occupationcountryLevel[e]) {
                                        occupationcountryLevelcountryData.push(occupationcountryLevel[e]);
                                    }
                                })

                                extractValues2(occupationcountryLevelcountryData,occupationcountryLevelcountryV,occupationcountryLevelcountryV2,occupationcountryLevelcountryB,occupationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(occupationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(occupationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(occupationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(occupationLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_19","occupation_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // incomecountryLevel

                                var finalincomecountryLevelcountryData = [];
                                var incomecountryLevelcountryData = [];
                                var incomecountryLevelcountryV = [];
                                var incomecountryLevelcountryV2 = [];
                                var incomecountryLevelcountryB = [];
                                var incomecountryLevelcountryC = [];
                                var incomecountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (incomecountryLevel[e]) {
                                        incomecountryLevelcountryData.push(incomecountryLevel[e]);
                                    }
                                })

                                extractValues2(incomecountryLevelcountryData,incomecountryLevelcountryV,incomecountryLevelcountryV2,incomecountryLevelcountryB,incomecountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(incomecountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(incomecountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(incomecountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(incomeLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_19","householdincome_tbl",transposefrequencycounsumptioncountryDataBase[0]);

                                // relationshipcountryLevel

                                var finalrelationcountryLevelcountryData = [];
                                var relationcountryLevelcountryData = [];
                                var relationcountryLevelcountryV = [];
                                var relationcountryLevelcountryV2 = [];
                                var relationcountryLevelcountryB = [];
                                var relationcountryLevelcountryC = [];
                                var relationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (relationcountryLevel[e]) {
                                        relationcountryLevelcountryData.push(relationcountryLevel[e]);
                                    }
                                })

                                extractValues2(relationcountryLevelcountryData,relationcountryLevelcountryV,relationcountryLevelcountryV2,relationcountryLevelcountryB,relationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(relationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(relationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(relationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(relationXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"ch_20","relationship_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                

                        },
                        complete: function (data) {
                            ajaxFlag[1+52] = true;
                            $(".splash").hide();
                        }
                    })
                }
                function fortyNinthAjax() {
                    $.ajax({
                        url: "api/ajax49.php",
                        type: "POST",
                        data: {
                            'condX': condX2,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            trends1Data = data;
                            console.log("ajax49.php");
                            console.log(data);
                            
                            var consumptioncountryLevel = data['ConsumptionCountry'];
                            var consumptionquarterLevel = data['ConsumptionQuarter'];

                            var frequencyconsumptioncountryLevel = data['S13_6Country'];
                            var frequencyconsumptionquarterLevel = data['S13_6Quarter'];

                            var subcategorycountryLevel = data['FD_C2Country'];
                            var subcategoryquarterLevel = data['FD_C2Quarter'];

                            var accompaniedcountryLevel = data['FD_C10Country'];
                            var accompaniedquarterLevel = data['FD_C10Quarter'];

                            var packaging_sizecountryLevel = data['FD_C7Country'];
                            var packaging_sizequarterLevel = data['FD_C7Quarter'];

                            var packaging_typecountryLevel = data['FD_C6Country'];
                            var packaging_typequarterLevel = data['FD_C6Quarter'];

                            var time_consumptioncountryLevel = data['FD_C8Country'];
                            var time_consumptionquarterLevel = data['FD_C8Quarter'];

                            var place_consumptioncountryLevel = data['FD_C9Country'];
                            var place_consumptionquarterLevel = data['FD_C9Quarter'];

                            var consumedalonecountryLevel = data['FD_C11Country'];
                            var consumedalonequarterLevel = data['FD_C11Quarter'];

                            var reasonconsumptioncountryLevel = data['FD_C12Country'];
                            var reasonconsumptionquarterLevel = data['FD_C12Quarter'];

                            var changepersonalconsumptioncountryLevel = data['FD_C15Country'];
                            var changepersonalconsumptionquarterLevel = data['FD_C15Quarter'];

                            var purchasehouseholdcountryLevel = data['FD_C17Country'];
                            var purchasehouseholdquarterLevel = data['FD_C17Quarter'];

                            var purchasehouseholdcountryLevel2 = data['FD_C17_1Country'];
                            var purchasehouseholdquarterLevel2 = data['FD_C17_1Quarter'];

                            var whopurchasecountryLevel = data['FD_C18Country'];
                            var whopurchasequarterLevel = data['FD_C18Quarter'];

                            var purchasechannelcountryLevel = data['FD_C19Country'];
                            var purchasechannelquarterLevel = data['FD_C19Quarter'];

                            var changehouseholdconsumptioncountryLevel = data['FD_C20Country'];
                            var changehouseholdconsumptionquarterLevel = data['FD_C20Quarter'];

                            var householdconsumptioncountryLevel = data['FD_C16Country'];
                            var householdconsumptionquarterLevel = data['FD_C16Quarter'];

                            var agecountryLevel = data['HAGE'];
                            var educationcountryLevel = data['P4'];
                            var dietarycountryLevel = data['S10'];
                            var occupationcountryLevel = data['P5'];
                            var incomecountryLevel = data['S7'];
                            var relationcountryLevel = data['P1'];
                            

                            // Quarter

                                // Slide 1

                                var finalconsumptionTrendData = [];

                                var consumptioneverDataQuarter = [];
                                var consumptionconsumed1YDataQuarter = [];
                                var consumptionconsumed3MDataQuarter = [];
                                var consumptionconsumed7DDataQuarter = [];

                                var finalconsumptionTrendData2 = [];

                                var consumptioneverDataQuarter2 = [];
                                var consumptionconsumed1YDataQuarter2 = [];
                                var consumptionconsumed3MDataQuarter2 = [];
                                var consumptionconsumed7DDataQuarter2 = [];

                                const consumptionquarterData = {};

                                quarterLabel.forEach(quarter => {
                                    if (consumptionquarterLevel[quarter]) {
                                        consumptionquarterData[quarter] = consumptionquarterLevel[quarter];
                                    }
                                });

                                for (let consumptionquarter in consumptionquarterData) {
                                    consumptioneverDataQuarter.push(consumptionquarterData[consumptionquarter].ever[0].percentage);
                                    consumptionconsumed1YDataQuarter.push(consumptionquarterData[consumptionquarter].consumed1Y[0].percentage);
                                    consumptionconsumed3MDataQuarter.push(consumptionquarterData[consumptionquarter].consumed3M[0].percentage);
                                    consumptionconsumed7DDataQuarter.push(consumptionquarterData[consumptionquarter].consumed7D[0].percentage);

                                    consumptioneverDataQuarter2.push(consumptionquarterData[consumptionquarter].ever[0].percentage2);
                                    consumptionconsumed1YDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed1Y[0].percentage2);
                                    consumptionconsumed3MDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed3M[0].percentage2);
                                    consumptionconsumed7DDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed7D[0].percentage2);
                                }

                                var consumptionquarterbCounts = {};
                                var consumptionquarters = Object.keys(consumptionquarterData);

                                consumptionquarters.forEach((quarter, index) => {
                                    consumptionquarterbCounts[index] = consumptionquarterLevel[quarter].ever[0].bCount;
                                });

                                const consumptionquarterflatArray = Object.values(consumptionquarterbCounts);
                                
                                finalconsumptionTrendData.push(consumptioneverDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed1YDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed3MDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed7DDataQuarter);

                                finalconsumptionTrendData2.push(consumptioneverDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed1YDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed3MDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed7DDataQuarter2);

                                formTable8(quarterLabel,tab1label,finalconsumptionTrendData,finalconsumptionTrendData2,"fd_1","consumtion_funnel",consumptionquarterflatArray);

                                var aHTML = ``;
                                consumptionquarterflatArray.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e}</span>`;
                                });
                                $("#fd_1").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 2

                                var finalfrequencyconsumptionTrendData = [];

                                var frequencyconsumptionquarterData = [];

                                var frequencyconsumptionquarterV = [];
                                var frequencyconsumptionquarterV2 = [];
                                var frequencyconsumptionquarterB = [];
                                var frequencyconsumptionquarterC = [];
                                var frequencyconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (frequencyconsumptionquarterLevel[e]) {
                                        frequencyconsumptionquarterData.push(frequencyconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(frequencyconsumptionquarterData,frequencyconsumptionquarterV,frequencyconsumptionquarterV2,frequencyconsumptionquarterB,frequencyconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(frequencyconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(frequencyconsumptionquarterV2)
                                var quarterBase = frequencyconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,S13label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_2","frequency_consumtion",quarterBase);

                                var aHTML = ``;
                                frequencyconsumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#fd_2").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 3

                                var finalsubcategoryTrendData = [];

                                var subcategoryquarterData = [];

                                var subcategoryquarterV = [];
                                var subcategoryquarterV2 = [];
                                var subcategoryquarterB = [];
                                var subcategoryquarterC = [];
                                var subcategoryquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (subcategoryquarterLevel[e]) {
                                        subcategoryquarterData.push(subcategoryquarterLevel[e]);
                                    }
                                })

                                extractValues2(subcategoryquarterData,subcategoryquarterV,subcategoryquarterV2,subcategoryquarterB,subcategoryquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(subcategoryquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(subcategoryquarterV2)
                                var quarterBase = subcategoryquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,FDC2label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_3","subcategory",quarterBase);

                                var aHTML = ``;
                                subcategoryquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#fd_3").find(".funnel-col").find(".foot").empty().append(aHTML);

                                
                                // Slide 5

                                var finalaccompaniedTrendData = [];

                                var accompaniedquarterData = [];

                                var accompaniedquarterV = [];
                                var accompaniedquarterV2 = [];
                                var accompaniedquarterB = [];
                                var accompaniedquarterC = [];
                                var accompaniedquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (accompaniedquarterLevel[e]) {
                                        accompaniedquarterData.push(accompaniedquarterLevel[e]);
                                    }
                                })

                                extractValues2(accompaniedquarterData,accompaniedquarterV,accompaniedquarterV2,accompaniedquarterB,accompaniedquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(accompaniedquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(accompaniedquarterV2)
                                var quarterBase = accompaniedquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC10label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_5","accompanied",quarterBase);

                                var aHTML = ``;
                                accompaniedquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#fd_5").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 7

                                var finalpackaging_sizeTrendData = [];

                                var packaging_sizequarterData = [];

                                var packaging_sizequarterV = [];
                                var packaging_sizequarterV2 = [];
                                var packaging_sizequarterB = [];
                                var packaging_sizequarterC = [];
                                var packaging_sizequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (packaging_sizequarterLevel[e]) {
                                        packaging_sizequarterData.push(packaging_sizequarterLevel[e]);
                                    }
                                })

                                extractValues2(packaging_sizequarterData,packaging_sizequarterV,packaging_sizequarterV2,packaging_sizequarterB,packaging_sizequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(packaging_sizequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(packaging_sizequarterV2)
                                var quarterBase = packaging_sizequarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC7label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_7","packaging_size",quarterBase);
                                var aHTML = ``;
                                packaging_sizequarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#fd_7").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 8

                                var finalpackaging_typeTrendData = [];

                                var packaging_typequarterData = [];

                                var packaging_typequarterV = [];
                                var packaging_typequarterV2 = [];
                                var packaging_typequarterB = [];
                                var packaging_typequarterC = [];
                                var packaging_typequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (packaging_typequarterLevel[e]) {
                                        packaging_typequarterData.push(packaging_typequarterLevel[e]);
                                    }
                                })

                                extractValues2(packaging_typequarterData,packaging_typequarterV,packaging_typequarterV2,packaging_typequarterB,packaging_typequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(packaging_typequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(packaging_typequarterV2)
                                var quarterBase = packaging_typequarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,FDC6label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_8","packaging_type",quarterBase);

                                var aHTML = ``;
                                packaging_typequarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#fd_8").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 9

                                var finaltime_consumptionTrendData = [];

                                var time_consumptionquarterData = [];

                                var time_consumptionquarterV = [];
                                var time_consumptionquarterV2 = [];
                                var time_consumptionquarterB = [];
                                var time_consumptionquarterC = [];
                                var time_consumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (time_consumptionquarterLevel[e]) {
                                        time_consumptionquarterData.push(time_consumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(time_consumptionquarterData,time_consumptionquarterV,time_consumptionquarterV2,time_consumptionquarterB,time_consumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(time_consumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(time_consumptionquarterV2)
                                var quarterBase = time_consumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC8label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_9","time_consumption",quarterBase);

                                var aHTML = ``;
                                time_consumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#fd_9").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 10

                                var finalplace_consumptionTrendData = [];

                                var place_consumptionquarterData = [];

                                var place_consumptionquarterV = [];
                                var place_consumptionquarterV2 = [];
                                var place_consumptionquarterB = [];
                                var place_consumptionquarterC = [];
                                var place_consumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (place_consumptionquarterLevel[e]) {
                                        place_consumptionquarterData.push(place_consumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(place_consumptionquarterData,place_consumptionquarterV,place_consumptionquarterV2,place_consumptionquarterB,place_consumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(place_consumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(place_consumptionquarterV2)
                                var quarterBase = place_consumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC9label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_10","place_consumption",quarterBase);
                                

                                var aHTML = ``;
                                place_consumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#fd_10").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 11

                                var finalconsumedalonequarterData = [];
                                var consumedalonequarterData = [];
                                var consumedalonequarterV = [];
                                var consumedalonequarterV2 = [];
                                var consumedalonequarterB = [];
                                var consumedalonequarterC = [];
                                var consumedalonequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (consumedalonequarterLevel[e]) {
                                        consumedalonequarterData.push(consumedalonequarterLevel[e]);
                                    }
                                })

                                extractValues2(consumedalonequarterData,consumedalonequarterV,consumedalonequarterV2,consumedalonequarterB,consumedalonequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(consumedalonequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(consumedalonequarterV2)
                                var sum1 = transposefrequencycounsumptionquarterData[3].map((val, i) => val + transposefrequencycounsumptionquarterData[4][i]);
                                transposefrequencycounsumptionquarterData.splice(3, 2);
                                transposefrequencycounsumptionquarterData.splice(3, 0, sum1);
                                var sum3 = transposefrequencycounsumptionquarterData2[3].map((val, i) => val + transposefrequencycounsumptionquarterData2[4][i]);
                                transposefrequencycounsumptionquarterData2.splice(3, 2);
                                transposefrequencycounsumptionquarterData2.splice(3, 0, sum3);
                                var sum2 = transposefrequencycounsumptionquarterData[4].map((val, i) => val + transposefrequencycounsumptionquarterData[5][i]);
                                transposefrequencycounsumptionquarterData.splice(4, 2);
                                transposefrequencycounsumptionquarterData.push(sum2);
                                var sum4 = transposefrequencycounsumptionquarterData2[4].map((val, i) => val + transposefrequencycounsumptionquarterData2[5][i]);
                                transposefrequencycounsumptionquarterData2.splice(4, 2);
                                transposefrequencycounsumptionquarterData2.push(sum4);
                                var transposefrequencycounsumptionquarterDataBase = transposeData(consumedalonequarterB);
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                console.log("transposefrequencycounsumptionquarterDataBase[0]");
                                console.log(transposefrequencycounsumptionquarterDataBase[0])
                                formTable8(quarterLabel,CMC11label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_11","data_table",transposefrequencycounsumptionquarterDataBase[0]);

                                // Slide 12

                                var finalchangepersonalconsumptionquarterData = [];
                                var changepersonalconsumptionquarterData = [];
                                var changepersonalconsumptionquarterV = [];
                                var changepersonalconsumptionquarterV2 = [];
                                var changepersonalconsumptionquarterB = [];
                                var changepersonalconsumptionquarterC = [];
                                var changepersonalconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (changepersonalconsumptionquarterLevel[e]) {
                                        changepersonalconsumptionquarterData.push(changepersonalconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(changepersonalconsumptionquarterData,changepersonalconsumptionquarterV,changepersonalconsumptionquarterV2,changepersonalconsumptionquarterB,changepersonalconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(changepersonalconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(changepersonalconsumptionquarterV2)
                                var quarterBase = changepersonalconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC20label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_14","pc_tbl2_fd",quarterBase);

                                // 

                                var finalchangehouseholdconsumptionquarterData = [];
                                var changehouseholdconsumptionquarterData = [];
                                var changehouseholdconsumptionquarterV = [];
                                var changehouseholdconsumptionquarterV2 = [];
                                var changehouseholdconsumptionquarterB = [];
                                var changehouseholdconsumptionquarterC = [];
                                var changehouseholdconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (changehouseholdconsumptionquarterLevel[e]) {
                                        changehouseholdconsumptionquarterData.push(changehouseholdconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(changehouseholdconsumptionquarterData,changehouseholdconsumptionquarterV,changehouseholdconsumptionquarterV2,changehouseholdconsumptionquarterB,changehouseholdconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(changehouseholdconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(changehouseholdconsumptionquarterV2)
                                var quarterBase = changehouseholdconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC20label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_14","hc_tbl2_fd",quarterBase);

                                // Slide 13

                                var finalpurchasehousehold1quarterData = [];
                                var purchasehousehold1quarterData = [];
                                var purchasehousehold1quarterV = [];
                                var purchasehousehold1quarterV2 = [];
                                var purchasehousehold1quarterB = [];
                                var purchasehousehold1quarterC = [];
                                var purchasehousehold1quarterVX = [];

                                var finalpurchasehousehold2quarterData = [];
                                var purchasehousehold2quarterData = [];
                                var purchasehousehold2quarterV = [];
                                var purchasehousehold2quarterV2 = [];
                                var purchasehousehold2quarterB = [];
                                var purchasehousehold2quarterC = [];
                                var purchasehousehold2quarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (purchasechannelquarterLevel[e]) {
                                        purchasehousehold1quarterData.push(purchasechannelquarterLevel[e]);
                                    }
                                })

                                quarterLabel.forEach(function(e,i,a){
                                    if (purchasehouseholdquarterLevel2[e]) {
                                        purchasehousehold2quarterData.push(purchasehouseholdquarterLevel2[e]);
                                    }
                                });

                                function colorizeTableByColumn(tableId) {
                                    const table = document.getElementById(tableId);
                                    if (!table) return;

                                    const rows = Array.from(table.querySelectorAll("tbody tr"));
                                    const numCols = rows[0].querySelectorAll("td").length;

                                    // Convert hex to RGB
                                    function hexToRgb(hex) {
                                        const bigint = parseInt(hex.replace('#', ''), 16);
                                        return {
                                        r: (bigint >> 16) & 255,
                                        g: (bigint >> 8) & 255,
                                        b: bigint & 255,
                                        };
                                    }

                                    // Interpolate between two RGB values
                                    function interpolateColor(color1, color2, factor) {
                                        return {
                                        r: Math.round(color1.r + (color2.r - color1.r) * factor),
                                        g: Math.round(color1.g + (color2.g - color1.g) * factor),
                                        b: Math.round(color1.b + (color2.b - color1.b) * factor),
                                        };
                                    }

                                    // Custom gradient: red → white → green
                                    function getColorByRank(percent) {
                                        const red = hexToRgb("#ff4d4d");
                                        const white = hexToRgb("#ffffff");
                                        const green = hexToRgb("#4caf50");

                                        let rgb;
                                        if (percent < 0.5) {
                                        rgb = interpolateColor(red, white, percent * 2); // 0 to 0.5 → red to white
                                        } else {
                                        rgb = interpolateColor(white, green, (percent - 0.5) * 2); // 0.5 to 1 → white to green
                                        }

                                        return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
                                    }

                                    // Loop through each column (excluding label column)
                                    for (let colIndex = 1; colIndex < numCols; colIndex++) {
                                        const values = [];

                                        // Collect values with index
                                        rows.forEach((row, rowIndex) => {
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        const val = parseFloat(cell.innerText.replace('%', ''));
                                        if (!isNaN(val)) values.push({ rowIndex, value: val });
                                        });

                                        const sorted = [...values].sort((a, b) => b.value - a.value);
                                        const total = sorted.length;

                                        sorted.forEach((item, i) => {
                                        const rankPercent = 1 - (i / (total - 1)); // highest = 1, lowest = 0
                                        const row = rows[item.rowIndex];
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        cell.style.backgroundColor = getColorByRank(rankPercent);
                                        cell.style.color = "#000";
                                        });
                                    }
                                }

                                function colorizeTableByColumn2(tableId) {
                                    ////debugger;
                                    const table = document.getElementById(tableId);
                                    if (!table) return;

                                    const rows = Array.from(table.querySelectorAll("tbody tr"));
                                    const numCols = rows[0].querySelectorAll("td").length;

                                    // Convert hex to RGB
                                    function hexToRgb2(hex) {
                                        const bigint = parseInt(hex.replace('#', ''), 16);
                                        return {
                                        r: (bigint >> 16) & 255,
                                        g: (bigint >> 8) & 255,
                                        b: bigint & 255,
                                        };
                                    }

                                    // Interpolate between two RGB values
                                    function interpolateColor2(color1, color2, factor) {
                                        return {
                                        r: Math.round(color1.r + (color2.r - color1.r) * factor),
                                        g: Math.round(color1.g + (color2.g - color1.g) * factor),
                                        b: Math.round(color1.b + (color2.b - color1.b) * factor),
                                        };
                                    }

                                    // Custom gradient: red → white → green
                                    function getColorByRank2(percent) {
                                        const red = hexToRgb2("#ff4d4d");
                                        const white = hexToRgb2("#ffffff");
                                        const green = hexToRgb2("#4caf50");

                                        let rgb;
                                        if (percent < 0.5) {
                                        rgb = interpolateColor2(red, white, percent * 2); // 0 to 0.5 → red to white
                                        } else {
                                        rgb = interpolateColor2(white, green, (percent - 0.5) * 2); // 0.5 to 1 → white to green
                                        }

                                        return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
                                    }

                                    // Loop through each column (excluding label column)
                                    for (let colIndex = 0; colIndex < numCols; colIndex++) {
                                        const values = [];

                                        // Collect values with index
                                        rows.forEach((row, rowIndex) => {
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        const val = parseFloat(cell.innerText.replace('%', ''));
                                        if (!isNaN(val)) values.push({ rowIndex, value: val });
                                        });

                                        const sorted = [...values].sort((a, b) => b.value - a.value);
                                        const total = sorted.length;

                                        sorted.forEach((item, i) => {
                                        const rankPercent = 1 - (i / (total - 1)); // highest = 1, lowest = 0
                                        const row = rows[item.rowIndex];
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        cell.style.backgroundColor = getColorByRank2(rankPercent);
                                        cell.style.color = "#000";
                                        });
                                    }
                                }

                                extractValues2(purchasehousehold1quarterData,purchasehousehold1quarterV,purchasehousehold1quarterV2,purchasehousehold1quarterB,purchasehousehold1quarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(purchasehousehold1quarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(purchasehousehold1quarterV2)
                                var transposefrequencycounsumptionquarterDataBase = transposeData(purchasehousehold1quarterB)
                                
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                formTable2(quarterLabel,CMC19label2,transposefrequencycounsumptionquarterData,"fd_15","purchase_behaviour_chart2_fd2",transposefrequencycounsumptionquarterDataBase[0]);
                                colorizeTableByColumn2("purchase_behaviour_chart2_fd2");
                                
                                extractValues2(purchasehousehold2quarterData,purchasehousehold2quarterV,purchasehousehold2quarterV2,purchasehousehold2quarterB,purchasehousehold2quarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(purchasehousehold2quarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(purchasehousehold2quarterV2)
                                var transposefrequencycounsumptionquarterDataBase = transposeData(purchasehousehold2quarterB)
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptionquarterData,purchasehousehold2quarterVX,["Yes"],colorPallet,"StackBar");
                                stackcolumnChart2(purchasehousehold2quarterVX,"purchase_behaviour_chart_fd2",quarterLabel,transposefrequencycounsumptionquarterDataBase[0],"100")

                                // Slide 15

                                var finalhouseholdconsumptionquarterLevelquarterData = [];
                                var householdconsumptionquarterLevelquarterData = [];
                                var householdconsumptionquarterLevelquarterV = [];
                                var householdconsumptionquarterLevelquarterV2 = [];
                                var householdconsumptionquarterLevelquarterB = [];
                                var householdconsumptionquarterLevelquarterC = [];
                                var householdconsumptionquarterLevelquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (householdconsumptionquarterLevel[e]) {
                                        householdconsumptionquarterLevelquarterData.push(householdconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(householdconsumptionquarterLevelquarterData,householdconsumptionquarterLevelquarterV,householdconsumptionquarterLevelquarterV2,householdconsumptionquarterLevelquarterB,householdconsumptionquarterLevelquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(householdconsumptionquarterLevelquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(householdconsumptionquarterLevelquarterV2)
                                var quarterBase = householdconsumptionquarterLevelquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC16label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"fd_16","household_consumption_chart_cm",quarterBase);

                            // Country

                                // Slide 1

                                var consumptionDataCountryTable = [];

                                var consumptioneverDataCountry = [];
                                var consumptionconsumed1YDataCountry = [];
                                var consumptionconsumed3MDataCountry = [];
                                var consumptionconsumed7DDataCountry = [];

                                var consumptionDataCountryTable2 = [];

                                var consumptioneverDataCountry2 = [];
                                var consumptionconsumed1YDataCountry2 = [];
                                var consumptionconsumed3MDataCountry2 = [];
                                var consumptionconsumed7DDataCountry2 = [];

                                var consumptioncountryData = {};



                                countryLabel4.forEach(country => {
                                    if (consumptioncountryLevel[country]) {
                                        consumptioncountryData[country] = consumptioncountryLevel[country];
                                    }
                                });

                                for (let consumptioncountry in consumptioncountryData) {
                                    consumptioneverDataCountry.push(consumptioncountryData[consumptioncountry].ever[0].percentage);
                                    consumptionconsumed1YDataCountry.push(consumptioncountryData[consumptioncountry].consumed1Y[0].percentage);
                                    consumptionconsumed3MDataCountry.push(consumptioncountryData[consumptioncountry].consumed3M[0].percentage);
                                    consumptionconsumed7DDataCountry.push(consumptioncountryData[consumptioncountry].consumed7D[0].percentage);

                                    consumptioneverDataCountry2.push(consumptioncountryData[consumptioncountry].ever[0].percentage2);
                                    consumptionconsumed1YDataCountry2.push(consumptioncountryData[consumptioncountry].consumed1Y[0].percentage2);
                                    consumptionconsumed3MDataCountry2.push(consumptioncountryData[consumptioncountry].consumed3M[0].percentage2);
                                    consumptionconsumed7DDataCountry2.push(consumptioncountryData[consumptioncountry].consumed7D[0].percentage2);
                                }2

                                var consumptioncountrybCounts = {};
                                var consumptioncountries = Object.keys(consumptioncountryData);

                                consumptioncountries.forEach((country, index) => {
                                    consumptioncountrybCounts[index] = consumptioncountryLevel[country].ever[0].bCount;
                                });

                                const consumptioncountryflatArray = Object.values(consumptioncountrybCounts);

                                $("#fd_1").find(".country-col").find(".base-note").each(function(i,e){
                                    $(this).empty().append(`n-${consumptioncountryflatArray[i]}`);
                                });
                                $("#fd_1").find(".country-col").find(".full").each(function(i,e){
                                    $(this).empty().append(consumptioneverDataCountry[i]+"%");
                                })
                                $("#fd_1").find(".country-col").find(".mid").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed1YDataCountry[i]+"%");
                                })
                                $("#fd_1").find(".country-col").find(".lighter").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed3MDataCountry[i]+"%");
                                })
                                $("#fd_1").find(".country-col").find(".lightest").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed7DDataCountry[i]+"%");
                                })

                                consumptionDataCountryTable.push(consumptioneverDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed1YDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed3MDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed7DDataCountry);

                                consumptionDataCountryTable2.push(consumptioneverDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed1YDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed3MDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed7DDataCountry2);

                                formTable3(tab1label,consumptionDataCountryTable,consumptionDataCountryTable2,"fd_1","data_table",consumptioncountryflatArray);

                                // Slide 2

                                var finalfrequencyconsumptioncountryData = [];

                                var frequencyconsumptioncountryData = [];

                                var frequencyconsumptioncountryV = [];
                                var frequencyconsumptioncountryV2 = [];
                                var frequencyconsumptioncountryB = [];
                                var frequencyconsumptioncountryC = [];
                                var frequencyconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (frequencyconsumptioncountryLevel[e]) {
                                        frequencyconsumptioncountryData.push(frequencyconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(frequencyconsumptioncountryData,frequencyconsumptioncountryV,frequencyconsumptioncountryV2,frequencyconsumptioncountryB,frequencyconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(frequencyconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(frequencyconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(frequencyconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,frequencyconsumptioncountryVX,S13label2,colorPalletX4,"StackBar");
                                stackcolumnChart3(frequencyconsumptioncountryVX,"frequency_counsumption_chart_fd",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX4)
                                formTable3(S13label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_2","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 3

                                var finalsubcategorycountryData = [];

                                var subcategorycountryData = [];

                                var subcategorycountryV = [];
                                var subcategorycountryV2 = [];
                                var subcategorycountryB = [];
                                var subcategorycountryC = [];
                                var subcategorycountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (subcategorycountryLevel[e]) {
                                        subcategorycountryData.push(subcategorycountryLevel[e]);
                                    }
                                })

                                extractValues2(subcategorycountryData,subcategorycountryV,subcategorycountryV2,subcategorycountryB,subcategorycountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(subcategorycountryV, FDC2label);
                                var sortingResult2 = sortByFirstCountryWithLabels(subcategorycountryV2, FDC2label);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(subcategorycountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,subcategorycountryVX,sortingResult.sortedLabels,colorPalletX5,"StackBar");
                                stackcolumnChart3(subcategorycountryVX,"subcategory_chart_fd",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX5)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_3","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                
                                // Slide 5

                                var finalaccompaniedcountryData = [];

                                var accompaniedcountryData = [];

                                var accompaniedcountryV = [];
                                var accompaniedcountryV2 = [];
                                var accompaniedcountryB = [];
                                var accompaniedcountryC = [];
                                var accompaniedcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (accompaniedcountryLevel[e]) {
                                        accompaniedcountryData.push(accompaniedcountryLevel[e]);
                                    }
                                })

                                extractValues2(accompaniedcountryData,accompaniedcountryV,accompaniedcountryV2,accompaniedcountryB,accompaniedcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(accompaniedcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(accompaniedcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(accompaniedcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,accompaniedcountryVX,CMC10label,colorPalletX4,"StackBar");
                                stackcolumnChart3(accompaniedcountryVX,"accompanied_chart_fd",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX4)
                                formTable3(CMC10label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_5","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 7

                                var finalpackaging_sizecountryData = [];

                                var packaging_sizecountryData = [];

                                var packaging_sizecountryV = [];
                                var packaging_sizecountryV2 = [];
                                var packaging_sizecountryB = [];
                                var packaging_sizecountryC = [];
                                var packaging_sizecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (packaging_sizecountryLevel[e]) {
                                        packaging_sizecountryData.push(packaging_sizecountryLevel[e]);
                                    }
                                })

                                extractValues2(packaging_sizecountryData,packaging_sizecountryV,packaging_sizecountryV2,packaging_sizecountryB,packaging_sizecountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(packaging_sizecountryV, CMC7label2);
                                var sortingResult2 = sortByFirstCountryWithLabels(packaging_sizecountryV2, CMC7label2);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(packaging_sizecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,packaging_sizecountryVX,sortingResult.sortedLabels,colorPalletX1,"StackBar");
                                stackcolumnChart3(packaging_sizecountryVX,"packaging_size_chart_fd",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX1)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_7","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 8

                                var finalpackaging_typecountryData = [];

                                var packaging_typecountryData = [];

                                var packaging_typecountryV = [];
                                var packaging_typecountryV2 = [];
                                var packaging_typecountryB = [];
                                var packaging_typecountryC = [];
                                var packaging_typecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (packaging_typecountryLevel[e]) {
                                        packaging_typecountryData.push(packaging_typecountryLevel[e]);
                                    }
                                })

                                extractValues2(packaging_typecountryData,packaging_typecountryV,packaging_typecountryV2,packaging_typecountryB,packaging_typecountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(packaging_typecountryV, FDC6label);
                                var sortingResult2 = sortByFirstCountryWithLabels(packaging_typecountryV2, FDC6label);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(packaging_typecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,packaging_typecountryVX,sortingResult.sortedLabels,colorPalletX5,"StackBar");
                                stackcolumnChart3(packaging_typecountryVX,"packaging_type_chart_fd",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX5)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_8","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 9
                                var finaltime_consumptioncountryData = [];

                                var time_consumptioncountryData = [];

                                var time_consumptioncountryV = [];
                                var time_consumptioncountryV2 = [];
                                var time_consumptioncountryB = [];
                                var time_consumptioncountryC = [];
                                var time_consumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (time_consumptioncountryLevel[e]) {
                                        time_consumptioncountryData.push(time_consumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(time_consumptioncountryData,time_consumptioncountryV,time_consumptioncountryV2,time_consumptioncountryB,time_consumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(time_consumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(time_consumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(time_consumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                renderDonutTable(transposefrequencycounsumptioncountryData, CMC8label, countryLabel4,flaggXX,"fd_9",transposefrequencycounsumptioncountryDataBase[0]);
                                formTable3(CMC8label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_9","data_table",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // Slide 10

                                var finalplace_consumptioncountryData = [];
                                var place_consumptioncountryData = [];
                                var place_consumptioncountryV = [];
                                var place_consumptioncountryV2 = [];
                                var place_consumptioncountryB = [];
                                var place_consumptioncountryC = [];
                                var place_consumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (place_consumptioncountryLevel[e]) {
                                        place_consumptioncountryData.push(place_consumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(place_consumptioncountryData,place_consumptioncountryV,place_consumptioncountryV2,place_consumptioncountryB,place_consumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(place_consumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(place_consumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(place_consumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,place_consumptioncountryVX,CMC9label,colorPalletX5,"StackBar");
                                stackcolumnChart3(place_consumptioncountryVX,"place_consumption_chart_fd",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX5)
                                formTable3(CMC9label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_10","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 11

                                var finalconsumedalonecountryData = [];
                                var consumedalonecountryData = [];
                                var consumedalonecountryV = [];
                                var consumedalonecountryV2 = [];
                                var consumedalonecountryB = [];
                                var consumedalonecountryC = [];
                                var consumedalonecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (consumedalonecountryLevel[e]) {
                                        consumedalonecountryData.push(consumedalonecountryLevel[e]);
                                    }
                                })

                                extractValues2(consumedalonecountryData,consumedalonecountryV,consumedalonecountryV2,consumedalonecountryB,consumedalonecountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(consumedalonecountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(consumedalonecountryV2)
                                var sum1 = transposefrequencycounsumptioncountryData[3].map((val, i) => val + transposefrequencycounsumptioncountryData[4][i]);
                                transposefrequencycounsumptioncountryData.splice(3, 2);
                                transposefrequencycounsumptioncountryData.splice(3, 0, sum1);
                                var sum3 = transposefrequencycounsumptioncountryData2[3].map((val, i) => val + transposefrequencycounsumptioncountryData2[4][i]);
                                transposefrequencycounsumptioncountryData2.splice(3, 2);
                                transposefrequencycounsumptioncountryData2.splice(3, 0, sum3);
                                var sum2 = transposefrequencycounsumptioncountryData[4].map((val, i) => val + transposefrequencycounsumptioncountryData[5][i]);
                                transposefrequencycounsumptioncountryData.splice(4, 2);
                                transposefrequencycounsumptioncountryData.push(sum2);
                                var sum4 = transposefrequencycounsumptioncountryData2[4].map((val, i) => val + transposefrequencycounsumptioncountryData2[5][i]);
                                transposefrequencycounsumptioncountryData2.splice(4, 2);
                                transposefrequencycounsumptioncountryData2.push(sum4);
                                var transposefrequencycounsumptioncountryDataBase = transposeData(consumedalonecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                renderDonutTable(transposefrequencycounsumptioncountryData, CMC11label2, countryLabel4,flaggXX,"fd_11",transposefrequencycounsumptioncountryDataBase[0]);
                                formTable3(CMC11label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_11","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 12

                                //debugger;
                                var finalchangepersonalconsumptioncountryData = [];
                                var changepersonalconsumptioncountryData = [];
                                var changepersonalconsumptioncountryV = [];
                                var changepersonalconsumptioncountryV2 = [];
                                var changepersonalconsumptioncountryB = [];
                                var changepersonalconsumptioncountryC = [];
                                var changepersonalconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (changepersonalconsumptioncountryLevel[e]) {
                                        changepersonalconsumptioncountryData.push(changepersonalconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(changepersonalconsumptioncountryData,changepersonalconsumptioncountryV,changepersonalconsumptioncountryV2,changepersonalconsumptioncountryB,changepersonalconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(changepersonalconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(changepersonalconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(changepersonalconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(CMC20label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_14","pc_tbl_fd",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                var finalchangehouseholdconsumptioncountryData = [];
                                var changehouseholdconsumptioncountryData = [];
                                var changehouseholdconsumptioncountryV = [];
                                var changehouseholdconsumptioncountryV2 = [];
                                var changehouseholdconsumptioncountryB = [];
                                var changehouseholdconsumptioncountryC = [];
                                var changehouseholdconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (changehouseholdconsumptioncountryLevel[e]) {
                                        changehouseholdconsumptioncountryData.push(changehouseholdconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(changehouseholdconsumptioncountryData,changehouseholdconsumptioncountryV,changehouseholdconsumptioncountryV2,changehouseholdconsumptioncountryB,changehouseholdconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(changehouseholdconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(changehouseholdconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(changehouseholdconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(CMC20label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_14","hc_tbl_fd",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 13

                                var finalpurchasehousehold1countryData = [];
                                var purchasehousehold1countryData = [];
                                var purchasehousehold1countryV = [];
                                var purchasehousehold1countryV2 = [];
                                var purchasehousehold1countryB = [];
                                var purchasehousehold1countryC = [];
                                var purchasehousehold1countryVX = [];

                                var finalpurchasehousehold2countryData = [];
                                var purchasehousehold2countryData = [];
                                var purchasehousehold2countryV = [];
                                var purchasehousehold2countryV2 = [];
                                var purchasehousehold2countryB = [];
                                var purchasehousehold2countryC = [];
                                var purchasehousehold2countryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (purchasechannelcountryLevel[e]) {
                                        purchasehousehold1countryData.push(purchasechannelcountryLevel[e]);
                                    }
                                })

                                countryLabel4.forEach(function(e,i,a){
                                    if (purchasehouseholdcountryLevel2[e]) {
                                        purchasehousehold2countryData.push(purchasehouseholdcountryLevel2[e]);
                                    }
                                });

                                function colorizeTableByColumn(tableId) {
                                    const table = document.getElementById(tableId);
                                    if (!table) return;

                                    const rows = Array.from(table.querySelectorAll("tbody tr"));
                                    const numCols = rows[0].querySelectorAll("td").length;

                                    // Convert hex to RGB
                                    function hexToRgb(hex) {
                                        const bigint = parseInt(hex.replace('#', ''), 16);
                                        return {
                                        r: (bigint >> 16) & 255,
                                        g: (bigint >> 8) & 255,
                                        b: bigint & 255,
                                        };
                                    }

                                    // Interpolate between two RGB values
                                    function interpolateColor(color1, color2, factor) {
                                        return {
                                        r: Math.round(color1.r + (color2.r - color1.r) * factor),
                                        g: Math.round(color1.g + (color2.g - color1.g) * factor),
                                        b: Math.round(color1.b + (color2.b - color1.b) * factor),
                                        };
                                    }

                                    // Custom gradient: red → white → green
                                    function getColorByRank(percent) {
                                        const red = hexToRgb("#ff4d4d");
                                        const white = hexToRgb("#ffffff");
                                        const green = hexToRgb("#4caf50");

                                        let rgb;
                                        if (percent < 0.5) {
                                        rgb = interpolateColor(red, white, percent * 2); // 0 to 0.5 → red to white
                                        } else {
                                        rgb = interpolateColor(white, green, (percent - 0.5) * 2); // 0.5 to 1 → white to green
                                        }

                                        return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
                                    }

                                    // Loop through each column (excluding label column)
                                    for (let colIndex = 1; colIndex < numCols; colIndex++) {
                                        const values = [];

                                        // Collect values with index
                                        rows.forEach((row, rowIndex) => {
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        const val = parseFloat(cell.innerText.replace('%', ''));
                                        if (!isNaN(val)) values.push({ rowIndex, value: val });
                                        });

                                        const sorted = [...values].sort((a, b) => b.value - a.value);
                                        const total = sorted.length;

                                        sorted.forEach((item, i) => {
                                        const rankPercent = 1 - (i / (total - 1)); // highest = 1, lowest = 0
                                        const row = rows[item.rowIndex];
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        cell.style.backgroundColor = getColorByRank(rankPercent);
                                        cell.style.color = "#000";
                                        });
                                    }
                                }

                                extractValues2(purchasehousehold1countryData,purchasehousehold1countryV,purchasehousehold1countryV2,purchasehousehold1countryB,purchasehousehold1countryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(purchasehousehold1countryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(purchasehousehold1countryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(purchasehousehold1countryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);

                                formTable4(CMC19label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"purchase_behaviour_chart2_fd",transposefrequencycounsumptioncountryDataBase[0]);
                                colorizeTableByColumn("purchase_behaviour_chart2_fd");
                                htmlZ = ``;
                                htmlZ += `<tr class="allbase">`;
                                htmlZ += `<td></td>`;
                                transposefrequencycounsumptioncountryDataBase[0].forEach(function(e2,i2,a2){
                                    htmlZ += `<td>n-${e2}</td>`;
                                });
                                htmlZ += `</tr>`;
                                $("#purchase_behaviour_chart2_fd > tbody").append(htmlZ);
                                
                                extractValues2(purchasehousehold2countryData,purchasehousehold2countryV,purchasehousehold2countryV2,purchasehousehold2countryB,purchasehousehold2countryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(purchasehousehold2countryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(purchasehousehold2countryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(purchasehousehold2countryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,purchasehousehold2countryVX,["Yes"],colorPallet,"StackBar");
                                stackcolumnChart2(purchasehousehold2countryVX,"purchase_behaviour_chart_fd",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],"100")

                                // Slide 14

                                var finalreasonconsumptioncountryData = [];
                                var reasonconsumptioncountryData = [];
                                var reasonconsumptioncountryV = [];
                                var reasonconsumptioncountryV2 = [];
                                var reasonconsumptioncountryB = [];
                                var reasonconsumptioncountryC = [];
                                var reasonconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (reasonconsumptioncountryLevel[e]) {
                                        reasonconsumptioncountryData.push(reasonconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(reasonconsumptioncountryData,reasonconsumptioncountryV,reasonconsumptioncountryV2,reasonconsumptioncountryB,reasonconsumptioncountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(reasonconsumptioncountryV, CMC12label);
                                var sortingResult2 = sortByFirstCountryWithLabels(reasonconsumptioncountryV2, CMC12label);
                                
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(reasonconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_12","roc_tt_fd",transposefrequencycounsumptioncountryDataBase[0]);

                                customizedArray(transposefrequencycounsumptioncountryData,reasonconsumptioncountryVX,sortingResult.sortedLabels,colorPallet,"StackBar");
                                
                                function transformToModelWise(input) {
                                    const result = [];
                                    for (let i = 0; i < 7; i++) {
                                        const modelData = {
                                        name: `Model ${i + 1}`,
                                        data: input.map(item => item.data[i])
                                        };
                                        result.push(modelData);
                                    }
                                    return result;
                                }

                                const modelWise = transformToModelWise(reasonconsumptioncountryVX);
                                console.log("modelWise");
                                console.log(modelWise);
                                console.log("reasonconsumptioncountryVX");
                                console.log(reasonconsumptioncountryVX);
                                
                                function generateColors(dataArray) {
                                    const indexed = dataArray.map((value, index) => ({ value, index }));
                                    indexed.sort((a, b) => b.value - a.value);
                                    
                                    const topIndexes = new Set(indexed.slice(0, 4).map(item => item.index));

                                    return dataArray.map((_, index) => topIndexes.has(index) ? '#4D6893' : '#7C985E');
                                }
                                modelWise.forEach(model => {
                                    model.color = 'transparent';
                                    model.colors = generateColors(model.data);
                                });


                                barChart88([modelWise[0]],"reason_consumption_fd_1",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][0],"SouthEast Asia",flagg2[0]);
                                barChart89([modelWise[1]],"reason_consumption_fd_2",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][1],"Singapore",flagg2[0]);
                                barChart89([modelWise[2]],"reason_consumption_fd_3",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][2],"Thailand",flagg2[1]);
                                barChart89([modelWise[3]],"reason_consumption_fd_4",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][3],"Malaysia",flagg2[2]);
                                barChart89([modelWise[4]],"reason_consumption_fd_5",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][4],"Indonesia",flagg2[3]);
                                barChart89([modelWise[5]],"reason_consumption_fd_6",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][5],"Philippines",flagg2[4]);
                                barChart89([modelWise[6]],"reason_consumption_fd_7",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][6],"Vietnam",flagg2[5]);

                                // Slide 15

                                var finalhouseholdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryV = [];
                                var householdconsumptioncountryLevelcountryV2 = [];
                                var householdconsumptioncountryLevelcountryB = [];
                                var householdconsumptioncountryLevelcountryC = [];
                                var householdconsumptioncountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (householdconsumptioncountryLevel[e]) {
                                        householdconsumptioncountryLevelcountryData.push(householdconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(householdconsumptioncountryLevelcountryData,householdconsumptioncountryLevelcountryV,householdconsumptioncountryLevelcountryV2,householdconsumptioncountryLevelcountryB,householdconsumptioncountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(householdconsumptioncountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(householdconsumptioncountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(householdconsumptioncountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(CMC16label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_16","household_consumption_chart_fd",transposefrequencycounsumptioncountryDataBase[0]);


                                // agecountryLevel

                                var finalagecountryLevelcountryData = [];
                                var agecountryLevelcountryData = [];
                                var agecountryLevelcountryV = [];
                                var agecountryLevelcountryV2 = [];
                                var agecountryLevelcountryB = [];
                                var agecountryLevelcountryC = [];
                                var agecountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (agecountryLevel[e]) {
                                        agecountryLevelcountryData.push(agecountryLevel[e]);
                                    }
                                })

                                extractValues2(agecountryLevelcountryData,agecountryLevelcountryV,agecountryLevelcountryV2,agecountryLevelcountryB,agecountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(agecountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(agecountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(agecountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(ageLabelXXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_18","age_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // educationcountryLevel

                                var finaleducationcountryLevelcountryData = [];
                                var educationcountryLevelcountryData = [];
                                var educationcountryLevelcountryV = [];
                                var educationcountryLevelcountryV2 = [];
                                var educationcountryLevelcountryB = [];
                                var educationcountryLevelcountryC = [];
                                var educationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (educationcountryLevel[e]) {
                                        educationcountryLevelcountryData.push(educationcountryLevel[e]);
                                    }
                                })

                                extractValues2(educationcountryLevelcountryData,educationcountryLevelcountryV,educationcountryLevelcountryV2,educationcountryLevelcountryB,educationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(educationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(educationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(educationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(educationXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_18","education_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // dietarycountryLevel

                                var finaldietarycountryLevelcountryData = [];
                                var dietarycountryLevelcountryData = [];
                                var dietarycountryLevelcountryV = [];
                                var dietarycountryLevelcountryV2 = [];
                                var dietarycountryLevelcountryB = [];
                                var dietarycountryLevelcountryC = [];
                                var dietarycountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (dietarycountryLevel[e]) {
                                        dietarycountryLevelcountryData.push(dietarycountryLevel[e]);
                                    }
                                })

                                extractValues2(dietarycountryLevelcountryData,dietarycountryLevelcountryV,dietarycountryLevelcountryV2,dietarycountryLevelcountryB,dietarycountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(dietarycountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(dietarycountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(dietarycountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(halalLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_18","dietary_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // occupationcountryLevel

                                var finaloccupationcountryLevelcountryData = [];
                                var occupationcountryLevelcountryData = [];
                                var occupationcountryLevelcountryV = [];
                                var occupationcountryLevelcountryV2 = [];
                                var occupationcountryLevelcountryB = [];
                                var occupationcountryLevelcountryC = [];
                                var occupationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (occupationcountryLevel[e]) {
                                        occupationcountryLevelcountryData.push(occupationcountryLevel[e]);
                                    }
                                })

                                extractValues2(occupationcountryLevelcountryData,occupationcountryLevelcountryV,occupationcountryLevelcountryV2,occupationcountryLevelcountryB,occupationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(occupationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(occupationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(occupationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(occupationLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_19","occupation_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // incomecountryLevel

                                var finalincomecountryLevelcountryData = [];
                                var incomecountryLevelcountryData = [];
                                var incomecountryLevelcountryV = [];
                                var incomecountryLevelcountryV2 = [];
                                var incomecountryLevelcountryB = [];
                                var incomecountryLevelcountryC = [];
                                var incomecountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (incomecountryLevel[e]) {
                                        incomecountryLevelcountryData.push(incomecountryLevel[e]);
                                    }
                                })

                                extractValues2(incomecountryLevelcountryData,incomecountryLevelcountryV,incomecountryLevelcountryV2,incomecountryLevelcountryB,incomecountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(incomecountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(incomecountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(incomecountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(incomeLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_19","householdincome_tbl",transposefrequencycounsumptioncountryDataBase[0]);

                                // relationshipcountryLevel

                                var finalrelationcountryLevelcountryData = [];
                                var relationcountryLevelcountryData = [];
                                var relationcountryLevelcountryV = [];
                                var relationcountryLevelcountryV2 = [];
                                var relationcountryLevelcountryB = [];
                                var relationcountryLevelcountryC = [];
                                var relationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (relationcountryLevel[e]) {
                                        relationcountryLevelcountryData.push(relationcountryLevel[e]);
                                    }
                                })

                                extractValues2(relationcountryLevelcountryData,relationcountryLevelcountryV,relationcountryLevelcountryV2,relationcountryLevelcountryB,relationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(relationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(relationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(relationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(relationXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_20","relationship_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // People living in household

                                var finalhouseholdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryV = [];
                                var householdconsumptioncountryLevelcountryV2 = [];
                                var householdconsumptioncountryLevelcountryB = [];
                                var householdconsumptioncountryLevelcountryC = [];
                                var householdconsumptioncountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (householdconsumptioncountryLevel[e]) {
                                        householdconsumptioncountryLevelcountryData.push(householdconsumptioncountryLevel[e]);
                                    }
                                })
                                ////debugger;
                                extractValues2(householdconsumptioncountryLevelcountryData,householdconsumptioncountryLevelcountryV,householdconsumptioncountryLevelcountryV2,householdconsumptioncountryLevelcountryB,householdconsumptioncountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(householdconsumptioncountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(householdconsumptioncountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(householdconsumptioncountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(CMC16label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"fd_20","livinghousehold_tbl",transposefrequencycounsumptioncountryDataBase[0]);

                        },
                        complete: function (data) {
                            ajaxFlag[1+53] = true;
                            $(".splash").hide();
                        }
                    })
                }

                function fiftythAjax() {
                    $.ajax({
                        url: "api/ajax50.php",
                        type: "POST",
                        data: {
                            'condX': condX2,
                            'conX': conX,
                            'tblX': tblX,
                        },
                        success: function(response) {
                            var data = JSON.parse(response);
                            trends1Data = data;
                            console.log("ajax50.php");
                            console.log(data);
                            
                            var consumptioncountryLevel = data['ConsumptionCountry'];
                            var consumptionquarterLevel = data['ConsumptionQuarter'];

                            var frequencyconsumptioncountryLevel = data['S13_2Country'];
                            var frequencyconsumptionquarterLevel = data['S13_2Quarter'];

                            var subcategorycountryLevel = data['Y_C2Country'];
                            var subcategoryquarterLevel = data['Y_C2Quarter'];

                            var accompaniedcountryLevel = data['Y_C10Country'];
                            var accompaniedquarterLevel = data['Y_C10Quarter'];

                            var packaging_sizecountryLevel = data['Y_C7Country'];
                            var packaging_sizequarterLevel = data['Y_C7Quarter'];

                            var packaging_typecountryLevel = data['Y_C6Country'];
                            var packaging_typequarterLevel = data['Y_C6Quarter'];

                            var time_consumptioncountryLevel = data['Y_C8Country'];
                            var time_consumptionquarterLevel = data['Y_C8Quarter'];

                            var place_consumptioncountryLevel = data['Y_C9Country'];
                            var place_consumptionquarterLevel = data['Y_C9Quarter'];

                            var consumedalonecountryLevel = data['Y_C11Country'];
                            var consumedalonequarterLevel = data['Y_C11Quarter'];

                            var reasonconsumptioncountryLevel = data['Y_C12Country'];
                            var reasonconsumptionquarterLevel = data['Y_C12Quarter'];

                            var changepersonalconsumptioncountryLevel = data['Y_C15Country'];
                            var changepersonalconsumptionquarterLevel = data['Y_C15Quarter'];

                            var purchasehouseholdcountryLevel = data['Y_C17Country'];
                            var purchasehouseholdquarterLevel = data['Y_C17Quarter'];

                            var purchasehouseholdcountryLevel2 = data['Y_C17_1Country'];
                            var purchasehouseholdquarterLevel2 = data['Y_C17_1Quarter'];

                            var whopurchasecountryLevel = data['Y_C18Country'];
                            var whopurchasequarterLevel = data['Y_C18Quarter'];

                            var purchasechannelcountryLevel = data['Y_C19Country'];
                            var purchasechannelquarterLevel = data['Y_C19Quarter'];

                            var changehouseholdconsumptioncountryLevel = data['Y_C20Country'];
                            var changehouseholdconsumptionquarterLevel = data['Y_C20Quarter'];

                            var householdconsumptioncountryLevel = data['Y_C16Country'];
                            var householdconsumptionquarterLevel = data['Y_C16Quarter'];

                            var agecountryLevel = data['HAGE'];
                            var educationcountryLevel = data['P4'];
                            var dietarycountryLevel = data['S10'];
                            var occupationcountryLevel = data['P5'];
                            var incomecountryLevel = data['S7'];
                            var relationcountryLevel = data['P1'];
                            

                            // Quarter

                                // Slide 1

                                var finalconsumptionTrendData = [];

                                var consumptioneverDataQuarter = [];
                                var consumptionconsumed1YDataQuarter = [];
                                var consumptionconsumed3MDataQuarter = [];
                                var consumptionconsumed7DDataQuarter = [];

                                var finalconsumptionTrendData2 = [];

                                var consumptioneverDataQuarter2 = [];
                                var consumptionconsumed1YDataQuarter2 = [];
                                var consumptionconsumed3MDataQuarter2 = [];
                                var consumptionconsumed7DDataQuarter2 = [];

                                const consumptionquarterData = {};

                                quarterLabel.forEach(quarter => {
                                    if (consumptionquarterLevel[quarter]) {
                                        consumptionquarterData[quarter] = consumptionquarterLevel[quarter];
                                    }
                                });

                                for (let consumptionquarter in consumptionquarterData) {
                                    consumptioneverDataQuarter.push(consumptionquarterData[consumptionquarter].ever[0].percentage);
                                    consumptionconsumed1YDataQuarter.push(consumptionquarterData[consumptionquarter].consumed1Y[0].percentage);
                                    consumptionconsumed3MDataQuarter.push(consumptionquarterData[consumptionquarter].consumed3M[0].percentage);
                                    consumptionconsumed7DDataQuarter.push(consumptionquarterData[consumptionquarter].consumed7D[0].percentage);

                                    consumptioneverDataQuarter2.push(consumptionquarterData[consumptionquarter].ever[0].percentage2);
                                    consumptionconsumed1YDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed1Y[0].percentage2);
                                    consumptionconsumed3MDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed3M[0].percentage2);
                                    consumptionconsumed7DDataQuarter2.push(consumptionquarterData[consumptionquarter].consumed7D[0].percentage2);
                                }

                                var consumptionquarterbCounts = {};
                                var consumptionquarters = Object.keys(consumptionquarterData);

                                consumptionquarters.forEach((quarter, index) => {
                                    consumptionquarterbCounts[index] = consumptionquarterLevel[quarter].ever[0].bCount;
                                });

                                const consumptionquarterflatArray = Object.values(consumptionquarterbCounts);
                                
                                finalconsumptionTrendData.push(consumptioneverDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed1YDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed3MDataQuarter);
                                finalconsumptionTrendData.push(consumptionconsumed7DDataQuarter);

                                finalconsumptionTrendData2.push(consumptioneverDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed1YDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed3MDataQuarter2);
                                finalconsumptionTrendData2.push(consumptionconsumed7DDataQuarter2);

                                formTable8(quarterLabel,tab1label,finalconsumptionTrendData,finalconsumptionTrendData2,"y_1","consumtion_funnel",consumptionquarterflatArray);

                                var aHTML = ``;
                                consumptionquarterflatArray.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e}</span>`;
                                });
                                $("#y_1").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 2

                                var finalfrequencyconsumptionTrendData = [];

                                var frequencyconsumptionquarterData = [];

                                var frequencyconsumptionquarterV = [];
                                var frequencyconsumptionquarterV2 = [];
                                var frequencyconsumptionquarterB = [];
                                var frequencyconsumptionquarterC = [];
                                var frequencyconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (frequencyconsumptionquarterLevel[e]) {
                                        frequencyconsumptionquarterData.push(frequencyconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(frequencyconsumptionquarterData,frequencyconsumptionquarterV,frequencyconsumptionquarterV2,frequencyconsumptionquarterB,frequencyconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(frequencyconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(frequencyconsumptionquarterV2)
                                var quarterBase = frequencyconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,S13label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_2","frequency_consumtion",quarterBase);

                                var aHTML = ``;
                                frequencyconsumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#y_2").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 3

                                var finalsubcategoryTrendData = [];

                                var subcategoryquarterData = [];

                                var subcategoryquarterV = [];
                                var subcategoryquarterV2 = [];
                                var subcategoryquarterB = [];
                                var subcategoryquarterC = [];
                                var subcategoryquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (subcategoryquarterLevel[e]) {
                                        subcategoryquarterData.push(subcategoryquarterLevel[e]);
                                    }
                                })

                                extractValues2(subcategoryquarterData,subcategoryquarterV,subcategoryquarterV2,subcategoryquarterB,subcategoryquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(subcategoryquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(subcategoryquarterV2)
                                var quarterBase = subcategoryquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,FDC2label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_3","subcategory",quarterBase);

                                var aHTML = ``;
                                subcategoryquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#y_3").find(".funnel-col").find(".foot").empty().append(aHTML);

                                
                                // Slide 5

                                var finalaccompaniedTrendData = [];

                                var accompaniedquarterData = [];

                                var accompaniedquarterV = [];
                                var accompaniedquarterV2 = [];
                                var accompaniedquarterB = [];
                                var accompaniedquarterC = [];
                                var accompaniedquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (accompaniedquarterLevel[e]) {
                                        accompaniedquarterData.push(accompaniedquarterLevel[e]);
                                    }
                                })

                                extractValues2(accompaniedquarterData,accompaniedquarterV,accompaniedquarterV2,accompaniedquarterB,accompaniedquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(accompaniedquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(accompaniedquarterV2)
                                var quarterBase = accompaniedquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC10label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_5","accompanied",quarterBase);

                                var aHTML = ``;
                                accompaniedquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#y_5").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 7

                                var finalpackaging_sizeTrendData = [];

                                var packaging_sizequarterData = [];

                                var packaging_sizequarterV = [];
                                var packaging_sizequarterV2 = [];
                                var packaging_sizequarterB = [];
                                var packaging_sizequarterC = [];
                                var packaging_sizequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (packaging_sizequarterLevel[e]) {
                                        packaging_sizequarterData.push(packaging_sizequarterLevel[e]);
                                    }
                                })

                                extractValues2(packaging_sizequarterData,packaging_sizequarterV,packaging_sizequarterV2,packaging_sizequarterB,packaging_sizequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(packaging_sizequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(packaging_sizequarterV2)
                                var quarterBase = packaging_sizequarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC7label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_7","packaging_size",quarterBase);
                                var aHTML = ``;
                                packaging_sizequarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#y_7").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 8

                                var finalpackaging_typeTrendData = [];

                                var packaging_typequarterData = [];

                                var packaging_typequarterV = [];
                                var packaging_typequarterV2 = [];
                                var packaging_typequarterB = [];
                                var packaging_typequarterC = [];
                                var packaging_typequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (packaging_typequarterLevel[e]) {
                                        packaging_typequarterData.push(packaging_typequarterLevel[e]);
                                    }
                                })

                                extractValues2(packaging_typequarterData,packaging_typequarterV,packaging_typequarterV2,packaging_typequarterB,packaging_typequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(packaging_typequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(packaging_typequarterV2)
                                var quarterBase = packaging_typequarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,FDC6label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_8","packaging_type",quarterBase);

                                var aHTML = ``;
                                packaging_typequarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#y_8").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 9

                                var finaltime_consumptionTrendData = [];

                                var time_consumptionquarterData = [];

                                var time_consumptionquarterV = [];
                                var time_consumptionquarterV2 = [];
                                var time_consumptionquarterB = [];
                                var time_consumptionquarterC = [];
                                var time_consumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (time_consumptionquarterLevel[e]) {
                                        time_consumptionquarterData.push(time_consumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(time_consumptionquarterData,time_consumptionquarterV,time_consumptionquarterV2,time_consumptionquarterB,time_consumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(time_consumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(time_consumptionquarterV2)
                                var quarterBase = time_consumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC8label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_9","time_consumption",quarterBase);

                                var aHTML = ``;
                                time_consumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#y_9").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 10

                                var finalplace_consumptionTrendData = [];

                                var place_consumptionquarterData = [];

                                var place_consumptionquarterV = [];
                                var place_consumptionquarterV2 = [];
                                var place_consumptionquarterB = [];
                                var place_consumptionquarterC = [];
                                var place_consumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (place_consumptionquarterLevel[e]) {
                                        place_consumptionquarterData.push(place_consumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(place_consumptionquarterData,place_consumptionquarterV,place_consumptionquarterV2,place_consumptionquarterB,place_consumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(place_consumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(place_consumptionquarterV2)
                                var quarterBase = place_consumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC9label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_10","place_consumption",quarterBase);
                                

                                var aHTML = ``;
                                place_consumptionquarterB.forEach(function(e,i,a){
                                    aHTML += `<span>n-${e[0]}</span>`;
                                });
                                $("#y_10").find(".funnel-col").find(".foot").empty().append(aHTML);

                                // Slide 11

                                var finalconsumedalonequarterData = [];
                                var consumedalonequarterData = [];
                                var consumedalonequarterV = [];
                                var consumedalonequarterV2 = [];
                                var consumedalonequarterB = [];
                                var consumedalonequarterC = [];
                                var consumedalonequarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (consumedalonequarterLevel[e]) {
                                        consumedalonequarterData.push(consumedalonequarterLevel[e]);
                                    }
                                })

                                extractValues2(consumedalonequarterData,consumedalonequarterV,consumedalonequarterV2,consumedalonequarterB,consumedalonequarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(consumedalonequarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(consumedalonequarterV2)
                                var sum1 = transposefrequencycounsumptionquarterData[3].map((val, i) => val + transposefrequencycounsumptionquarterData[4][i]);
                                transposefrequencycounsumptionquarterData.splice(3, 2);
                                transposefrequencycounsumptionquarterData.splice(3, 0, sum1);
                                var sum3 = transposefrequencycounsumptionquarterData2[3].map((val, i) => val + transposefrequencycounsumptionquarterData2[4][i]);
                                transposefrequencycounsumptionquarterData2.splice(3, 2);
                                transposefrequencycounsumptionquarterData2.splice(3, 0, sum3);
                                var sum2 = transposefrequencycounsumptionquarterData[4].map((val, i) => val + transposefrequencycounsumptionquarterData[5][i]);
                                transposefrequencycounsumptionquarterData.splice(4, 2);
                                transposefrequencycounsumptionquarterData.push(sum2);
                                var sum4 = transposefrequencycounsumptionquarterData2[4].map((val, i) => val + transposefrequencycounsumptionquarterData2[5][i]);
                                transposefrequencycounsumptionquarterData2.splice(4, 2);
                                transposefrequencycounsumptionquarterData2.push(sum4);
                                var transposefrequencycounsumptionquarterDataBase = transposeData(consumedalonequarterB);
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                console.log("transposefrequencycounsumptionquarterDataBase[0]");
                                console.log(transposefrequencycounsumptionquarterDataBase[0])
                                formTable8(quarterLabel,CMC11label2,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_11","data_table",transposefrequencycounsumptionquarterDataBase[0]);

                                // Slide 12

                                var finalchangepersonalconsumptionquarterData = [];
                                var changepersonalconsumptionquarterData = [];
                                var changepersonalconsumptionquarterV = [];
                                var changepersonalconsumptionquarterV2 = [];
                                var changepersonalconsumptionquarterB = [];
                                var changepersonalconsumptionquarterC = [];
                                var changepersonalconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (changepersonalconsumptionquarterLevel[e]) {
                                        changepersonalconsumptionquarterData.push(changepersonalconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(changepersonalconsumptionquarterData,changepersonalconsumptionquarterV,changepersonalconsumptionquarterV2,changepersonalconsumptionquarterB,changepersonalconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(changepersonalconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(changepersonalconsumptionquarterV2)
                                var quarterBase = changepersonalconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC20label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_14","pc_tbl2_y",quarterBase);

                                // 

                                var finalchangehouseholdconsumptionquarterData = [];
                                var changehouseholdconsumptionquarterData = [];
                                var changehouseholdconsumptionquarterV = [];
                                var changehouseholdconsumptionquarterV2 = [];
                                var changehouseholdconsumptionquarterB = [];
                                var changehouseholdconsumptionquarterC = [];
                                var changehouseholdconsumptionquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (changehouseholdconsumptionquarterLevel[e]) {
                                        changehouseholdconsumptionquarterData.push(changehouseholdconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(changehouseholdconsumptionquarterData,changehouseholdconsumptionquarterV,changehouseholdconsumptionquarterV2,changehouseholdconsumptionquarterB,changehouseholdconsumptionquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(changehouseholdconsumptionquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(changehouseholdconsumptionquarterV2)
                                var quarterBase = changehouseholdconsumptionquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC20label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_14","hc_tbl2_y",quarterBase);

                                // Slide 13

                                var finalpurchasehousehold1quarterData = [];
                                var purchasehousehold1quarterData = [];
                                var purchasehousehold1quarterV = [];
                                var purchasehousehold1quarterV2 = [];
                                var purchasehousehold1quarterB = [];
                                var purchasehousehold1quarterC = [];
                                var purchasehousehold1quarterVX = [];

                                var finalpurchasehousehold2quarterData = [];
                                var purchasehousehold2quarterData = [];
                                var purchasehousehold2quarterV = [];
                                var purchasehousehold2quarterV2 = [];
                                var purchasehousehold2quarterB = [];
                                var purchasehousehold2quarterC = [];
                                var purchasehousehold2quarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (purchasechannelquarterLevel[e]) {
                                        purchasehousehold1quarterData.push(purchasechannelquarterLevel[e]);
                                    }
                                })

                                quarterLabel.forEach(function(e,i,a){
                                    if (purchasehouseholdquarterLevel2[e]) {
                                        purchasehousehold2quarterData.push(purchasehouseholdquarterLevel2[e]);
                                    }
                                });

                                function colorizeTableByColumn(tableId) {
                                    const table = document.getElementById(tableId);
                                    if (!table) return;

                                    const rows = Array.from(table.querySelectorAll("tbody tr"));
                                    const numCols = rows[0].querySelectorAll("td").length;

                                    // Convert hex to RGB
                                    function hexToRgb(hex) {
                                        const bigint = parseInt(hex.replace('#', ''), 16);
                                        return {
                                        r: (bigint >> 16) & 255,
                                        g: (bigint >> 8) & 255,
                                        b: bigint & 255,
                                        };
                                    }

                                    // Interpolate between two RGB values
                                    function interpolateColor(color1, color2, factor) {
                                        return {
                                        r: Math.round(color1.r + (color2.r - color1.r) * factor),
                                        g: Math.round(color1.g + (color2.g - color1.g) * factor),
                                        b: Math.round(color1.b + (color2.b - color1.b) * factor),
                                        };
                                    }

                                    // Custom gradient: red → white → green
                                    function getColorByRank(percent) {
                                        const red = hexToRgb("#ff4d4d");
                                        const white = hexToRgb("#ffffff");
                                        const green = hexToRgb("#4caf50");

                                        let rgb;
                                        if (percent < 0.5) {
                                        rgb = interpolateColor(red, white, percent * 2); // 0 to 0.5 → red to white
                                        } else {
                                        rgb = interpolateColor(white, green, (percent - 0.5) * 2); // 0.5 to 1 → white to green
                                        }

                                        return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
                                    }

                                    // Loop through each column (excluding label column)
                                    for (let colIndex = 1; colIndex < numCols; colIndex++) {
                                        const values = [];

                                        // Collect values with index
                                        rows.forEach((row, rowIndex) => {
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        const val = parseFloat(cell.innerText.replace('%', ''));
                                        if (!isNaN(val)) values.push({ rowIndex, value: val });
                                        });

                                        const sorted = [...values].sort((a, b) => b.value - a.value);
                                        const total = sorted.length;

                                        sorted.forEach((item, i) => {
                                        const rankPercent = 1 - (i / (total - 1)); // highest = 1, lowest = 0
                                        const row = rows[item.rowIndex];
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        cell.style.backgroundColor = getColorByRank(rankPercent);
                                        cell.style.color = "#000";
                                        });
                                    }
                                }

                                function colorizeTableByColumn2(tableId) {
                                    ////debugger;
                                    const table = document.getElementById(tableId);
                                    if (!table) return;

                                    const rows = Array.from(table.querySelectorAll("tbody tr"));
                                    const numCols = rows[0].querySelectorAll("td").length;

                                    // Convert hex to RGB
                                    function hexToRgb2(hex) {
                                        const bigint = parseInt(hex.replace('#', ''), 16);
                                        return {
                                        r: (bigint >> 16) & 255,
                                        g: (bigint >> 8) & 255,
                                        b: bigint & 255,
                                        };
                                    }

                                    // Interpolate between two RGB values
                                    function interpolateColor2(color1, color2, factor) {
                                        return {
                                        r: Math.round(color1.r + (color2.r - color1.r) * factor),
                                        g: Math.round(color1.g + (color2.g - color1.g) * factor),
                                        b: Math.round(color1.b + (color2.b - color1.b) * factor),
                                        };
                                    }

                                    // Custom gradient: red → white → green
                                    function getColorByRank2(percent) {
                                        const red = hexToRgb2("#ff4d4d");
                                        const white = hexToRgb2("#ffffff");
                                        const green = hexToRgb2("#4caf50");

                                        let rgb;
                                        if (percent < 0.5) {
                                        rgb = interpolateColor2(red, white, percent * 2); // 0 to 0.5 → red to white
                                        } else {
                                        rgb = interpolateColor2(white, green, (percent - 0.5) * 2); // 0.5 to 1 → white to green
                                        }

                                        return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
                                    }

                                    // Loop through each column (excluding label column)
                                    for (let colIndex = 0; colIndex < numCols; colIndex++) {
                                        const values = [];

                                        // Collect values with index
                                        rows.forEach((row, rowIndex) => {
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        const val = parseFloat(cell.innerText.replace('%', ''));
                                        if (!isNaN(val)) values.push({ rowIndex, value: val });
                                        });

                                        const sorted = [...values].sort((a, b) => b.value - a.value);
                                        const total = sorted.length;

                                        sorted.forEach((item, i) => {
                                        const rankPercent = 1 - (i / (total - 1)); // highest = 1, lowest = 0
                                        const row = rows[item.rowIndex];
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        cell.style.backgroundColor = getColorByRank2(rankPercent);
                                        cell.style.color = "#000";
                                        });
                                    }
                                }

                                extractValues2(purchasehousehold1quarterData,purchasehousehold1quarterV,purchasehousehold1quarterV2,purchasehousehold1quarterB,purchasehousehold1quarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(purchasehousehold1quarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(purchasehousehold1quarterV2)
                                var transposefrequencycounsumptionquarterDataBase = transposeData(purchasehousehold1quarterB)
                                
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                formTable2(quarterLabel,CMC19label2,transposefrequencycounsumptionquarterData,"y_15","purchase_behaviour_chart2_y2",transposefrequencycounsumptionquarterDataBase[0]);
                                colorizeTableByColumn2("purchase_behaviour_chart2_y2");
                                
                                extractValues2(purchasehousehold2quarterData,purchasehousehold2quarterV,purchasehousehold2quarterV2,purchasehousehold2quarterB,purchasehousehold2quarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(purchasehousehold2quarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(purchasehousehold2quarterV2)
                                var transposefrequencycounsumptionquarterDataBase = transposeData(purchasehousehold2quarterB)
                                transposefrequencycounsumptionquarterDataBase[0] = transposefrequencycounsumptionquarterDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptionquarterData,purchasehousehold2quarterVX,["Yes"],colorPallet,"StackBar");
                                stackcolumnChart2(purchasehousehold2quarterVX,"purchase_behaviour_chart_y2",quarterLabel,transposefrequencycounsumptionquarterDataBase[0],"100")

                                // Slide 15

                                var finalhouseholdconsumptionquarterLevelquarterData = [];
                                var householdconsumptionquarterLevelquarterData = [];
                                var householdconsumptionquarterLevelquarterV = [];
                                var householdconsumptionquarterLevelquarterV2 = [];
                                var householdconsumptionquarterLevelquarterB = [];
                                var householdconsumptionquarterLevelquarterC = [];
                                var householdconsumptionquarterLevelquarterVX = [];

                                quarterLabel.forEach(function(e,i,a){
                                    if (householdconsumptionquarterLevel[e]) {
                                        householdconsumptionquarterLevelquarterData.push(householdconsumptionquarterLevel[e]);
                                    }
                                })

                                extractValues2(householdconsumptionquarterLevelquarterData,householdconsumptionquarterLevelquarterV,householdconsumptionquarterLevelquarterV2,householdconsumptionquarterLevelquarterB,householdconsumptionquarterLevelquarterC,"Simple2");
                                var transposefrequencycounsumptionquarterData = transposeData(householdconsumptionquarterLevelquarterV)
                                var transposefrequencycounsumptionquarterData2 = transposeData(householdconsumptionquarterLevelquarterV2)
                                var quarterBase = householdconsumptionquarterLevelquarterB.map(row => parseInt(row[0]));
                                formTable8(quarterLabel,CMC16label,transposefrequencycounsumptionquarterData,transposefrequencycounsumptionquarterData2,"y_16","household_consumption_chart_cm",quarterBase);

                            // Country

                                // Slide 1

                                var consumptionDataCountryTable = [];

                                var consumptioneverDataCountry = [];
                                var consumptionconsumed1YDataCountry = [];
                                var consumptionconsumed3MDataCountry = [];
                                var consumptionconsumed7DDataCountry = [];

                                var consumptionDataCountryTable2 = [];

                                var consumptioneverDataCountry2 = [];
                                var consumptionconsumed1YDataCountry2 = [];
                                var consumptionconsumed3MDataCountry2 = [];
                                var consumptionconsumed7DDataCountry2 = [];

                                var consumptioncountryData = {};



                                countryLabel4.forEach(country => {
                                    if (consumptioncountryLevel[country]) {
                                        consumptioncountryData[country] = consumptioncountryLevel[country];
                                    }
                                });

                                for (let consumptioncountry in consumptioncountryData) {
                                    consumptioneverDataCountry.push(consumptioncountryData[consumptioncountry].ever[0].percentage);
                                    consumptionconsumed1YDataCountry.push(consumptioncountryData[consumptioncountry].consumed1Y[0].percentage);
                                    consumptionconsumed3MDataCountry.push(consumptioncountryData[consumptioncountry].consumed3M[0].percentage);
                                    consumptionconsumed7DDataCountry.push(consumptioncountryData[consumptioncountry].consumed7D[0].percentage);

                                    consumptioneverDataCountry2.push(consumptioncountryData[consumptioncountry].ever[0].percentage2);
                                    consumptionconsumed1YDataCountry2.push(consumptioncountryData[consumptioncountry].consumed1Y[0].percentage2);
                                    consumptionconsumed3MDataCountry2.push(consumptioncountryData[consumptioncountry].consumed3M[0].percentage2);
                                    consumptionconsumed7DDataCountry2.push(consumptioncountryData[consumptioncountry].consumed7D[0].percentage2);
                                }2

                                var consumptioncountrybCounts = {};
                                var consumptioncountries = Object.keys(consumptioncountryData);

                                consumptioncountries.forEach((country, index) => {
                                    consumptioncountrybCounts[index] = consumptioncountryLevel[country].ever[0].bCount;
                                });

                                const consumptioncountryflatArray = Object.values(consumptioncountrybCounts);

                                $("#y_1").find(".country-col").find(".base-note").each(function(i,e){
                                    $(this).empty().append(`n-${consumptioncountryflatArray[i]}`);
                                });
                                $("#y_1").find(".country-col").find(".full").each(function(i,e){
                                    $(this).empty().append(consumptioneverDataCountry[i]+"%");
                                })
                                $("#y_1").find(".country-col").find(".mid").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed1YDataCountry[i]+"%");
                                })
                                $("#y_1").find(".country-col").find(".lighter").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed3MDataCountry[i]+"%");
                                })
                                $("#y_1").find(".country-col").find(".lightest").each(function(i,e){
                                    $(this).empty().append(consumptionconsumed7DDataCountry[i]+"%");
                                })

                                consumptionDataCountryTable.push(consumptioneverDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed1YDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed3MDataCountry);
                                consumptionDataCountryTable.push(consumptionconsumed7DDataCountry);

                                consumptionDataCountryTable2.push(consumptioneverDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed1YDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed3MDataCountry2);
                                consumptionDataCountryTable2.push(consumptionconsumed7DDataCountry2);

                                formTable3(tab1label,consumptionDataCountryTable,consumptionDataCountryTable2,"y_1","data_table",consumptioncountryflatArray);

                                // Slide 2

                                var finalfrequencyconsumptioncountryData = [];

                                var frequencyconsumptioncountryData = [];

                                var frequencyconsumptioncountryV = [];
                                var frequencyconsumptioncountryV2 = [];
                                var frequencyconsumptioncountryB = [];
                                var frequencyconsumptioncountryC = [];
                                var frequencyconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (frequencyconsumptioncountryLevel[e]) {
                                        frequencyconsumptioncountryData.push(frequencyconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(frequencyconsumptioncountryData,frequencyconsumptioncountryV,frequencyconsumptioncountryV2,frequencyconsumptioncountryB,frequencyconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(frequencyconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(frequencyconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(frequencyconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,frequencyconsumptioncountryVX,S13label2,colorPalletX4,"StackBar");
                                stackcolumnChart3(frequencyconsumptioncountryVX,"frequency_counsumption_chart_y",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX4)
                                formTable3(S13label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_2","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 3

                                var finalsubcategorycountryData = [];

                                var subcategorycountryData = [];

                                var subcategorycountryV = [];
                                var subcategorycountryV2 = [];
                                var subcategorycountryB = [];
                                var subcategorycountryC = [];
                                var subcategorycountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (subcategorycountryLevel[e]) {
                                        subcategorycountryData.push(subcategorycountryLevel[e]);
                                    }
                                })

                                extractValues2(subcategorycountryData,subcategorycountryV,subcategorycountryV2,subcategorycountryB,subcategorycountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(subcategorycountryV, FDC2label);
                                var sortingResult2 = sortByFirstCountryWithLabels(subcategorycountryV2, FDC2label);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(subcategorycountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,subcategorycountryVX,sortingResult.sortedLabels,colorPalletX5,"StackBar");
                                stackcolumnChart3(subcategorycountryVX,"subcategory_chart_y",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX5)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_3","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                
                                // Slide 5

                                var finalaccompaniedcountryData = [];

                                var accompaniedcountryData = [];

                                var accompaniedcountryV = [];
                                var accompaniedcountryV2 = [];
                                var accompaniedcountryB = [];
                                var accompaniedcountryC = [];
                                var accompaniedcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (accompaniedcountryLevel[e]) {
                                        accompaniedcountryData.push(accompaniedcountryLevel[e]);
                                    }
                                })

                                extractValues2(accompaniedcountryData,accompaniedcountryV,accompaniedcountryV2,accompaniedcountryB,accompaniedcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(accompaniedcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(accompaniedcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(accompaniedcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,accompaniedcountryVX,CMC10label,colorPalletX4,"StackBar");
                                stackcolumnChart3(accompaniedcountryVX,"accompanied_chart_y",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX4)
                                formTable3(CMC10label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_5","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 7

                                var finalpackaging_sizecountryData = [];

                                var packaging_sizecountryData = [];

                                var packaging_sizecountryV = [];
                                var packaging_sizecountryV2 = [];
                                var packaging_sizecountryB = [];
                                var packaging_sizecountryC = [];
                                var packaging_sizecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (packaging_sizecountryLevel[e]) {
                                        packaging_sizecountryData.push(packaging_sizecountryLevel[e]);
                                    }
                                })

                                extractValues2(packaging_sizecountryData,packaging_sizecountryV,packaging_sizecountryV2,packaging_sizecountryB,packaging_sizecountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(packaging_sizecountryV, CMC7label2);
                                var sortingResult2 = sortByFirstCountryWithLabels(packaging_sizecountryV2, CMC7label2);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(packaging_sizecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,packaging_sizecountryVX,sortingResult.sortedLabels,colorPalletX1,"StackBar");
                                stackcolumnChart3(packaging_sizecountryVX,"packaging_size_chart_y",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX1)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_7","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 8

                                var finalpackaging_typecountryData = [];

                                var packaging_typecountryData = [];

                                var packaging_typecountryV = [];
                                var packaging_typecountryV2 = [];
                                var packaging_typecountryB = [];
                                var packaging_typecountryC = [];
                                var packaging_typecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (packaging_typecountryLevel[e]) {
                                        packaging_typecountryData.push(packaging_typecountryLevel[e]);
                                    }
                                })

                                extractValues2(packaging_typecountryData,packaging_typecountryV,packaging_typecountryV2,packaging_typecountryB,packaging_typecountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(packaging_typecountryV, FDC6label);
                                var sortingResult2 = sortByFirstCountryWithLabels(packaging_typecountryV2, FDC6label);
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(packaging_typecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,packaging_typecountryVX,sortingResult.sortedLabels,colorPalletX5,"StackBar");
                                stackcolumnChart3(packaging_typecountryVX,"packaging_type_chart_y",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX5)
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_8","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 9
                                var finaltime_consumptioncountryData = [];

                                var time_consumptioncountryData = [];

                                var time_consumptioncountryV = [];
                                var time_consumptioncountryV2 = [];
                                var time_consumptioncountryB = [];
                                var time_consumptioncountryC = [];
                                var time_consumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (time_consumptioncountryLevel[e]) {
                                        time_consumptioncountryData.push(time_consumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(time_consumptioncountryData,time_consumptioncountryV,time_consumptioncountryV2,time_consumptioncountryB,time_consumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(time_consumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(time_consumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(time_consumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                renderDonutTable(transposefrequencycounsumptioncountryData, CMC8label, countryLabel4,flaggXX,"y_9",transposefrequencycounsumptioncountryDataBase[0]);
                                formTable3(CMC8label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_9","data_table",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // Slide 10

                                var finalplace_consumptioncountryData = [];
                                var place_consumptioncountryData = [];
                                var place_consumptioncountryV = [];
                                var place_consumptioncountryV2 = [];
                                var place_consumptioncountryB = [];
                                var place_consumptioncountryC = [];
                                var place_consumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (place_consumptioncountryLevel[e]) {
                                        place_consumptioncountryData.push(place_consumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(place_consumptioncountryData,place_consumptioncountryV,place_consumptioncountryV2,place_consumptioncountryB,place_consumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(place_consumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(place_consumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(place_consumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,place_consumptioncountryVX,CMC9label,colorPalletX5,"StackBar");
                                stackcolumnChart3(place_consumptioncountryVX,"place_consumption_chart_y",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],colorPalletX5)
                                formTable3(CMC9label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_10","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 11

                                var finalconsumedalonecountryData = [];
                                var consumedalonecountryData = [];
                                var consumedalonecountryV = [];
                                var consumedalonecountryV2 = [];
                                var consumedalonecountryB = [];
                                var consumedalonecountryC = [];
                                var consumedalonecountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (consumedalonecountryLevel[e]) {
                                        consumedalonecountryData.push(consumedalonecountryLevel[e]);
                                    }
                                })

                                extractValues2(consumedalonecountryData,consumedalonecountryV,consumedalonecountryV2,consumedalonecountryB,consumedalonecountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(consumedalonecountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(consumedalonecountryV2)
                                var sum1 = transposefrequencycounsumptioncountryData[3].map((val, i) => val + transposefrequencycounsumptioncountryData[4][i]);
                                transposefrequencycounsumptioncountryData.splice(3, 2);
                                transposefrequencycounsumptioncountryData.splice(3, 0, sum1);
                                var sum3 = transposefrequencycounsumptioncountryData2[3].map((val, i) => val + transposefrequencycounsumptioncountryData2[4][i]);
                                transposefrequencycounsumptioncountryData2.splice(3, 2);
                                transposefrequencycounsumptioncountryData2.splice(3, 0, sum3);
                                var sum2 = transposefrequencycounsumptioncountryData[4].map((val, i) => val + transposefrequencycounsumptioncountryData[5][i]);
                                transposefrequencycounsumptioncountryData.splice(4, 2);
                                transposefrequencycounsumptioncountryData.push(sum2);
                                var sum4 = transposefrequencycounsumptioncountryData2[4].map((val, i) => val + transposefrequencycounsumptioncountryData2[5][i]);
                                transposefrequencycounsumptioncountryData2.splice(4, 2);
                                transposefrequencycounsumptioncountryData2.push(sum4);
                                var transposefrequencycounsumptioncountryDataBase = transposeData(consumedalonecountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                renderDonutTable(transposefrequencycounsumptioncountryData, CMC11label2, countryLabel4,flaggXX,"y_11",transposefrequencycounsumptioncountryDataBase[0]);
                                formTable3(CMC11label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_11","data_table",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 12

                                //debugger;
                                var finalchangepersonalconsumptioncountryData = [];
                                var changepersonalconsumptioncountryData = [];
                                var changepersonalconsumptioncountryV = [];
                                var changepersonalconsumptioncountryV2 = [];
                                var changepersonalconsumptioncountryB = [];
                                var changepersonalconsumptioncountryC = [];
                                var changepersonalconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (changepersonalconsumptioncountryLevel[e]) {
                                        changepersonalconsumptioncountryData.push(changepersonalconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(changepersonalconsumptioncountryData,changepersonalconsumptioncountryV,changepersonalconsumptioncountryV2,changepersonalconsumptioncountryB,changepersonalconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(changepersonalconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(changepersonalconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(changepersonalconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(CMC20label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_14","pc_tbl_y",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                var finalchangehouseholdconsumptioncountryData = [];
                                var changehouseholdconsumptioncountryData = [];
                                var changehouseholdconsumptioncountryV = [];
                                var changehouseholdconsumptioncountryV2 = [];
                                var changehouseholdconsumptioncountryB = [];
                                var changehouseholdconsumptioncountryC = [];
                                var changehouseholdconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (changehouseholdconsumptioncountryLevel[e]) {
                                        changehouseholdconsumptioncountryData.push(changehouseholdconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(changehouseholdconsumptioncountryData,changehouseholdconsumptioncountryV,changehouseholdconsumptioncountryV2,changehouseholdconsumptioncountryB,changehouseholdconsumptioncountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(changehouseholdconsumptioncountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(changehouseholdconsumptioncountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(changehouseholdconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(CMC20label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_14","hc_tbl_y",transposefrequencycounsumptioncountryDataBase[0]);

                                // Slide 13

                                var finalpurchasehousehold1countryData = [];
                                var purchasehousehold1countryData = [];
                                var purchasehousehold1countryV = [];
                                var purchasehousehold1countryV2 = [];
                                var purchasehousehold1countryB = [];
                                var purchasehousehold1countryC = [];
                                var purchasehousehold1countryVX = [];

                                var finalpurchasehousehold2countryData = [];
                                var purchasehousehold2countryData = [];
                                var purchasehousehold2countryV = [];
                                var purchasehousehold2countryV2 = [];
                                var purchasehousehold2countryB = [];
                                var purchasehousehold2countryC = [];
                                var purchasehousehold2countryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (purchasechannelcountryLevel[e]) {
                                        purchasehousehold1countryData.push(purchasechannelcountryLevel[e]);
                                    }
                                })

                                countryLabel4.forEach(function(e,i,a){
                                    if (purchasehouseholdcountryLevel2[e]) {
                                        purchasehousehold2countryData.push(purchasehouseholdcountryLevel2[e]);
                                    }
                                });

                                function colorizeTableByColumn(tableId) {
                                    const table = document.getElementById(tableId);
                                    if (!table) return;

                                    const rows = Array.from(table.querySelectorAll("tbody tr"));
                                    const numCols = rows[0].querySelectorAll("td").length;

                                    // Convert hex to RGB
                                    function hexToRgb(hex) {
                                        const bigint = parseInt(hex.replace('#', ''), 16);
                                        return {
                                        r: (bigint >> 16) & 255,
                                        g: (bigint >> 8) & 255,
                                        b: bigint & 255,
                                        };
                                    }

                                    // Interpolate between two RGB values
                                    function interpolateColor(color1, color2, factor) {
                                        return {
                                        r: Math.round(color1.r + (color2.r - color1.r) * factor),
                                        g: Math.round(color1.g + (color2.g - color1.g) * factor),
                                        b: Math.round(color1.b + (color2.b - color1.b) * factor),
                                        };
                                    }

                                    // Custom gradient: red → white → green
                                    function getColorByRank(percent) {
                                        const red = hexToRgb("#ff4d4d");
                                        const white = hexToRgb("#ffffff");
                                        const green = hexToRgb("#4caf50");

                                        let rgb;
                                        if (percent < 0.5) {
                                        rgb = interpolateColor(red, white, percent * 2); // 0 to 0.5 → red to white
                                        } else {
                                        rgb = interpolateColor(white, green, (percent - 0.5) * 2); // 0.5 to 1 → white to green
                                        }

                                        return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
                                    }

                                    // Loop through each column (excluding label column)
                                    for (let colIndex = 1; colIndex < numCols; colIndex++) {
                                        const values = [];

                                        // Collect values with index
                                        rows.forEach((row, rowIndex) => {
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        const val = parseFloat(cell.innerText.replace('%', ''));
                                        if (!isNaN(val)) values.push({ rowIndex, value: val });
                                        });

                                        const sorted = [...values].sort((a, b) => b.value - a.value);
                                        const total = sorted.length;

                                        sorted.forEach((item, i) => {
                                        const rankPercent = 1 - (i / (total - 1)); // highest = 1, lowest = 0
                                        const row = rows[item.rowIndex];
                                        const cell = row.querySelectorAll("td")[colIndex];
                                        cell.style.backgroundColor = getColorByRank(rankPercent);
                                        cell.style.color = "#000";
                                        });
                                    }
                                }

                                extractValues2(purchasehousehold1countryData,purchasehousehold1countryV,purchasehousehold1countryV2,purchasehousehold1countryB,purchasehousehold1countryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(purchasehousehold1countryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(purchasehousehold1countryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(purchasehousehold1countryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);

                                formTable4(CMC19label2,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"purchase_behaviour_chart2_y",transposefrequencycounsumptioncountryDataBase[0]);
                                colorizeTableByColumn("purchase_behaviour_chart2_y");
                                htmlZ = ``;
                                htmlZ += `<tr class="allbase">`;
                                htmlZ += `<td></td>`;
                                transposefrequencycounsumptioncountryDataBase[0].forEach(function(e2,i2,a2){
                                    htmlZ += `<td>n-${e2}</td>`;
                                });
                                htmlZ += `</tr>`;
                                $("#purchase_behaviour_chart2_y > tbody").append(htmlZ);
                                
                                extractValues2(purchasehousehold2countryData,purchasehousehold2countryV,purchasehousehold2countryV2,purchasehousehold2countryB,purchasehousehold2countryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(purchasehousehold2countryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(purchasehousehold2countryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(purchasehousehold2countryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                customizedArray(transposefrequencycounsumptioncountryData,purchasehousehold2countryVX,["Yes"],colorPallet,"StackBar");
                                stackcolumnChart2(purchasehousehold2countryVX,"purchase_behaviour_chart_y",countryLabel4,transposefrequencycounsumptioncountryDataBase[0],"100")

                                // Slide 14

                                var finalreasonconsumptioncountryData = [];
                                var reasonconsumptioncountryData = [];
                                var reasonconsumptioncountryV = [];
                                var reasonconsumptioncountryV2 = [];
                                var reasonconsumptioncountryB = [];
                                var reasonconsumptioncountryC = [];
                                var reasonconsumptioncountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (reasonconsumptioncountryLevel[e]) {
                                        reasonconsumptioncountryData.push(reasonconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(reasonconsumptioncountryData,reasonconsumptioncountryV,reasonconsumptioncountryV2,reasonconsumptioncountryB,reasonconsumptioncountryC,"Simple2");
                                var sortingResult = sortByFirstCountryWithLabels(reasonconsumptioncountryV, CMC12label);
                                var sortingResult2 = sortByFirstCountryWithLabels(reasonconsumptioncountryV2, CMC12label);
                                
                                var transposefrequencycounsumptioncountryData = transposeData(sortingResult.sortedData)
                                var transposefrequencycounsumptioncountryData2 = transposeData(sortingResult2.sortedData)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(reasonconsumptioncountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(sortingResult.sortedLabels,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_12","roc_tt_y",transposefrequencycounsumptioncountryDataBase[0]);

                                customizedArray(transposefrequencycounsumptioncountryData,reasonconsumptioncountryVX,sortingResult.sortedLabels,colorPallet,"StackBar");
                                
                                function transformToModelWise(input) {
                                    const result = [];
                                    for (let i = 0; i < 7; i++) {
                                        const modelData = {
                                        name: `Model ${i + 1}`,
                                        data: input.map(item => item.data[i])
                                        };
                                        result.push(modelData);
                                    }
                                    return result;
                                }

                                const modelWise = transformToModelWise(reasonconsumptioncountryVX);
                                console.log("modelWise");
                                console.log(modelWise);
                                console.log("reasonconsumptioncountryVX");
                                console.log(reasonconsumptioncountryVX);
                                
                                function generateColors(dataArray) {
                                    const indexed = dataArray.map((value, index) => ({ value, index }));
                                    indexed.sort((a, b) => b.value - a.value);
                                    
                                    const topIndexes = new Set(indexed.slice(0, 4).map(item => item.index));

                                    return dataArray.map((_, index) => topIndexes.has(index) ? '#4D6893' : '#7C985E');
                                }
                                modelWise.forEach(model => {
                                    model.color = 'transparent';
                                    model.colors = generateColors(model.data);
                                });


                                barChart88([modelWise[0]],"reason_consumption_y_1",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][0],"SouthEast Asia",flagg2[0]);
                                barChart89([modelWise[1]],"reason_consumption_y_2",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][1],"Singapore",flagg2[0]);
                                barChart89([modelWise[2]],"reason_consumption_y_3",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][2],"Thailand",flagg2[1]);
                                barChart89([modelWise[3]],"reason_consumption_y_4",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][3],"Malaysia",flagg2[2]);
                                barChart89([modelWise[4]],"reason_consumption_y_5",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][4],"Indonesia",flagg2[3]);
                                barChart89([modelWise[5]],"reason_consumption_y_6",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][5],"Philippines",flagg2[4]);
                                barChart89([modelWise[6]],"reason_consumption_y_7",sortingResult.sortedLabels,transposefrequencycounsumptioncountryDataBase[0][6],"Vietnam",flagg2[5]);

                                // Slide 15

                                var finalhouseholdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryV = [];
                                var householdconsumptioncountryLevelcountryV2 = [];
                                var householdconsumptioncountryLevelcountryB = [];
                                var householdconsumptioncountryLevelcountryC = [];
                                var householdconsumptioncountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (householdconsumptioncountryLevel[e]) {
                                        householdconsumptioncountryLevelcountryData.push(householdconsumptioncountryLevel[e]);
                                    }
                                })

                                extractValues2(householdconsumptioncountryLevelcountryData,householdconsumptioncountryLevelcountryV,householdconsumptioncountryLevelcountryV2,householdconsumptioncountryLevelcountryB,householdconsumptioncountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(householdconsumptioncountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(householdconsumptioncountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(householdconsumptioncountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable3(CMC16label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_16","household_consumption_chart_y",transposefrequencycounsumptioncountryDataBase[0]);


                                // agecountryLevel

                                var finalagecountryLevelcountryData = [];
                                var agecountryLevelcountryData = [];
                                var agecountryLevelcountryV = [];
                                var agecountryLevelcountryV2 = [];
                                var agecountryLevelcountryB = [];
                                var agecountryLevelcountryC = [];
                                var agecountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (agecountryLevel[e]) {
                                        agecountryLevelcountryData.push(agecountryLevel[e]);
                                    }
                                })

                                extractValues2(agecountryLevelcountryData,agecountryLevelcountryV,agecountryLevelcountryV2,agecountryLevelcountryB,agecountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(agecountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(agecountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(agecountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(ageLabelXXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_18","age_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // educationcountryLevel

                                var finaleducationcountryLevelcountryData = [];
                                var educationcountryLevelcountryData = [];
                                var educationcountryLevelcountryV = [];
                                var educationcountryLevelcountryV2 = [];
                                var educationcountryLevelcountryB = [];
                                var educationcountryLevelcountryC = [];
                                var educationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (educationcountryLevel[e]) {
                                        educationcountryLevelcountryData.push(educationcountryLevel[e]);
                                    }
                                })

                                extractValues2(educationcountryLevelcountryData,educationcountryLevelcountryV,educationcountryLevelcountryV2,educationcountryLevelcountryB,educationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(educationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(educationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(educationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(educationXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_18","education_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // dietarycountryLevel

                                var finaldietarycountryLevelcountryData = [];
                                var dietarycountryLevelcountryData = [];
                                var dietarycountryLevelcountryV = [];
                                var dietarycountryLevelcountryV2 = [];
                                var dietarycountryLevelcountryB = [];
                                var dietarycountryLevelcountryC = [];
                                var dietarycountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (dietarycountryLevel[e]) {
                                        dietarycountryLevelcountryData.push(dietarycountryLevel[e]);
                                    }
                                })

                                extractValues2(dietarycountryLevelcountryData,dietarycountryLevelcountryV,dietarycountryLevelcountryV2,dietarycountryLevelcountryB,dietarycountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(dietarycountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(dietarycountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(dietarycountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(halalLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_18","dietary_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // occupationcountryLevel

                                var finaloccupationcountryLevelcountryData = [];
                                var occupationcountryLevelcountryData = [];
                                var occupationcountryLevelcountryV = [];
                                var occupationcountryLevelcountryV2 = [];
                                var occupationcountryLevelcountryB = [];
                                var occupationcountryLevelcountryC = [];
                                var occupationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (occupationcountryLevel[e]) {
                                        occupationcountryLevelcountryData.push(occupationcountryLevel[e]);
                                    }
                                })

                                extractValues2(occupationcountryLevelcountryData,occupationcountryLevelcountryV,occupationcountryLevelcountryV2,occupationcountryLevelcountryB,occupationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(occupationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(occupationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(occupationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(occupationLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_19","occupation_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // incomecountryLevel

                                var finalincomecountryLevelcountryData = [];
                                var incomecountryLevelcountryData = [];
                                var incomecountryLevelcountryV = [];
                                var incomecountryLevelcountryV2 = [];
                                var incomecountryLevelcountryB = [];
                                var incomecountryLevelcountryC = [];
                                var incomecountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (incomecountryLevel[e]) {
                                        incomecountryLevelcountryData.push(incomecountryLevel[e]);
                                    }
                                })

                                extractValues2(incomecountryLevelcountryData,incomecountryLevelcountryV,incomecountryLevelcountryV2,incomecountryLevelcountryB,incomecountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(incomecountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(incomecountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(incomecountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(incomeLabel,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_19","householdincome_tbl",transposefrequencycounsumptioncountryDataBase[0]);

                                // relationshipcountryLevel

                                var finalrelationcountryLevelcountryData = [];
                                var relationcountryLevelcountryData = [];
                                var relationcountryLevelcountryV = [];
                                var relationcountryLevelcountryV2 = [];
                                var relationcountryLevelcountryB = [];
                                var relationcountryLevelcountryC = [];
                                var relationcountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (relationcountryLevel[e]) {
                                        relationcountryLevelcountryData.push(relationcountryLevel[e]);
                                    }
                                })

                                extractValues2(relationcountryLevelcountryData,relationcountryLevelcountryV,relationcountryLevelcountryV2,relationcountryLevelcountryB,relationcountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(relationcountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(relationcountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(relationcountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(relationXX,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_20","relationship_tbl",transposefrequencycounsumptioncountryDataBase[0]);
                                
                                // People living in household

                                var finalhouseholdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryData = [];
                                var householdconsumptioncountryLevelcountryV = [];
                                var householdconsumptioncountryLevelcountryV2 = [];
                                var householdconsumptioncountryLevelcountryB = [];
                                var householdconsumptioncountryLevelcountryC = [];
                                var householdconsumptioncountryLevelcountryVX = [];

                                countryLabel4.forEach(function(e,i,a){
                                    if (householdconsumptioncountryLevel[e]) {
                                        householdconsumptioncountryLevelcountryData.push(householdconsumptioncountryLevel[e]);
                                    }
                                })
                                ////debugger;
                                extractValues2(householdconsumptioncountryLevelcountryData,householdconsumptioncountryLevelcountryV,householdconsumptioncountryLevelcountryV2,householdconsumptioncountryLevelcountryB,householdconsumptioncountryLevelcountryC,"Simple2");
                                var transposefrequencycounsumptioncountryData = transposeData(householdconsumptioncountryLevelcountryV)
                                var transposefrequencycounsumptioncountryData2 = transposeData(householdconsumptioncountryLevelcountryV2)
                                var transposefrequencycounsumptioncountryDataBase = transposeData(householdconsumptioncountryLevelcountryB)
                                transposefrequencycounsumptioncountryDataBase[0] = transposefrequencycounsumptioncountryDataBase[0].map(Number);
                                formTable7(CMC16label,transposefrequencycounsumptioncountryData,transposefrequencycounsumptioncountryData2,"y_20","livinghousehold_tbl",transposefrequencycounsumptioncountryDataBase[0]);

                        },
                        complete: function (data) {
                            ajaxFlag[1+54] = true;
                            $(".splash").hide();
                        }
                    })
                }

                function fiftyOneAjax()
                {
                    
                }
            //=================================Ajax End============================================

            //=================================Chart Start============================================

            function doughnutChartF(lucifer,divId,seriesName,heightX,filterName)
            {
                Highcharts.chart(divId, {
                    chart: {
                        type: 'pie',
                        style: {
                            fontFamily: "ARIAL",
                        },
                        "backgroundColor": "transparent",
                        height: heightX
                    },
                    accessibility: {
                        point: {
                            valueSuffix: '%'
                        }
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    title: {
                        text: ''
                    },
                    subtitle: {
                        text: ''
                    },
                    tooltip: {
                        pointFormat: '<b>{point.y:.0f}%</b>'
                    },
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        verticalAlign: 'bottom',
                        width: '100%',
                        itemStyle: {
                            width: '80%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: false,
                            dataLabels: {
                                enabled: true
                            },
                        },
                        series: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: [{
                                enabled: true,
                                formatter: function() {
                                    return this.y > 0 ? this.y.toFixed(0) + '%' : null;
                                },
                                distance: 5,
                                style: {
                                    fontSize: '0.6rem',
                                    color: '#000000',
                                    fontWeight: 'normal' 
                                }
                            }],
                            showInLegend: true,
                            point: {
                                events: {
                                    click: function() {
                                        var idX = this.series.chart.renderTo.id;
                                        //console.log(idX);
                                        var dataNameX = $(`#${idX}`).data("name");
                                        var dropdownName = this.series.name.toLowerCase();
                                        var valueName = this.name;
                                        clickableSlice(idX, dataNameX, filterName, valueName, "charts", "fresh");
                                    }
                                }
                            }
                        }
                    },
                    // colors: ['#C07B60','#FA8D62','#2C626E','#B1DCD3','#74A9CE','#A6BCDB','#D0D0E7'],
                    series: [{
                        name: '',
                        colorByPoint: true,
                        innerSize: '85%',
                        data: lucifer
                    }],
                });
            }

            function doughnutChart(lucifer,divId,seriesName,heightX)
            {
                Highcharts.chart(divId, {
                    chart: {
                        type: 'pie',
                        style: {
                            fontFamily: "ARIAL",
                        },
                        "backgroundColor": "transparent",
                        height: heightX
                    },
                    accessibility: {
                        point: {
                            valueSuffix: '%'
                        }
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    title: {
                        text: ''
                    },
                    subtitle: {
                        text: ''
                    },
                    tooltip: {
                        pointFormat: '<b>{point.y:.0f}%</b>'
                    },
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        verticalAlign: 'bottom',
                        width: '90%',
                        itemStyle: {
                            width: '80%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    plotOptions: {
                        pie: {
                            dataLabels: {
                                enabled: true
                            },
                        },
                        series: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            // borderRadius: 8,
                            dataLabels: [{
                                enabled: false,
                                distance: 20,
                                format: '{point.name}'
                            }, {
                                enabled: true,
                                formatter: function() {
                                    return this.y > 0 ? this.y.toFixed(0) + '%' : null;
                                },
                                distance: 5,
                                // format: '{point.percentage:.1f}%',
                                style: {
                                    fontSize: '0.6rem',
                                    color: '#000000',
                                }
                            }],
                            showInLegend: true,
                        }
                    },
                    // colors: ['#C07B60','#FA8D62','#2C626E','#B1DCD3','#74A9CE','#A6BCDB','#D0D0E7'],
                    series: [{
                        name: '',
                        colorByPoint: true,
                        innerSize: '85%',
                        data: lucifer
                    }],
                });
            }

            function doughnutChart1_2(lucifer,divId,seriesName,heightX)
            {
                Highcharts.chart(divId, {
                    chart: {
                        type: 'pie',
                        style: {
                            fontFamily: "ARIAL",
                        },
                        "backgroundColor": "transparent",
                        height: heightX
                    },
                    accessibility: {
                        point: {
                            valueSuffix: '%'
                        }
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    title: {
                        text: ''
                    },
                    subtitle: {
                        text: ''
                    },
                    tooltip: {
                        pointFormat: '<b>{point.y:.0f}%</b>'
                    },
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        width: '100%',
                        verticalAlign: 'bottom',
                        itemStyle: {
                            width: '80%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    plotOptions: {
                        pie: {
                            dataLabels: {
                                enabled: true
                            },
                        },
                        series: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            // borderRadius: 8,
                            dataLabels: [{
                                enabled: false,
                                distance: 20,
                                format: '{point.name}'
                            }, {
                                enabled: true,
                                formatter: function() {
                                    return this.y > 0 ? this.y.toFixed(0) + '%' : null;
                                },
                                distance: 5,
                                // format: '{point.percentage:.1f}%',
                                style: {
                                    fontSize: '0.6rem',
                                    color: '#000000'
                                }
                            }],
                            showInLegend: true,
                        }
                    },
                    // colors: ['#C07B60','#FA8D62','#2C626E','#B1DCD3','#74A9CE','#A6BCDB','#D0D0E7'],
                    series: [{
                        name: '',
                        colorByPoint: true,
                        innerSize: '85%',
                        data: lucifer
                    }],
                });
            }

            function doughnutChart1_3(lucifer,divId,seriesName,heightX)
            {
                Highcharts.chart(divId, {
                    chart: {
                        type: 'pie',
                        style: {
                            fontFamily: "ARIAL",
                        },
                        "backgroundColor": "transparent",
                        height: heightX
                    },
                    accessibility: {
                        point: {
                            valueSuffix: '%'
                        }
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    title: {
                        text: ''
                    },
                    subtitle: {
                        text: ''
                    },
                    tooltip: {
                        pointFormat: '<b>{point.y:.0f}%</b>'
                    },
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        width: '100%',
                        verticalAlign: 'bottom',
                        itemStyle: {
                            width: '70%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    plotOptions: {
                        pie: {
                            dataLabels: {
                                enabled: true
                            },
                        },
                        series: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            // borderRadius: 8,
                            dataLabels: [{
                                enabled: false,
                                distance: 20,
                                format: '{point.name}'
                            }, {
                                enabled: true,
                                formatter: function() {
                                    return this.y > 0 ? this.y.toFixed(0) + '%' : null;
                                },
                                distance: 5,
                                // format: '{point.percentage:.1f}%',
                                style: {
                                    fontSize: '0.6rem',
                                    color: '#000000'
                                }
                            }],
                            showInLegend: true,
                        }
                    },
                    // colors: ['#C07B60','#FA8D62','#2C626E','#B1DCD3','#74A9CE','#A6BCDB','#D0D0E7'],
                    series: [{
                        name: '',
                        colorByPoint: true,
                        innerSize: '85%',
                        data: lucifer
                    }],
                });
            }

            function doughnutChart2(lucifer,divId,seriesName,heightX)
            {
                Highcharts.chart(divId, {
                    chart: {
                        type: 'pie',
                        style: {
                            fontFamily: "ARIAL",
                        },
                        "backgroundColor": "transparent",
                        "height": heightX
                    },
                    accessibility: {
                        point: {
                            valueSuffix: '%'
                        }
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    title: {
                        text: ''
                    },
                    subtitle: {
                        text: ''
                    },
                    tooltip: {
                        pointFormat: '<b>{point.y:.0f}%</b>'
                    },
                    legend: {
                        layout: 'horizontal', 
                        verticalAlign: 'bottom',
                        itemStyle: {
                            // width: '50%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    plotOptions: {
                        pie: {
                            dataLabels: {
                                enabled: true
                            },
                            // colors: ['rgba(255, 99, 132, 0.5)', 'rgba(54, 162, 235, 0.5)', 'rgba(255, 206, 86, 0.5)', 'rgba(75, 192, 192, 0.5)'] // Transparent colors
                        },
                        series: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: [{
                                enabled: false,
                                distance: 20,
                                format: '{point.name}'
                            }, {
                                enabled: true,
                                formatter: function() {
                                    return this.y > 0 ? this.y.toFixed(0) + '%' : null;
                                },
                                distance: 5,
                                // format: '{point.percentage:.1f}%',
                                style: {
                                    fontSize: '0.6rem',
                                    color: '#000000'
                                }
                            }],
                            showInLegend: true,
                        }
                    },
                    // colors: ['#C07B60','#FA8D62','#2C626E','#B1DCD3','#74A9CE','#A6BCDB','#D0D0E7'],
                    series: [{
                        name: seriesName,
                        colorByPoint: true,
                        innerSize: '85%',
                        data: lucifer
                    }],
                });
            }
            
            function doughnutChart3(lucifer,id,color) {
                Highcharts.chart(id, {
                    chart: {
                        type: 'pie',
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                    },
                    title: {
                        text: ''
                    },
                    subtitle: {
                        text: `<div style='font-size:0.9rem'><b>${lucifer}%</b></div>`,
                        align: "center",
                        verticalAlign: "middle",
                        style: {
                            "textAlign": "center"
                        },
                        y: 15,
                        useHTML: true
                    },
                    credits: {
                        enabled: false
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    series: [{
                        type: 'pie',
                        enableMouseTracking: false,
                        innerSize: '80%',
                        dataLabels: {
                            enabled: false
                        },
                        data: [{
                            y: lucifer,
                            color: color
                        }, {
                            y: 100 - lucifer,
                            color: '#e3e3e3'
                        }]
                    }]
                });
            }

            function doughnutChart4(lucifer,divId,seriesName,heightX)
            {
                Highcharts.chart(divId, {
                    chart: {
                        type: 'pie',
                        style: {
                            fontFamily: "ARIAL",
                        },
                        "backgroundColor": "transparent",
                        height: heightX
                    },
                    accessibility: {
                        point: {
                            valueSuffix: '%'
                        }
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    title: {
                        text: ''
                    },
                    subtitle: {
                        text: ''
                    },
                    tooltip: {
                        pointFormat: '<b>{point.y:.0f}%</b>'
                    },
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        width: '100%',
                        verticalAlign: 'bottom',
                        itemStyle: {
                            width: '40%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    plotOptions: {
                        pie: {
                            dataLabels: {
                                enabled: true
                            },
                        },
                        series: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            // borderRadius: 8,
                            dataLabels: [{
                                enabled: false,
                                distance: 20,
                                format: '{point.name}'
                            }, {
                                enabled: true,
                                formatter: function() {
                                    return this.y > 0 ? this.y.toFixed(0) + '%' : null;
                                },
                                distance: 5,
                                // format: '{point.percentage:.1f}%',
                                style: {
                                    fontSize: '0.6rem',
                                    color: '#000000'
                                }
                            }],
                            showInLegend: true,
                        }
                    },
                    // colors: ['#C07B60','#FA8D62','#2C626E','#B1DCD3','#74A9CE','#A6BCDB','#D0D0E7'],
                    series: [{
                        name: '',
                        colorByPoint: true,
                        innerSize: '85%',
                        data: lucifer
                    }],
                });
            }

            function doughnutChart1_1(lucifer,divId,seriesName,heightX)
            {
                Highcharts.chart(divId, {
                    chart: {
                        type: 'pie',
                        style: {
                            fontFamily: "ARIAL",
                        },
                        "backgroundColor": "transparent",
                        height: heightX
                    },
                    accessibility: {
                        point: {
                            valueSuffix: '%'
                        }
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    title: {
                        text: ''
                    },
                    subtitle: {
                        text: ''
                    },
                    tooltip: {
                        pointFormat: '<b>{point.y:.0f}%</b>'
                    },
                    legend: {
                        layout: 'horizontal',
                        align: 'center',
                        width: '100%',
                        verticalAlign: 'bottom',
                        itemStyle: {
                            width: '80%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    plotOptions: {
                        pie: {
                            dataLabels: {
                                enabled: true
                            },
                        },
                        series: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            // borderRadius: 8,
                            dataLabels: [{
                                enabled: false,
                                distance: 20,
                                format: '{point.name}'
                            }, {
                                enabled: true,
                                formatter: function() {
                                    return this.y > 0 ? this.y.toFixed(0) + '%' : null;
                                },
                                distance: 5,
                                // format: '{point.percentage:.1f}%',
                                style: {
                                    fontSize: '0.6rem',
                                    color: '#000000'
                                }
                            }],
                            showInLegend: true,
                        }
                    },
                    // colors: ['#C07B60','#FA8D62','#2C626E','#B1DCD3','#74A9CE','#A6BCDB','#D0D0E7'],
                    series: [{
                        name: '',
                        colorByPoint: true,
                        innerSize: '85%',
                        data: lucifer
                    }],
                });
            }

            function pieChart(lucifer,divId,heightX)
            {
                Highcharts.chart(divId, {
                    chart: {
                        plotShadow: false,
                        type: 'pie',
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        height: heightX
                    },
                    title: {
                        text: '',
                        align: 'left'
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    tooltip: {
                        pointFormat: '<b>{point.percentage:.0f}%</b>'
                        //valueSuffix: '%'
                    },
                    accessibility: {
                        point: {
                            valueSuffix: '%'
                        }
                    },
                    legend: {
                        layout: 'horizontal', 
                        verticalAlign: 'bottom',
                        itemStyle: {
                            // width: '50%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        }
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true
                            },
                            showInLegend: true
                        },
                        series: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: [{
                                enabled: false,
                                distance: 20,
                                format: '{point.name}'
                            }, {
                                enabled: true,
                                formatter: function() {
                                    return this.y > 0 ? this.y.toFixed(0) + '%' : null;
                                },
                                distance: 5,
                                // format: '{point.percentage:.1f}%',
                                style: {
                                    fontSize: '0.6rem',
                                    color: '#000000'
                                }
                            }],
                            showInLegend: true,
                        }
                    },
                    series: [{
                        name: '',
                        colorByPoint: true,
                        data: lucifer
                    }]
                });
            }

            function columnChart(data,id,cat,max)
            {
                Highcharts.chart(id, {
                    chart: {
                        type: 'column',
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    xAxis: {
                        categories: cat,
                        gridLineWidth: 0,
                        // lineWidth: 0,
                        labels: {
                            style: {
                                fontSize: '0.6rem',
                                color: '#000000'
                            },
                            rotation:0,
                        }
                    },
                    yAxis: {
                        min: 0,
                        max:max,
                        title: {
                            text: ''
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                    },
                    tooltip: {
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> <b>{point.y}%</b> <br/>'
                    },
                    legend:
                    {
                        enabled:false
                    },
                    plotOptions: {
                        column: {
                            // borderRadius: {
                            //     radius: 10,
                            //     where: 'all'
                            // },
                            pointPadding: 0.2,
                            // borderWidth: 0
                        },
                        series: {
                            colorByPoint: true,
                            pointWidth: 16,
                            cursor: 'pointer',
                            dataLabels: {
                                
                                enabled: true,
                                style: {
                                    textOutline: false,
                                    fontSize : "0.85rem",
                                    color: '#000000'
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return this.y + "%";
                                    }
                                    
                                },
                            }
                        }
                    },
                    colors: colorPallet69,
                    series: [{
                        name: 'Category Data',
                        data: data
                    }]
                });
            }

            function barChart(data,id,cat,max)
            {
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        type: 'bar',
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    xAxis: {
                        categories: cat,
                        title: {
                            text: null
                        },
                        gridLineWidth: 0,
                        lineWidth: 0,
                        labels: {
                            style: {
                                fontSize: '0.6rem',
                                color: '#000000'
                            }
                        }
                    },
                    yAxis: {
                        min: 0,
                        max: max,
                        title: {
                            text: '',
                            align: 'high'
                        },
                        labels: {
                            overflow: 'justify'
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                    },
                    tooltip: {
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> <b>{point.y}%</b> <br/>'
                    },
                    plotOptions: {
                        bar: {
                            borderRadius: {
                                radius: 10,
                                where: 'all'
                            },
                            pointPadding: 0.2,
                            borderWidth: 0,
                        },
                        series: {
                            colorByPoint: true,
                            pointWidth: 16,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                style: {
                                    textOutline: false,
                                    fontSize : "0.85rem",
                                    color: '#000000'
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return this.y + "%";
                                    }
                                },
                            },
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        enabled: false
                    },
                    colors: colorPallet69,
                    series: [{
                        name: 'Category Data',
                        data: data
                    }]
                });
            }

            function barChart2(data,id,cat,max,colorX)
            {
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        type: 'bar',
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    xAxis: {
                        categories: cat,
                        title: {
                            text: null
                        },
                        // gridLineWidth: 0,
                        // lineWidth: 0,
                        labels: {
                            style: {
                                fontSize: '0.6rem',
                                color: '#000000'
                            }
                        }
                    },
                    yAxis: {
                        min: 0,
                        max: max,
                        title: {
                            text: '',
                            align: 'high'
                        },
                        labels: {
                            overflow: 'justify'
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                    },
                    tooltip: {
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> <b>{point.y}%</b> <br/>'
                    },
                    plotOptions: {
                        bar: {
                            pointPadding: 0.2,
                            borderWidth: 0,
                        },
                        series: {
                            colorByPoint: true,
                            // pointWidth: 16,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                style: {
                                    textOutline: false,
                                    fontSize : "0.85rem",
                                    color: '#000000'
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return this.y + "%";
                                    }
                                },
                            }
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        enabled: false
                    },
                    colors: colorX,
                    series: [{
                        name: 'Category Data',
                        data: data
                    }]
                });
            }

            function barChart3(data,id,cat,max,colorX)
            {
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        type: 'bar',
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    xAxis: {
                        categories: cat,
                        title: {
                            text: null
                        },
                        // gridLineWidth: 0,
                        // lineWidth: 0,
                        labels: {
                            style: {
                                fontSize: '0.6rem',
                                color: '#000000'
                            },
                            rotation:0,
                            useHTML: true,
                            padding:15,
                            height:10,
                            width:10,
                            formatter: function(){
                                return im2(this.value);
                            }
                        }
                    },
                    yAxis: {
                        min: 0,
                        max: 120,
                        title: {
                            text: '',
                            align: 'high'
                        },
                        labels: {
                            overflow: 'justify'
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                    },
                    tooltip: {
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> <b>{point.y}%</b> <br/>'
                    },
                    plotOptions: {
                        bar: {
                            pointPadding: 0.2,
                            borderWidth: 0,
                        },
                        series: {
                            //colorByPoint: true,
                            // pointWidth: 16,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                style: {
                                    textOutline: false,
                                    fontSize : "0.85rem",
                                    color: '#000000'
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return this.y + "%";
                                    }
                                },
                            }
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        enabled: true,
                        align: 'center',    // Centers the legend horizontally
                        verticalAlign: 'top', // Positions it at the top
                        layout: 'horizontal' // Arranges legend items in a horizontal row
                    },
                    colors: colorX,
                    series: data
                });
            }

            function barChart88(data,id,cat,baseX,txt,urls)
            {
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        type: 'bar',
                        height: "900px",
                        marginLeft: 220 
                    },
                    title: {
                        useHTML: true,
                        style: {
                            fontSize: '1.6vh',
                            color: '#000000' // Optional: set text color
                        },
                        text: `<span style="margin-left:120px;display:flex;flex-direction: column;align-items: center;"><img src="${urls}" style="height:30px;width:30px;border-radius: 60px;box-shadow: 2px 2px 5px -2px black;visibility:hidden"></br>${txt}</span>`,
                        align: 'center', // or 'left', 'right'
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    xAxis: {
                        categories: cat,
                        title: {
                            text: null
                        },
                        gridLineWidth: 0,
                        lineWidth: 0,
                        labels: {
                            enabled: true,
                            // align: 'left', // ← this aligns the label block
                            style: {
                                whiteSpace: 'nowrap',
                                overflow: 'visible',
                                textOverflow: 'unset',
                                
                                fontSize: '0.75rem',
                                color: '#000000'
                            }
                        }
                    },
                    yAxis: {
                        min: 0,
                        title: {
                            text: '',
                            align: 'high'
                        },
                        labels: {
                            overflow: 'justify'
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                    },
                    tooltip: {
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> <b>{point.y}%</b> <br/>'
                    },
                    plotOptions: {
                        bar: {
                            pointPadding: 0.2,
                            borderWidth: 0,
                        },
                        series: {
                            colorByPoint: true,
                            pointWidth: 16,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                style: {
                                    textOutline: false,
                                    fontSize : "0.85rem",
                                    color: '#000000'
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return this.y + "%";
                                    }
                                },
                            },
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        enabled: false
                    },
                    colors: colorPallet99,
                    series: data
                });
            }

            function barChart89(data,id,cat,baseX,txt,urls)
            {
                debugger;
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        type: 'bar',
                        height: "900px",
                    },
                    title: {
                        useHTML: true,
                        style: {
                            fontSize: '1.6vh',
                            color: '#000000' // Optional: set text color
                        },
                        text: `<span style="margin-left:10px;display:flex;flex-direction: column;align-items: center;"><img src="${urls}" style="height:30px;width:30px;border-radius: 60px;box-shadow: 2px 2px 5px -2px black;"></br>${txt}</span>`,
                        align: 'center', // or 'left', 'right'
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    xAxis: [{
                        visible: false, // Hides everything: labels, ticks, line
                        categories: cat,
                        labels: {
                            enabled: false // Not required if visible is false, but safe to include
                        }
                    }],
                    yAxis: {
                        min: 0,
                        title: {
                            text: '',
                            align: 'high'
                        },
                        labels: {
                            overflow: 'justify'
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                    },
                    tooltip: {
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> <b>{point.y}%</b> <br/>'
                    },
                    plotOptions: {
                        bar: {
                            pointPadding: 0.2,
                            borderWidth: 0,
                        },
                        series: {
                            colorByPoint: true,
                            pointWidth: 16,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                style: {
                                    textOutline: false,
                                    fontSize : "0.85rem",
                                    color: '#000000'
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return this.y + "%";
                                    }
                                },
                            },
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        enabled: false
                    },
                    colors: colorPallet99,
                    series: data
                });
            }
            
            function lineChart(data,id,cat,colorXX)
            {
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    yAxis: {
                        title: {
                            text: ''
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        enabled: false,
                        layout: 'horizontal',
                        align: 'center',
                        verticalAlign: 'bottom',
                        itemStyle: {
                            width: '100%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        },
                        backgroundColor: Highcharts.defaultOptions.legend.backgroundColor || // theme
                            '#fff'
                    },
                    xAxis: {
                        lineWidth: 0,
                        labels: {
                            enabled: false
                        },
                        categories: cat
                    },
                    tooltip: {
                        shared: true,
                        split: false,
                        enabled: true,
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}%</b> <br/>',
                    },
                    plotOptions: {
                        series: {
                            stacking: 'normal',
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                color: '#000000',
                                style: {
                                    textOutline: false,
                                    fontSize: '0.6rem',
                                    // color: '#000000'
                                },
                                formatter: function() {
                                    return (this.y)+"%";
                                },
                            },
                            label: {
                                connectorAllowed: false
                            },
                        }
                    },
                    colors:colorXX,
                    series: data,
                });
            }
            function stackbarChart(data,id)
            {
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        type: 'bar'
                    },
                    title: {
                        text: ''
                    },
                    xAxis: {
                        categories: ["JFM’25","AMJ’25","JAS’25","OND’25","JFM’26","AMJ’26","JAS’26","OND’26"],
                        labels: {
                            style: {
                                fontSize: '10px',
                                color: '#000000'
                            },
                            rotation:0,
                            useHTML: true,
                        }
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    yAxis: {
                        min: 0,
                        title: {
                            text: ''
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                    },
                    tooltip: {
                        valueSuffix: ' %'
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        reversed: true,
                        itemStyle: {
                            width: '100%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        }
                    },
                    plotOptions: {
                        series: {
                            stacking: 'normal',
                            dataLabels: {
                                enabled: true,
                                style: {
                                    textOutline: false,
                                    fontSize: '0.6rem',
                                    // color: '#000000'
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return this.y + "%";
                                    }
                                    
                                }
                            }
                        }
                    },
                    colors:colorPallet69,
                    series: data
                });
            }

            function stackcolumnChart(data,id,cat,baseE,heightX)
            {
                //////debugger;
                if(heightX==undefined)
                {
                    heightX = "auto";
                }
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        type: 'column',
                        height: heightX
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    xAxis: [{
                        categories: cat,
                        labels: {
                            style: {
                                fontSize: '10px',
                                color: '#000000'
                            },
                            rotation:0,
                            useHTML: true,
                            formatter: function(){
                                var index = this.pos;
                                var base = baseE[index];
                                return `(n-${base})`;
                            }
                        },
                        
                    }],
                    yAxis: [{
                        min: 0,
                        title: {
                            text:''
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                        stackLabels: {
                            textAlign: 'center',
                            enabled: false,
                            borderRadius: 5,
                            backgroundColor: '#333333',
                            borderWidth: 1,
                            borderColor: '#AAA',
                            y: -15,
                            align: 'center',
                            style: {
                                fontWeight: 'bold',
                                fontSize:'13px',
                                // shadow: false,
                                color: '#FFFFFF',
                            }
                        }
                    }],

                    tooltip: {
                        shared: true,
                        split: false,
                        enabled: true,
                        headerFormat: '<b>{point.x}</b><br/>',
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}%</b> <br/>',
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        layout: 'vertical',
                        align: 'left',
                        verticalAlign: 'middle',
                        itemStyle: {
                            width: '100%',
                            fontSize: '0.6rem',
                            color: '#000000'
                        },
                    },
                    plotOptions: {
                        column: {
                            stacking: 'normal',

                        },
                        series: {
                            pointWidth: 56,
                            cursor: 'pointer',
                                style: {
                                    textOutline: false,
                                    fontSize : "14px"
                                },
                            dataLabels: {
                                style: {
                                    textOutline: false,
                                    fontSize: '0.6rem',
                                },

                                enabled: true,
                                style: {
                                    textOutline: false
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return (this.y) + '%';
                                    }
                                    
                                },
                            }
                        }
                    },
                    colors:colorPallet69,
                    series: data
                });
            }

            function stackcolumnChart2(data,id,cat,baseE,heightX)
            {
                //debugger;
                if(heightX==undefined)
                {
                    heightX = "auto";
                }
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        type: 'column',
                        height: heightX
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    xAxis: [{
                        visible: false, // Hides everything: labels, ticks, line
                        categories: cat,
                        labels: {
                            enabled: false // Not required if visible is false, but safe to include
                        }
                    }],
                    yAxis: [{
                        min: 0,
                        title: {
                            text:''
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                        stackLabels: {
                            textAlign: 'center',
                            enabled: false,
                            borderRadius: 5,
                            backgroundColor: '#333333',
                            borderWidth: 1,
                            borderColor: '#AAA',
                            y: -15,
                            align: 'center',
                            style: {
                                fontWeight: 'bold',
                                fontSize:'13px',
                                // shadow: false,
                                color: '#FFFFFF',
                            }
                        }
                    }],

                    tooltip: {
                        shared: true,
                        split: false,
                        enabled: true,
                        headerFormat: '<b>{point.x}</b><br/>',
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}%</b> <br/>',
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        layout: 'vertical',
                        align: 'left',
                        verticalAlign: 'middle',
                        itemStyle: {
                            width: '100%',
                            fontSize: '0.6rem',
                            color: '#000000'
                        },
                        enabled: false
                    },
                    plotOptions: {
                        column: {
                            stacking: 'normal',

                        },
                        series: {
                            pointWidth: 56,
                            cursor: 'pointer',
                                style: {
                                    textOutline: false,
                                    fontSize : "14px"
                                },
                            dataLabels: {
                                style: {
                                    textOutline: false,
                                    fontSize: '0.6rem',
                                },

                                enabled: true,
                                style: {
                                    textOutline: false
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return (this.y) + '%';
                                    }
                                    
                                },
                            }
                        }
                    },
                    colors:colorPallet99,
                    series: data
                });
            }

            function stackcolumnChart3(data,id,cat,baseE,colorXX)
            {
                debugger;
                Highcharts.chart(id, {
                    chart: {
                        style: {
                            fontFamily: "ARIAL"
                        },
                        "backgroundColor": "transparent",
                        type: 'column',
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    xAxis: [{
                        categories: cat,
                        labels: {
                            style: {
                                fontSize: '0.7rem',
                                color: '#000000'
                            },
                            rotation:0,
                            useHTML: true,
                            formatter: function(){
                                var index = this.pos;
                                var base = baseE[index];
                                return `n-${base}`;
                            }
                        },
                        
                    }],
                    yAxis: [{
                        min: 0,
                        title: {
                            text:''
                        },
                        gridLineWidth: 0,
                        minorGridLineWidth: 0,
                        alignTicks: false,
                        labels: {
                            enabled: false
                        },
                        stackLabels: {
                            textAlign: 'center',
                            enabled: false,
                            borderRadius: 5,
                            backgroundColor: '#333333',
                            borderWidth: 1,
                            borderColor: '#AAA',
                            y: -15,
                            align: 'center',
                            style: {
                                fontWeight: 'bold',
                                fontSize:'13px',
                                // shadow: false,
                                color: '#FFFFFF',
                            }
                        }
                    }],

                    tooltip: {
                        shared: true,
                        split: false,
                        enabled: true,
                        headerFormat: '<b>{point.x}</b><br/>',
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}%</b> <br/>',
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        layout: 'vertical',
                        align: 'left',
                        verticalAlign: 'middle',
                        width: 200, // Add or increase this for the overall legend box width
                        itemStyle: {
                            width: 180, // Increase this to prevent text clipping
                            fontSize: '0.6rem',
                            color: '#000000'
                        },
                        itemMarginBottom: 5 // Optional: adds spacing between items
                    },
                    plotOptions: {
                        column: {
                            stacking: 'normal',

                        },
                        series: {
                            pointWidth: 56,
                            cursor: 'pointer',
                                style: {
                                    textOutline: false,
                                    fontSize : "14px"
                                },
                            dataLabels: {
                                style: {
                                    textOutline: false,
                                    fontSize: '0.6rem',
                                },

                                enabled: true,
                                style: {
                                    textOutline: false
                                },
                                formatter: function() {
                                    if(this)
                                    {
                                        return (this.y) + '%';
                                    }
                                    
                                },
                            }
                        }
                    },
                    colors:colorXX,
                    series: data
                });
            }

            function heatChart(lucifer,id,cat2)
            {
                Highcharts.chart(id, {
                    chart: {
                        type: 'heatmap',
                        plotBorderWidth: 1
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    credits: {
                        enabled: false
                    },

                    xAxis: {
                       categories: ["JFM’25","AMJ’25","JAS’25","OND’25","JFM’26","AMJ’26","JAS’26","OND’26"],
                        labels: {
                            enabled: true,
                            style: {
                                fontSize: '10px',
                                color: '#000000'
                            },
                        }
                    },
                    // #70db70 - Green
                    yAxis: {
                        categories: cat2,
                        title: null,
                        reversed: true,
                        labels: {
                            enabled: true,
                            style: {
                                fontSize: '10px',
                                color: '#000000',
                            },
                        }
                    },

                    colorAxis: {
                        min: 0,
                        minColor: '#FFFFFF',
                        maxColor: '#6BC4FF'
                    },

                    legend: {
                        align: 'right',
                        layout: 'vertical',
                        margin: 0,
                        verticalAlign: 'top',
                        y: 25,
                        symbolHeight: 280,
                        enabled:false
                    },

                    tooltip: {
                        format: '<b>{series.xAxis.categories.(point.x)}</b><br>' +
                            '<b>{series.yAxis.categories.(point.y)} : {point.value}%</b>'
                    },

                    series: [{
                        name: 'Sales per employee',
                        borderColor: '#000000',
                        borderWidth: 1,
                        data: lucifer,
                        dataLabels: {
                            enabled: true,
                            color: '#000000',
                            style: {
                                textOutline: false,
                                fontSize : "0.85rem"
                            },
                            formatter: function () {
                                return this.point.value + '%';
                            }
                        }
                    }],

                    responsive: {
                        rules: [{
                            condition: {
                                maxWidth: 500
                            },
                            chartOptions: {
                                yAxis: {
                                    labels: {
                                        format: '{substr value 0 1}'
                                    }
                                }
                            }
                        }]
                    }

                });
            }

            function spiderChart(lucifer,id,catX)
            {
                Highcharts.chart(id, {
                    chart: {
                        polar: true,
                        type: 'line'
                    },
                    title: {
                        text: '',
                    },
                    navigation: {
                        buttonOptions: {
                            enabled: false
                        }
                    },
                    pane: {
                        size: '80%'
                    },
                    xAxis: {
                        categories: catX,
                        labels: {
                            style: {
                                fontSize: '10px',
                                color: '#000000'
                            },
                            rotation:0,
                            useHTML: true,
                            padding:15,
                            height:10,
                            width:10,
                        },
                        tickmarkPlacement: 'on',
                        lineWidth: 0
                    },
                    yAxis: {
                        gridLineInterpolation: 'polygon',
                        lineWidth: 0,
                        min: 0,
                        labels: {
                            enabled: false
                        }
                    },

                    tooltip: {
                        shared: true,
                        split: false,
                        enabled: true,
                        pointFormat: '<span style="color:{point.color}">\u25CF</span> <b>{point.y}%</b> <br/>',
                    },
                    credits: {
                        enabled: false
                    },
                    legend: {
                        enabled: false,
                        layout: 'horizontal',
                        align: 'center',
                        verticalAlign: 'bottom',
                        itemStyle: {
                            width: '100%',
                            fontSize: "0.6rem",
                            color: '#000000'
                        },
                        backgroundColor: Highcharts.defaultOptions.legend.backgroundColor || // theme
                            '#fff'
                    },
                    series: [{
                        name: 'Category Consumed',
                        data: lucifer,
                        color: "#2A3EB3",
                        pointPlacement: 'on',
                        dataLabels: {
                            enabled: true,
                            align: 'center',  // Align horizontally
                            verticalAlign: 'bottom',  // Align vertically
                            distance: 10,  // Distance from the point
                            
                            style: {
                                fontSize: '12px',
                                fontWeight: 'bold'
                            },
                            formatter: function() {
                                return this.y > 0 ? this.y.toFixed(0) + '%' : null;
                            },

                        }
                    }]
                });
            }
            //=================================Chart END============================================

            function exportExcelFlag()
            {
                $(".hidekro").each(function(){
                    $(this).show();
                });
                const additionalRow = [[`${filtercondX}`],[`Sample Size:${overallBase}`]];
                let workbook = XLSX.utils.book_new(); // Initialize the workbook outside the loop
                //console.log("classArr");
                //console.log(classArr);
                classArr.forEach(function(ele, ind) {
                    const sheetName = innerTabE[ind];
                    const tables = document.getElementsByClassName(ele);
                    // Initialize an array to store data from all tables
                    let allTablesData = [];

                    // Loop through each table
                    for (let i = 0; i < tables.length; i++) {
                        const table = tables[i];
                        const ws = XLSX.utils.table_to_sheet(table, { raw: true });

                        // Append data from current table to allTablesData
                        allTablesData.push(XLSX.utils.sheet_to_json(ws, { header: 1 }));
                    }

                    // Calculate the total column count for all tables
                    let totalColCount = 0;
                    for (let i = 0; i < allTablesData.length; i++) {
                        const tableData = allTablesData[i];
                        const tableColCount = getColumnCount(tableData);
                        totalColCount = Math.max(totalColCount, tableColCount);
                    }

                    // Add an empty row between each table's data
                    for (let i = 0; i < allTablesData.length - 1; i++) {
                        allTablesData[i].push([]);
                    }

                    // Merge data from all tables into one array
                    let mergedData = [];
                    for (let i = 0; i < allTablesData.length; i++) {
                        mergedData = mergedData.concat(allTablesData[i]);
                    }
                    mergedData = additionalRow.concat(mergedData);
                    // Merge cells for the first row of each table
                    const merges = [];
                    let rowIndex = 0;
                    for (let i = 0; i < allTablesData.length; i++) {
                        const tableData = allTablesData[i];
                        const rowCount = tableData.length;
                        merges.push({
                            s: { r: rowIndex, c: 0 },
                            e: { r: rowIndex, c: totalColCount - 1 }
                        });
                        rowIndex += rowCount;
                    }

                    // Convert merged data back to a worksheet
                    const mergedSheet = XLSX.utils.aoa_to_sheet(mergedData);

                    // Add merges to the mergedSheet
                    mergedSheet["!merges"] = merges;

                    // Set column widths if needed
                    mergedSheet['!cols'] = [{ width: 60 }, { width: 20 }, { width: 20 }, { width: 20 }];

                    XLSX.utils.book_append_sheet(workbook, mergedSheet, `${sheetName}`);
                });

                XLSX.writeFile(workbook, "US Dairy Dashboard Data.xlsx");

                $(".hidekro").each(function(){
                    $(this).hide();
                });

                // Function to get the number of columns in a table
                function getColumnCount(ws) {
                    let maxCol = 0;
                    for (const cellRange in ws) {
                        const colIndex = XLSX.utils.decode_cell(cellRange).c;
                        maxCol = Math.max(maxCol, colIndex);
                    }
                    return maxCol + 1; // Since column indices start from 0
                }
            }
			
			
			/* ppt export  */
function exportPptFlag()
{
    var data=trends1Data;
            
    let pptx = new PptxGenJS();   
    let slide = pptx.addSlide();  // slide number - 1
    let slide2 = pptx.addSlide();  // slide number - 2
    let slide21 = pptx.addSlide();  // slide number - 3
	let slide3 = pptx.addSlide();  // slide number - 4
	let slide4 = pptx.addSlide();  // slide number - 5
	let slide5 = pptx.addSlide();  // slide number - 6
	let slide6 = pptx.addSlide();  // slide number - 7
	let slide7 = pptx.addSlide();  // slide number - 8
	let slide8 = pptx.addSlide();  // slide number - 9
	let slide9 = pptx.addSlide();  // slide number - 10
	let slide10 = pptx.addSlide();  // slide number - 11
	let slide11 = pptx.addSlide();  // slide number - 12
    let slide12 = pptx.addSlide();  // slide number - 13
    let slide22 = pptx.addSlide();  // slide number - 14
    let slide23 = pptx.addSlide();  // slide number - 15
    // let slide13 = pptx.addSlide();  // slide number - 16
    let slide14 = pptx.addSlide();  // slide number - 17 // slide number - 16
    let slide15 = pptx.addSlide();  // slide number - 18 // slide number - 17
    let slide16 = pptx.addSlide();  // slide number - 19  // slide number - 18
    let slide17 = pptx.addSlide();  // slide number - 20 // slide number - 19
    let slide18 = pptx.addSlide();  // slide number - 21  // slide number - 20
    let slide19 = pptx.addSlide();  // slide number - 22 // slide number - 21
    let slide20 = pptx.addSlide();  // slide number - 23  // slide number - 22


     /* function sortSEAAndAlignwithoutColor(data) {
        // Create array of indices sorted by SEA values descending
        const sortedIndices = data['Southeast Asia']
            .map((value, index) => ({ value, index }))
            .sort((a, b) => b.value - a.value)
            .map(item => item.index);

        // Create new object with sorted arrays based on sortedIndices
        const sortedData = {};
        for (const key in data) {
            sortedData[key] = sortedIndices.map(i => data[key][i]);
        }

        return sortedData;
    } */
 

    function sortSEAAndAlignwithoutColor(data, labels) {
        // Step 1: Get sorted indices based on SEA values (descending)
        const sortedIndices = data['Southeast Asia']
            .map((value, index) => ({ value, index }))
            .sort((a, b) => b.value - a.value)
            .map(item => item.index);

        // Step 2: Sort all data arrays using sortedIndices
        const sortedData = {};
        for (const key in data) {
            sortedData[key] = sortedIndices.map(i => data[key][i]);
        }

        // Step 3: Sort the labels using the same indices
        const sortedLabels = sortedIndices.map(i => labels[i]);

        // Step 4: Return both
        return { sortedData, sortedLabels };
    }


    function sortSEAAndAlign(data) {
    const BLUE = "4D6893";
    const GREEN = "7C985E";

    // Step 1: Sort SEA values in descending order and get sorted indices
    const sortedIndices = data['Southeast Asia']
        .map((value, index) => ({ value, index }))
        .sort((a, b) => b.value - a.value)
        .map(item => item.index);

    const sortedData = {};

    // Step 2: For each key, reorder values and assign colors
    for (const key in data) {
        const sortedValues = sortedIndices.map(i => data[key][i]);

        // Find the top 4 values for the current country
        const topFourValues = [...sortedValues]
            .sort((a, b) => b - a)
            .slice(0, 4);

        // Assign colors based on whether the value is in the top 4
        let remainingTop = [...topFourValues]; // copy to handle duplicates correctly
        const colorArray = sortedValues.map(value => {
            const index = remainingTop.indexOf(value);
            if (index !== -1) {
                remainingTop.splice(index, 1); // ensure only top 4 get blue
                return BLUE;
            }
            return GREEN;
        });

        sortedData[key] = sortedValues;
        sortedData[`${key}_color`] = colorArray;
    }

    return sortedData;
}

	
	
	// Slide1 Consumption Funnel
    let topHead = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let rightSubHead = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    
    let country1 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
	
    let left_legend1 = { x: 0.01, y: 1.87, w: 1.10, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend2 = { x: 0.007, y: 2.41, w: 1.10, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend3 = { x: 0.007, y: 2.89, w: 1.10, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend4 = { x: 0.007, y: 3.41, w: 1.10, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
	
    let fTextOne = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 6, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fTextTwo = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 6, italic: true, fontFace: "Arial", bold: false, color: '969696' };

    let rect1 = { x: 1.16, y: 1.87, w: 0.64, h: 0.39, fill: 'd6e6fd' };
    let rectText1 = { x: 1.16, y: 1.87, w: 0.64, h: 0.39, align: 'center', fontSize: 7, fontFace: "Arial", bold: true, color: '000000' };
	
    let rect2 = { x: 1.21, y: 2.38, w: 0.56, h: 0.39, fill: '71a7ff', line: { color: '71a7ff' } };
    let rectText2 = { x: 1.21, y: 2.38, w: 0.56, h: 0.39, align: 'center', fontSize: 7, fontFace: "Arial", bold: true, color: 'ffffff' };
	
    let rect3 = { x: 1.25, y: 2.86, w: 0.49, h: 0.39, fill: '156eff', line: { color: '156eff' } };
    let rectText3 = { x: 1.25, y: 2.86, w: 0.49, h: 0.39, align: 'center', fontSize: 7, bold: true, fontFace: "Arial", color: 'ffffff' };
	
    let rect4 = { x: 1.29, y: 3.37, w: 0.41, h: 0.39, fill: '0046b8', line: { color: '0046b8' } };
    let rectText4 = { x: 1.29, y: 3.37, w: 0.41, h: 0.39, align: 'center', fontSize: 7, bold: true, fontFace: "Arial", color: 'ffffff' };

    let countryBase = {x: 1.13,y: 3.74,w: 0.72,h: 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};
	
    let tableBase = {"x": 7.85,"y": 3.83,"w": 0.67,"h": 0.11,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1 = {"x": 8.00,"y": 5.21,"w": 0.54,"h": 0.28};
    let logo2 = {"x": 8.70,"y": 5.22,"w": 0.80,"h": 0.24};

    var DairycountryLevel = data['ConsumptionCountry'];
    var DairyquarterLevel = data['ConsumptionQuarter'];
                        
    var DairyfinalTrendData = [];
    var DairyfinalTrendDataX = [];

    var Q1 = DairyquarterLevel["Q1'25"];
    var Q2 = DairyquarterLevel["Q2'25"];
    /* const Dairyquarterq1= Q1.map(item => item.percentage);
    const Dairyquarterq2= Q2.map(item => item.percentage);
    const sigDairyquarterq1= Q1.map(item => item.percentage2);
    const sigDairyquarterq2= Q2.map(item => item.percentage2); */
    
    var DairybaseData = [Q1.ever[0].bCount, Q2.ever[0].bCount];
    var DairyeverData = [Q1.ever[0].percentage, Q2.ever[0].percentage, Q1.ever[0].percentage2, Q2.ever[0].percentage2];
    var Dairyconsumed1YData = [Q1.consumed1Y[0].percentage, Q2.consumed1Y[0].percentage, Q1.consumed1Y[0].percentage2, Q2.consumed1Y[0].percentage2];
    var Dairyconsumed3MData = [Q1.consumed3M[0].percentage, Q2.consumed3M[0].percentage, Q1.consumed3M[0].percentage2, Q2.consumed3M[0].percentage2];
    var Dairyconsumed7DData = [Q1.consumed7D[0].percentage, Q2.consumed7D[0].percentage, Q1.consumed7D[0].percentage2, Q2.consumed7D[0].percentage2];
            
    DairyfinalTrendData.push(DairyeverData);
    DairyfinalTrendData.push(Dairyconsumed1YData);
    DairyfinalTrendData.push(Dairyconsumed3MData);
    DairyfinalTrendData.push(Dairyconsumed7DData);
    
    var DairyeverDataCountry = [];
    var Dairyconsumed1YDataCountry = [];
    var Dairyconsumed3MDataCountry = [];
    var Dairyconsumed7DDataCountry = [];

    const DairycountryData = {};

    countryLabel4.forEach(country => {
        if (DairycountryLevel[country]) {
            DairycountryData[country] = DairycountryLevel[country];
        }
    });

    for (let country in DairycountryData) {
        DairyeverDataCountry.push(DairycountryData[country].ever[0].percentage);
        Dairyconsumed1YDataCountry.push(DairycountryData[country].consumed1Y[0].percentage);
        Dairyconsumed3MDataCountry.push(DairycountryData[country].consumed3M[0].percentage);
        Dairyconsumed7DDataCountry.push(DairycountryData[country].consumed7D[0].percentage);
    }

    const DairybCounts = {};
    const Dairycountries = Object.keys(DairycountryData);

    Dairycountries.forEach((country, index) => {
        DairybCounts[index] = DairycountryLevel[country].ever[0].bCount;
    });

    const DairyflatArray = Object.values(DairybCounts);
    const ConsumptionFunnelArray = [{
        title: "Consumption Funnel",
        subtitle: "Dairy Milk (Flavored & Unflavored)",
        subtitle1: "Half Yearly (H1’25)",
        subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
        countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
        
        ever:DairyeverDataCountry,
        consumed1:Dairyconsumed1YDataCountry,
        consumed3:Dairyconsumed3MDataCountry,
        consumed7:Dairyconsumed7DDataCountry,
        
        funnel: ["","Ever Tried","Consumed in Past 12 Months","Consumed in Past 3 Months","Consumed in Past 7 Days"],
        sampleSizes:DairyflatArray,
        bottom1:"S11. In the past 7 days, have you personally consumed < CATEGORY > at home, at a restaurant, during travel or anywhere else?",
        bottom2:"S12. When was the last time you had < CATEGORY CODED ‘NO’ and ‘DON’T REMEMBER’ IN S11>? It could be at home, at a restaurant, during travel or anywhere else?",
        
        btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
        tblB:[DairybaseData[0],DairybaseData[1]],
        table: [
        ["","Q1'25", "Q2'25"],
        [consumptionLabel[0],DairyeverData[0]+'%', DairyeverData[1]+'%'],
        [consumptionLabel[1],Dairyconsumed1YData[0]+'%',Dairyconsumed1YData[1]+'%'],
        [consumptionLabel[2],Dairyconsumed3MData[0]+'%', Dairyconsumed3MData[1]+'%'],
        [consumptionLabel[3],Dairyconsumed7DData[0]+'%', Dairyconsumed7DData[1]+'%'],
        ],
        table2: [
        
        [DairyeverData[2], DairyeverData[3]],
        [Dairyconsumed1YData[2], Dairyconsumed1YData[3]],
        [Dairyconsumed3MData[2], Dairyconsumed3MData[3]],
        [Dairyconsumed7DData[2], Dairyconsumed7DData[3]],
        ]
    }];

    ConsumptionFunnelArray.forEach(slideData => {
        slide.addText(slideData.title,topHead);
        slide.addText(slideData.subtitle,subHead);
        slide.addText(slideData.subtitle1, leftHead);
        slide.addText("Base – All Respondents",leftSubHead);
		slide.addText(slideData.subtitle3,rightHead);
        slide.addText("Base – All Respondents",rightSubHead);
        
        slide.addShape(pptx.ShapeType.line, { x:0.16,y:1.02,w:6.51,h:0,line:{color:'75b1bb',width:1.2} });
        slide.addShape(pptx.ShapeType.line, { x:6.83,y:1.02,w:2.46,h:0,line:{color:'75b1bb',width:1.2} });
		
        slide.addText(slideData.countries[0],country1);
        slide.addText(slideData.countries[1],country2);
        slide.addText(slideData.countries[2],country3);
        slide.addText(slideData.countries[3],country4);
        slide.addText(slideData.countries[4],country5);
        slide.addText(slideData.countries[5],country6);
        slide.addText(slideData.countries[6],country7);

        slide.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
        slide.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
        slide.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
        slide.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
        slide.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
        slide.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

        slide.addText(slideData.funnel[1],left_legend1);
        slide.addText(slideData.funnel[2],left_legend2);
        slide.addText(slideData.funnel[3],left_legend3);
        slide.addText(slideData.funnel[4],left_legend4);



        // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_1 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_1.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_1 = [];
        slideMerged_1.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_1[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_1.push(newRow);
        }

        //console.log("abc",slideMerged_1);


        
        // <==================================|Significance Testing|==================================>slide12.addTable(countryTable


        

        // Column 1
            var x1_c1 = 1.16;
            var w1_c1 = ((slideData.ever[0]/10)/3)/5;
            var w1_c2 = ((slideData.consumed1[0]/10)/3)/5;
            var w1_c3 = ((slideData.consumed3[0]/10)/3)/5;
            var w1_c4 = ((slideData.consumed7[0]/10)/3)/5;
            var center_c1 = x1_c1 + (w1_c1/2);

            var x1_c1 = center_c1-(w1_c1/2);
            var x1_c2 = center_c1-(w1_c2/2);
            var x1_c3 = center_c1-(w1_c3/2);
            var x1_c4 = center_c1-(w1_c4/2);
        // Column 1

        // Column 2
            var x2_c1 = 1.96;
            var w2_c1 = ((slideData.ever[1]/10)/3)/5;
            var w2_c2 = ((slideData.consumed1[1]/10)/3)/5;
            var w2_c3 = ((slideData.consumed3[1]/10)/3)/5;
            var w2_c4 = ((slideData.consumed7[1]/10)/3)/5;
            var center_c2 = x2_c1 + (w2_c1/2);

            var x2_c1 = center_c2-(w2_c1/2);
            var x2_c2 = center_c2-(w2_c2/2);
            var x2_c3 = center_c2-(w2_c3/2);
            var x2_c4 = center_c2-(w2_c4/2);
        // Column 2

        // Column 3
            var x3_c1 = 2.79;
            var w3_c1 = ((slideData.ever[2]/10)/3)/5;
            var w3_c2 = ((slideData.consumed1[2]/10)/3)/5;
            var w3_c3 = ((slideData.consumed3[2]/10)/3)/5;
            var w3_c4 = ((slideData.consumed7[2]/10)/3)/5;
            var center_c3 = x3_c1 + (w3_c1/2);

            var x3_c1 = center_c3-(w3_c1/2);
            var x3_c2 = center_c3-(w3_c2/2);
            var x3_c3 = center_c3-(w3_c3/2);
            var x3_c4 = center_c3-(w3_c4/2);
        // Column 3

        // Column 4
            var x4_c1 = 3.60;
            var w4_c1 = ((slideData.ever[3]/10)/3)/5;
            var w4_c2 = ((slideData.consumed1[3]/10)/3)/5;
            var w4_c3 = ((slideData.consumed3[3]/10)/3)/5;
            var w4_c4 = ((slideData.consumed7[3]/10)/3)/5;
            var center_c4 = x4_c1 + (w4_c1/2);

            var x4_c1 = center_c4-(w4_c1/2);
            var x4_c2 = center_c4-(w4_c2/2);
            var x4_c3 = center_c4-(w4_c3/2);
            var x4_c4 = center_c4-(w4_c4/2);
        // Column 4

        // Column 5
            var x5_c1 = 4.41;
            var w5_c1 = ((slideData.ever[4]/10)/3)/5;
            var w5_c2 = ((slideData.consumed1[4]/10)/3)/5;
            var w5_c3 = ((slideData.consumed3[4]/10)/3)/5;
            var w5_c4 = ((slideData.consumed7[4]/10)/3)/5;
            var center_c5 = x5_c1 + (w5_c1/2);

            var x5_c1 = center_c5-(w5_c1/2);
            var x5_c2 = center_c5-(w5_c2/2);
            var x5_c3 = center_c5-(w5_c3/2);
            var x5_c4 = center_c5-(w5_c4/2);
        // Column 5

        // Column 6
            var x6_c1 = 5.19;
            var w6_c1 = ((slideData.ever[5]/10)/3)/5;
            var w6_c2 = ((slideData.consumed1[5]/10)/3)/5;
            var w6_c3 = ((slideData.consumed3[5]/10)/3)/5;
            var w6_c4 = ((slideData.consumed7[5]/10)/3)/5;
            var center_c6 = x6_c1 + (w6_c1/2);

            var x6_c1 = center_c6-(w6_c1/2);
            var x6_c2 = center_c6-(w6_c2/2);
            var x6_c3 = center_c6-(w6_c3/2);
            var x6_c4 = center_c6-(w6_c4/2);
        // Column 6

        // Column 7
            var x7_c1 = 5.96;
            var w7_c1 = ((slideData.ever[6]/10)/3)/5;
            var w7_c2 = ((slideData.consumed1[6]/10)/3)/5;
            var w7_c3 = ((slideData.consumed3[6]/10)/3)/5;
            var w7_c4 = ((slideData.consumed7[6]/10)/3)/5;
            var center_c7 = x7_c1 + (w7_c1/2);

            var x7_c1 = center_c7-(w7_c1/2);
            var x7_c2 = center_c7-(w7_c2/2);
            var x7_c3 = center_c7-(w7_c3/2);
            var x7_c4 = center_c7-(w7_c4/2);
        // Column 7

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w1_c1,x: x1_c1});
        slide.addText(slideData.ever[0]+'%',{...rectText1,w: w1_c1,x: x1_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w1_c2,x: x1_c2});
        slide.addText(slideData.consumed1[0]+'%',{...rectText2,w: w1_c2,x: x1_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w1_c3,x: x1_c3});
        slide.addText(slideData.consumed3[0]+'%',{...rectText3,w: w1_c3,x: x1_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w1_c4,x: x1_c4});
        slide.addText(slideData.consumed7[0]+'%',{...rectText4,w: w1_c4,x: x1_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w2_c1,x: x2_c1});
        slide.addText(slideData.ever[1]+'%',{...rectText1,w: w2_c1,x: x2_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w2_c2,x: x2_c2});
        slide.addText(slideData.consumed1[1]+'%',{...rectText2,w: w2_c2,x: x2_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w2_c3,x: x2_c3});
        slide.addText(slideData.consumed3[1]+'%',{...rectText3,w: w2_c3,x: x2_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w2_c4,x: x2_c4});
        slide.addText(slideData.consumed7[1]+'%',{...rectText4,w: w2_c4,x: x2_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w3_c1,x: x3_c1});
        slide.addText(slideData.ever[2]+'%',{...rectText1,w: w3_c1,x: x3_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w3_c2,x: x3_c2});
        slide.addText(slideData.consumed1[2]+'%',{...rectText2,w: w3_c2,x: x3_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w3_c3,x: x3_c3});
        slide.addText(slideData.consumed3[2]+'%',{...rectText3,w: w3_c3,x: x3_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w3_c4,x: x3_c4});
        slide.addText(slideData.consumed7[2]+'%',{...rectText4,w: w3_c4,x: x3_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w4_c1,x: x4_c1});
        slide.addText(slideData.ever[3]+'%',{...rectText1,w: w4_c1,x: x4_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w4_c2,x: x4_c2});
        slide.addText(slideData.consumed1[3]+'%',{...rectText2,w: w4_c2,x: x4_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w4_c3,x: x4_c3});
        slide.addText(slideData.consumed3[3]+'%',{...rectText3,w: w4_c3,x: x4_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w4_c4,x: x4_c4});
        slide.addText(slideData.consumed7[3]+'%',{...rectText4,w: w4_c4,x: x4_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w5_c1,x: x5_c1});
        slide.addText(slideData.ever[4]+'%',{...rectText1,w: w5_c1,x: x5_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w5_c2,x: x5_c2});
        slide.addText(slideData.consumed1[4]+'%',{...rectText2,w: w5_c2,x: x5_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w5_c3,x: x5_c3});
        slide.addText(slideData.consumed3[4]+'%',{...rectText3,w: w5_c3,x: x5_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w5_c4,x: x5_c4});
        slide.addText(slideData.consumed7[4]+'%',{...rectText4,w: w5_c4,x: x5_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w6_c1,x: x6_c1});
        slide.addText(slideData.ever[5]+'%',{...rectText1,w: w6_c1,x: x6_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w6_c2,x: x6_c2});
        slide.addText(slideData.consumed1[5]+'%',{...rectText2,w: w6_c2,x: x6_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,w: w6_c3,x: x6_c3});
        slide.addText(slideData.consumed3[5]+'%',{...rectText3,w: w6_c3,x: x6_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,w: w6_c4,x: x6_c4});
        slide.addText(slideData.consumed7[5]+'%',{...rectText4,w: w6_c4,x: x6_c4});

        slide.addShape(pptx.ShapeType.rect,{...rect1,w: w7_c1,x: x7_c1});
        slide.addText(slideData.ever[6]+'%',{...rectText1,w: w7_c1,x: x7_c1});
        
        slide.addShape(pptx.ShapeType.rect,{...rect2,w: w7_c2,x: x7_c2});
        slide.addText(slideData.consumed1[6]+'%',{...rectText2,w: w7_c2,x: x7_c2});
        
        slide.addShape(pptx.ShapeType.rect,{...rect3,x: 6.05,w: w7_c3,x: x7_c3});
        slide.addText(slideData.consumed3[6]+'%',{...rectText3,x: 6.05,w: w7_c3,x: x7_c3});
        
        slide.addShape(pptx.ShapeType.rect,{...rect4,x: 6.08,w: w7_c4,x: x7_c4});
        slide.addText(slideData.consumed7[6]+'%',{...rectText4,x: 6.08,w: w7_c4,x: x7_c4});

        slide.addShape(pptx.ShapeType.line, {x: 0.28,y:2.31,w:6.38,h:0,line:{ color:'e0e0e0', width: 1 } });
        slide.addShape(pptx.ShapeType.line, {x: 0.28,y:2.82,w:6.38,h:0,line:{ color:'e0e0e0', width: 1 } });
        slide.addShape(pptx.ShapeType.line, {x: 0.28,y:3.31,w:6.38,h:0,line:{ color:'e0e0e0', width: 1 } });
        slide.addShape(pptx.ShapeType.line, {x: 0.28,y:3.80,w:6.38,h:0,line:{ color:'e0e0e0', width: 1 } });

        slide.addText("n-"+slideData.sampleSizes[0],countryBase);
        slide.addText("n-"+slideData.sampleSizes[1],{...countryBase,x: 1.91});
        slide.addText("n-"+slideData.sampleSizes[2],{...countryBase,x: 2.74});
        slide.addText("n-"+slideData.sampleSizes[3],{...countryBase,x: 3.55});
        slide.addText("n-"+slideData.sampleSizes[4],{...countryBase,x: 4.35});
        slide.addText("n-"+slideData.sampleSizes[5],{...countryBase,x: 5.14});
        slide.addText("n-"+slideData.sampleSizes[6],{...countryBase,x: 5.91});

        slide.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });


        let tableRows = slideMerged_1.map((row, rowIndex, allRows) =>
            row.map(cell => ({
                text: cell,
                    options: {
                        border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                        ? [false, false, false, false] // No border for first and last row
                        : [false, false, true, false], // Bottom border only
                        borderColor: 'e0e0e0',
                        borderSize: 0.5,
                        fontSize: 8,
                        align: 'center',
                        valign: 'middle',
                    }
            }))
        );

        slide.addTable(tableRows, {"x": 6.83,"y": 1.33,"w": 2.76,"h": 2.46});
		
        slide.addText("n-"+slideData.tblB[0],tableBase);
        slide.addText("n-"+slideData.tblB[1],{...tableBase,x: 8.82});

        slide.addText([
            { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
            { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
            { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
        ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

        slide.addImage({...logo1,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});
        slide.addImage({...logo2,path: "https://keresearch.in/mdynata/assets/images/strategic.png"});
        slide.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width: 1,dashType: 'dash'}});

        slide.addText(slideData.bottom1,fTextOne);
        slide.addText(slideData.bottom2,fTextTwo);
    });	
        
   
   // Slide 2 Frequency of Consumption
	
    let topHead_2 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_2 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_2 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_2 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_2 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let rightSubHead_2 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    
    let country1_2 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_2 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_2 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_2 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_2 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_2 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_2 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
	
    let left_legend1_2 = { x: 0.01, y: 1.87, w: 1.34, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend2_2 = { x: 0.007, y: 2.41, w: 1.34, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend3_2 = { x: 0.007, y: 2.89, w: 1.34, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
    let left_legend4_2 = { x: 0.007, y: 3.41, w: 1.34, h: 0.43, fontSize: 6, fontFace: "Arial", bold: false, color: '000000' };
	
    let fTextOne_2 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 6, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fTextTwo_2 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 6, italic: true, fontFace: "Arial", bold: false, color: '969696' };

    let tableBase_2 = {"x": 7.88,"y": 4.35,"w": 0.67,"h": 0.11,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_2 = {"x": 8.00,"y": 5.21,"w": 0.54,"h": 0.28};
    let logo2_2 = {"x": 8.70,"y": 5.22,"w": 0.80,"h": 0.24};

	let opts12_2 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_2 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_2 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_2 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_2 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 6, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_2 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 6, italic: true, fontFace: "Arial", bold: false, color: '969696' };

	let stackChart = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['f2ad61','6D8A42','C6E48B','70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
	var frequencyconsumptioncountryLevel = data['S13_3Country'];
    var frequencyconsumptionquarterLevel = data['S13_3Quarter'];
    var frequencyconsumptionopt= S13label2;
    var Q1 = frequencyconsumptionquarterLevel["Q1'25"];
    var Q2 = frequencyconsumptionquarterLevel["Q2'25"];
    const frequencyconsumptionq1= Q1.map(item => item.percentage);
    const frequencyconsumptionq2= Q2.map(item => item.percentage);
    const sigfrequencyconsumptionq1= Q1.map(item => item.percentage2);
    const sigfrequencyconsumptionq2= Q2.map(item => item.percentage2);
    var frequencyconsumptionbaseData = [Q1[0].bCount, Q2[0].bCount];
    const frequencycountryData = {};
    const frequencyconsumption1 = [];
    const frequencyconsumption2 = [];
    const frequencyconsumption3 = [];
    const frequencyconsumption4 = [];
    const frequencyconsumption5 = [];
    const frequencyconsumptionbaseArray = [];

    countryLabel4.forEach(country => {
        if (frequencyconsumptioncountryLevel[country]) {
            frequencycountryData[country] = frequencyconsumptioncountryLevel[country];
        }
    });
            
    for (const country in frequencycountryData) {
        const countryData = frequencycountryData[country];
        frequencyconsumptionbaseArray.push(`n-${countryData[0].bCount}`);
        frequencyconsumption1.push(countryData[0].percentage);
        frequencyconsumption2.push(countryData[1].percentage);
        frequencyconsumption3.push(countryData[2].percentage);
        frequencyconsumption4.push(countryData[3].percentage);
        frequencyconsumption5.push(countryData[4].percentage);
    }

    const frequencyconsumptionArray = [{
        title: "Frequency of Consumption",
        subtitle: "Dairy Milk (Flavored & Unflavored)",
        subtitle1: "Half Yearly (H1’25)",
        subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
        countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
        funnel: frequencyconsumptionopt,
        f:[frequencyconsumption1,frequencyconsumption2,frequencyconsumption3,frequencyconsumption4,frequencyconsumption5],
        sampleSizes:frequencyconsumptionbaseArray,
        bottom1:"S13. You said you have had < CATEGORY >? recently. How often do you usually have?",
        bottom2:"",
        btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
        tblB:[frequencyconsumptionbaseData[0],frequencyconsumptionbaseData[1]],
        table: [
            ["","Q1'25", "Q2'25"],
            [frequencyconsumptionopt[0],frequencyconsumptionq1[0]+'%', frequencyconsumptionq2[0]+'%'],
            [frequencyconsumptionopt[1],frequencyconsumptionq1[1]+'%',frequencyconsumptionq2[1]+'%'],
            [frequencyconsumptionopt[2],frequencyconsumptionq1[2]+'%',frequencyconsumptionq2[2]+'%'],
            [frequencyconsumptionopt[3],frequencyconsumptionq1[3]+'%',frequencyconsumptionq2[3]+'%'],
            [frequencyconsumptionopt[4],frequencyconsumptionq1[4]+'%',frequencyconsumptionq2[4]+'%'],
        ],
        table2: [
            [sigfrequencyconsumptionq1[0],sigfrequencyconsumptionq2[0]],
            [sigfrequencyconsumptionq1[1],sigfrequencyconsumptionq2[1]],
            [sigfrequencyconsumptionq1[2],sigfrequencyconsumptionq2[2]],
            [sigfrequencyconsumptionq1[3],sigfrequencyconsumptionq2[3]],
            [sigfrequencyconsumptionq1[4],sigfrequencyconsumptionq2[4]]
        ],
    }];

    frequencyconsumptionArray.forEach(slideData => {
        // Headings and Subheadings
        slide2.addText(slideData.title, topHead_2);
        slide2.addText(slideData.subtitle, subHead_2);
        slide2.addText(slideData.subtitle1, leftHead_2);
        slide2.addText("Base – Those who consumed in Past 3 months", leftSubHead_2);
        slide2.addText("Base – Those who consumed in Past 3 months", rightSubHead_2);
        slide2.addText(slideData.subtitle3, rightHead_2);

        // Horizontal top lines
        slide2.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
        slide2.addShape(pptx.ShapeType.line, { x: 6.83, y: 1.02, w: 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });

        // Country labels
        slide2.addText(slideData.countries[0], country1);
        slide2.addText(slideData.countries[1], country2);
        slide2.addText(slideData.countries[2], country3);
        slide2.addText(slideData.countries[3], country4);
        slide2.addText(slideData.countries[4], country5);
        slide2.addText(slideData.countries[5], country6);
        slide2.addText(slideData.countries[6], country7);

        // Country flags (starting from index 1)
        slide2.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
        slide2.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
        slide2.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
        slide2.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
        slide2.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
        slide2.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });


        // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var frequencyconsumptionsignificance = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            frequencyconsumptionsignificance.push(significantResults);
            // console.log("c", significantResults);
        });

        var frequencyconsumptionMerged = [];
        frequencyconsumptionMerged.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = frequencyconsumptionsignificance[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            frequencyconsumptionMerged.push(newRow);
        }

        console.log("abc",frequencyconsumptionMerged);


        
        // <==================================|Significance Testing|==================================>


        // Chart data
        const colors = ['ffffff', 'ffffff','000000','ffffff','ffffff'];
        const chartData = slideData.f.slice().reverse().map((freq, i) => ({
            name: slideData.funnel[slideData.f.length - 1 - i],
            labels: slideData.sampleSizes,
            values: freq,
            dataLabelColor: colors[i]
        }));
        //console.log("chartData")
        //console.log(chartData)
        slide2.addChart(pptx.charts.BAR, chartData, stackChart);
        // Legends
        const legendItems = [
            { color: '3A5A81', text: 'Everyday' },
            { color: '70A6FF', text: '2-3 times a week' },
            { color: 'C6E48B', text: 'Once a week' },
            { color: '6D8A42', text: 'Once every 2 weeks/ once a month' },
            { color: 'f2ad61', text: 'Once every 2-3 months or less often' }
        ];

        legendItems.forEach((item, index) => {
            slide2.addShape(pptx.ShapeType.rect, {
                x: 0.2,
                y: 2.2 + index * 0.5,
                w: 0.06,
                h: 0.06,
                fill: { color: item.color },
                line: { color: 'FFFFFF' }
            });

            slide2.addText(item.text, {
                x: 0.3,
                y: 2.2 + index * 0.5,
                fontSize: 6,
                w: 1,
                color: '000000',
                fontFace: 'Arial'
            });
        });

        // Line below chart
        slide2.addShape(pptx.ShapeType.line, {
            x: 0.28,
            y: 5.06,
            w: 9.72,
            h: 0,
            line: { color: '75b1bb', width: 1.2 }
        });

        // Table
        // const tableRows2 = slideData.table.map((row, rowIndex, allRows) =>
        const tableRows2 = frequencyconsumptionMerged.map((row, rowIndex, allRows) =>
            row.map(cell => ({
                text: cell,
                options: {
                    border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                        ? [false, false, false, false]
                        : [false, false, true, false],
                    borderColor: 'e0e0e0',
                    borderSize: 0.5,
                    fontSize: 8,
                    align: 'center',
                    valign: 'middle'
                }
            }))
        );

        slide2.addTable(tableRows2, {
            "x": 6.83,"y": 1.46,"w": 2.76,"h": 2.83
        });

        // Table Base
        slide2.addText("n-" + slideData.tblB[0], tableBase_2);
        slide2.addText("n-" + slideData.tblB[1], { ...tableBase_2, x: 8.81 });

        // Bottom footer texts
        slide2.addText([
            { text: slideData.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
            { text: slideData.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6 } },
            { text: slideData.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6 } },
            { text: slideData.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
            { text: slideData.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
            { text: slideData.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } }
        ], {
            x: 8.07,
            y: 4.84,
            w: 1.83,
            h: 0.30
        });

        // Logo
        slide2.addImage({...logo1_2,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});
        slide2.addImage({...logo2_2,path: "https://keresearch.in/mdynata/assets/images/strategic.png"});

        // Vertical separator line
        slide2.addShape(pptx.ShapeType.line, {
            x: 6.74,
            y: 0.96,
            w: 0.00,
            h: 4.09,
            line: { color: '969696', width: 1, dashType: 'dash' }
        });

        // Bottom right texts
        slide2.addText(slideData.bottom1, fText1_2);
        slide2.addText(slideData.bottom2, fText2_2);
    });
		
		
 // Slide 3 Sub-Categories
	
	let topHead_3 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_3 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_3 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_3 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_3 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_3 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_3 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_3 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_3 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_3 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_3 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_3 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_3 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };


    let opts12_3 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_3 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_3 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_3 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_3 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_3 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_3 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_3 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_3 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_3 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['f2ad61','6D8A42','C6E48B','70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var SubCategoriescountryLevel = data['CM_C2Country'];
        var SubCategoriesquarterLevel = data['CM_C2Quarter'];
        var SubCategoriesopt=CMC2label;

        var subCategoryCountry = sortSEAAndAlignwithoutColor(SubCategoriescountryLevel, SubCategoriesopt);
        console.log("newdata", subCategoryCountry);
        SubCategoriescountryLevel = subCategoryCountry['sortedData'];
        SubCategoriesopt = subCategoryCountry['sortedLabels'];

        var Q1 = SubCategoriesquarterLevel["Q1'25"];
        var Q2 = SubCategoriesquarterLevel["Q2'25"];
        const SubCategoriesq1= Q1.map(item => item.percentage);
        const SubCategoriesq2= Q2.map(item => item.percentage);
        const sigSubCategoriesq1= Q1.map(item => item.percentage2);
        const sigSubCategoriesq2= Q2.map(item => item.percentage2);
        var SubCategoriesbaseData = [Q1[0].bCount, Q2[0].bCount];
        const SubCategoriescountryData = {};
        const SubCategories1 = [];
        const SubCategories2 = [];
        const SubCategories3 = [];
        const SubCategories4 = [];
        const SubCategories5 = [];
        const SubCategoriesbaseArray = [];

        countryLabel4.forEach(country => {
            if (SubCategoriescountryLevel[country]) {
                SubCategoriescountryData[country] = SubCategoriescountryLevel[country];
            }
        });
                
        for (const country in SubCategoriescountryData) {
            const countryData = SubCategoriescountryData[country];
            SubCategoriesbaseArray.push(`n-${countryData[0].bCount}`);
            SubCategories1.push(countryData[0].percentage);
            SubCategories2.push(countryData[1].percentage);
            SubCategories3.push(countryData[2].percentage);
            SubCategories4.push(countryData[3].percentage);
            SubCategories5.push(countryData[4].percentage);
        }

        const SubCategoriesArray = [{
            title: "Sub-Categories",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: SubCategoriesopt,
            f:[SubCategories1,SubCategories2,SubCategories3,SubCategories4,SubCategories5],
            sampleSizes:SubCategoriesbaseArray,
            bottom1:"C2. On this most recent occasion, please select the type of Dairy Milk (from Cows) you had?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[SubCategoriesbaseData[0],SubCategoriesbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [SubCategoriesopt[0],SubCategoriesq1[0]+'%', SubCategoriesq2[0]+'%'],
                [SubCategoriesopt[1],SubCategoriesq1[1]+'%',SubCategoriesq2[1]+'%'],
                [SubCategoriesopt[2],SubCategoriesq1[2]+'%',SubCategoriesq2[2]+'%'],
                [SubCategoriesopt[3],SubCategoriesq1[3]+'%',SubCategoriesq2[3]+'%'],
                [SubCategoriesopt[4],SubCategoriesq1[4]+'%',SubCategoriesq2[4]+'%'],
            ],
            table2: [
                [sigSubCategoriesq1[0],sigSubCategoriesq2[0]],
                [sigSubCategoriesq1[1],sigSubCategoriesq2[1]],
                [sigSubCategoriesq1[2],sigSubCategoriesq2[2]],
                [sigSubCategoriesq1[3],sigSubCategoriesq2[3]],
                [sigSubCategoriesq1[4],sigSubCategoriesq2[4]],
            ],
        }];

        SubCategoriesArray.forEach(slideData => {
            slide3.addText(slideData.title,topHead_3);
            slide3.addText(slideData.subtitle,subHead_3);
            slide3.addText(slideData.subtitle1,leftHead_3);
            slide3.addText("Base – Those who Consumed in Past 3 months",leftSubHead_3);
            slide3.addText("Base – Those who consumed in Past 3 months",rightSubHead_3);
            slide3.addText(slideData.subtitle3,rightHead_3);
            slide3.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide3.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide3.addText(slideData.countries[0],{...country1_3,x: 1.01});
            slide3.addText(slideData.countries[1],{...country2_3,x: 1.87});
            slide3.addText(slideData.countries[2],{...country3_3,x: 2.74});
            slide3.addText(slideData.countries[3],{...country4_3,x: 3.55});
            slide3.addText(slideData.countries[4],{...country5_3,x: 4.32});
            slide3.addText(slideData.countries[5],{...country6_3,x: 5.10});
            slide3.addText(slideData.countries[6],{...country7_3,x: 5.91});
            slide3.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide3.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide3.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide3.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide3.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide3.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });



        // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_3 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_3.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_3 = [];
        slideMerged_3.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_3[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_3.push(newRow);
        }

        console.log("abc",slideMerged_3);


        
        // <==================================|Significance Testing|==================================>


            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide3.addChart(tnpa, stackChart_3);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[0] },
                 { color: '70A6FF', text: slideData.funnel[1] },
                 { color: 'C6E48B', text: slideData.funnel[2] },
                 { color: '6D8A42', text: slideData.funnel[3] },
                 { color: 'f2ad61', text: slideData.funnel[4] },
             ];
             legendItems.forEach((item, index) => {
                 slide3.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide3.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     w:1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide3.addText(slideData.bottom1,fText1_3);
             slide3.addText(slideData.bottom2,fText2_3);
             slide3.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideMerged_3.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                        options: {
                            border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                                ? [false, false, false, false] //No border for first and last row
                                : [false, false, true, false], //Bottom border only
                            borderColor: 'e0e0e0',
                            borderSize: 0.5,
                            fontSize: 8,
                            align: 'center',
                            valign: 'middle'
                        }
                 }))
             );
             slide3.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 3.08,
                 "h": 2.76
             });
             
			slide3.addText("n-"+slideData.tblB[0],tableBase_3);
			slide3.addText("n-"+slideData.tblB[1],{...tableBase_3,x: 9.0});
			
            slide3.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide3.addImage({...logo1_3,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide3.addImage({...logo2_3,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide3.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
		
	// Slide 4 How is it Consumed?
	
	let topHead_4 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_4 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_4 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_4 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_4 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_4 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_4 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_4 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_4 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_4 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_4 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_4 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_4 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_4 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_4 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_4 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_4 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_4 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_4 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_4 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_4 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_4 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_4 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['6D8A42','C6E48B','70A6FF','3A5A81','F28C28'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var ConsumedcountryLevel = data['CM_C5Country'];
        var ConsumedquarterLevel = data['CM_C5Quarter'];
        var Consumedopt=CMC5label2;

        var ConsumedcountryCountry = sortSEAAndAlignwithoutColor(ConsumedcountryLevel, Consumedopt);
        console.log("newdata", ConsumedcountryCountry);
        ConsumedcountryLevel = ConsumedcountryCountry['sortedData'];
        Consumedopt = ConsumedcountryCountry['sortedLabels'];

        var Q1 = ConsumedquarterLevel["Q1'25"];
        var Q2 = ConsumedquarterLevel["Q2'25"];
        const Consumedq1= Q1.map(item => item.percentage);
        const Consumedq2= Q2.map(item => item.percentage);
        const sigConsumedq1= Q1.map(item => item.percentage2);
        const sigConsumedq2= Q2.map(item => item.percentage2);
        var ConsumedbaseData = [Q1[0].bCount, Q2[0].bCount];
        const ConsumedcountryData = {};
        const Consumed1 = [];
        const Consumed2 = [];
        const Consumed3 = [];
        const Consumed4 = [];
        
        const ConsumedbaseArray = [];

        countryLabel4.forEach(country => {
            if (ConsumedcountryLevel[country]) {
                ConsumedcountryData[country] = ConsumedcountryLevel[country];
            }
        });
                
        for (const country in ConsumedcountryData) {
            const countryData = ConsumedcountryData[country];
            ConsumedbaseArray.push(`n-${countryData[0].bCount}`);
            Consumed1.push(countryData[0].percentage);
            Consumed2.push(countryData[1].percentage);  
            Consumed4.push(countryData[3].percentage);
            Consumed3.push(countryData[2].percentage);
            
        }

        const ConsumedArray = [{
            title: "How is it Consumed?",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: Consumedopt,
            f:[Consumed1,Consumed2,Consumed3,Consumed4],
            sampleSizes:ConsumedbaseArray,
            bottom1:"C5. How did you have it on this occasion?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[ConsumedbaseData[0],ConsumedbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [Consumedopt[0],Consumedq1[0]+'%', Consumedq2[0]+'%'],
                [Consumedopt[1],Consumedq1[1]+'%',Consumedq2[1]+'%'],
                [Consumedopt[3],Consumedq1[3]+'%',Consumedq2[3]+'%'],
                [Consumedopt[2],Consumedq1[2]+'%',Consumedq2[2]+'%'],
               
            ],
            table2: [
                [sigConsumedq1[0], sigConsumedq2[0]],
                [sigConsumedq1[1],sigConsumedq2[1]],
                [sigConsumedq1[3],sigConsumedq2[3]],
                [sigConsumedq1[2],sigConsumedq2[2]],
               
            ],
        }];

        ConsumedArray.forEach(slideData => {
            slide4.addText(slideData.title,topHead_4);
            slide4.addText(slideData.subtitle,subHead_4);
            slide4.addText(slideData.subtitle1,leftHead_4);
            slide4.addText("Base – Those who Consumed in Past 3 months",leftSubHead_4);
            slide4.addText("Base – Those who consumed in Past 3 months",rightSubHead_4);
            slide4.addText(slideData.subtitle3,rightHead_4);
            slide4.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide4.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide4.addText(slideData.countries[0],{...country1_4,x: 1.01});
            slide4.addText(slideData.countries[1],{...country2_4,x: 1.87});
            slide4.addText(slideData.countries[2],{...country3_4,x: 2.74});
            slide4.addText(slideData.countries[3],{...country4_4,x: 3.55});
            slide4.addText(slideData.countries[4],{...country5_4,x: 4.32});
            slide4.addText(slideData.countries[5],{...country6_4,x: 5.10});
            slide4.addText(slideData.countries[6],{...country7_4,x: 5.91});
            slide4.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide4.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide4.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide4.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide4.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide4.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

        // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_4 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_4.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_4 = [];
        slideMerged_4.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_4[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_4.push(newRow);
        }

        console.log("abc",slideMerged_4);


        
        // <==================================|Significance Testing|==================================>
            

            [slideData.f[2], slideData.f[3]] = [slideData.f[3], slideData.f[2]];
            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide4.addChart(tnpa, stackChart_4);
             let legendItems = [
                 { color: '3a5a81', text: slideData.funnel[0] },
                 { color: '70a6ff', text: slideData.funnel[1] },
                 { color: 'c6e48b', text: slideData.funnel[3] },
                 { color: '6d8a42', text: slideData.funnel[2] },
                 
             ];
             legendItems.forEach((item, index) => {
                 slide4.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide4.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     w: 1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide4.addText(slideData.bottom1,fText1_4);
             slide4.addText(slideData.bottom2,fText2_4);
             slide4.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideMerged_4.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide4.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide4.addText("n-"+slideData.tblB[0],tableBase_4);
			slide4.addText("n-"+slideData.tblB[1],{...tableBase_4,x: 9.0});
			
            slide4.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide4.addImage({...logo1_4,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide4.addImage({...logo2_4,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide4.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
	
	
	 // Slide 5 Accompanied with…
	
	let topHead_5 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_5 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_5 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_5 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_5 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_5 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_5 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_5 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_5 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_5 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_5 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_5 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_5 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_5 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_5 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_5 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_5 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_5 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_5 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_5 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_5 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_5 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_5 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['6D8A42','C6E48B','70A6FF','3A5A81','F28C28'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var AccompanycountryLevel = data['CM_C10Country'];
        var AccompanyquarterLevel = data['CM_C10Quarter'];
        var Accompanyopt=CMC10label;
        var Q1 = AccompanyquarterLevel["Q1'25"];
        var Q2 = AccompanyquarterLevel["Q2'25"];
        const Accompanyq1= Q1.map(item => item.percentage);
        const Accompanyq2= Q2.map(item => item.percentage);
        const sigAccompanyq1= Q1.map(item => item.percentage2);
        const sigAccompanyq2= Q2.map(item => item.percentage2);
        var AccompanybaseData = [Q1[0].bCount, Q2[0].bCount];
        const AccompanycountryData = {};
        const Accompany1 = [];
        const Accompany2 = [];
        const Accompany3 = [];
        const Accompany4 = [];
        
        const AccompanybaseArray = [];

        countryLabel4.forEach(country => {
            if (AccompanycountryLevel[country]) {
                AccompanycountryData[country] = AccompanycountryLevel[country];
            }
        });
                
        for (const country in AccompanycountryData) {
            const countryData = AccompanycountryData[country];
            AccompanybaseArray.push(`n-${countryData[0].bCount}`);
            Accompany1.push(countryData[0].percentage);
            Accompany2.push(countryData[1].percentage);
            Accompany3.push(countryData[2].percentage);
            Accompany4.push(countryData[3].percentage);
            
        }

        const AccompanyArray = [{
            title: "Accompanied with…",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: Accompanyopt,
            f:[Accompany1,Accompany2,Accompany3,Accompany4],
            sampleSizes:AccompanybaseArray,
            bottom1:"C10. Did you have it along with anything else or by itself on this occasion?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[AccompanybaseData[0],AccompanybaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [Accompanyopt[0],Accompanyq1[0]+'%', Accompanyq2[0]+'%'],
                [Accompanyopt[1],Accompanyq1[1]+'%',Accompanyq2[1]+'%'],
                [Accompanyopt[2],Accompanyq1[2]+'%',Accompanyq2[2]+'%'],
                [Accompanyopt[3],Accompanyq1[3]+'%',Accompanyq2[3]+'%'],
                
            ],
            table2: [
                [sigAccompanyq1[0], sigAccompanyq2[0]],
                [sigAccompanyq1[1], sigAccompanyq2[1]],
                [sigAccompanyq1[2], sigAccompanyq2[2]],
                [sigAccompanyq1[3], sigAccompanyq2[3]],
                
            ],
        }];

        AccompanyArray.forEach(slideData => {
            slide5.addText(slideData.title,topHead_5);
            slide5.addText(slideData.subtitle,subHead_5);
            slide5.addText(slideData.subtitle1,leftHead_5);
            slide5.addText("Base – Accompany in Past 3 months",leftSubHead_5);
            slide5.addText("Base – Those who consumed in Past 3 months",rightSubHead_5);
            slide5.addText(slideData.subtitle3,rightHead_5);
            slide5.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide5.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide5.addText(slideData.countries[0],{...country1_5,x: 1.01});
            slide5.addText(slideData.countries[1],{...country2_5,x: 1.87});
            slide5.addText(slideData.countries[2],{...country3_5,x: 2.74});
            slide5.addText(slideData.countries[3],{...country4_5,x: 3.55});
            slide5.addText(slideData.countries[4],{...country5_5,x: 4.32});
            slide5.addText(slideData.countries[5],{...country6_5,x: 5.10});
            slide5.addText(slideData.countries[6],{...country7_5,x: 5.91});
            slide5.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide5.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide5.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide5.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide5.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide5.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });


            // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_5 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_5.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_5 = [];
        slideMerged_5.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_5[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_5.push(newRow);
        }

        console.log("abc",slideMerged_5);


        
        // <==================================|Significance Testing|==================================>


            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide5.addChart(tnpa, stackChart_5);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[0] },
                 { color: '70A6FF', text: slideData.funnel[1] },
                 { color: 'C6E48B', text: slideData.funnel[2] },
                 { color: '6D8A42', text: slideData.funnel[3] },
                 
             ];
             legendItems.forEach((item, index) => {
                 slide5.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide5.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide5.addText(slideData.bottom1,fText1_5);
             slide5.addText(slideData.bottom2,fText2_5);
             slide5.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideMerged_5.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide5.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide5.addText("n-"+slideData.tblB[0],tableBase_5);
			slide5.addText("n-"+slideData.tblB[1],{...tableBase_5,x: 9.0});
			
            slide5.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide5.addImage({...logo1_5,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide5.addImage({...logo2_5,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide5.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
	
	 
	 // Slide 6 Temperature of Milk
	
	let topHead_6 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_6 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
     let leftHead_6 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_6 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_6 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_6 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_6 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_6 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_6 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_6 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_6 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_6 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_6 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };


    let opts12_6 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_6 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_6 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_6 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_6 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_6 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_6 = {"x": 7.95,"y": 2.8,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_6 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_6 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_6 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['7c985e','4d6893'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var TemperaturecountryLevel = data['CM_C4bCountry'];
        var TemperaturequarterLevel = data['CM_C4bQuarter'];
        var Temperatureopt=CMC4blabel;

        var TemperaturecountryCountry = sortSEAAndAlignwithoutColor(TemperaturecountryLevel, Temperatureopt);
        console.log("newdata", TemperaturecountryCountry);
        TemperaturecountryLevel = TemperaturecountryCountry['sortedData'];
        Temperatureopt = TemperaturecountryCountry['sortedLabels'];


        var Q1 = TemperaturequarterLevel["Q1'25"];
        var Q2 = TemperaturequarterLevel["Q2'25"];
        const Temperatureq1= Q1.map(item => item.percentage);
        const Temperatureq2= Q2.map(item => item.percentage);
        const sigTemperatureq1= Q1.map(item => item.percentage2);
        const sigTemperatureq2= Q2.map(item => item.percentage2);
        var TemperaturebaseData = [Q1[0].bCount, Q2[0].bCount];
        const TemperaturecountryData = {};
        const Temperature1 = [];
        const Temperature2 = [];
       
        
        const TemperaturebaseArray = [];

        countryLabel4.forEach(country => {
            if (TemperaturecountryLevel[country]) {
                TemperaturecountryData[country] = TemperaturecountryLevel[country];
            }
        });
                
        for (const country in TemperaturecountryData) {
            const countryData = TemperaturecountryData[country];
            TemperaturebaseArray.push(`n-${countryData[0].bCount}`);
            
            Temperature2.push(countryData[1].percentage);
            Temperature1.push(countryData[0].percentage);
           
            
        }

        const TemperatureArray = [{
            title: "Temperature of Milk",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: Temperatureopt,
            f:[Temperature1,Temperature2],
            sampleSizes:TemperaturebaseArray,
            bottom1:"C4b. Did you have it…?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[TemperaturebaseData[0],TemperaturebaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                
                [Temperatureopt[1],Temperatureq1[1]+'%',Temperatureq2[1]+'%'],
                [Temperatureopt[0],Temperatureq1[0]+'%', Temperatureq2[0]+'%'],
                
                
            ],
            table2: [
                [sigTemperatureq1[1],sigTemperatureq2[1]],
                [sigTemperatureq1[0],sigTemperatureq2[0]],
            ],
        }];

        TemperatureArray.forEach(slideData => {
            slide6.addText(slideData.title,topHead_6);
            slide6.addText(slideData.subtitle,subHead_6);
            slide6.addText(slideData.subtitle1,leftHead_6);
            slide6.addText("Base – Temperature in Past 3 months",leftSubHead_6);
            slide6.addText("Base – Those who consumed in Past 3 months",rightSubHead_6);
            slide6.addText(slideData.subtitle3,rightHead_6);
            slide6.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide6.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide6.addText(slideData.countries[0],{...country1_6,x: 1.01});
            slide6.addText(slideData.countries[1],{...country2_6,x: 1.87});
            slide6.addText(slideData.countries[2],{...country3_6,x: 2.74});
            slide6.addText(slideData.countries[3],{...country4_6,x: 3.55}); 
            slide6.addText(slideData.countries[4],{...country5_6,x: 4.32});
            slide6.addText(slideData.countries[5],{...country6_6,x: 5.10});
            slide6.addText(slideData.countries[6],{...country7_6,x: 5.91});
            slide6.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide6.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide6.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide6.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide6.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide6.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

            // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_6 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_6.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_6 = [];
        slideMerged_6.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_6[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_6.push(newRow);
        }

        console.log("abc",slideMerged_6);


        
        // <==================================|Significance Testing|==================================>

            
            [slideData.f[0], slideData.f[1]] = [slideData.f[1], slideData.f[0]];
            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide6.addChart(tnpa, stackChart_6);
             let legendItems = [
                 { color: '4d6893', text: slideData.funnel[1] },
                 { color: '7c985e', text: slideData.funnel[0] },
             ];
             legendItems.forEach((item, index) => {
                 slide6.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide6.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     w: 1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide6.addText(slideData.bottom1,fText1_6);
             slide6.addText(slideData.bottom2,fText2_6);
             slide6.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideMerged_6.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide6.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 1.24
             });
             
			slide6.addText("n-"+slideData.tblB[0],tableBase_6);
			slide6.addText("n-"+slideData.tblB[1],{...tableBase_6,x: 9.0});
			
            slide6.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide6.addImage({...logo1_6,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide6.addImage({...logo2_6,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide6.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
	
	
	  // Slide 7 Packaging Size
	
	let topHead_7 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_7 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_7 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_7 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_7 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_7 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_7 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_7 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_7 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_7 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_7 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_7 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_7 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_7 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_7 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_7 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_7 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_7 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_7 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_7 = {"x": 7.95,"y": 2.8,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_7 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_7 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_7 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['7c985e','4d6893'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var PackcountryLevel = data['CM_C7Country'];
        var PackquarterLevel = data['CM_C7Quarter'];
        var Packopt=CMC7label2;

        var PackcountryCountry = sortSEAAndAlignwithoutColor(PackcountryLevel, Packopt);
        console.log("newdata", PackcountryCountry);
        PackcountryLevel = PackcountryCountry['sortedData'];
        Packopt = PackcountryCountry['sortedLabels'];


        var Q1 = PackquarterLevel["Q1'25"];
        var Q2 = PackquarterLevel["Q2'25"];
        const Packq1= Q1.map(item => item.percentage);
        const Packq2= Q2.map(item => item.percentage);
        const sigPackq1= Q1.map(item => item.percentage2);
        const sigPackq2= Q2.map(item => item.percentage2);
        var PackbaseData = [Q1[0].bCount, Q2[0].bCount];
        const PackcountryData = {};
        const Pack1 = [];
        const Pack2 = [];
       
        
        const PackbaseArray = [];

        countryLabel4.forEach(country => {
            if (PackcountryLevel[country]) {
                PackcountryData[country] = PackcountryLevel[country];
            }
        });
                
        for (const country in PackcountryData) {
            const countryData = PackcountryData[country];
            PackbaseArray.push(`n-${countryData[0].bCount}`);
            Pack2.push(countryData[1].percentage);
            Pack1.push(countryData[0].percentage);
           
            
        }

        const PackArray = [{
            title: "Packaging Size",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: Packopt,
            f:[Pack1,Pack2],
            sampleSizes:PackbaseArray,
            bottom1:"C7. Was it…?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[PackbaseData[0],PackbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [Packopt[1],Packq1[1]+'%',Packq2[1]+'%'],
                [Packopt[0],Packq1[0]+'%', Packq2[0]+'%'],                
            ],
            table2: [
                [sigPackq1[1],sigPackq2[1]],
                [sigPackq1[0],sigPackq2[0]],                
            ],
        }];

        PackArray.forEach(slideData => {
            slide7.addText(slideData.title,topHead_7);
            slide7.addText(slideData.subtitle,subHead_7);
            slide7.addText(slideData.subtitle1,leftHead_7);
            slide7.addText("Base – Pack in Past 3 months",leftSubHead_7);
            slide7.addText("Base – Those who consumed in Past 3 months",rightSubHead_7);
            slide7.addText(slideData.subtitle3,rightHead_7);
            slide7.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide7.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide7.addText(slideData.countries[0],{...country1_7,x: 1.01});
            slide7.addText(slideData.countries[1],{...country2_7,x: 1.87});
            slide7.addText(slideData.countries[2],{...country3_7,x: 2.74});
            slide7.addText(slideData.countries[3],{...country4_7,x: 3.55});
            slide7.addText(slideData.countries[4],{...country5_7,x: 4.32});
            slide7.addText(slideData.countries[5],{...country6_7,x: 5.10});
            slide7.addText(slideData.countries[6],{...country7_7,x: 5.91});
            slide7.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide7.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide7.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide7.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide7.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide7.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });

        // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_7 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_7.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_7 = [];
        slideMerged_7.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_7[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_7.push(newRow);
        }

        console.log("abc",slideMerged_7);


        
        // <==================================|Significance Testing|==================================>

            [slideData.f[0], slideData.f[1]] = [slideData.f[1], slideData.f[0]];
            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide7.addChart(tnpa, stackChart_7);
             let legendItems = [
                 { color: '4d6893', text: slideData.funnel[1] },
                 { color: '7c985e', text: slideData.funnel[0] },
                 
                 
             ];
             legendItems.forEach((item, index) => {
                 slide7.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.5,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide7.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.5,
                     w: 1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide7.addText(slideData.bottom1,fText1_7);
             slide7.addText(slideData.bottom2,fText2_7);
             slide7.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideMerged_7.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide7.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 1.24
             });
             
			slide7.addText("n-"+slideData.tblB[0],tableBase_7);
			slide7.addText("n-"+slideData.tblB[1],{...tableBase_7,x: 8.90});
			
            slide7.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide7.addImage({...logo1_7,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide7.addImage({...logo2_7,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide7.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });
		
	// Slide 8 PackTaging Type
	
	let topHead_8 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_8 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_8 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_8 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_8 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_8 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_8 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_8 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_8 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_8 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_8 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_8 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_8 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_8 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_8 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_8 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_8 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_8 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_8 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_8 = {"x": 7.95,"y": 4.4,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_8 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_8 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_8 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['f2ad61', 'F28C28','6D8A42','C6E48B','70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var PackTcountryLevel = data['CM_C6Country'];
        var PackTquarterLevel = data['CM_C6Quarter'];
        var PackTopt=CMC6label;

        var PackTcountryCountry = sortSEAAndAlignwithoutColor(PackTcountryLevel, PackTopt);
        console.log("newdata", PackTcountryCountry);
        PackTcountryLevel = PackTcountryCountry['sortedData'];
        PackTopt = PackTcountryCountry['sortedLabels'];


        var Q1 = PackTquarterLevel["Q1'25"];
        var Q2 = PackTquarterLevel["Q2'25"];
        const PackTq1= Q1.map(item => item.percentage);
        const PackTq2= Q2.map(item => item.percentage);
        const sigPackTq1= Q1.map(item => item.percentage2);
        const sigPackTq2= Q2.map(item => item.percentage2);
        var PackTbaseData = [Q1[0].bCount, Q2[0].bCount];
        const PackTcountryData = {};
        const PackT1 = [];
        const PackT2 = [];
		const PackT3 = [];
		const PackT4 = [];
		const PackT5 = [];
		const PackT6 = [];
       
        
        const PackTbaseArray = [];

        countryLabel4.forEach(country => {
            if (PackTcountryLevel[country]) {
                PackTcountryData[country] = PackTcountryLevel[country];
            }
        });
        // console.log('pcdata', PackTcountryData);
                
        for (const country in PackTcountryData) {
            const countryData = PackTcountryData[country];
            PackTbaseArray.push(`n-${countryData[0].bCount}`);
			PackT4.push(countryData[3].percentage);
			PackT3.push(countryData[2].percentage);
            PackT1.push(countryData[0].percentage);
			PackT5.push(countryData[4].percentage);
            PackT2.push(countryData[1].percentage);
			PackT6.push(countryData[5].percentage);  
        }

        const PackTArray = [{
            title: "PackTaging Type",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: PackTopt,
            // f:[PackT1,PackT2,PackT3,PackT4,PackT5,PackT6],
            // f:[PackT4, PackT3, PackT1, PackT5, PackT2],
            f:[PackT4, PackT3, PackT1, PackT5, PackT2, PackT6],
            sampleSizes:PackTbaseArray,
            bottom1:"C6. What type of packaging did it come in?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[PackTbaseData[0],PackTbaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [PackTopt[3],PackTq1[3]+'%',PackTq2[3]+'%'],
                [PackTopt[2],PackTq1[2]+'%',PackTq2[2]+'%'],
                [PackTopt[0],PackTq1[0]+'%', PackTq2[0]+'%'],
				[PackTopt[4],PackTq1[4]+'%',PackTq2[4]+'%'],
                [PackTopt[1],PackTq1[1]+'%',PackTq2[1]+'%'],
				[PackTopt[5],PackTq1[5]+'%',PackTq2[5]+'%'],
            ],
            table2: [
                [sigPackTq1[3],sigPackTq2[3]],
                [sigPackTq1[2],sigPackTq2[2]],
                [sigPackTq1[0],sigPackTq2[0]],
				[sigPackTq1[4],sigPackTq2[4]],
                [sigPackTq1[1],sigPackTq2[1]],
				[sigPackTq1[5],sigPackTq2[5]],
            ],
            
        }];

        PackTArray.forEach(slideData => {
            slide8.addText(slideData.title,topHead_8);
            slide8.addText(slideData.subtitle,subHead_8);
            slide8.addText(slideData.subtitle1,leftHead_8);
            slide8.addText("Base – PackT in Past 3 months",leftSubHead_8);
            slide8.addText("Base – Those who consumed in Past 3 months",rightSubHead_8);
            slide8.addText(slideData.subtitle3,rightHead_8);
            slide8.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide8.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide8.addText(slideData.countries[0],{...country1_8,x: 1.01});
            slide8.addText(slideData.countries[1],{...country2_8,x: 1.87});
            slide8.addText(slideData.countries[2],{...country3_8,x: 2.74});
            slide8.addText(slideData.countries[3],{...country4_8,x: 3.55});
            slide8.addText(slideData.countries[4],{...country5_8,x: 4.32});
            slide8.addText(slideData.countries[5],{...country6_8,x: 5.10});
            slide8.addText(slideData.countries[6],{...country7_8,x: 5.91});
            slide8.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide8.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide8.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide8.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide8.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide8.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });


            // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_8 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_8.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_8 = [];
        slideMerged_8.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_8[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_8.push(newRow);
        }

        console.log("abc",slideMerged_8);


        
        // <==================================|Significance Testing|==================================>


            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide8.addChart(tnpa, stackChart_8);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[3] },
                 { color: '70A6FF', text: slideData.funnel[2] },
                 { color: 'C6E48B', text: slideData.funnel[0] },
                 { color: '6D8A42', text: slideData.funnel[4] },
                 { color: 'F28C28', text: slideData.funnel[1] },
                 { color: 'f2ad61', text: slideData.funnel[5] },
				//  { color: 'F7B267', text: slideData.funnel[5] },
                 
                 
             ];
             legendItems.forEach((item, index) => {
                 slide8.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.35,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide8.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.35,
                     w: 1.2,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide8.addText(slideData.bottom1,fText1_8);
             slide8.addText(slideData.bottom2,fText2_8);
             slide8.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideMerged_8.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] // No border for first and last row
                             : [false, false, true, false], // Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             slide8.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 3
             });
             
			slide8.addText("n-"+slideData.tblB[0],tableBase_8);
			slide8.addText("n-"+slideData.tblB[1],{...tableBase_8,x: 9.0});
			
            slide8.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 //{ text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide8.addImage({...logo1_8,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide8.addImage({...logo2_8,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide8.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});
        });


    // Slide 10 Place of consumption
	
	let topHead_10 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_10 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_10 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_10 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_10 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_10 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    
    let country1_10 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_10 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_10 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_10 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_10 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_10 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_10 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };


    let opts12_10 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_10 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_10 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_10 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_10 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_10 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_10 = {"x": 7.95,"y": 4.21,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_10 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_10 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	let stackChart_10 = {x: 1.02,y: 1.4,w: 5.81,h: 3.20,barDir: "col",barGrouping: "stacked",barGapWidthPct: 110,dataLabelColor: "FFFFFF",dataLabelFontFace: "Arial",dataLabelFontSize: 9,dataLabelFontBold: true,showValue: true,dataLabelFormatCode: '0"%"', chartColors: ['7f7f7f','f2ad61','F28C28','6D8A42','C6E48B','70A6FF','3A5A81'],lineDataSymbolSize: 15,catAxisLabelColor: "969696", catAxisLabelFontFace: "Arial",catAxisLabelFontSize: 8,catAxisOrientation: "minMax",showLegend: false,legendPos: 'l', legendFontSize: 9, showTitle: false,showValAxis: false,valAxisLabelPos: 'none',valAxisLineShow: false,valGridLine:{style: 'none'},};
	
		var consumptionPlacecountryLevel = data['CM_C9Country'];
        var consumptionPlacequarterLevel = data['CM_C9Quarter'];
        var consumptionPlaceopt=CMC9label;
        var Q1 = consumptionPlacequarterLevel["Q1'25"];
        var Q2 = consumptionPlacequarterLevel["Q2'25"];
        const consumptionPlaceq1= Q1.map(item => item.percentage);
        const consumptionPlaceq2= Q2.map(item => item.percentage);
        const sigconsumptionPlaceq1= Q1.map(item => item.percentage2);
        const sigconsumptionPlaceq2= Q2.map(item => item.percentage2);
        var consumptionPlacebaseData = [Q1[0].bCount, Q2[0].bCount];
        const consumptionPlacecountryData = {};
        const consumptionPlace1 = [];
        const consumptionPlace2 = [];
        const consumptionPlace3 = [];
        const consumptionPlace4 = [];
        const consumptionPlace5 = [];
        const consumptionPlace6 = [];
        const consumptionPlace7 = [];
        const consumptionPlacebaseArray = [];

        countryLabel4.forEach(country => {
            if (consumptionPlacecountryLevel[country]) {
                consumptionPlacecountryData[country] = consumptionPlacecountryLevel[country];
            }
        });
                
        for (const country in consumptionPlacecountryData) {
            const countryData = consumptionPlacecountryData[country];
            consumptionPlacebaseArray.push(`n-${countryData[0].bCount}`);
            consumptionPlace1.push(countryData[0].percentage);
            consumptionPlace2.push(countryData[1].percentage);
            consumptionPlace3.push(countryData[2].percentage);
            consumptionPlace4.push(countryData[3].percentage);
            consumptionPlace5.push(countryData[4].percentage);
            consumptionPlace6.push(countryData[5].percentage);
            consumptionPlace7.push(countryData[6].percentage);
        }

        const consumptionPlaceArray = [{
            title: "Place of Consumption",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            funnel: consumptionPlaceopt,
            f:[consumptionPlace1,consumptionPlace2,consumptionPlace3,consumptionPlace4,consumptionPlace5, consumptionPlace6, consumptionPlace7],
            sampleSizes:consumptionPlacebaseArray,
            bottom1:"C9. Where did you have it?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            tblB:[consumptionPlacebaseData[0],consumptionPlacebaseData[1]],
            table: [
                ["","Q1'25", "Q2'25"],
                [consumptionPlaceopt[0],consumptionPlaceq1[0]+'%', consumptionPlaceq2[0]+'%'],
                [consumptionPlaceopt[1],consumptionPlaceq1[1]+'%',consumptionPlaceq2[1]+'%'],
                [consumptionPlaceopt[2],consumptionPlaceq1[2]+'%',consumptionPlaceq2[2]+'%'],
                [consumptionPlaceopt[3],consumptionPlaceq1[3]+'%',consumptionPlaceq2[3]+'%'],
                [consumptionPlaceopt[4],consumptionPlaceq1[4]+'%',consumptionPlaceq2[4]+'%'],
                [consumptionPlaceopt[5],consumptionPlaceq1[5]+'%',consumptionPlaceq2[5]+'%'],
                [consumptionPlaceopt[6],consumptionPlaceq1[6]+'%',consumptionPlaceq2[6]+'%'],
            ],
            table2: [
                [sigconsumptionPlaceq1[0],sigconsumptionPlaceq2[0]],
                [sigconsumptionPlaceq1[1],sigconsumptionPlaceq2[1]],
                [sigconsumptionPlaceq1[2],sigconsumptionPlaceq2[2]],
                [sigconsumptionPlaceq1[3],sigconsumptionPlaceq2[3]],
                [sigconsumptionPlaceq1[4],sigconsumptionPlaceq2[4]],
                [sigconsumptionPlaceq1[5],sigconsumptionPlaceq2[5]],
                [sigconsumptionPlaceq1[6],sigconsumptionPlaceq2[6]],
            ],
            tblB2:[
                [consumptionPlacebaseData[0],consumptionPlacebaseData[1]],
                [consumptionPlacebaseData[0],consumptionPlacebaseData[1]],
                [consumptionPlacebaseData[0],consumptionPlacebaseData[1]],
                [consumptionPlacebaseData[0],consumptionPlacebaseData[1]]
                [consumptionPlacebaseData[0],consumptionPlacebaseData[1]],
                [consumptionPlacebaseData[0],consumptionPlacebaseData[1]],
                [consumptionPlacebaseData[0],consumptionPlacebaseData[1]]
            ],
        }];

        consumptionPlaceArray.forEach(slideData => {
            slide10.addText(slideData.title,topHead_10);
            slide10.addText(slideData.subtitle,subHead_10);
            slide10.addText(slideData.subtitle1,leftHead_10);
            slide10.addText("Base – Those who Consumed in Past 3 months",leftSubHead_10);
            slide10.addText("Base – Those who consumed in Past 3 months",rightSubHead_10);
            slide10.addText(slideData.subtitle3,rightHead_10);
            slide10.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide10.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide10.addText(slideData.countries[0],{...country1_10,x: 1.01});
            slide10.addText(slideData.countries[1],{...country2_10,x: 1.87});
            slide10.addText(slideData.countries[2],{...country3_10,x: 2.74});
            slide10.addText(slideData.countries[3],{...country4_10,x: 3.55});
            slide10.addText(slideData.countries[4],{...country5_10,x: 4.32});
            slide10.addText(slideData.countries[5],{...country6_10,x: 5.10});
            slide10.addText(slideData.countries[6],{...country7_10,x: 5.91});
            slide10.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide10.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide10.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide10.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide10.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide10.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });


            // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_10 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_10.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_10 = [];
        slideMerged_10.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_10[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_10.push(newRow);
        }

        console.log("abc",slideMerged_10);


        
        // <==================================|Significance Testing|==================================>

            const chartData = slideData.f.slice() .reverse().map((freq, i) => ({
					name: slideData.funnel[slideData.f.length - 1 - i], 
					labels: slideData.sampleSizes,
					values: freq,
             }));
             let tnpa=[];
             tnpa = [
                 {
                     type: pptx.charts.BAR,
                     data:chartData ,
                     options: {
                         barGrouping: "stacked",
                     },
                 },
             ];
             slide10.addChart(tnpa, stackChart_10);
             let legendItems = [
                 { color: '3A5A81', text: slideData.funnel[0] },
                 { color: '70A6FF', text: slideData.funnel[1] },
                 { color: 'C6E48B', text: slideData.funnel[2] },
                 { color: '6D8A42', text: slideData.funnel[3] },
                 { color: 'F28C28', text: slideData.funnel[4] },
                 { color: 'f2ad61', text: slideData.funnel[5] },
                 { color: '7f7f7f', text: slideData.funnel[6] },
             ];
             legendItems.forEach((item, index) => {
                 slide10.addShape(pptx.ShapeType.rect, {
                     x: 0.2,
                     y: 2.2 + index * 0.3,  
                     w: 0.060,
                     h: 0.060,
                     fill: { color: item.color },
                     line: { color: 'FFFFFF' }
                 });
                 slide10.addText(item.text, {
                     x: 0.2,
                     y: 2.24 + index * 0.3,
                     w: 1,
                     fontSize: 7,
                     color: '000000',
                     fontFace: 'Arial'
                 });
             });

             slide10.addText(slideData.bottom1,fText1_10);
             slide10.addText(slideData.bottom2,fText2_10);
             slide10.addShape(pptx.ShapeType.line, { "x": 0.28,"y": 5.06,"w": 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             let tableRows = slideMerged_10.map((row, rowIndex, allRows) =>
                 row.map(cell => ({
                     text: cell,
                     options: {
                         border: (rowIndex === 0 || rowIndex === allRows.length - 1)
                             ? [false, false, false, false] //No border for first and last row
                             : [false, false, true, false], //Bottom border only
                         borderColor: 'e0e0e0',
                         borderSize: 0.5,
                         fontSize: 8,
                         align: 'center',
                         valign: 'middle'
                     }
                 }))
             );
             
             
             slide10.addTable(tableRows, {
                 "x": 6.83,
                 "y": 1.46,
                 "w": 2.89,
                 "h": 2.76
             });
             
			slide10.addText("n-"+slideData.tblB[0],tableBase_10);
			slide10.addText("n-"+slideData.tblB[1],{...tableBase_10,x: 9.0});
			
            slide10.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide10.addImage({...logo1_10,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide10.addImage({...logo2_10,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             slide10.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});

             /* var significantResults = [];
             slideData.table2.forEach(function(e,i,a){
                significantResults = getSignificanceMatrix(slideData.tblB2[i], e);
                console.log(slideData.tblB2[i]);
                console.log(e);
             }) 
             console.log("significantResults");
             console.log(significantResults);*/
        }); 


        // Slide 9: Time of Consumption — Circular Progress Bars (Donuts) for Each Combination

        // ---- TEXT AND SHAPE POSITION PRESETS ----
        let topHead_9 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
        let subHead_9 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
        let leftHead_9 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
        let leftSubHead_9 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
        let rightHead_9 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
        let rightSubHead_9 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
        let fText1_9 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
        let fText2_9 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
        let tableBase_9 = { x: 7.95, y: 4.21, w: 0.67, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, align: 'center', color: '969696' };
        let logo1_9 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
        let logo2_9 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

        // ---- DONUT STYLE PRESETS ----
        var donutConfig = {
            width: 0.65,
            height: 0.65,
            spacingX: 0.12,
            spacingY: 0.03,
            baseX: 1.00,
            baseY: 1.48,
            leftLabelWidth: 1,
            leftLabelFontSize: 6,
            percentFontSize: 5,
            percentColor: '000000',
            chartMainColor: '000000',
            chartBaseColor: '#e0e0e0'
        };

        // ---- DATA PREPARATION ----
        const countryLabels9 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
        var consumptionTimecountryLevel = data['CM_C8Country'];
        var consumptionTimequarterLevel = data['CM_C8Quarter'];
        var consumptionTimeopt = CMC8label;
        var Q1 = consumptionTimequarterLevel["Q1'25"];
        var Q2 = consumptionTimequarterLevel["Q2'25"];
        const consumptionTimeq1 = Q1.map(item => item.percentage);
        const consumptionTimeq2 = Q2.map(item => item.percentage);
        const sigconsumptionTimeq1 = Q1.map(item => item.percentage2);
        const sigconsumptionTimeq2 = Q2.map(item => item.percentage2);
        var consumptionTimebaseData = [Q1[0].bCount, Q2[0].bCount];
        const consumptionTime1 = [], consumptionTime2 = [], consumptionTime3 = [], consumptionTime4 = [], consumptionTime5 = [], consumptionTimebaseArray = [];

        const baseArray9 = [];
        for (const country of countryLabels9) {
        const cData = consumptionTimecountryLevel[country];
        baseArray9.push(
            cData && cData[0] && typeof cData[0].bCount !== "undefined"
            ? `n-${cData[0].bCount}`
            : "n--"
        );
        }
        const bCountRow9 = [{ text: "", options: {} }];
        baseArray9.forEach(val => {
        bCountRow9.push({
            text: val,
            options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
        });
        });

        slide9.addTable([bCountRow9], {
        x: 0.23, y: 4.86, w: 6.04,
        colW: [1, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8],
        fontSize: 7,
        fontFace: 'Arial',
        align: 'center',
        border: [0]
        });

        countryLabel4.forEach(country => {
            if (consumptionTimecountryLevel[country]) {
                let countryData = consumptionTimecountryLevel[country];
                consumptionTimebaseArray.push(`n-${countryData[0].bCount}`);
                consumptionTime1.push(countryData[0].percentage);
                consumptionTime2.push(countryData[1].percentage);
                consumptionTime3.push(countryData[2].percentage);
                consumptionTime4.push(countryData[3].percentage);
                consumptionTime5.push(countryData[4].percentage);
            }
        });

        const consumptionTimeArray = [{
            title: "Time of Consumption",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: [
                "", 
                "https://keresearch.in/mdynata/assets/images/1.png",
                "https://keresearch.in/mdynata/assets/images/2.png",
                "https://keresearch.in/mdynata/assets/images/3.png",
                "https://keresearch.in/mdynata/assets/images/4.png",
                "https://keresearch.in/mdynata/assets/images/5.png",
                "https://keresearch.in/mdynata/assets/images/6.png"
            ],
            funnel: consumptionTimeopt,
            f: [consumptionTime1, consumptionTime2, consumptionTime3, consumptionTime4, consumptionTime5],
            sampleSizes: consumptionTimebaseArray,
            bottom1: "C8. When did you have it?",
            bottom2: "",
            btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous wave", btm6: " at 95% CI",
            tblB: [consumptionTimebaseData[0], consumptionTimebaseData[1]],
            table: [
                ["", "Q1'25", "Q2'25"],
                [consumptionTimeopt[0], consumptionTimeq1[0] + '%', consumptionTimeq2[0] + '%'],
                [consumptionTimeopt[1], consumptionTimeq1[1] + '%', consumptionTimeq2[1] + '%'],
                [consumptionTimeopt[2], consumptionTimeq1[2] + '%', consumptionTimeq2[2] + '%'],
                [consumptionTimeopt[3], consumptionTimeq1[3] + '%', consumptionTimeq2[3] + '%'],
                [consumptionTimeopt[4], consumptionTimeq1[4] + '%', consumptionTimeq2[4] + '%']
            ],
            table2: [
                [sigconsumptionTimeq1[0], sigconsumptionTimeq2[0]],
                [sigconsumptionTimeq1[1], sigconsumptionTimeq2[1]],
                [sigconsumptionTimeq1[2], sigconsumptionTimeq2[2]],
                [sigconsumptionTimeq1[3], sigconsumptionTimeq2[3]],
                [sigconsumptionTimeq1[4], sigconsumptionTimeq2[4]]
            ]
        }];

        // ---- DRAW SLIDE ----
        consumptionTimeArray.forEach(slideData => {
            slide9.addText(slideData.title, topHead_9);
            slide9.addText(slideData.subtitle, subHead_9);
            slide9.addText(slideData.subtitle1, leftHead_9);
            slide9.addText("Base – Those who Consumed in Past 3 months", leftSubHead_9);
            slide9.addText("Base – Those who consumed in Past 3 months", rightSubHead_9);
            slide9.addText(slideData.subtitle3, rightHead_9);
            slide9.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide9.addShape(pptx.ShapeType.line, { x: 6.83, y: 1.02, w: 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });

// <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_9 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_9.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_9 = [];
        slideMerged_9.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_9[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_9.push(newRow);
        }

        console.log("abc",slideMerged_9);


        
        // <==================================|Significance Testing|==================================>


            // ---- MAIN GRID: 5 Rows (labels) × 7 Columns (countries) ----
            for (let labelIdx = 0; labelIdx < 5; labelIdx++) {
                let label = slideData.funnel[labelIdx];
                slideData.countries.forEach((country, countryIdx) => {
                    let percent = slideData.f[labelIdx][countryIdx];
                    let x = donutConfig.baseX + countryIdx * (donutConfig.width + donutConfig.spacingX);
                    let y = donutConfig.baseY + labelIdx * (donutConfig.height + donutConfig.spacingY) + 0.1;

                    slide9.addChart(pptx.charts.DOUGHNUT, [{
                        name: `${country} - ${label}`,
                        labels: [label, ""],
                        values: [percent, 100 - percent]
                    }], {
                        x, y,
                        w: donutConfig.width,
                        h: donutConfig.height,
                        chartColors: [donutConfig.chartMainColor, donutConfig.chartBaseColor],
                        showLegend: false,
                        showValue: false,
                        dataLabelFontSize: 0
                    });

                    slide9.addText(`${percent}%`, {
                        x: x + 0.12 , y: y + 0.16, w: 0.4, h: 0.32,
                        fontSize: donutConfig.percentFontSize,
                        color: donutConfig.percentColor,
                        fontFace: 'Arial',
                        bold: true,
                        align: 'center',
                        valign: 'middle'
                    });

                    if (labelIdx === 0) {
                        slide9.addText(country, {
                        x: x - 0.05, y: y - 0.11, w: 0.80, h: 0.2,
                        align: 'center', fontSize: 8, bold: true,
                        fontFace: "Arial", color: "000000"
                    });
                        if (slideData.flags[countryIdx]) {
                            slide9.addImage({
                                x: x + (donutConfig.width - 0.30) / 2,
                                y: y - 0.38,
                                w: 0.35,
                                h: 0.33,
                                path: slideData.flags[countryIdx]
                            });
                        }
                    }

                    if (countryIdx === 0) {
                        slide9.addText(label, {
                            // x: x - (donutConfig.leftLabelWidth + 0.1),
                            x: x - (donutConfig.leftLabelWidth),
                            y: y + 0.23,
                            w: donutConfig.leftLabelWidth,
                            h: 0.2,
                            align: 'left',
                            fontSize: donutConfig.leftLabelFontSize,
                            bold: true,
                            fontFace: "Arial",
                            color: donutConfig.percentColor
                        });
                    }
                    if (labelIdx < 4) {  // Skip after last row
                        slide9.addShape(pptx.ShapeType.line, {
                            x: donutConfig.baseX - 0.75,
                            y: donutConfig.baseY + (labelIdx + 1) * (donutConfig.height + donutConfig.spacingY) + 0.07,
                            w: 6.5,
                            h: 0,
                            line: { color: 'e0e0e0', width: 0.75 }
                        });
                    }
                });
            }

    // Table
    let tableRows = slideMerged_9.map((row, rowIndex, allRows) =>
        row.map(cell => ({
            text: cell,
            options: {
                border: (rowIndex === 0 || rowIndex === allRows.length - 1) ? [false, false, false, false] : [false, false, true, false],
                borderColor: 'e0e0e0',
                borderSize: 0.5,
                fontSize: 8,
                align: 'center',
                valign: 'middle'
            }
        }))
    );
    slide9.addTable(tableRows, { x: 6.83, y: 1.46, w: 2.89, h: 2.76 });

    slide9.addText("n-" + slideData.tblB[0], tableBase_9);
    slide9.addText("n-" + slideData.tblB[1], { ...tableBase_9, x: 9.0 });

    slide9.addText([
        { text: slideData.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
        { text: slideData.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } }
    ], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });

    slide9.addText(slideData.bottom1, fText1_9);
    slide9.addText(slideData.bottom2, fText2_9);
    slide9.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

    slide9.addImage({ ...logo1_9, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
    slide9.addImage({ ...logo2_9, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });
    slide9.addShape(pptx.ShapeType.line, { x: 6.74, y: 0.96, w: 0.00, h: 4.09, line: { color: '969696', width: 1, dashType: 'dash' } });
});



// Slide 11:Consumed alone or with others

        // ---- TEXT AND SHAPE POSITION PRESETS ----
        let topHead_11 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
        let subHead_11 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
        let leftHead_11 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
        let leftSubHead_11 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
        let rightHead_11 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
        let rightSubHead_11 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
        let fText1_11 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
        let fText2_11 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
        let tableBase_11 = { x: 7.95, y: 4.21, w: 0.67, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, align: 'center', color: '969696' };
        let logo1_11 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
        let logo2_11 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

        // ---- DONUT STYLE PRESETS ----
        var donutConfig = {
            width: 0.65,
            height: 0.65,
            spacingX: 0.12,
            spacingY: 0.03,
            baseX: 1.00,
            baseY: 1.48,
            leftLabelWidth: 1,
            leftLabelFontSize: 6,
            percentFontSize: 5,
            percentColor: '000000',
            chartMainColor: '000000',
            chartBaseColor: '#e0e0e0'
        };

        // ---- DATA PREPARATION ----
        const countryLabels11 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
        var consumptionWithcountryLevel = data['CM_C11Country'];
        var consumptionWithquarterLevel = data['CM_C11Quarter'];
        var consumptionWithopt = CMC11label2;
        var Q1 = consumptionWithquarterLevel["Q1'25"];
        var Q2 = consumptionWithquarterLevel["Q2'25"];
        const consumptionWithq1 = Q1.map(item => item.percentage);
        const consumptionWithq2 = Q2.map(item => item.percentage);
        const sigconsumptionWithq1 = Q1.map(item => item.percentage2);
        const sigconsumptionWithq2 = Q2.map(item => item.percentage2);
        var consumptionWithbaseData = [Q1[0].bCount, Q2[0].bCount];
        const consumptionWith1 = [], consumptionWith2 = [], consumptionWith3 = [], consumptionWith4 = [], consumptionWith5 = [], consumptionWithbaseArray = [];


        const baseArray11 = [];
        for (const country of countryLabels11) {
        const cData = consumptionWithcountryLevel[country];
        baseArray11.push(
            cData && cData[0] && typeof cData[0].bCount !== "undefined"
            ? `n-${cData[0].bCount}`
            : "n--"
        );
        }
        const bCountRow11 = [{ text: "", options: {} }];
        baseArray11.forEach(val => {
        bCountRow11.push({
            text: val,
            options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
        });
        });

        slide11.addTable([bCountRow11], {
        x: 0.23, y: 4.86, w: 6.04,
        colW: [1, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8],
        fontSize: 7,
        fontFace: 'Arial',
        align: 'center',
        border: [0]
        });



        countryLabel4.forEach(country => {
            if (consumptionWithcountryLevel[country]) {
                let countryData = consumptionWithcountryLevel[country];
                consumptionWithbaseArray.push(`n-${countryData[0].bCount}`);
                consumptionWith1.push(countryData[0].percentage);
                consumptionWith2.push(countryData[1].percentage);
                consumptionWith3.push(countryData[2].percentage);
                consumptionWith4.push(countryData[3].percentage+countryData[4].percentage);
                consumptionWith5.push(countryData[5].percentage+countryData[6].percentage);
            }
        });

        const consumptionWithArray = [{
            title: "Consumed Alone vs. with others",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "Half Yearly (H1’25)",
            subtitle3: "Quarterly – SEA (Q1’25 & Q2’25)",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: [
                "", 
                "https://keresearch.in/mdynata/assets/images/1.png",
                "https://keresearch.in/mdynata/assets/images/2.png",
                "https://keresearch.in/mdynata/assets/images/3.png",
                "https://keresearch.in/mdynata/assets/images/4.png",
                "https://keresearch.in/mdynata/assets/images/5.png",
                "https://keresearch.in/mdynata/assets/images/6.png"
            ],
            funnel: consumptionWithopt,
            f: [consumptionWith1, consumptionWith2, consumptionWith3, consumptionWith4, consumptionWith5],
            sampleSizes: consumptionWithbaseArray,
            bottom1: "C10. Did you have it along with anything else or by itself on this occasion?",
            bottom2: "",
            btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous wave", btm6: " at 95% CI",
            tblB: [consumptionWithbaseData[0], consumptionWithbaseData[1]],
            table: [
                ["", "Q1'25", "Q2'25"],
                [consumptionWithopt[0].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[0] + '%', consumptionWithq2[0] + '%'],
                [consumptionWithopt[1].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[1] + '%', consumptionWithq2[1] + '%'],
                [consumptionWithopt[2].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[2] + '%', consumptionWithq2[2] + '%'],
                [consumptionWithopt[3].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[3]+consumptionWithq1[4] + '%', consumptionWithq2[3]+consumptionWithq2[4] + '%'],
                [consumptionWithopt[4].replace(/<[^>]*>/g, '').trim(), consumptionWithq1[5]+consumptionWithq1[6] + '%', consumptionWithq2[5]+consumptionWithq2[6] + '%']
            ],
            table2: [
                [sigconsumptionWithq1[0] , sigconsumptionWithq2[0] ],
                [sigconsumptionWithq1[1] , sigconsumptionWithq2[1] ],
                [sigconsumptionWithq1[2] , sigconsumptionWithq2[2] ],
                [sigconsumptionWithq1[3]+sigconsumptionWithq1[4] , sigconsumptionWithq2[3]+sigconsumptionWithq2[4] ],
                [sigconsumptionWithq1[5]+sigconsumptionWithq1[6] , sigconsumptionWithq2[5]+sigconsumptionWithq2[6] ]
            ]
        }];

        // ---- DRAW SLIDE ----
        consumptionWithArray.forEach(slideData => {
            slide11.addText(slideData.title, topHead_11);
            slide11.addText(slideData.subtitle, subHead_11);
            slide11.addText(slideData.subtitle1, leftHead_11);
            slide11.addText("Base – Those who Consumed in Past 3 months", leftSubHead_11);
            slide11.addText("Base – Those who consumed in Past 3 months", rightSubHead_11);
            slide11.addText(slideData.subtitle3, rightHead_11);
            slide11.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide11.addShape(pptx.ShapeType.line, { x: 6.83, y: 1.02, w: 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });

            // <==================================|Significance Testing|==================================>

        var baseArray = slideData.tblB;
        var tabArray = slideData.table2;
        // console.log('barray', baseArray);
        // console.log('darray', tabArray);
        var slidesignificance_11 = [];
        tabArray.forEach(element => {
            // console.log("a",baseArray);
            // console.log("b",element);
            var significantResults = getSignificanceMatrix(baseArray, element);
            slidesignificance_11.push(significantResults);
            // console.log("c", significantResults);
        });

        var slideMerged_11 = [];
        slideMerged_11.push(slideData.table[0]);
        for (let i = 1; i < slideData.table.length; i++) {
            let originalRow = slideData.table[i];
            let additionalRow = slidesignificance_11[i - 1]; 

            let newRow = [];

            for (let j = 0; j < originalRow.length; j++) {
                if (j === 0) {
                    // Keep row heading
                    newRow.push(originalRow[j]);
                } else {
                    let originalValue = originalRow[j];
                    let additionalValue = (additionalRow && additionalRow[j - 1]) ? additionalRow[j - 1] : "";
                    newRow.push(originalValue + additionalValue);
                }
            }

            slideMerged_11.push(newRow);
        }

        console.log("abc",slideMerged_11);


        
        // <==================================|Significance Testing|==================================>

            
            for (let labelIdx = 0; labelIdx < 5; labelIdx++) {
                let label = slideData.funnel[labelIdx];
                slideData.countries.forEach((country, countryIdx) => {
                    let percent = slideData.f[labelIdx][countryIdx];
                    let x = donutConfig.baseX + countryIdx * (donutConfig.width + donutConfig.spacingX);
                    let y = donutConfig.baseY + labelIdx * (donutConfig.height + donutConfig.spacingY) + 0.1;

                    slide11.addChart(pptx.charts.DOUGHNUT, [{
                        name: `${country} - ${label}`,
                        labels: [label, ""],
                        values: [percent, 100 - percent]
                    }], {
                        x, y,
                        w: donutConfig.width,
                        h: donutConfig.height,
                        chartColors: [donutConfig.chartMainColor, donutConfig.chartBaseColor],
                        showLegend: false,
                        showValue: false,
                        dataLabelFontSize: 0
                    });

                    slide11.addText(`${percent}%`, {
                        x: x + 0.12 , y: y + 0.16, w: 0.4, h: 0.32,
                        fontSize: donutConfig.percentFontSize,
                        color: donutConfig.percentColor,
                        fontFace: 'Arial',
                        bold: true,
                        align: 'center',
                        valign: 'middle'
                    });

                    if (labelIdx === 0) {
                        slide11.addText(country, {
                        x: x - 0.05, y: y - 0.11, w: 0.80, h: 0.2,
                        align: 'center', fontSize: 8, bold: true,
                        fontFace: "Arial", color: "000000"
                    });
                        if (slideData.flags[countryIdx]) {
                            slide11.addImage({
                                x: x + (donutConfig.width - 0.30) / 2,
                                y: y - 0.38,
                                w: 0.35,
                                h: 0.33,
                                path: slideData.flags[countryIdx]
                            });
                        }
                    }

                    let cleanLabel = label.replace(/<[^>]*>/g, '').trim();
                    if (countryIdx === 0) {
                        slide11.addText(cleanLabel, {
                            // x: x - (donutConfig.leftLabelWidth + 0.1),
                            x: x - (donutConfig.leftLabelWidth),
                            y: y + 0.23,
                            w: donutConfig.leftLabelWidth,
                            h: 0.2,
                            align: 'left',
                            fontSize: donutConfig.leftLabelFontSize,
                            bold: true,
                            fontFace: "Arial",
                            color: donutConfig.percentColor
                        });
                    }
                    if (labelIdx < 4) {  // Skip after last row
                        slide11.addShape(pptx.ShapeType.line, {
                            x: donutConfig.baseX - 0.75,
                            y: donutConfig.baseY + (labelIdx + 1) * (donutConfig.height + donutConfig.spacingY) + 0.07,
                            w: 6.5,
                            h: 0,
                            line: { color: 'e0e0e0', width: 0.75 }
                        });
                    }
                });
            }

    // Table
    let tableRows = slideMerged_11.map((row, rowIndex, allRows) =>
        row.map(cell => ({
            text: cell,
            options: {
                border: (rowIndex === 0 || rowIndex === allRows.length - 1) ? [false, false, false, false] : [false, false, true, false],
                borderColor: 'e0e0e0',
                borderSize: 0.5,
                fontSize: 8,
                align: 'center',
                valign: 'middle'
            }
        }))
    );
    slide11.addTable(tableRows, { x: 6.83, y: 1.46, w: 3.07, h: 2.76 });

    slide11.addText("n-" + slideData.tblB[0], tableBase_11);
    slide11.addText("n-" + slideData.tblB[1], { ...tableBase_11, x: 9.0 });

    slide11.addText([
        { text: slideData.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } },
        { text: slideData.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
        { text: slideData.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6 } }
    ], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });

    slide11.addText(slideData.bottom1, fText1_11);
    slide11.addText(slideData.bottom2, fText2_11);
    slide11.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

    slide11.addImage({ ...logo1_11, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
    slide11.addImage({ ...logo2_11, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });
    slide11.addShape(pptx.ShapeType.line, { x: 6.74, y: 0.96, w: 0.00, h: 4.09, line: { color: '969696', width: 1, dashType: 'dash' } });
});





// ----------- PPT Slide 12: S -----------

// Slide essentials
let topHead_12 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_12 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
// let subHead_12_2 = { x: 0.24, y: 2.79, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_12 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_12_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_12 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_12 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_12 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_12 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_12 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_12 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_12 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_12 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_12 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_12 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_12 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// ---- Prepare table arrays ----
const countryLabels = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const quarterLabels = ["Q1'25", "Q2'25"];
const funnelLabels = CMC15label; 
const countryData = data['CM_C15Country'];
const quarterData = data['CM_C15Quarter'];
const countryData2 = data['CM_C20Country'];
const quarterData2 = data['CM_C20Quarter'];



// Slide titles/static text
const slideData = {
  title: "Change in Consumption",
  subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "Change in personal consumption over last 12 months",
  subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "C15/ C20. Compared to the last 1 year, how has your personal/ household consumption of Dairy Milk (from Cows) changed?",
  bottom2: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide12.addText(slideData.title, topHead_12);
slide12.addText(slideData.subtitle, subHead_12);
slide12.addText(slideData.subtitle2, leftHead_12_2);
slide12.addText(slideData.subtitle1, leftHead_12);
slide12.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide12.addShape(pptx.ShapeType.line, { x: 0.16, y: 3.08, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide12.addText(slideData.countries[0], { ...country1_12, x: 1.01 });
slide12.addText(slideData.countries[1], { ...country2_12, x: 1.87 });
slide12.addText(slideData.countries[2], { ...country3_12, x: 2.74 });
slide12.addText(slideData.countries[3], { ...country4_12, x: 3.55 });
slide12.addText(slideData.countries[4], { ...country5_12, x: 4.32 });
slide12.addText(slideData.countries[5], { ...country6_12, x: 5.10 });
slide12.addText(slideData.countries[6], { ...country7_12, x: 5.91 });

slide12.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
slide12.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
slide12.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
slide12.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
slide12.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
slide12.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });


const baseArray12_1 = [];
const baseArray12_P1 = [];
for (const country of countryLabels) {
  const cData = countryData[country];
  baseArray12_1.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray12_P1.push(cData[0].bCount);
}
const bCountRow12_1 = [{ text: "", options: {} }];
baseArray12_1.forEach(val => {
  bCountRow12_1.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

const baseArray12_2 = [];
const baseArray12_P2 = [];
for (const country of countryLabels) {
  const cData = countryData2[country];
  baseArray12_2.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray12_P2.push(cData[0].bCount);
}
const bCountRow12_2 = [{ text: "", options: {} }];
baseArray12_2.forEach(val => {
  bCountRow12_2.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

const baseArray12_3 = [];
const baseArray12_P3 = [];
for (const quarter of quarterLabels) {
  const cData = quarterData[quarter];
  baseArray12_3.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray12_P3.push(cData[0].bCount);
}
const bCountRow12_3 = [{ text: "", options: {} }];
baseArray12_3.forEach(val => {
  bCountRow12_3.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

const baseArray12_4 = [];
const baseArray12_P4 = [];
for (const quarter of quarterLabels) {
  const cData = quarterData2[quarter];
  baseArray12_4.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray12_P4.push(cData[0].bCount);
}
const bCountRow12_4 = [{ text: "", options: {} }];
baseArray12_4.forEach(val => {
  bCountRow12_4.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

slide12.addTable([bCountRow12_1], {
  x: 0.23, y: 2.59, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
slide12.addTable([bCountRow12_2], {
  x: 0.23, y: 4.09, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
slide12.addTable([bCountRow12_3], {
  x: 7.35, y: 2.59, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
slide12.addTable([bCountRow12_4], {
  x: 7.35, y: 4.09, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});


// Country table
let countryTable = [];
let countryTableP2 = [];
let countryTable2 = [];
let countryTable2P2 = [];
for (let i = 0; i < funnelLabels.length; i++) {
    let row = [funnelLabels[i]]; 
    let row2 = [];
  countryLabels.forEach(country => {
    const cell = countryData[country][i].percentage + "%";
    const cell2 = countryData[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable.push(row);
  countryTableP2.push(row2);  
}

for (let i = 0; i < funnelLabels.length; i++) {
    let row = [funnelLabels[i]]; 
    let row2 = [];
  countryLabels.forEach(country => {
    const cell = countryData2[country][i].percentage + "%";
    const cell2 = countryData2[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable2.push(row);
  countryTable2P2.push(row2); 
}
// Quarter table
let quarterTable = [ [ "", "Q1'25", "Q2'25" ] ];
let quarterTableP2 = [];
let quarterTable2 = [ [ "", "Q1'25", "Q2'25" ] ];
let quarterTable2P2 = [];
for (let i = 0; i < funnelLabels.length; i++) {
  quarterTable.push([ funnelLabels[i], quarterData["Q1'25"][i].percentage + "%", quarterData["Q2'25"][i].percentage + "%" ]);
  quarterTableP2.push([quarterData["Q1'25"][i].percentage2, quarterData["Q2'25"][i].percentage2]);
}
for (let i = 0; i < funnelLabels.length; i++) {
  quarterTable2.push([ funnelLabels[i], quarterData2["Q1'25"][i].percentage + "%", quarterData2["Q2'25"][i].percentage + "%" ]);
  quarterTable2P2.push([ quarterData2["Q1'25"][i].percentage2 , quarterData2["Q2'25"][i].percentage2]);
}

// <==================================|Significance Testing1|==================================>
var baseArray = baseArray12_P1;
var tabArray = countryTableP2;
var slidesignificance_12_1 = [];

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_12_1.push(significantResults);
});

var slideMerged_12_1 = [];
for (let i = 0; i < countryTable.length; i++) {
    let originalRow = countryTable[i];               
    let significanceRow = slidesignificance_12_1[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_12_1.push(newRow);
}
countryTable = slideMerged_12_1;
// <==================================|Significance Testing1|==================================>
// <==================================|Significance Testing2|==================================>
var baseArray = baseArray12_P2;
var tabArray = countryTable2P2;
var slidesignificance_12_2 = [];

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_12_2.push(significantResults);
});

var slideMerged_12_2 = [];
for (let i = 0; i < countryTable2.length; i++) {
    let originalRow = countryTable2[i];               
    let significanceRow = slidesignificance_12_2[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_12_2.push(newRow);
}
countryTable2 = slideMerged_12_2;
console.log("nnnnn",countryTable2 );
// <==================================|Significance Testing2|==================================>
// <==================================|Significance Testing3|==================================>
var baseArray = baseArray12_P3;
var tabArray = quarterTableP2;
var slidesignificance_12_3 = [];

// Generate significance matrix
tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_12_3.push(significantResults);
});

var slideMerged_12_3 = [];

// Keep header row as-is
slideMerged_12_3.push(quarterTable[0]);

// Process data rows with significance
for (let i = 1; i < quarterTable.length; i++) {
    let originalRow = quarterTable[i];               
    let significanceRow = slidesignificance_12_3[i - 1]; 
    let newRow = [];

    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");

        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [
                    { pt: 0, color: "FFFFFF" },
                    { pt: 0, color: "FFFFFF" },
                    { pt: 0.5, color: "cccccc" },
                    { pt: 0, color: "FFFFFF" }
                ]
            }
        });
    }

    slideMerged_12_3.push(newRow);
}

quarterTable = slideMerged_12_3;
// <==================================|Significance Testing3|==================================>

// <==================================|Significance Testing4|==================================>
var baseArray = baseArray12_P4;
var tabArray = quarterTable2P2;
var slidesignificance_12_4 = [];

// Generate significance matrix
tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_12_4.push(significantResults);
});

var slideMerged_12_4 = [];

// Preserve the first row (header)
slideMerged_12_4.push(quarterTable2[0]);

// Apply significance to remaining rows
for (let i = 1; i < quarterTable2.length; i++) {
    let originalRow = quarterTable2[i];               
    let significanceRow = slidesignificance_12_4[i - 1]; 
    let newRow = [];

    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");

        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [
                    { pt: 0, color: "FFFFFF" },
                    { pt: 0, color: "FFFFFF" },
                    { pt: 0.5, color: "cccccc" },
                    { pt: 0, color: "FFFFFF" }
                ]
            }
        });
    }

    slideMerged_12_4.push(newRow);
}

quarterTable2 = slideMerged_12_4;
// <==================================|Significance Testing4|==================================>



// ---- Add side-by-side tables ----
slide12.addTable(countryTable, {
  x: 0.23, y: 1.86, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
slide12.addTable(countryTable2, {
  x: 0.23, y: 3.42, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
slide12.addTable(quarterTable, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
slide12.addTable(quarterTable2, {
  x: 7.35, y: 3.2, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});

// ---- Footnotes and Logos ----
slide12.addText(slideData.bottom1, fText1_12);
slide12.addText(slideData.bottom2, fText2_12);
slide12.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide12.addText([
  { text: slideData.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide12.addImage({ ...logo1_12, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide12.addImage({ ...logo2_12, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });

// ----------- End of Slide 12 Code -----------
	

// ----------- PPT Slide 14-----------
let topHead_14 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_14 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_14 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_14_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_14 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_14 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_14 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_14 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_14 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_14 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_14 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_14 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_14 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_14 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_14 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData14 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "S5. Indicate your age in completed years.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide14.addText(slideData14.title, topHead_14);
slide14.addText("Age", { x: 0.16, y: 1.51, w: 1.6, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 10, bold: true, color: '000000'});
// slide14.addText(slideData14.subtitle, subHead_14);
// slide14.addText(slideData14.subtitle2, leftHead_14_2);
slide14.addText(slideData14.subtitle1, leftHead_14);
slide14.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide14.addText(slideData14.countries[0], { ...country1_14, x: 1.56 });
slide14.addText(slideData14.countries[1], { ...country2_14, x: 2.8 });
slide14.addText(slideData14.countries[2], { ...country3_14, x: 4.06 });
slide14.addText(slideData14.countries[3], { ...country4_14, x: 5.27 });
slide14.addText(slideData14.countries[4], { ...country5_14, x: 6.43 });
slide14.addText(slideData14.countries[5], { ...country6_14, x: 7.6 });
slide14.addText(slideData14.countries[6], { ...country7_14, x: 8.9 });

slide14.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[1] });
slide14.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[2] });
slide14.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[3] });
slide14.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[4] });
slide14.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[5] });
slide14.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData14.flags[6] });

// ---- Prepare table arrays ----
const countryLabels14 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels14 = ageLabelXXX;
const countryData14 = data['HAGE'];
// const quarterData14 = data['CM_C15Quarter'];

const baseArray14 = [];
const baseArray14_P1 = [];
for (const country of countryLabels14) {
  const cData = countryData14[country];
  baseArray14.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray14_P1.push(cData[0].bCount);
}
const bCountRow14 = [{ text: "", options: {} }];
baseArray14.forEach(val => {
  bCountRow14.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable14 = [];
let countryTable14_P2 = [];
for (let i = 0; i < funnelLabels14.length; i++) {
  let row = [funnelLabels14[i]];
  let row2 = [];
  countryLabels14.forEach(country => {
    const cell = countryData14[country][i].percentage + "%";
    const cell2 = countryData14[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable14.push(row);
  countryTable14_P2.push(row2);
}
// <==================================|Significance Testing|==================================>
var baseArray = baseArray14_P1;
var tabArray = countryTable14_P2;
var slidesignificance_14 = [];

// console.log("bArr", baseArray);
// console.log("dArr", tabArray);

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_14.push(significantResults);
});
console.log("sig", slidesignificance_14);

var slideMerged_14 = [];
for (let i = 0; i < countryTable14.length; i++) {
    let originalRow = countryTable14[i];               
    let significanceRow = slidesignificance_14[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_14.push(newRow);
}
countryTable14 = slideMerged_14;
// <==================================|Significance Testing|==================================>


slide14.addTable(countryTable14, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});

slide14.addTable([bCountRow14], {
  x: 0.23, y: 2.96, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

// ---- Footnotes and Logos ----
slide14.addText(slideData14.bottom1, fText1_14);
slide14.addText(slideData14.bottom2, fText2_14);
slide14.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide14.addText([
  { text: slideData14.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData14.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData14.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData14.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData14.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData14.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide14.addImage({ ...logo1_14, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide14.addImage({ ...logo2_14, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });


// ----------- PPT Slide 15-----------
let topHead_15 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_15 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_15 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_15_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_15 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_15 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_15 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_15 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_15 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_15 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_15 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_15 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_15 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_15 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_15 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData15 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "P4. Please Indicate your Education.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide15.addText(slideData15.title, topHead_15);
slide15.addText("Education", { x: 0.16, y: 1.51, w: 1.6, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 10, bold: true, color: '000000'});
// slide15.addText(slideData15.subtitle, subHead_15);
// slide15.addText(slideData15.subtitle2, leftHead_15_2);
slide15.addText(slideData15.subtitle1, leftHead_15);
slide15.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide15.addText(slideData15.countries[0], { ...country1_15, x: 1.56 });
slide15.addText(slideData15.countries[1], { ...country2_15, x: 2.8 });
slide15.addText(slideData15.countries[2], { ...country3_15, x: 4.06 });
slide15.addText(slideData15.countries[3], { ...country4_15, x: 5.27 });
slide15.addText(slideData15.countries[4], { ...country5_15, x: 6.43 });
slide15.addText(slideData15.countries[5], { ...country6_15, x: 7.6 });
slide15.addText(slideData15.countries[6], { ...country7_15, x: 8.9 });

slide15.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[1] });
slide15.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[2] });
slide15.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[3] });
slide15.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[4] });
slide15.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[5] });
slide15.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData15.flags[6] });

// ---- Prepare table arrays ----
const countryLabels15 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels15 = educationXX;
const countryData15 = data['P4'];
// const quarterData15 = data['CM_C15Quarter'];

const baseArray15 = [];
const baseArray15_P2 = [];
for (const country of countryLabels15) {
  const cData = countryData15[country];
  baseArray15.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray15_P2.push(cData[0].bCount);
}
const bCountRow15 = [{ text: "", options: {} }];
baseArray15.forEach(val => {
  bCountRow15.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable15 = [];
let countryTable15_P2 = [];
for (let i = 0; i < funnelLabels15.length; i++) {
  let row = [funnelLabels15[i],];
  let row2 = [];
  countryLabels15.forEach(country => {
    const cell = countryData15[country][i].percentage + "%";
    const cell2 = countryData15[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable15.push(row);
  countryTable15_P2.push(row2);
}
// <==================================|Significance Testing|==================================>
var baseArray = baseArray15_P2;
var tabArray = countryTable15_P2;
var slidesignificance_15 = [];

console.log("bArr", baseArray);
console.log("dArr", tabArray);

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_15.push(significantResults);
});
console.log("sig", slidesignificance_15);

var slideMerged_15 = [];
for (let i = 0; i < countryTable15.length; i++) {
    let originalRow = countryTable15[i];               
    let significanceRow = slidesignificance_15[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_15.push(newRow);
}
countryTable15 = slideMerged_15;
// <==================================|Significance Testing|==================================>
slide15.addTable(countryTable15, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});

slide15.addTable([bCountRow15], {
  x: 0.23, y: 3.43, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

// ---- Footnotes and Logos ----
slide15.addText(slideData15.bottom1, fText1_15);
slide15.addText(slideData15.bottom2, fText2_15);
slide15.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide15.addText([
  { text: slideData15.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData15.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData15.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData15.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData15.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData15.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide15.addImage({ ...logo1_15, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide15.addImage({ ...logo2_15, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });



// ----------- PPT Slide 16-----------
let topHead_16 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_16 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_16 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_16_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_16 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_16 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_16 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_16 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_16 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_16 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_16 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_16 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_16 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_16 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_16 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData16 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "S10. Do you follow Halal dietary requirements.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide16.addText(slideData16.title, topHead_16);
slide16.addText("Dietary Restrictions", { x: 0.16, y: 1.51, w: 1.6, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 10, bold: true, color: '000000'});
// slide16.addText(slideData16.subtitle, subHead_16);
// slide16.addText(slideData16.subtitle2, leftHead_16_2);
slide16.addText(slideData16.subtitle1, leftHead_16);
slide16.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide16.addText(slideData16.countries[0], { ...country1_16, x: 1.56 });
slide16.addText(slideData16.countries[1], { ...country2_16, x: 2.8 });
slide16.addText(slideData16.countries[2], { ...country3_16, x: 4.06 });
slide16.addText(slideData16.countries[3], { ...country4_16, x: 5.27 });
slide16.addText(slideData16.countries[4], { ...country5_16, x: 6.43 });
slide16.addText(slideData16.countries[5], { ...country6_16, x: 7.6 });
slide16.addText(slideData16.countries[6], { ...country7_16, x: 8.9 });

slide16.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[1] });
slide16.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[2] });
slide16.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[3] });
slide16.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[4] });
slide16.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[5] });
slide16.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData16.flags[6] });

// ---- Prepare table arrays ----
const countryLabels16 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels16 = halalLabel;
const countryData16 = data['S10'];
// const quarterData16 = data['CM_C16Quarter'];

const baseArray16 = [];
const baseArray16_P2 = [];
for (const country of countryLabels16) {
  const cData = countryData16[country];
  baseArray16.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray16_P2.push(cData[0].bCount);
}
const bCountRow16 = [{ text: "", options: {} }];
baseArray16.forEach(val => {
  bCountRow16.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable16 = [];
let countryTable16_P2 = [];
for (let i = 0; i < funnelLabels16.length; i++) {
  let row = [funnelLabels16[i]];
  let row2 = [];
  countryLabels16.forEach(country => {
    const cell = countryData16[country][i].percentage + "%";
    const cell2 = countryData16[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable16.push(row);
  countryTable16_P2.push(row2);
}
// <==================================|Significance Testing|==================================>
var baseArray = baseArray16_P2;
var tabArray = countryTable16_P2;
var slidesignificance_16 = [];

console.log("bArr", baseArray);
console.log("dArr", tabArray);

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_16.push(significantResults);
});
console.log("sig", slidesignificance_16);

var slideMerged_16 = [];
for (let i = 0; i < countryTable16.length; i++) {
    let originalRow = countryTable16[i];               
    let significanceRow = slidesignificance_16[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_16.push(newRow);
}
countryTable16 = slideMerged_16;
// <==================================|Significance Testing|==================================>
/* let quarterTable16 = [
  ["", "Q1'25", "Q2'25"]
];
for (let i = 0; i < funnelLabels16.length; i++) {
  quarterTable16.push([
    funnelLabels16[i],
    quarterData16["Q1'25"][i].percentage + "%",
    quarterData16["Q2'25"][i].percentage + "%"
  ]);
} */

slide16.addTable(countryTable16, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});
slide16.addTable([bCountRow16], {
  x: 0.23, y: 2.52, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* 
slide16.addTable(quarterTable16, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide16.addText(slideData16.bottom1, fText1_16);
slide16.addText(slideData16.bottom2, fText2_16);
slide16.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide16.addText([
  { text: slideData16.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData16.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData16.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData16.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData16.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData16.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide16.addImage({ ...logo1_16, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide16.addImage({ ...logo2_16, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });



// ----------- PPT Slide 17-----------
let topHead_17 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_17 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_17 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_17_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_17 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_17 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_17 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_17 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_17 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_17 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_17 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_17 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_17 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_17 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_17 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData17 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "P5. Please select your Relationship status.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide17.addText(slideData17.title, topHead_17);
slide17.addText("Occupation", { x: 0.16, y: 1.51, w: 1.6, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 10, bold: true, color: '000000'});
// slide17.addText(slideData17.subtitle, subHead_17);
// slide17.addText(slideData17.subtitle2, leftHead_17_2);
slide17.addText(slideData17.subtitle1, leftHead_17);
slide17.addShape(pptx.ShapeType.line, { x: 0.17, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide17.addText(slideData17.countries[0], { ...country1_17, x: 1.56 });
slide17.addText(slideData17.countries[1], { ...country2_17, x: 2.8 });
slide17.addText(slideData17.countries[2], { ...country3_17, x: 4.06 });
slide17.addText(slideData17.countries[3], { ...country4_17, x: 5.27 });
slide17.addText(slideData17.countries[4], { ...country5_17, x: 6.43 });
slide17.addText(slideData17.countries[5], { ...country6_17, x: 7.6 });
slide17.addText(slideData17.countries[6], { ...country7_17, x: 8.9 });

slide17.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[1] });
slide17.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[2] });
slide17.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[3] });
slide17.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[4] });
slide17.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[5] });
slide17.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData17.flags[6] });

// ---- Prepare table arrays ----
const countryLabels17 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels17 = occupationLabel;
const countryData17 = data['P5'];
// const quarterData17 = data['CM_C17Quarter'];

const baseArray17 = [];
const baseArray17_P2 = [];
for (const country of countryLabels17) {
  const cData = countryData17[country];
  baseArray17.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray17_P2.push(cData[0].bCount);
}
const bCountRow17 = [{ text: "", options: {} }];
baseArray17.forEach(val => {
  bCountRow17.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable17 = [];
let countryTable17_P2 = [];
for (let i = 0; i < funnelLabels17.length; i++) {
  let cleanLabel = funnelLabels17[i];
  cleanLabel = cleanLabel.replace(/<[^>]*>/g, '').trim();
  let row = [cleanLabel];
  let row2 = [];
  countryLabels17.forEach(country => {
    const cell = countryData17[country][i].percentage + "%";
    const cell2 = countryData17[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable17.push(row);
  countryTable17_P2.push(row2);
}

// <==================================|Significance Testing|==================================>
var baseArray = baseArray17_P2;
var tabArray = countryTable17_P2;
var slidesignificance_17 = [];

console.log("bArr", baseArray);
console.log("dArr", tabArray);

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_17.push(significantResults);
});
console.log("sig", slidesignificance_17);

var slideMerged_17 = [];
for (let i = 0; i < countryTable17.length; i++) {
    let originalRow = countryTable17[i];               
    let significanceRow = slidesignificance_17[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_17.push(newRow);
}
countryTable17 = slideMerged_17;
// <==================================|Significance Testing|==================================>


slide17.addTable(countryTable17, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});
slide17.addTable([bCountRow17], {
  x: 0.23, y: 3.62, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* 
slide17.addTable(quarterTable17, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide17.addText(slideData17.bottom1, fText1_17);
slide17.addText(slideData17.bottom2, fText2_17);
slide17.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide17.addText([
  { text: slideData17.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData17.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData17.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData17.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData17.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData17.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide17.addImage({ ...logo1_17, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide17.addImage({ ...logo2_17, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });


// ----------- PPT Slide 18-----------
let topHead_18 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_18 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_18 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_18_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_18 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_18 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_18 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_18 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_18 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_18 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_18 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_18 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_18 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_18 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_18 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData18 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "S7. Please indicate your gross monthly household income. By gross, this means before tax, national insurance or any other deductions",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide18.addText(slideData18.title, topHead_18);
slide18.addText("Household Income", { x: 0.16, y: 1.51, w: 1.6, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 10, bold: true, color: '000000'});
// slide18.addText(slideData18.subtitle, subHead_18);
// slide18.addText(slideData18.subtitle2, leftHead_18_2);
slide18.addText(slideData18.subtitle1, leftHead_18);
slide18.addShape(pptx.ShapeType.line, { x: 0.18, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide18.addText(slideData18.countries[0], { ...country1_18, x: 1.56 });
slide18.addText(slideData18.countries[1], { ...country2_18, x: 2.8 });
slide18.addText(slideData18.countries[2], { ...country3_18, x: 4.06 });
slide18.addText(slideData18.countries[3], { ...country4_18, x: 5.27 });
slide18.addText(slideData18.countries[4], { ...country5_18, x: 6.43 });
slide18.addText(slideData18.countries[5], { ...country6_18, x: 7.6 });
slide18.addText(slideData18.countries[6], { ...country7_18, x: 8.9 });

slide18.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[1] });
slide18.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[2] });
slide18.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[3] });
slide18.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[4] });
slide18.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[5] });
slide18.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData18.flags[6] });

// ---- Prepare table arrays ----
const countryLabels18 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels18 = incomeLabel;
const countryData18 = data['S7'];
// const quarterData18 = data['CM_C18Quarter'];

const baseArray18 = [];
const baseArray18_P2 = [];
for (const country of countryLabels18) {
  const cData = countryData18[country];
  baseArray18.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray18_P2.push(cData[0].bCount);
}
const bCountRow18 = [{ text: "", options: {} }];
baseArray18.forEach(val => {
  bCountRow18.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable18 = [];
let countryTable18_P2 = [];
for (let i = 0; i < funnelLabels18.length; i++) {
  let row = [funnelLabels18[i]];
  let row2 = [];
  countryLabels18.forEach(country => {
    const cell = countryData18[country][i].percentage + "%";
    const cell2 = countryData18[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable18.push(row);
  countryTable18_P2.push(row2);
}
// <==================================|Significance Testing|==================================>
var baseArray = baseArray18_P2;
var tabArray = countryTable18_P2;
var slidesignificance_18 = [];

console.log("bArr", baseArray);
console.log("dArr", tabArray);

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_18.push(significantResults);
});
console.log("sig", slidesignificance_18);

var slideMerged_18 = [];
for (let i = 0; i < countryTable18.length; i++) {
    let originalRow = countryTable18[i];               
    let significanceRow = slidesignificance_18[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_18.push(newRow);
}
countryTable18 = slideMerged_18;
// <==================================|Significance Testing|==================================>
/* let quarterTable18 = [
  ["", "Q1'25", "Q2'25"]
];
for (let i = 0; i < funnelLabels18.length; i++) {
  quarterTable18.push([
    funnelLabels18[i],
    quarterData18["Q1'25"][i].percentage + "%",
    quarterData18["Q2'25"][i].percentage + "%"
  ]);
} */

slide18.addTable(countryTable18, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});
slide18.addTable([bCountRow18], {
  x: 0.23, y: 3.3, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* 
slide18.addTable(quarterTable18, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide18.addText(slideData18.bottom1, fText1_18);
slide18.addText(slideData18.bottom2, fText2_18);
slide18.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide18.addText([
  { text: slideData18.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData18.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData18.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData18.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData18.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData18.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide18.addImage({ ...logo1_18, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide18.addImage({ ...logo2_18, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });


// slide 19 -------------------------------

let topHead_19 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_19 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_19 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_19_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_19 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_19 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_19 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_19 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_19 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_19 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_19 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_19 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_19 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_19 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_19 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData19 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "P5. Please select your Occupation status.",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide19.addText(slideData19.title, topHead_19);
slide19.addText("Relationship Status", { x: 0.16, y: 1.51, w: 1.6, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 10, bold: true, color: '000000'});
// slide19.addText(slideData19.subtitle, subHead_19);
// slide19.addText(slideData19.subtitle2, leftHead_19_2);
slide19.addText(slideData19.subtitle1, leftHead_19);
slide19.addShape(pptx.ShapeType.line, { x: 0.19, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide19.addText(slideData19.countries[0], { ...country1_19, x: 1.56 });
slide19.addText(slideData19.countries[1], { ...country2_19, x: 2.8 });
slide19.addText(slideData19.countries[2], { ...country3_19, x: 4.06 });
slide19.addText(slideData19.countries[3], { ...country4_19, x: 5.27 });
slide19.addText(slideData19.countries[4], { ...country5_19, x: 6.43 });
slide19.addText(slideData19.countries[5], { ...country6_19, x: 7.6 });
slide19.addText(slideData19.countries[6], { ...country7_19, x: 8.9 });

slide19.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[1] });
slide19.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[2] });
slide19.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[3] });
slide19.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[4] });
slide19.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[5] });
slide19.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData19.flags[6] });

// ---- Prepare table arrays ----
const countryLabels19 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels19 = relationXX;
const countryData19 = data['P1'];
// const quarterData19 = data['CM_C19Quarter'];

const baseArray19 = [];
const baseArray19_P2 = [];
for (const country of countryLabels19) {
  const cData = countryData19[country];
  baseArray19.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray19_P2.push(cData[0].bCount);
}
const bCountRow19 = [{ text: "", options: {} }];
baseArray19.forEach(val => {
  bCountRow19.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

// Country table
let countryTable19 = [];
let countryTable19_P2 = [];
for (let i = 0; i < funnelLabels19.length; i++) {
  let row = [funnelLabels19[i]];
  let row2 = [];
  countryLabels19.forEach(country => {
    const cell = countryData19[country][i].percentage + "%";
    const cell2 = countryData19[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable19.push(row);
  countryTable19_P2.push(row2);
}

// <==================================|Significance Testing|==================================>
var baseArray = baseArray19_P2;
var tabArray = countryTable19_P2;
var slidesignificance_19 = [];

console.log("bArr", baseArray);
console.log("dArr", tabArray);

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_19.push(significantResults);
});
console.log("sig", slidesignificance_19);

var slideMerged_19 = [];
for (let i = 0; i < countryTable19.length; i++) {
    let originalRow = countryTable19[i];               
    let significanceRow = slidesignificance_19[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_19.push(newRow);
}
countryTable19 = slideMerged_19;
// <==================================|Significance Testing|==================================>

slide19.addTable(countryTable19, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
});
slide19.addTable([bCountRow19], {
  x: 0.23, y: 3.08, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});
/* 
slide19.addTable(quarterTable19, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide19.addText(slideData19.bottom1, fText1_19);
slide19.addText(slideData19.bottom2, fText2_19);
slide19.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide19.addText([
  { text: slideData19.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData19.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData19.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData19.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData19.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData19.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide19.addImage({ ...logo1_19, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide19.addImage({ ...logo2_19, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });

	
// slide 20 ----------------------------
let topHead_20 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_20 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_20 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_20_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_20 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_20 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_20 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_20 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_20 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_20 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_20 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_20 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_20 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_20 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_20 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData20 = {
  title: "Profile of Consumers",
//   subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "H1'25",
//   subtitle2: "Change in household consumption over last 12 months",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "S7. Please indicate your gross monthly household income. By gross, this means before tax, national insurance or any other deductions",
  bottom2: "",
  bottom3: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide20.addText(slideData20.title, topHead_20);
slide20.addText("People living in household", { x: 0.16, y: 1.51, w: 1.6, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 10, bold: true, color: '000000'});
// slide20.addText(slideData20.subtitle, subHead_20);
// slide20.addText(slideData20.subtitle2, leftHead_20_2);
slide20.addText(slideData20.subtitle1, leftHead_20);
slide20.addShape(pptx.ShapeType.line, { x: 0.20, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide20.addText(slideData20.countries[0], { ...country1_20, x: 1.56 });
slide20.addText(slideData20.countries[1], { ...country2_20, x: 2.8 });
slide20.addText(slideData20.countries[2], { ...country3_20, x: 4.06 });
slide20.addText(slideData20.countries[3], { ...country4_20, x: 5.27 });
slide20.addText(slideData20.countries[4], { ...country5_20, x: 6.43 });
slide20.addText(slideData20.countries[5], { ...country6_20, x: 7.6 });
slide20.addText(slideData20.countries[6], { ...country7_20, x: 8.9 });

slide20.addImage({ x: 3.04, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[1] });
slide20.addImage({ x: 4.28, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[2] });
slide20.addImage({ x: 5.50, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[3] });
slide20.addImage({ x: 6.69, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[4] });
slide20.addImage({ x: 7.87, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[5] });
slide20.addImage({ x: 9.13, y: 1.22, w: 0.37, h: 0.38, path: slideData20.flags[6] });

// ---- Prepare table arrays ----
const countryLabels20 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const funnelLabels20 = CMC16label;
const countryData20 = data['CM_C16Country'];
// const quarterData20 = data['CM_C20Quarter'];

const baseArray20 = [];
const baseArray20_P2 = [];
for (const country of countryLabels20) {
  const cData = countryData20[country];
  baseArray20.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray20_P2.push(cData[0].bCount);
}

const bCountRow20 = [{ text: "", options: {} }];
baseArray20.forEach(val => {
  bCountRow20.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});


// Country table
let countryTable20 = [];
let countryTable20_P2 = [];
for (let i = 0; i < funnelLabels20.length; i++) {
  let row = [funnelLabels20[i]];
  let row2 = [];
  countryLabels20.forEach(country => {
    const cell = countryData20[country][i].percentage + "%";
    const cell2 = countryData20[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable20.push(row);
  countryTable20_P2.push(row2);
}

// <==================================|Significance Testing|==================================>
var baseArray = baseArray20_P2;
var tabArray = countryTable20_P2;
var slidesignificance_20 = [];

console.log("bArr", baseArray);
console.log("dArr", tabArray);

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_20.push(significantResults);
});
console.log("sig", slidesignificance_20);

var slideMerged_20 = [];
for (let i = 0; i < countryTable20.length; i++) {
    let originalRow = countryTable20[i];               
    let significanceRow = slidesignificance_20[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_20.push(newRow);
}
countryTable20 = slideMerged_20;
// <==================================|Significance Testing|==================================>
slide20.addTable(countryTable20, {
  x: 0.23, y: 1.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
});

slide20.addTable([bCountRow20], {
  x: 0.23, y: 3.86, w: 9.67,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

/* 
slide20.addTable(quarterTable20, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  border: { type: "bottom", pt: '0.5', color: 'cccccc' }
}); */

// ---- Footnotes and Logos ----
slide20.addText(slideData20.bottom1, fText1_20);
slide20.addText(slideData20.bottom2, fText2_20);
slide20.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide20.addText([
  { text: slideData20.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData20.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData20.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData20.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData20.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData20.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide20.addImage({ ...logo1_20, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide20.addImage({ ...logo2_20, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });


// ----------- PPT Slide 23: S -----------

// Slide essentials
let topHead_23 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_23 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
// let subHead_23_2 = { x: 0.24, y: 2.79, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_23 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_23_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_23 = { x: 0.20, y: 5.06, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_23 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_23 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_23 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_23 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_23 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_23 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_23 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_23 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_23 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_23 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData23 = {
  title: "Household Consumption",
  subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "Who else consumes at home, once a month",
//   subtitle2: "Quarterly – SEA (Q1’25 & Q2’25)",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "C16. Earlier, you mentioned that you have household members in the following age groups. Who else at home consumes Dairy Milk (from Cows) at least once a month besides you?",
  bottom2: "",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide23.addText(slideData23.title, topHead_23);
slide23.addText(slideData23.subtitle, subHead_23);
// slide23.addText(slideData23.subtitle2, leftHead_23_2);
slide23.addText(slideData23.subtitle1, leftHead_23);
slide23.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });
// slide23.addShape(pptx.ShapeType.line, { x: 0.16, y: 3.08, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide23.addText(slideData23.countries[0], { ...country1_23, x: 1.01 });
slide23.addText(slideData23.countries[1], { ...country2_23, x: 1.87 });
slide23.addText(slideData23.countries[2], { ...country3_23, x: 2.74 });
slide23.addText(slideData23.countries[3], { ...country4_23, x: 3.55 });
slide23.addText(slideData23.countries[4], { ...country5_23, x: 4.32 });
slide23.addText(slideData23.countries[5], { ...country6_23, x: 5.10 });
slide23.addText(slideData23.countries[6], { ...country7_23, x: 5.91 });

slide23.addImage({ x: 2.09, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[1] });
slide23.addImage({ x: 2.94, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[2] });
slide23.addImage({ x: 3.73, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[3] });
slide23.addImage({ x: 4.54, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[4] });
slide23.addImage({ x: 5.33, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[5] });
slide23.addImage({ x: 6.09, y: 1.22, w: 0.37, h: 0.38, path: slideData23.flags[6] });

// ---- Prepare table arrays ----
const countryLabels23 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const quarterLabels23 = ["Q1'25", "Q2'25"];
const funnelLabels23 = CMC16label; // Example: ["Increased", "No Change", "Decreased"]
const countryData23 = data['CM_C16Country'];
const quarterData23 = data['CM_C16Quarter'];

const baseArray23_1 = [];
const baseArray23_1_P2 = [];
for (const country of countryLabels23) {
  const cData = countryData23[country];
  baseArray23_1.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray23_1_P2.push(cData[0].bCount);
}
const bCountRow23_1 = [{ text: "", options: {} }];
baseArray23_1.forEach(val => {
  bCountRow23_1.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});


const baseArray23_3 = [];
const baseArray23_3_P2 = [];
for (const quarter of quarterLabels23) {
  const cData = quarterData23[quarter];
  baseArray23_3.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
  baseArray23_3_P2.push(cData[0].bCount);
}
const bCountRow23_3 = [{ text: "", options: {} }];
baseArray23_3.forEach(val => {
  bCountRow23_3.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

slide23.addTable([bCountRow23_1], {
  x: 0.23, y: 4.05, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

slide23.addTable([bCountRow23_3], {
  x: 7.35, y: 4.05, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

// Country table
let countryTable23 = [];
let countryTable23_P2 = [];
// let countryTable232 = [];
for (let i = 0; i < funnelLabels23.length; i++) {
  let row = [funnelLabels23[i]];
  let row2 = [];
    
  countryLabels23.forEach(country => {
    const cell = countryData23[country][i].percentage + "%";
    const cell2 = countryData23[country][i].percentage2;
    row.push(cell);
    row2.push(cell2);
  });
  countryTable23.push(row);
  countryTable23_P2.push(row2);
}

// Quarter table
let quarterTable23 = [ [ "", "Q1'25", "Q2'25" ] ];
let quarterTable23_P2 = [ [ "", "Q1'25", "Q2'25" ] ];

for (let i = 0; i < funnelLabels23.length; i++) {
  quarterTable23.push([ funnelLabels23[i], quarterData23["Q1'25"][i].percentage + "%", quarterData23["Q2'25"][i].percentage + "%" ]);
  quarterTable23_P2.push([quarterData23["Q1'25"][i].percentage2, quarterData23["Q2'25"][i].percentage2]);
}

// <==================================|Significance Testing1|==================================>
var baseArray = baseArray23_1_P2;
var tabArray = countryTable23_P2;
var slidesignificance_23 = [];

console.log("bArr", baseArray);
console.log("dArr", tabArray);

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_23.push(significantResults);
});
console.log("sig", slidesignificance_23);

var slideMerged_23 = [];
for (let i = 0; i < countryTable23.length; i++) {
    let originalRow = countryTable23[i];               
    let significanceRow = slidesignificance_23[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_23.push(newRow);
}
countryTable23 = slideMerged_23;
// <==================================|Significance Testing1|==================================>
// <==================================|Significance Testing2|==================================>
var baseArray = baseArray23_3_P2;
var tabArray = quarterTable23_P2;
var slidesignificance_23 = [];

console.log("bArr", baseArray);
console.log("dArr", tabArray);

tabArray.forEach((element) => {
    var significantResults = getSignificanceMatrix(baseArray, element);
    slidesignificance_23.push(significantResults);
});
console.log("sig", slidesignificance_23);

var slideMerged_23 = [];
for (let i = 0; i < quarterTable23.length; i++) {
    let originalRow = quarterTable23[i];               
    let significanceRow = slidesignificance_23[i]; 
    let newRow = [];
    for (let j = 0; j < originalRow.length; j++) {
        let cell = originalRow[j];
        let baseText = typeof cell === 'object' ? cell.text : cell;
        let significance = (j === 0) ? "" : ((significanceRow && significanceRow[j - 1]) || "");
        newRow.push({
            text: baseText + significance,
            options: {
                ...(cell.options || {}), 
                border: [ { pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" } ]
            }
        });
    }

    slideMerged_23.push(newRow);
}
quarterTable23 = slideMerged_23;
// <==================================|Significance Testing2|==================================>
// ---- Add side-by-side tables ----
slide23.addTable(countryTable23, {
  x: 0.23, y: 1.86, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
/* slide23.addTable(countryTable232, {
  x: 0.23, y: 3.42, w: 6.5,
  colW: [1.2, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
}); */
slide23.addTable(quarterTable23, {
  x: 7.35, y: 1.65, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});
/* slide23.addTable(quarterTable232, {
  x: 7.35, y: 3.2, w: 2.2,
  colW: [1, 0.6, 0.6],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
}); */

// ---- Footnotes and Logos ----
slide23.addText(slideData23.bottom1, fText1_23);
slide23.addText(slideData23.bottom2, fText2_23);
slide23.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide23.addText([
  { text: slideData23.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData23.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData23.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData23.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData23.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData23.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide23.addImage({ ...logo1_23, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide23.addImage({ ...logo2_23, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });

// ----------- End of Slide 23 Code -----------

// Slide 21 Reason for Consumption
	
	let topHead_21 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
    let subHead_21 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
    let leftHead_21 = { x: 0.12, y: 0.75, w: 1.64, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let leftSubHead_21 = { x: 0.12, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };
    let rightHead_21 = { x: 6.74, y: 0.75, w: 2.50, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
    let  rightSubHead_21 = { x: 6.74, y: 1.05, w: 2.33, h: 0.12, fontSize: 6, fontFace: 'Arial', bold: false, color: '969696' };

    let country1_21 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country2_21 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country3_21 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country4_21 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country5_21 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country6_21 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
    let country7_21 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

    let opts12_21 = { x: 0.36, y: 2.22, w: 0.96, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts13_21 = { x: 0.34, y: 2.79, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts14_21 = { x: 0.32, y: 3.43, w: 1.08, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let opts15_21 = { x: 0.33, y: 4.04, w: 0.99, h: 0.43, fontSize: 8, fontFace: "Arial", bold: true, color: '000000' };
    let fText1_21 = { x: 0.20, y: 5.0, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
    let fText2_21 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
	
	let tableBase_21 = {"x": 7.95,"y": 2.84,"w": 0.67,"h": 0.30,fontSize: 7,fontFace: "Arial",bold: false,align: 'center',color: '969696'};

    let logo1_21 = {"x": 8.51,"y": 5.21,"w": 0.80,"h": 0.28};
    let logo2_21 = {"x": 9.36,"y": 5.18,"w": 0.54,"h": 0.35};
	
	
/* let stackChart_21 = {
  x: 1.88,
  y: 1.71,
  w: 1.39,
  h: 2.87,
  barDir: "bar", // Horizontal bars
  barGrouping: "standard", // Not stacked
  barGapWidthPct: 50, // Reduce gap between bars
  showValue: true,
  dataLabelColor: "000000",
  dataLabelFontFace: "Arial",
  dataLabelFontSize: 7,
  dataLabelFontBold: false,
  dataLabelFormatCode: '0"%"',
 
//  chartColors:["CFCFCF", "F29E1F", "F8A75B", "5C7146", "B8E986", "80B8FF", "365A8C", "E0E0E0", "7C7C7C", "F5A623", "C8B800", "70854A", "B5E3A6", "7FB2FF", "3A5A81"],
 
  showValAxis: false,
  valAxisLabelPos: 'none',
  valAxisLineShow: false,
  valGridLine: { style: 'none' },
valAxisMaxVal: 70,
  // Hide Y-axis title and legend
  showLegend: false,
  showTitle: false,

  // Optional: category axis (Y) label tweaks
  showCatAxis: true,
  catAxisLabelFontSize: 1,
  catAxisLabelColor: "ffffff",
  
  valGridLine: {
    style: 'none'
  }
}; */


	
		var ReasonforConsumptioncountryLevel = data['CM_C12Country'];
        var ReasonforConsumptionquarterLevel = data['CM_C12Quarter'];
        var Q1 = ReasonforConsumptionquarterLevel["Q1'25"];
        var Q2 = ReasonforConsumptionquarterLevel["Q2'25"];
        const ReasonforConsumptionq1= Q1.map(item => item.percentage);
        const ReasonforConsumptionq2= Q2.map(item => item.percentage);
        var ReasonforConsumptionbaseData = [Q1[0].bCount, Q2[0].bCount];
        const ReasonforConsumptioncountryData = {};
        const ReasonforConsumption1 = [];
        
        const ReasonforConsumptionbaseArray = [];

        countryLabel4.forEach(country => {

            if (ReasonforConsumptioncountryLevel[country]) {
                ReasonforConsumptioncountryData[country] = ReasonforConsumptioncountryLevel[country];
            }

        });
        // var sortingResult = sortByFirstCountryWithLabels(reasonconsumptioncountryV, CMC12label);
        // var sortingResult2 = sortByFirstCountryWithLabels(reasonconsumptioncountryV2, CMC12label);
                                
		
		const percentageMap = {};
        

		Object.keys(ReasonforConsumptioncountryData).forEach(country => {
			const entries = ReasonforConsumptioncountryData[country];
			if (Array.isArray(entries)) {
				percentageMap[country] = entries.map(item => item.percentage);
			} else {
				console.warn(`Skipping ${country} — not an array`);
			}
		});
		console.log("ddd");
		// console.log('permap', percentageMap);

        

        var reasonofconsumptionsorted1 = sortSEAAndAlign(percentageMap);
        var reasonofconsumptionsorted2 = sortSEAAndAlignwithoutColor(percentageMap, CMC12labelX3);
        var reasonofconsumptionsortedLabels = reasonofconsumptionsorted2['sortedLabels'];
        console.log('permap', reasonofconsumptionsorted1);

        console.log('permaplabelsorg', CMC12labelX3);
        console.log('permaplabels', reasonofconsumptionsortedLabels);

        
                
        for (const country in ReasonforConsumptioncountryData) {
            const countryData = ReasonforConsumptioncountryData[country];
            ReasonforConsumptionbaseArray.push(`n-${countryData[0].bCount}`);
            ReasonforConsumption1.push(countryData[0].percentage);
        }

        function getCountryChartObjects(reasonData) {
            const countries = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
            const result = {};

            countries.forEach((country) => {
                const values = reasonData[country];
                const colors = reasonData[`${country}_color`];

                result[country] = values.map((value, index) => ({
                value,
                color: colors[index].startsWith("#") ? colors[index].substring(1) : colors[index] // remove # if present
                }));
            });

            return result;
        }
        
        var reasonofconsumptiondataobj = getCountryChartObjects(reasonofconsumptionsorted1);
        console.log("obj", reasonofconsumptiondataobj);
        const ReasonforConsumptionArray = [{
            title: "Reason for Consumption (SEA)",
            subtitle: "Dairy Milk (Flavored & Unflavored)",
            subtitle1: "",
            subtitle3: "",
            countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
            flags: ["","https://keresearch.in/mdynata/assets/images/1.png","https://keresearch.in/mdynata/assets/images/2.png","https://keresearch.in/mdynata/assets/images/3.png","https://keresearch.in/mdynata/assets/images/4.png","https://keresearch.in/mdynata/assets/images/5.png","https://keresearch.in/mdynata/assets/images/6.png"],
            // funnel:["Supports overall good health","Good balance of taste and health","Has high-quality ingredients","It keeps me from feeling hungry until the next meal","Convenient to purchase, consume, or store","Good value for money","Something that I usually have","Something new and exciting","Improves physical performance/Provides energy","It helps me concentrate and focus","Helps reduce stress or overcome boredom","It is something I enjoy having","It is something to share with friends and family","It has a taste that I prefer","Sustainable and environmentally friendly choice"],
            funnel: reasonofconsumptionsortedLabels,
            f:[ReasonforConsumption1],
			// f1:[percentageMap['SEA'],percentageMap['Singapore'],percentageMap['Thailand'],percentageMap['Malaysia'],percentageMap['Indonesia'],percentageMap['Philippines'],percentageMap['Vietnam']],
			f1:[reasonofconsumptionsorted1['Southeast Asia'],reasonofconsumptionsorted1['Singapore'],reasonofconsumptionsorted1['Thailand'],reasonofconsumptionsorted1['Malaysia'],reasonofconsumptionsorted1['Indonesia'],reasonofconsumptionsorted1['Philippines'],reasonofconsumptionsorted1['Vietnam']],
			f2:[reasonofconsumptionsorted1['Southeast Asia_color'],reasonofconsumptionsorted1['Singapore_color'],reasonofconsumptionsorted1['Thailand_color'],reasonofconsumptionsorted1['Malaysia_color'],reasonofconsumptionsorted1['Indonesia_color'],reasonofconsumptionsorted1['Philippines_color'],reasonofconsumptionsorted1['Vietnam_color']],
            f3: reasonofconsumptiondataobj,
            sampleSizes:ReasonforConsumptionbaseArray,
            bottom1:"C12. Which of these BEST describes why you had it?",
            bottom2:"",
            btm1:"Sig.", btm2:"High/", btm3:"Low", btm4:" vs.", btm5:"previous wave", btm6:" at 95% CI",
            
            
        }];

        ReasonforConsumptionArray.forEach(slideData => {
            slide21.addText(slideData.title,topHead_21);
            slide21.addText(slideData.subtitle,subHead_21);
            slide21.addText(slideData.subtitle1,leftHead_21);
            slide21.addText(slideData.subtitle3,rightHead_21);
			
            /*slide21.addShape(pptx.ShapeType.line, { x: 0.16,y: 1.02,w: 6.51, h: 0, line: { color: '75b1bb', width: 1.2 } });
            slide21.addShape(pptx.ShapeType.line, { "x": 6.83,"y": 1.02,"w": 2.46, h: 0, line: { color: '75b1bb', width: 1.2 } });*/
            slide21.addText(slideData.countries[0],{...country1_21,x: 1.81});
            slide21.addText(slideData.countries[1],{...country2_21,x: 2.98});
            slide21.addText(slideData.countries[2],{...country3_21,x: 4.24});
            slide21.addText(slideData.countries[3],{...country4_21,x: 5.43});
            slide21.addText(slideData.countries[4],{...country5_21,x: 6.54});
            slide21.addText(slideData.countries[5],{...country6_21,x: 7.66});
            slide21.addText(slideData.countries[6],{...country7_21,x: 8.84});
            slide21.addImage({ x: 3.19, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[1] });
            slide21.addImage({ x: 4.40, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[2] });
            slide21.addImage({ x: 5.57, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[3] });
            slide21.addImage({ x: 6.73, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[4] });
            slide21.addImage({ x: 7.85, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[5] });
            slide21.addImage({ x: 8.97, y: 1.22, w: 0.37, h: 0.38, path: slideData.flags[6] });
			
			const xPositions = [1.88, 2.83, 4.09, 5.24, 6.42, 7.56, 8.66];
			console.log("color-dataarray", slideData.f2[0].slice().reverse());
			
            var stackChart_21a = {
                x: 0.1,
                y: 1.71,
                w: 4.18,
                h: 2.87,
                barDir: "bar", // Horizontal bars
                barGrouping: "standard", // Not stacked
                barGapWidthPct: 50, // Reduce gap between bars
                showValue: true,
                dataLabelColor: "000000",
                dataLabelFontFace: "Arial",
                dataLabelFontSize: 7,
                dataLabelFontBold: false,
                dataLabelFormatCode: '0"%"',
                
                // chartColors:["CFCFCF", "F29E1F", "F8A75B", "5C7146", "B8E986", "80B8FF", "365A8C", "E0E0E0", "7C7C7C", "F5A623", "C8B800", "70854A", "B5E3A6", "7FB2FF", "3A5A81"],
                chartColors: slideData.f2[0].slice().reverse(),
                
                showValAxis: false,
                valAxisLabelPos: 'none',
                valAxisLineShow: false,
                valGridLine: { style: 'none' },
                valAxisMaxVal: 70,
                // Hide Y-axis title and legend
                showLegend: false,
                showTitle: false,

                // Optional: category axis (Y) label tweaks
                showCatAxis: true,
                catAxisLabelFontSize: 6,
                catAxisLabelColor: "000000",
                
                valGridLine: {
                    style: 'none'
                }
            };


			slide21.addChart(
                pptx.ChartType.bar,
                [
                    {
                        name: 'Reason for Consumption',
                        labels: slideData.funnel.slice().reverse(),
                        values: slideData.f1[0].slice().reverse(),
                        colors: slideData.f2[0].slice().reverse()
                    }
                ],
                stackChart_21a
            );
			  
			for (let i = 1; i < 7; i++) {
            /* const chartOpts = JSON.parse(JSON.stringify(stackChart_21)); // Deep copy to avoid mutation
            chartOpts.x = xPositions[i]; */

            var stackChart_21 = {
                x: xPositions[i],
                y: 1.71,
                w: 1.39,
                h: 2.87,
                barDir: "bar", // Horizontal bars
                barGrouping: "standard", // Not stacked
                barGapWidthPct: 50, // Reduce gap between bars
                showValue: true,
                dataLabelColor: "000000",
                dataLabelFontFace: "Arial",
                dataLabelFontSize: 7,
                dataLabelFontBold: false,
                dataLabelFormatCode: '0"%"',
                
                // chartColors:["CFCFCF", "F29E1F", "F8A75B", "5C7146", "B8E986", "80B8FF", "365A8C", "E0E0E0", "7C7C7C", "F5A623", "C8B800", "70854A", "B5E3A6", "7FB2FF", "3A5A81"],
                chartColors: slideData.f2[i].slice().reverse(), 
                
                showValAxis: false,
                valAxisLabelPos: 'none',
                valAxisLineShow: false,
                valGridLine: { style: 'none' },
                valAxisMaxVal: 70,
                // Hide Y-axis title and legend
                showLegend: false,
                showTitle: false,

                // Optional: category axis (Y) label tweaks
                showCatAxis: true,
                catAxisLabelFontSize: 1,
                catAxisLabelColor: "ffffff",
                
                valGridLine: {
                    style: 'none'
                }
            };

            slide21.addChart(
                pptx.ChartType.bar,
                [
                    {
                        name: 'Reason for Consumption',
                        labels: slideData.funnel.slice().reverse(),
                        values: slideData.f1[i].slice().reverse(),
                        colors: slideData.f2[i].slice().reverse()
                    }
                ],
                stackChart_21
            );

			}
             
			
			
			
			slide21.addText("H1’25",{"x": 1.04,"y": 1.53,"w": 0.70, "h": 0.21,fontSize: 8,fontFace: 'Arial', align: 'center',color: '000000', bold: true, }); 
			
			slide21.addText('Base – Consumed in Past 7 days',{"x": 0.20,"y": 4.46,"w": 1.73, "h": 0.20,fontSize: 7,fontFace: 'Arial', align: 'center',color: '969696'}); 

			const xPositions1 = [1.57,2.91, 4.13, 5.31, 6.50, 7.64, 8.74];

			for (let i = 0; i < 7; i++) {
			slide21.addText(slideData.sampleSizes[i],{"x": xPositions1[i],"y": 4.46,"w": 1.04, h: 0.20,fontSize: 7,fontFace: 'Arial', align: 'center',color: '969696'});
			}
			
			
			const xPositions2 = [2.02, 2.19, 2.36, 2.52, 2.72, 2.87, 3.03, 3.23, 3.39, 3.54,3.74, 3.90, 4.09, 4.25];

			for (let i = 0; i < 14; i++) {
			slide21.addShape(pptx.ShapeType.line, { x: 0.24, y: xPositions2[i], w: 9.54, h: 0, line: { color: 'e0e0e0', width: 1 } });
			}

			 

             slide21.addText(slideData.bottom1,fText1_21);
             slide21.addText(slideData.bottom2,fText2_21);
             slide21.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });

             
			
            slide21.addText([
                 { text: slideData.btm1, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm2, options: { color: '00b050',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm3, options: { color: 'ff0000',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm4, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } },
                 { text: slideData.btm5, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: true } },
                 { text: slideData.btm6, options: { color: '002a5c',fontFace: "Arial", fontSize: 6, bold: false } }
             ], {"x": 8.07,"y": 4.84,"w": 1.83,"h": 0.30});

             slide21.addImage({...logo1_21,path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png"});
             slide21.addImage({...logo2_21,path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png"});

             /*slide21.addShape(pptx.ShapeType.line, {x: 6.74,y: 0.96,w: 0.00,h: 4.09,line: {color:'969696',width:1,dashType:'dash'}});*/
        });


        // ----------- PPT Slide 22: S -----------

// Slide essentials
let topHead_22 = { x: 0.12, y: 0.05, w: 5, h: 0.29, fontFace: "Arial", fontSize: 18, bold: true, color: '002a5c' };
let subHead_22 = { x: 0.24, y: 0.38, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
// let subHead_22_2 = { x: 0.24, y: 2.79, w: 2.78, h: 0.32, fontFace: "Arial", fontSize: 12, bold: false, color: 'ffffff', fill: '002a5c', line: { color: 'cccccc', width: 1 }, shadow: { type: 'outer', color: 'aaaaaa', blur: 3, offset: 1 }, align: 'center', shape: pptx.ShapeType.rect };
let leftHead_22 = { x: 0.12, y: 0.75, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let leftHead_22_2 = { x: 0.12, y: 2.79, w: 6, h: 0.29, fontSize: 8, fontFace: 'Arial', bold: true, color: '002a5c' };
let fText1_22 = { x: 0.20, y: 5.06, w: 6.69, h: 0.30, fontSize: 7, fontFace: "Arial", bold: false, italic: true, color: '969696' };
let fText2_22 = { x: 0.20, y: 5.13, w: 8.20, h: 0.30, fontSize: 7, italic: true, fontFace: "Arial", bold: false, color: '969696' };
let logo1_22 = { x: 8.51, y: 5.21, w: 0.80, h: 0.28 };
let logo2_22 = { x: 9.36, y: 5.18, w: 0.54, h: 0.35 };

let country1_22 = { x: 1.01, y: 1.49, w: 0.89, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country2_22 = { x: 1.87, y: 1.55, w: 0.78, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country3_22 = { x: 2.74, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country4_22 = { x: 3.55, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country5_22 = { x: 4.32, y: 1.55, w: 0.81, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country6_22 = { x: 5.10, y: 1.55, w: 0.83, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };
let country7_22 = { x: 5.91, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' };

// Slide titles/static text
const slideData22 = {
  title: "Purchase Behaviour",
  subtitle: "Dairy Milk (Flavored & Unflavored)",
  subtitle1: "Purchased in Household & Place of Purchase",
//   subtitle2: "Quarterly – SEA (Q1’25 & Q2’25)",
  countries: ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"],
        flags: [
            "", // SEA; can be filled with an icon path if available
            "https://keresearch.in/mdynata/assets/images/1.png",
            "https://keresearch.in/mdynata/assets/images/2.png",
            "https://keresearch.in/mdynata/assets/images/3.png",
            "https://keresearch.in/mdynata/assets/images/4.png",
            "https://keresearch.in/mdynata/assets/images/5.png",
            "https://keresearch.in/mdynata/assets/images/6.png"
        ],
  bottom1: "C17_1. Do you or anyone else in the household purchase Category from a supermarket, retail shop, or online?",
  bottom2: "C19. Where do you or anyone in your household usually buy Category from?",
  btm1: "Sig.", btm2: "High/", btm3: "Low", btm4: " vs.", btm5: "previous year", btm6: " at 95% CI"
};

// ---- Draw headings and visuals ----
slide22.addText(slideData22.title, topHead_22);
slide22.addText(slideData22.subtitle, subHead_22);
slide22.addText("Purchased in Household", { x: 0.16, y: 2.28, w: 2, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 10, bold: true, color: '000000'});
// slide22.addText(slideData22.subtitle2, leftHead_22_2);
slide22.addText(slideData22.subtitle1, leftHead_22);
slide22.addShape(pptx.ShapeType.line, { x: 0.16, y: 1.02, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });
// slide22.addShape(pptx.ShapeType.line, { x: 0.16, y: 3.08, w: 9.7, h: 0, line: { color: '75b1bb', width: 1.2 } });

slide22.addText(slideData22.countries[0], { ...country1_22, x: 2.37 });
slide22.addText(slideData22.countries[1], { ...country2_22, x: 3.18 });
slide22.addText(slideData22.countries[2], { ...country3_22, x: 3.95 });
slide22.addText(slideData22.countries[3], { ...country4_22, x: 4.71 });
slide22.addText(slideData22.countries[4], { ...country5_22, x: 5.41 });
slide22.addText(slideData22.countries[5], { ...country6_22, x: 6.16 });
slide22.addText(slideData22.countries[6], { ...country7_22, x: 6.96 });

slide22.addImage({ x: 3.40, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[1] });
slide22.addImage({ x: 4.14, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[2] });
slide22.addImage({ x: 4.89, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[3] });
slide22.addImage({ x: 5.63, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[4] });
slide22.addImage({ x: 6.37, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[5] });
slide22.addImage({ x: 7.15, y: 1.22, w: 0.37, h: 0.38, path: slideData22.flags[6] });

slide22.addText("Q1'25", { x: 8.02, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' });
slide22.addText("Q2'25", { x: 9.00, y: 1.55, w: 0.74, h: 0.30, fontFace: 'Arial', align: "center", fontSize: 8, bold: true, color: '000000' });

// ---- Prepare table arrays ----
const countryLabels22 = ["Southeast Asia", "Singapore", "Thailand", "Malaysia", "Indonesia", "Philippines", "Vietnam"];
const quarterLabels22 = ["Q1'25", "Q2'25"];
const funnelLabels22 = CMC19label2; 
const countryData22 = data['CM_C19Country'];
const quarterData22 = data['CM_C19Quarter'];

const countryBarData22 = data['CM_C17_1Country'];
const quarterBarData22 = data['CM_C17_1Quarter'];

// const lthcolor = ["f8696b","f8878a","f9a6a9","fac5c8","fbe4e7","f4f9f9","d4ecdd","b4dfc1","94d2a5","63be7b"];


const countryPercentages = countryLabels22.map(
  country => countryBarData22[country]?.[0]?.percentage ?? 0
);

const quarterPercentages = quarterLabels22.map(
    quarter => quarterBarData22[quarter]?.[0]?.percentage ?? 0
);
console.log("conPer", countryPercentages);
console.log("quaPer", quarterPercentages);
slide22.addChart(
    pptx.ChartType.bar,
    [
        {
        name: "Purchase %",
        labels: countryLabels22,
        values: countryPercentages,
        color: '#3A5A81'
        }
    ],
    {
        x: 2.30,
        y: 1.76,
        w: 5.57,
        h: 0.97,
        barDir: "col",
        fontFace: "Arial",
        fontSize: 5,
        showValue: true,
        dataLabelFormatCode: '0"%"',
        dataLabelPosition: 'center',
        dataLabelColor: '#000000',
        catAxisLabelFontFace: "Arial",
        catAxisLabelFontSize: 5,
        valAxisLabelFontFace: "Arial",
        valAxisLabelFontSize: 5,
        dataLabelFontSize: 6,
        chartColors:['3A5A81'],
        barGapWidth: 90, 
        valGridLine: { color: 'FFFFFF', width: 0 },
        catGridLine: { color: 'FFFFFF', width: 0 },
        valAxisLine: { color: 'FFFFFF', width: 0 },
        catAxisLine: { color: 'cccccc', width: 0.5 },
        valAxisHidden: true,
        catAxisHidden: true
    }
);

slide22.addChart(
    pptx.ChartType.bar,
    [
        {
        name: "Purchase %",
        labels: quarterLabels22,
        values: quarterPercentages,
        color: '#3A5A81'
        }
    ],
    {
        x: 7.79,
        y: 1.76,
        w: 2.23,
        h: 0.97,
        barDir: "col",
        fontFace: "Arial",
        fontSize: 5,
        showValue: true,
        dataLabelFormatCode: '0"%"',
        dataLabelPosition: 'center',
        dataLabelColor: '#000000',
        catAxisLabelFontFace: "Arial",
        catAxisLabelFontSize: 5,
        valAxisLabelFontFace: "Arial",
        valAxisLabelFontSize: 5,
        dataLabelFontSize: 6,
        chartColors:['3A5A81'],
        barGapWidth: 90, 
        valGridLine: { color: 'FFFFFF', width: 0 },
        catGridLine: { color: 'FFFFFF', width: 0 },
        valAxisLine: { color: 'FFFFFF', width: 0 },
        catAxisLine: { color: 'cccccc', width: 0.5 },
        valAxisHidden: true,
        catAxisHidden: true
    }
);
const baseArray22_1 = [];
for (const country of countryLabels22) {
  const cData = countryData22[country];
  baseArray22_1.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow22_1 = [];
bCountRow22_1.push({ text: "", options: {} }); // Ensure this is always present

while (bCountRow22_1.length <= 7) { // Ensure row has 7 cells for 7 columns
    const idx = bCountRow22_1.length - 1;
    const val = baseArray22_1[idx] || "n--";
    bCountRow22_1.push({
        text: val,
        options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
    });
}


const baseArray22_3 = [];
for (const quarter of quarterLabels22) {
  const cData = quarterData22[quarter];
  baseArray22_3.push(
    cData && cData[0] && typeof cData[0].bCount !== "undefined"
      ? `n-${cData[0].bCount}`
      : "n--"
  );
}
const bCountRow22_3 = [{ text: "", options: {} }];
baseArray22_3.forEach(val => {
  bCountRow22_3.push({
    text: val,
    options: { fontSize: 7, italic: true, color: '969696', align: 'center' }
  });
});

slide22.addTable([bCountRow22_1], {
  x: 0.22, y: 4.75, w: 7.5,
  colW: [2.25, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

slide22.addTable([bCountRow22_3], {
  x: 7.67, y: 4.75, w: 2,
  colW: [0, 1, 1],
  fontSize: 7,
  fontFace: 'Arial',
  align: 'center',
  border: [0]
});

/* // Country table
let countryTable22 = [];
// let countryTable222 = [];
for (let i = 0; i < funnelLabels22.length; i++) {
//   let row = [funnelLabels22[i]];
    let row = [];
  row.push({
    text: funnelLabels22[i],
    options: {
        border: [{ pt: 0, color: "FFFFFF" }, { pt: 0, color: "FFFFFF" }, { pt: 0.5, color: "cccccc" }, { pt: 0, color: "FFFFFF" }]
    }   
  });
  
  
    const cPercentages2 = countryLabels22.map(country => {
        const val = countryData22[country]?.[i]?.percentage;
        return typeof val === 'number' ? val : null;
    });

    const validValues = cPercentages2.filter(val => val !== null);
    const minVal = Math.min(...validValues);
    const maxVal = Math.max(...validValues);

function getColorIndex(val) {
  if (minVal === maxVal) return Math.floor(lthcolor.length / 2); // uniform
  const scaled = Math.floor(((val - minVal) / (maxVal - minVal)) * (lthcolor.length - 1));
  return Math.min(Math.max(scaled, 0), lthcolor.length - 1);
}

countryLabels22.forEach((country, idx) => {
  const val = cPercentages2[idx];
  const text = val !== null ? `${val}%` : "-";
  const bgColor = val !== null ? lthcolor[getColorIndex(val)] : "FFFFFF";

  row.push({
    text,
    options: {
      fill: bgColor,
      color: '000000',
      border: [
        { pt: 0, color: "FFFFFF" },
        { pt: 0, color: "FFFFFF" },
        { pt: 0.5, color: "cccccc" },
        { pt: 0, color: "FFFFFF" }
      ]
    }
  });
});

  countryTable22.push(row);
}*/
const lthcolor = ["f8696b","f8878a","f9a6a9","fac5c8","fbe4e7","f4f9f9","d4ecdd","b4dfc1","94d2a5","63be7b"];

let countryTable22 = [];

// Step 1: Build color mapping per country based on RANK (highest = green, lowest = red)
const countryColorMap = {};
countryLabels22.forEach(country => {
  const colValues = funnelLabels22.map((_, i) => {
    const val = countryData22[country]?.[i]?.percentage;
    return typeof val === "number" ? val : null;
  });

  // Create rank-based mapping
  const indexed = colValues
    .map((val, i) => ({ val, i }))
    .filter(obj => obj.val !== null)
    .sort((a, b) => b.val - a.val); // Descending

  const colorMap = new Array(funnelLabels22.length).fill("FFFFFF"); // default fill

  indexed.forEach((obj, rank) => {
    const colorIdx = Math.min(rank, lthcolor.length - 1); // Clamp if more than 10
    colorMap[obj.i] = lthcolor[lthcolor.length - 1 - colorIdx]; // Reverse index
  });

  countryColorMap[country] = colorMap;
});

// Step 2: Create the table rows
for (let i = 0; i < funnelLabels22.length; i++) {
  const row = [];

  // First column: label
  row.push({
    text: funnelLabels22[i],
    options: {
      border: [
        { pt: 0, color: "FFFFFF" },
        { pt: 0, color: "FFFFFF" },
        { pt: 0.5, color: "cccccc" },
        { pt: 0, color: "FFFFFF" }
      ],
      align: 'left',
      fontFace: 'Arial',
      fontSize: 7,
    }
  });

  // Country columns
  countryLabels22.forEach(country => {
    const val = countryData22[country]?.[i]?.percentage;
    const text = typeof val === "number" ? `${val}%` : "-";
    const fill = countryColorMap[country][i] ?? "FFFFFF";

    row.push({
      text,
      options: {
        fill,
        color: '000000',
        fontFace: 'Arial',
        fontSize: 7,
        align: 'center',
        border: [
          { pt: 0, color: "FFFFFF" },
          { pt: 0.5, color: "cccccc" },
          { pt: 0.5, color: "cccccc" },
          { pt: 0, color: "FFFFFF" }
        ]
      }
    });
  });

  countryTable22.push(row);
}


console.log("q1", quarterData22["Q1'25"]);
console.log("q2", quarterData22["Q2'25"]);

// Quarter table
/* let quarterTable22 = [
  [
    { text: "", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q1'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } },
    { text: "Q2'25", options: { border: [{pt:0,color:"FFFFFF"},{pt:0,color:"FFFFFF"},{pt:0.5,color:"cccccc"},{pt:0,color:"FFFFFF"}] } }
  ]
]; */
// const lthcolor = ["f8696b","f8878a","f9a6a9","fac5c8","fbe4e7","f4f9f9","d4ecdd","b4dfc1","94d2a5","63be7b"];


let quarterTable22 = [];

// Step 1: Build color mapping per quarter based on vertical ranks
const quarterColorMap = {}; // quarter → [color by row]

quarterLabels22.forEach(quarter => {
  const colValues = funnelLabels22.map((_, i) => {
    const val = quarterData22[quarter]?.[i]?.percentage;
    return typeof val === "number" ? val : null;
  });

  const indexed = colValues
    .map((val, i) => ({ val, i }))
    .filter(obj => obj.val !== null)
    .sort((a, b) => b.val - a.val); // Descending

  const colorMap = new Array(funnelLabels22.length).fill("FFFFFF");

  indexed.forEach((obj, rank) => {
    const colorIdx = Math.min(rank, lthcolor.length - 1);
    colorMap[obj.i] = lthcolor[lthcolor.length - 1 - colorIdx]; // reversed for highest = green
  });

  quarterColorMap[quarter] = colorMap;
});

// Step 2: Create the table rows (excluding row labels)
for (let i = 0; i < funnelLabels22.length; i++) {
  const row = [];

  quarterLabels22.forEach(quarter => {
    const val = quarterData22[quarter]?.[i]?.percentage;
    const text = typeof val === "number" ? `${val}%` : "-";
    const fill = quarterColorMap[quarter][i] ?? "FFFFFF";

    row.push({
      text,
      options: {
        fill,
        color: '000000',
        fontFace: 'Arial',
        fontSize: 7,
        align: 'center',
        border: [
          { pt: 0, color: "FFFFFF" },
          { pt: 0.5, color: "cccccc" },
          { pt: 0.5, color: "cccccc" },
          { pt: 0, color: "FFFFFF" }
        ]
      }
    });
  });

  quarterTable22.push(row);
}


// ---- Add side-by-side tables ----
slide22.addTable(countryTable22, {
  x: 0.22, y: 2.59, w: 7.5,
  colW: [2.25, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});

slide22.addTable(quarterTable22, {
  x: 7.9, y: 2.59, w: 2,
  colW: [1, 1],
  fontSize: 7, fontFace: 'Arial', align: 'center',
  
});



// ---- Footnotes and Logos ----
slide22.addText(slideData22.bottom1, fText1_22);
slide22.addText(slideData22.bottom2, fText2_22);
slide22.addShape(pptx.ShapeType.line, { x: 0.28, y: 5.06, w: 9.72, h: 0, line: { color: '75b1bb', width: 1.2 } });
slide22.addText([
  { text: slideData22.btm1, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData22.btm2, options: { color: '00b050', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData22.btm3, options: { color: 'ff0000', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData22.btm4, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } },
  { text: slideData22.btm5, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: true } },
  { text: slideData22.btm6, options: { color: '002a5c', fontFace: "Arial", fontSize: 6, bold: false } }
], { x: 8.07, y: 4.84, w: 1.83, h: 0.30 });
slide22.addImage({ ...logo1_22, path: "https://keresearch.in/mdynata/assets/images/dynata_logo.png" });
slide22.addImage({ ...logo2_22, path: "https://keresearch.in/mdynata/assets/images/dynata_logo3.png" });

// ----------- End of Slide 22 Code -----------


	
        
    pptx.writeFile({ fileName: "Dynata Dashboard PPT Report.pptx" });
}
			
			
			
        </script>
    </body>
</html>