<?php
session_start(['gc_maxlifetime' => 14400, 'cookie_httponly' => true]); // Starting Session
include('member_session.php'); // Auth guard: redirects to login if not authenticated
include('../coach/functions.php');
include("../coach/objects/class.member.php");
// include '../coach/objects/class.baseline_details.php';
include '../coach/objects/baseline_measurement.class.php';
include '../coach/objects/baseline_screen.class.php';
include '../coach/objects/baseline_bodycomposition.class.php';


$chart_from_date = date('m/d/y', strtotime('-2 weeks'));
$chart_to_date = date('m/d/y');
$pdf_file = $_POST['pdf_file'] ?? '';
//defining array
$selected_dates = array('x');
$selected_dates_grid = array();
$height_dates = array();
$weight_dates = array();
$bf_percnt_dates = array();
$lean_mass_dates = array();
$total_fat_dates = array();
$visceral_fat_dates = array();
$muscle_mass_dates = array();
$height = array('Height / Inches');
$weight = array('Weight / LBS');
$bf_percnt = array('Body Fat %');
$lean_mass = array('Lean Mass / LBS');
$total_fat = array('Total FAT / LBS');
$visceral_fat = array('Visceral Fat');
$muscle_mass = array('Muscle Mass');
$chest = array('Chest');
$arm = array('Arm');
$waist = array('Waist');
$hips = array('Hips');
$thigh = array('Thigh');
$calf = array('Calf');


$baseline_bodycomposition_data = array();

if (($_POST['submit'] ?? '') || $pdf_file == 'pdf_file') {
    $chart_from_date = ($_POST['chart_from_date'] != '' && $_POST['chart_from_date'] != '01/01/70' && $_POST['chart_from_date'] != '00/00/00') ? date('m/d/y', strtotime($_POST['chart_from_date'])) : $chart_from_date;
    $chart_to_date = ($_POST['chart_to_date'] != '' && $_POST['chart_to_date'] != '01/01/70' && $_POST['chart_to_date'] != '00/00/00') ? date('m/d/y', strtotime($_POST['chart_to_date'])) : $chart_to_date;
}
$member_id = $_SESSION['memberid'];
$bodycomposition = new Baseline_bodycomposition();
$measurement = new Baseline_measurement();

//getting baseline details
$baseline_bodycomposition_data = $bodycomposition->GetList(array(array('member_id', '=', $member_id), array('date', '>=', date('Y-m-d', strtotime($chart_from_date))), array('date', '<=', date('Y-m-d', strtotime($chart_to_date)))), 'date', true);
$baseline_measurement_data = $measurement->GetList(array(array('member_id', '=', $member_id), array('date', '>=', date('Y-m-d', strtotime($chart_from_date))), array('date', '<=', date('Y-m-d', strtotime($chart_to_date)))), 'date', true);

$arr = 0;
for ($i = strtotime($chart_from_date); $i <= strtotime($chart_to_date);) {
    $selected_dates[] = date('m/d/y', $i);
    $selected_dates_grid[$arr]['value'] = date('m/d/y', $i);
    $height[] = '';
    $weight[] = '';
    $bf_percnt[] = '';
    $lean_mass[] = '';
    $total_fat[] = '';
    $visceral_fat[] = '';
    $muscle_mass[] = '';
    $chest[] = '';
    $arm[] = '';
    $wait[] = '';
    $hips[] = '';
    $thigh[] = '';
    $calf[] = '';
    $i = strtotime('+1 day', $i);
    $arr++;
}

for ($j = 0; $j < count($baseline_bodycomposition_data); $j++) {
    if (in_array(date('m/d/y', strtotime($baseline_bodycomposition_data[$j]->date)), $selected_dates)) {
        $key = array_search(date('m/d/y', strtotime($baseline_bodycomposition_data[$j]->date)), $selected_dates);
        $height[$key] = $baseline_bodycomposition_data[$j]->height;
        $weight[$key] = $baseline_bodycomposition_data[$j]->weight;
        $bf_percnt[$key] = $baseline_bodycomposition_data[$j]->body_fat;
        $lean_mass[$key] = $baseline_bodycomposition_data[$j]->lean_body_mass;
        $total_fat[$key] = $baseline_bodycomposition_data[$j]->fat_weight;
        $visceral_fat[$key] = $baseline_bodycomposition_data[$j]->visceral_fat;
        $muscle_mass[$key] = $baseline_bodycomposition_data[$j]->muscle_mass;
    }
}

