return $a['c'][4]['v'] - $b['c'][4]['v'];
                });
                $data = array('cols' => array(array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK_FACTOR'), 'type' => 'string'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_COST_OF_PROBLEM'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_COST_OF_INTERVENTION'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_BENEFIT'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_NET_BENEFIT'), 'type' => 'number')), 'rows' => $rowArray);
                $height = $i * 80 + 100;
                $chart->load(json_encode($data));
                $options = array();
                $main_title = JText::sprintf("COM_COSTBENEFITPROJECTION_INTERVENTIONS_NAME_S", $intervention->name);
                $title = '';
                if ($intervention->duration > 1) {
                    $title .= JText::sprintf('COM_COSTBENEFITPROJECTION_DURATION_S_YEARS', $intervention->duration);
                } else {
                    $title .= JText::sprintf('COM_COSTBENEFITPROJECTION_DURATION_S_YEAR', $intervention->duration);
                }
                $title .= ' | ' . JText::sprintf('COM_COSTBENEFITPROJECTION_COVERAGE_S', round($intervention->coverage)) . '%';
                $options = array('title' => $main_title, 'colors' => array('#cc0000', '#ff9933', '#0070c0', '#70ad47'), 'backgroundColor' => $this->Chart['backgroundColor'], 'width' => $this->Chart['width'], 'height' => $height, 'chartArea' => $this->Chart['chartArea'], 'legend' => $this->Chart['legend'], 'vAxis' => $this->Chart['vAxis'], 'hAxis' => array('textStyle' => $this->Chart['hAxis']['textStyle'], 'title' => $title, 'titleTextStyle' => $this->Chart['hAxis']['titleTextStyle']));
                echo $chart->draw('icb_' . $intervention_number . '_' . $scale, $options);
                $intervention_number++;
            }
        }
    }
}
?>
<div id="view_icb">
    <div style="margin:0 auto; width: <?php 
echo $this->Chart['width'];
?>
px; height: 100%;">
        <h1><?php 
echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COST_BENEFIT');
?>
</h1>
                return $a['c'][3]['v'] - $b['c'][3]['v'];
            });
            $data = array('cols' => array(array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK_FACTOR'), 'type' => 'string'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_COST_OF_PROBLEM'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_COST_OF_INTERVENTION'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_BENEFIT'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_NET_BENEFIT'), 'type' => 'number')), 'rows' => $rowArray);
            $height = $i * 80 + 100;
            $chart->load(json_encode($data));
            $options = array();
            $main_title = JText::sprintf("COM_COSTBENEFITPROJECTION_INTERVENTIONS_NAME_S", $intervention->name);
            $title = '';
            if ($intervention->duration > 1) {
                $title .= JText::sprintf('COM_COSTBENEFITPROJECTION_DURATION_S_YEARS', $intervention->duration);
            } else {
                $title .= JText::sprintf('COM_COSTBENEFITPROJECTION_DURATION_S_YEAR', $intervention->duration);
            }
            $title .= ' | ' . JText::sprintf('COM_COSTBENEFITPROJECTION_COVERAGE_S', round($intervention->coverage)) . '%';
            $options = array('title' => $main_title, 'colors' => array('#cc0000', '#ff9933', '#0070c0', '#70ad47'), 'backgroundColor' => $this->Chart['backgroundColor'], 'width' => 800, 'height' => $height, 'chartArea' => $this->Chart['chartArea'], 'legend' => $this->Chart['legend'], 'vAxis' => $this->Chart['vAxis'], 'hAxis' => array('textStyle' => $this->Chart['hAxis']['textStyle'], 'title' => $title, 'titleTextStyle' => $this->Chart['hAxis']['titleTextStyle']));
            echo $chart->draw('public_int_' . $intervention_number . '_unscaled', $options);
            $intervention_number++;
        } else {
            $no_intervention[] = $intervention->name;
        }
    }
}
?>
<div id="view_icb">
    <div style="margin:0 auto; width: <?php 
