<commit_before><?php
/**
 * $Id$
 *
 * Renders a Yahoo UI 3 chart (svg or canvas object)
 *
 * http://developer.yahoo.com/yui/3/charts/
 *
 * @author <NAME>, 2010-2011 <<EMAIL>>
 */

//STATUS: wip

//TODO (MISSING FROM YUI2-chart): visa label för x & y led: setYTitle(), setXTitle()

require_once('output_js.php');

class Yui3Chart
{
    private $data_source = '';   ///< array of data to display
    private $width  = 700;
    private $height = 400;
    private $x_field;           ///< group by this field (usually a timestamp)
    private $x_title, $y_title; ///< display titles

    private $x_type = ''; ///< is the X-axis a timestamp?

    function setDataSource($arr)
    {
        if (!$this->x_field)
            throw new Exception ('x field must be set before data source');

        $this->data_source = array();

        foreach ($arr as $idx => $vals) {

            $x = array($this->x_field => $idx);
            foreach ($vals as $idx => $val)
                $x[ $idx] = $val;

            $this->data_source[] = $x;
        }
    }

    function setXType($t)
    {
        if ($t != 'time')
            throw new Exception ('unknown x type');

        $this->x_type = $t;
    }

    function setXField($name) { $this->x_field = $name; }

    function setXTitle($title) { $this->x_title = $title; }
    function setYTitle($title) { $this->y_title = $title; }

    function render()
    {
        $header = XhtmlHeader::getInstance();

        $header->includeJs('http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js');

        $div_holder = 'yui_chart'.mt_rand(0,99999);

        $header->embedCss('#'.$div_holder.' { width: '.$this->width.'px; height: '.$this->height.'px; }');

        $res =<commit_msg>Yui3Chart->setDataSource: handle 1d-arrays<commit_after><?php
/**
 * $Id$
 *
 * Renders a Yahoo UI 3 chart (svg or canvas object)
 *
 * http://developer.yahoo.com/yui/3/charts/
 *
 * @author <NAME>, 2010-2011 <<EMAIL>>
 */

//STATUS: wip

//TODO (MISSING FROM YUI2-chart): visa label för x & y led: setYTitle(), setXTitle()

require_once('output_js.php');

class Yui3Chart
{
    private $data_source = '';   ///< array of data to display
    private $width  = 700;
    private $height = 400;
    private $x_field;           ///< group by this field (usually a timestamp)
    private $x_title, $y_title; ///< display titles

    private $x_type = ''; ///< is the X-axis a timestamp?

    function setDataSource($arr)
    {
        if (!$this->x_field)
            throw new Exception ('x field must be set before data source');

        $this->data_source = array();

        foreach ($arr as $idx => $vals)
        {
            $x = array($this->x_field => $idx);
            if (is_array($vals))
                foreach ($vals as $idx => $val)
                    $x[$idx] = $val;
            else
                $x['value'] = $vals;

            $this->data_source[] = $x;
        }
    }

    function setXType($t)
    {
        if ($t != 'time')
            throw new Exception ('unknown x type');

        $this->x_type = $t;
    }

    function setXField($name) { $this->x_field = $name; }

    function setXTitle($title) { $this->x_title = $title; }
    function setYTitle($title) { $this->y_title = $title; }

    function render()
    {
        $header = XhtmlHeader::getInstance();

        $header->includeJs('http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js');

        $div_holder = 'yui_chart'.mt_rand(0,99999);

        $header->embedCss('#'.$div_holder.' { width: '.$this->width.'px; height: '.$this->height.'px; }');

        $res =
{'fraction_non_alphanumeric': 0.17300167691447735, 'fraction_numerical': 0.015651201788708775, 'mean_word_length': 2.215633423180593, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '343557', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1169, 'n_words': 288}