for ($j = 0; $j < count($baseline_measurement_data); $j++) {
    if (in_array(date('m/d/y', strtotime($baseline_measurement_data[$j]->date)), $selected_dates)) {
        $key = array_search(date('m/d/y', strtotime($baseline_measurement_data[$j]->date)), $selected_dates);
        $chest[$key] = $baseline_measurement_data[$j]->chest;
        $arm[$key] = $baseline_measurement_data[$j]->arm1;
        $waist[$key] = $baseline_measurement_data[$j]->waist;
        $hips[$key] = $baseline_measurement_data[$j]->hips;
        $thigh[$key] = $baseline_measurement_data[$j]->thigh1;
        $calf[$key] = $baseline_measurement_data[$j]->calf1;
    }
}

//removing empty data
$height_dates = $selected_dates;
$weight_dates = $selected_dates;
$bf_percnt_dates = $selected_dates;
$lean_mass_dates = $selected_dates;
$total_fat_dates = $selected_dates;
$visceral_fat_dates = $selected_dates;
$muscle_mass_dates = $selected_dates;
$chest_dates = $selected_dates;
$arm_dates = $selected_dates;
$waist_dates = $selected_dates;
$hips_dates = $selected_dates;
$thigh_dates = $selected_dates;
$calf_dates = $selected_dates;


//to remove the empty values in graph
for ($k = 0; $k < count($selected_dates); $k++) {
    if (($height[$k] ?? '') == '' || ($height[$k] ?? '') == '0') {
        unset($height[$k]);
        unset($height_dates[$k]);
    }
    if (($weight[$k] ?? '') == '' || ($weight[$k] ?? '') == '0') {
        unset($weight[$k]);
        unset($weight_dates[$k]);
    }
    if (($bf_percnt[$k] ?? '') == '' || ($bf_percnt[$k] ?? '') == '0') {
        unset($bf_percnt[$k]);
        unset($bf_percnt_dates[$k]);
    }
    if (($lean_mass[$k] ?? '') == '' || ($lean_mass[$k] ?? '') == '0') {
        unset($lean_mass[$k]);
        unset($lean_mass_dates[$k]);
    }
    if (($total_fat[$k] ?? '') == '' || ($total_fat[$k] ?? '') == '0') {
        unset($total_fat[$k]);
        unset($total_fat_dates[$k]);
    }
    if (($visceral_fat[$k] ?? '') == '' || ($visceral_fat[$k] ?? '') == '0') {
        unset($visceral_fat[$k]);
        unset($visceral_fat_dates[$k]);
    }
    if (($muscle_mass[$k] ?? '') == '' || ($muscle_mass[$k] ?? '') == '0') {
        unset($muscle_mass[$k]);
        unset($muscle_mass_dates[$k]);
    }

    if (($chest[$k] ?? '') == '' || ($chest[$k] ?? '') == '0') {
        unset($chest[$k]);
        unset($chest_dates[$k]);
    }
    if (($arm[$k] ?? '') == '' || ($arm[$k] ?? '') == '0') {
        unset($arm[$k]);
        unset($arm_dates[$k]);
    }
    if (($waist[$k] ?? '') == '' || ($waist[$k] ?? '') == '0') {
        unset($waist[$k]);
        unset($waist_dates[$k]);
    }
    if (($hips[$k] ?? '') == '' || ($hips[$k] ?? '') == '0') {
        unset($hips[$k]);
        unset($hips_dates[$k]);
    }
    if (($thigh[$k] ?? '') == '' || ($thigh[$k] ?? '') == '0') {
        unset($thigh[$k]);
        unset($thigh_dates[$k]);
    }
    if (($calf[$k] ?? '') == '' || ($calf[$k] ?? '') == '0') {
        unset($calf[$k]);
        unset($calf_dates[$k]);
    }
}
$height = array_values($height);
$height_dates = array_values($height_dates);
$weight = array_values($weight);
$weight_dates = array_values($weight_dates);
$bf_percnt = array_values($bf_percnt);
$bf_percnt_dates = array_values($bf_percnt_dates);
$lean_mass = array_values($lean_mass);
$lean_mass_dates = array_values($lean_mass_dates);
$total_fat = array_values($total_fat);
$total_fat_dates = array_values($total_fat_dates);
$visceral_fat = array_values($visceral_fat);
$visceral_fat_dates = array_values($visceral_fat_dates);
$muscle_mass = array_values($muscle_mass);
$muscle_mass_dates = array_values($muscle_mass_dates);
$chest = array_values($chest);
$chest_dates = array_values($chest_dates);
$arm = array_values($arm);
$arm_dates = array_values($arm_dates);
$waist = array_values($waist);
$waist_dates = array_values($waist_dates);
$hips = array_values($hips);
$hips_dates = array_values($hips_dates);
$thigh = array_values($thigh);
$thigh_dates = array_values($thigh_dates);
$calf = array_values($calf);
$calf_dates = array_values($calf_dates);