echo $this->Chart['width'];
?>
px; height: 100%;">
        <h1><?php 
echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COST_BENEFIT');
?>
                    // set the table values
                    $rowArray_numbers[$nr] .= '<td data-value="' . $val . '">' . $val . '%</td>';
                } else {
                    $rowArray[$nr]['c'][] = array('v' => $val, 'f' => JText::_('COM_COSTBENEFITPROJECTION_AGE') . ' ' . $val);
                    // set the table values
                    $rowArray_numbers[$nr] .= '<td>' . JText::_('COM_COSTBENEFITPROJECTION_AGE') . ' ' . $val . '</td>';
                }
            }
            $i++;
        }
        $data['rows'] = $rowArray;
        $string = json_encode($data);
        $chart->load($string);
        $title = $gender == 'male' ? JText::_('COM_COSTBENEFITPROJECTION_MALES') : JText::_('COM_COSTBENEFITPROJECTION_FEMALES');
        $options = array('backgroundColor' => '#fafafa', 'title' => $title, 'height' => '500', 'width' => '500', 'is3D' => 'true', 'tabclickdraw' => 'charttab');
        echo $chart->draw('age_' . $gender . '_' . $displayData->id, $options);
        // set chart array
        $age[] = '<div id="age_' . $gender . '_' . $displayData->id . '" style="width: 100%;"></div>';
        $gen[$title] = '<tr>' . implode('</tr><tr>', $rowArray_numbers) . '</tr>';
        $both++;
    }
}
// now set the group percentages to the view
if ($both) {
    // setup the chart
    $agepercents = '<div data-uk-grid-margin="" class="uk-grid" data-uk-grid-match="{target:\'.uk-panel\'}">';
    foreach ($age as $gender) {
        $agepercents .= '<div class="uk-width-medium-1-' . $both . '">';
        $agepercents .= '<div class="uk-panel uk-panel-box">';
        $agepercents .= $gender;
        $agepercents .= '</div>';
if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) {
    foreach ($scaled as $scale) {
        $i = 0;
        $rowArray = array();
        foreach ($this->results->items as $key => &$item) {
            $rowArray[] = array('c' => array(array('v' => $item->details->name), array('v' => round($item->{'subtotal_cost_' . $scale} / $this->results->totals->{'total_cost_' . $scale} * 100), 'f' => (double) round($item->{'subtotal_cost_' . $scale} / $this->results->totals->{'total_cost_' . $scale} * 100, 3) . '%')));
            $i++;
        }
        usort($rowArray, function ($b, $a) {
            return $a['c'][1]['v'] - $b['c'][1]['v'];
        });
        $data = array('cols' => array(array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK_FACTOR'), 'type' => 'string'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_PERCENT_OF_TOTAL_COST'), 'type' => 'number')), 'rows' => $rowArray);
        $height = $i * 70 + 100;
        $chart->load(json_encode($data));
        $options = array('backgroundColor' => $this->Chart['backgroundColor'], 'width' => $this->Chart['width'], 'height' => $height, 'chartArea' => $this->Chart['chartArea'], 'legend' => $this->Chart['legend'], 'vAxis' => $this->Chart['vAxis'], 'hAxis' => array('textStyle' => $this->Chart['hAxis']['textStyle'], 'title' => JText::_('COM_COSTBENEFITPROJECTION__OF_ALL_HEALTHCARE_COSTS_CAUSED_BY_THE_CAUSERISK_FACTOR'), 'titleTextStyle' => $this->Chart['hAxis']['titleTextStyle']));
        echo $chart->draw('cp_' . $scale, $options);
    }
}
?>
<div id="view_cp">
	<div style="margin:0 auto; width: <?php 
echo $this->Chart['width'];
?>
px; height: 100%;">
		<h1><?php 
