<?php if(isset($top_pincode_data) && count($top_pincode_data)): ?>
    <div class="tab-pane active" id="line-chart-2">
        <div id="pin-bar-chart" class="morrischart" style="height: 300px"></div>
    </div>
<?php else: ?>
     <center>
        <?php echo \Illuminate\Support\Facades\Lang::get('routes.MESSAGE_DATA_NOT_AVAILABLE'); ?>
    </center>
<?php endif; ?>
<script type="text/javascript">
$(function() {

        <?php if(isset($top_pincode_data) && count($top_pincode_data)): ?>
                var line_chart_demo_3 = $("#pin-bar-chart");
                var sales_data_3 =  [];
                    <?php $i=0; ?>
                    <?php foreach($top_pincode_data as $key => $top_pincode_data_row): ?>

                        <?php if(isset($top_pincode_data_row->PincodeValue) && isset($top_pincode_data_row->Pincode)): ?>

                            sales_data_3['<?php echo $i++; ?>'] =
                            {
                             x: '<?php echo $top_pincode_data_row->Pincode; ?>',
                             y: '<?php echo $top_pincode_data_row->PincodeValue; ?>'
                             }
                        <?php endif; ?>
                    <?php endforeach; ?>
            Morris.Bar({
                        element: 'pin-bar-chart',
                        data: sales_data_3,
                        xkey: 'x',
                        ykeys: ['y'],
                        labels:['<?php echo $report_label; ?>'],
                        barColors: ['#3399FF'],
                            hoverCallback:function (index, options, content, row) {
                                if('<?php echo $report_label; ?>' ==  'Extension Cost' || '<?php echo $report_label; ?>' ==  'Pin Cost') {
                                    return '<div class="morris-hover-row-label">' + row.x + '</div><div style="color: #3399FF" class="morris-hover-point"><?php echo $report_label; ?>: <?php echo $CurrencySymbol; ?>' + row.y + '</div>'
                                }else{
                                    return '<div class="morris-hover-row-label">' + row.x + '</div><div style="color: #3399FF" class="morris-hover-point"><?php echo $report_label; ?>: ' + row.y + '</div>'
                                }
                            }

                    }).on('click', function(i, row){
                            if(sales_data_3[i].x) {
                                dataGrid(sales_data_3[i].x,'<?php echo $data['Startdate']; ?>','<?php echo $data['Enddate']; ?>','<?php echo $data['PinExt']; ?>','<?php echo $data['CurrencyID']; ?>');
                            }
                    });
    line_chart_demo_3.parent().attr('style', '');

        <?php endif; ?>
});
</script>