$no_data = 0;
if (count($height_dates) <= 1 && count($weight_dates) <= 1 && count($bf_percnt_dates) <= 1 && count($lean_mass_dates) <= 1 && count($total_fat_dates) <= 1 && count($visceral_fat_dates) <= 1 && count($muscle_mass_dates) <= 1 && count($chest_dates) <= 1 && count($arm_dates) <= 1 && count($waist_dates) <= 1 && count($hips_dates) <= 1 && count($thigh_dates) <= 1 && count($calf_dates) <= 1) {
    $no_data = 1;
}

include('member-header.php');
?>
<style type="text/css">
    #chart1 {
        width: 100%;
        min-height: 400px;
    }
    #daily_log_id { width: 75%; margin: 5px 0px 52px 0px; }
    .success { background-color: #4592e0; width: 150px; height: 25px; text-align: center; color: #ffffff;}

    #accountability_chart_form label.error { color: red; }
    #thd{
        text-align: center;
        font-weight: bold;
    }
    td{
        padding:10px 15px;
    }
    .text-center{
        text-align: center;
    }
    .text-upper{
        text-transform: uppercase;
    }
    .mandatory{
        color: red;
        font-size: 14px;
    }
    .btn {
        background-color: #c0c0c0;
    }
    @media (max-width: 768px) {
        #daily_log_id { width: 90%; margin: 5px 0px 52px 0px; }
    }     
</style>
<?php include('menu.php'); ?>
<div style=""></br></br><p style="text-align: center;font-weight: bold;">Progress Graph</p></div>
<div>  
    <form method="POST">
        <div class="row">
            <div class="form-group row">
                <div class="col-md-1"></div>
                <div class="col-md-4"><label for="start_date">Start Date:</label></div>
                <div class="col-md-6"><input type="text" maxlength="10" class="datepicker form-control text text-upper" id="start_date" name="chart_from_date" value="<?php echo $chart_from_date; ?>" placeholder="MM/DD/YYYY"/></div>
                <div class="col-md-1"></div>
            </div>
            <div class="form-group row">
                <div class="col-md-1"></div>
                <div class="col-md-4"><label for="end_date"> End Date:</label></div>
                <div class="col-md-6"> <input type="text" maxlength="10" class="datepicker form-control text text-upper" id="end_date" name="chart_to_date" value="<?php echo $chart_to_date; ?>" placeholder="MM/DD/YYYY"/></div>
                <div class="col-md-1"></div>
            </div>
            <div class="form-group row">
                <div class="col-md-1"></div>
                <div class="col-md-12"><input type="submit" name="submit" class="btn btn-default" value="Submit" class="submit"/></div>
                <div class="col-md-6"></div>
            </div>
        </div>
    </form>    
</div>
<br/>
<br/>

<div id="chart_display" style="">
    <div style="font-size: 18px;"><b>Progress Graph:</b></div>
    <?php if ($no_data == 0) { ?>
        <?php if (count($height_dates) > 1) { ?>
            <div id="chart1"></div><br/>
        <?php } ?>
        <?php if (count($weight_dates) > 1) { ?>
            <div id="chart2"></div> <br/>
        <?php } ?>
        <?php if (count($bf_percnt_dates) > 1) { ?>
            <div id ="chart3"></div><br/>
        <?php } ?>
        <?php if (count($lean_mass_dates) > 1) { ?>
            <div id ="chart4"></div><br/>
        <?php } ?>
        <?php if (count($total_fat_dates) > 1) { ?>
            <div id ="chart5"></div><br/><!--  style="height:500px;"-->
        <?php } ?>
        <?php if (count($visceral_fat_dates) > 1) { ?>
            <div id ="chart6"></div><br/>
        <?php } ?>
        <?php if (count($muscle_mass_dates) > 1) { ?>
            <div id ="chart7"></div><br/>
        <?php } ?>
        <?php if (count($chest_dates) > 1) { ?>
            <div id ="chart8"></div><br/>
        <?php } ?>
        <?php if (count($arm_dates) > 1) { ?>
            <div id ="chart9"></div><br/>
        <?php } ?>
        <?php if (count($waist_dates) > 1) { ?>
            <div id ="chart10"></div><br/>
        <?php } ?>
        <?php if (count($hips_dates) > 1) { ?>
            <div id ="chart11"></div><br/>
        <?php } ?>
        <?php if (count($thigh_dates) > 1) { ?>
            <div id ="chart12"></div><br/>
        <?php } ?>
        <?php if (count($calf_dates) > 1) { ?>
            <div id ="chart13"></div><br/>
        <?php } ?>
        <?php
    } else {
        if ($pdf_file == '') {
            ?>
            <div style="padding-left:20px;font-weight:bold;color: red;">Please change the date criteria as the selected date range has no data available to display</div>
            <?php
        }
    }
    ?>