echo JText::_('COM_COSTBENEFITPROJECTION_COST_PERCENT');
?>
</h1>
		<?php 
if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) {
    ?>
if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) {
    foreach ($scaled as $scale) {
        $i = 0;
        $rowArray = array();
        foreach ($this->results->items as $key => &$item) {
            $rowArray[$i] = array('c' => array(array('v' => $item->details->name), array('v' => (double) round($item->{'subtotal_morbidity_' . $scale}, 2)), array('v' => (double) round($item->{'subtotal_presenteeism_' . $scale}, 2)), array('v' => (double) round($item->{'subtotal_days_lost_mortality_' . $scale}, 2)), array('v' => (double) round($item->{'subtotal_days_lost_' . $scale}, 2))));
            $i++;
        }
        usort($rowArray, function ($b, $a) {
            return $a['c'][4]['v'] - $b['c'][4]['v'];
        });
        $data = array('cols' => array(array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK_FACTOR'), 'type' => 'string'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_MORBIDITY'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_PRESENTEEISM_MORBIDITY'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_MORTALITY'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_TOTAL_DAYS_LOST'), 'type' => 'number')), 'rows' => $rowArray);
        $height = $i * 110 + 50;
        $chart->load(json_encode($data));
        $options = array('backgroundColor' => $this->Chart['backgroundColor'], 'width' => $this->Chart['width'], 'height' => $height, 'chartArea' => $this->Chart['chartArea'], 'legend' => $this->Chart['legend'], 'vAxis' => $this->Chart['vAxis'], 'hAxis' => array('textStyle' => $this->Chart['hAxis']['textStyle'], 'title' => JText::_('COM_COSTBENEFITPROJECTION_NUMBER_OF_WORK_DAYS_LOST'), 'titleTextStyle' => $this->Chart['hAxis']['titleTextStyle']));
        echo $chart->draw('wdl_' . $scale, $options);
    }
}
?>
<div id="view_wdl">
	<div style="margin:0 auto; width: <?php 
echo $this->Chart['width'];
?>
px; height: 100%;">
		<h1><?php 
echo JText::_('COM_COSTBENEFITPROJECTION_WORK_DAYS_LOST');
?>
</h1>
		<?php 
if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) {
    ?>
if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) {
    $i = 0;
    $rowArray = array();
    foreach ($this->results->items as $key => &$item) {
        $rowArray[] = array('c' => array(array('v' => $item->details->name), array('v' => $item->{'subtotal_cost_unscaled'}, 'f' => $item->{'subtotal_costmoney_unscaled'})));
        $i++;
    }
    usort($rowArray, function ($b, $a) {
        return $a['c'][1]['v'] - $b['c'][1]['v'];
    });
    $data = array('cols' => array(array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK_FACTOR_NAME'), 'type' => 'string'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_TOTAL_COST'), 'type' => 'number')), 'rows' => $rowArray);
    $height = $i * 55 + 10;
    $title = JText::sprintf('COM_COSTBENEFITPROJECTION_COST_IN_S', $this->item->currency_name);
    $chart->load(json_encode($data));
    $options = array('backgroundColor' => $this->Chart['backgroundColor'], 'width' => $this->Chart['width'], 'height' => $height, 'chartArea' => $this->Chart['chartArea'], 'legend' => $this->Chart['legend'], 'vAxis' => $this->Chart['vAxis'], 'hAxis' => array('textStyle' => $this->Chart['hAxis']['textStyle'], 'title' => $title, 'titleTextStyle' => $this->Chart['hAxis']['titleTextStyle']));
    echo $chart->draw('c_public', $options);
}
?>
<div id="view_c">
	<div style="margin:0 auto; width: <?php 
echo $this->Chart['width'];
?>
px; height: 100%;">
	<h1><?php 
echo JText::_('COM_COSTBENEFITPROJECTION_COST');
?>
</h1>
	<?php 
if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) {
    ?>
		<!-- This is the container of the content items -->