Back to PhocacartStatistics class

Method renderFunctions

public
renderFunctions
()

Method renderFunctions - Source code

public function renderFunctions()
{
    $s = array();
    $s[] = 'window.onload = function() {';
    if (!empty($this->fn)) {
        foreach ($this->fn as $k => $v) {
            $s[] = 'var ctx' . $v['id'] . ' = document.getElementById(\'' . $v['area'] . '\').getContext(\'2d\');';
            $s[] = 'window.' . $v['type'] . ' = new Chart(ctx' . $v['id'] . ', config' . $v['id'] . ');';
        }
    }
    $s[] = '};';
    Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
}