</div>  
</div>
<script language="javascript" type="text/javascript" src="../coach/js/jquery.js"></script>
<script src="../coach/js/jquery.datetimepicker.full.js"></script>
<!--<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>-->
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script src="../coach/js/c3.min.js"></script>

<script type="text/javascript">

    var selected_dates = <?php echo json_encode($selected_dates); ?>;
    var selected_dates_grid = <?php echo json_encode($selected_dates_grid); ?>;
    var weight = <?php echo json_encode($weight); ?>;
    var weight_dates = <?php echo json_encode($weight_dates); ?>;
    var bf_percnt = <?php echo json_encode($bf_percnt); ?>;
    var bf_percnt_dates = <?php echo json_encode($bf_percnt_dates); ?>;
    var lean_mass = <?php echo json_encode($lean_mass); ?>;
    var lean_mass_dates = <?php echo json_encode($lean_mass_dates); ?>;
    var total_fat = <?php echo json_encode($total_fat); ?>;
    var total_fat_dates = <?php echo json_encode($total_fat_dates); ?>;
    var height = <?php echo json_encode($height); ?>;
    var height_dates = <?php echo json_encode($height_dates); ?>;
    var visceral_fat = <?php echo json_encode($visceral_fat); ?>;
    var visceral_fat_dates = <?php echo json_encode($visceral_fat_dates); ?>;
    var muscle_mass = <?php echo json_encode($muscle_mass); ?>;
    var muscle_mass_dates = <?php echo json_encode($muscle_mass_dates); ?>;
    var chest = <?php echo json_encode($chest); ?>;
    var chest_dates = <?php echo json_encode($chest_dates); ?>;
    var arm = <?php echo json_encode($arm); ?>;
    var arm_dates = <?php echo json_encode($arm_dates); ?>;
    var waist = <?php echo json_encode($waist); ?>;
    var waist_dates = <?php echo json_encode($waist_dates); ?>;
    var hips = <?php echo json_encode($hips); ?>;
    var hips_dates = <?php echo json_encode($hips_dates); ?>;
    var thigh = <?php echo json_encode($thigh); ?>;
    var thigh_dates = <?php echo json_encode($thigh_dates); ?>;
    var calf = <?php echo json_encode($calf); ?>;
    var calf_dates = <?php echo json_encode($calf_dates); ?>;
    var no_data = <?php echo $no_data; ?>;

    if (no_data == 0) {
        var chart1 = c3.generate({
            bindto: '#chart1',
            data: {
                x: 'x',
                columns: [height_dates, height],
                labels: true,
                type: 'line',
                colors: {
                    'Height / Inches': '#eeb422',
                },
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category',
                },
                y: {
                    label: {
                        text: 'Height / Inches',
                        position: 'outer-middle'
                    },
                    show: true,
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart2 = c3.generate({
            bindto: '#chart2',
            data: {
                x: 'x',
                columns: [weight_dates, weight],
                labels: true,
                type: 'line'
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    ////lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Weight / LBS',
                        position: 'outer-middle'
                    },
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart3 = c3.generate({
            bindto: '#chart3',
            data: {
                x: 'x',
                columns: [bf_percnt_dates, bf_percnt],
                labels: true,
                type: 'line',
                colors: {
                    'Body Fat %': '#cd0000'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Body Fat %',
                        position: 'outer-middle'
                    },
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart4 = c3.generate({
            bindto: '#chart4',
            data: {
                x: 'x',
                columns: [lean_mass_dates, lean_mass],
                labels: true,
                type: 'line',
                colors: {
                    'Lean Mass / LBS': '#9acd32'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Lean Mass / LBS',
                        position: 'outer-middle'
                    },
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart5 = c3.generate({
            bindto: '#chart5',
            data: {
                x: 'x',
                columns: [total_fat_dates, total_fat],
                labels: true,
                type: 'line',
                colors: {
                    'Total FAT / LBS': '#483d8b'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Total Fat / LBS',
                        position: 'outer-middle'
                    }
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart6 = c3.generate({
            bindto: '#chart6',
            data: {
                x: 'x',
                columns: [visceral_fat_dates, visceral_fat],
                labels: true,
                type: 'line',
                colors: {
                    'Visceral Fat': '#A52A2A'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Visceral',
                        position: 'outer-middle'
                    },
                    tick: {
                        format: d3.format('.2f')
                    }
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart7 = c3.generate({
            bindto: '#chart7',
            data: {
                x: 'x',
                columns: [muscle_mass_dates, muscle_mass],
                labels: true,
                type: 'line',
                colors: {
                    'Muscle Mass / LBS': '#483d8b'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Muscle Mass / LBS',
                        position: 'outer-middle'
                    },
                    tick: {
                        format: d3.format('.2f')
                    }
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart8 = c3.generate({
            bindto: '#chart8',
            data: {
                x: 'x',
                columns: [chest_dates, chest],
                labels: true,
                type: 'line',
                colors: {
                    'Chest': '#483d8b'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Chest',
                        position: 'outer-middle'
                    },
                    tick: {
                        format: d3.format('.2f')
                    }
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart9 = c3.generate({
            bindto: '#chart9',
            data: {
                x: 'x',
                columns: [arm_dates, arm],
                labels: true,
                type: 'line',
                colors: {
                    'Arm': '#483d8b'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Arm',
                        position: 'outer-middle'
                    },
                    tick: {
                        format: d3.format('.2f')
                    }
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart10 = c3.generate({
            bindto: '#chart10',
            data: {
                x: 'x',
                columns: [waist_dates, waist],
                labels: true,
                type: 'line',
                colors: {
                    'Waist': '#483d8b'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Waist',
                        position: 'outer-middle'
                    },
                    tick: {
                        format: d3.format('.2f')
                    }
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart11 = c3.generate({
            bindto: '#chart11',
            data: {
                x: 'x',
                columns: [hips_dates, hips],
                labels: true,
                type: 'line',
                colors: {
                    'Hips': '#483d8b'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Hips',
                        position: 'outer-middle'
                    },
                    tick: {
                        format: d3.format('.2f')
                    }
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart12 = c3.generate({
            bindto: '#chart12',
            data: {
                x: 'x',
                columns: [thigh_dates, thigh],
                labels: true,
                type: 'line',
                colors: {
                    'Thigh': '#483d8b'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Thigh',
                        position: 'outer-middle'
                    },
                    tick: {
                        format: d3.format('.2f')
                    }
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }
    if (no_data == 0) {
        var chart13 = c3.generate({
            bindto: '#chart13',
            data: {
                x: 'x',
                columns: [calf_dates, calf],
                labels: true,
                type: 'line',
                colors: {
                    'Calf': '#483d8b'
                }
            },
            point: {
                r: 5
            },
            grid: {
                x: {
                    //lines: selected_dates_grid,
                },
                y: {
                    show: true,
                }
            },
            axis: {
                x: {
                    label: {
                        position: 'outer-center'
                    },
                    type: 'category'
                },
                y: {
                    label: {
                        text: 'Calf',
                        position: 'outer-middle'
                    },
                    tick: {
                        format: d3.format('.2f')
                    }
                }
            },
            padding: {
                top: 10,
                bottom: 10
            }
        });
    }

    $('.c3-legend-item text').css('font-size', '16px');
    $('.c3-legend-item text').css('font-weight', 'bold');
    $('.c3-legend-item-tile').attr('stroke-width', '14');
    $('.c3-text').css('font-size', '24px');
    $('.c3-shapes path').css('stroke-width', '2.5px');
    $('.c3-grid line').css('stroke', '#aaa');
    d3.select('#chart1 .c3-title').style('font-size', '18px').style('fill', '#0000bb');

    jQuery(document).ready(function () {
        $('.datepicker').datetimepicker({
            timepicker: false,
            format: 'm/d/y',
            formatDate: 'm/d/y',
        });
    });
</script>
<?php
include('member-footer.php');
?>