function tc_ratings_chart_dev_function($atts, $content = null)
{
    extract(shortcode_atts(array("challengetype" => "", "handle" => ""), $atts));
    $url = "http://api.topcoder.com/v2/develop/statistics/" . $handle . "/" . $challengetype . "/";
    $cdata = get_data_dev($url);
    $hseries = $cdata['hseries'];
    $dseries = $cdata['dseries'];
    /* ratings chart */
    $ratingsChart = new Highchart();
    $ratingsChart->chart = array('renderTo' => 'chart_' . $handle, 'type' => 'line', 'marginRight' => 15, 'marginLeft' => 30, 'marginBottom' => 20, 'marginTop' => 20, 'width' => 768);
    $ratingsChart->credits = array('enabled' => false);
    $ratingsChart->title = array('text' => null);
    $ratingsChart->yAxis = array('title' => array('text' => null), 'plotLines' => array(array('value' => 0, 'width' => 1, 'color' => '#808080')), 'plotBands' => array(array("from" => 0, "to" => 899, "color" => "rgba(153, 153, 153, 0.2)"), array("from" => 900, "to" => 1199, "color" => "rgba(0, 169, 0, 0.2)"), array("from" => 1200, "to" => 1499, "color" => "rgba(102, 102, 255, 0.2)"), array("from" => 1500, "to" => 2199, "color" => "rgba(221, 204, 0, 0.2)"), array("from" => 2200, "to" => 10000, "color" => "rgba(238, 0, 0, 0.2)")));
    $ratingsChart->xAxis = array('type' => "datetime", dateTimeLabelFormats => array(year => '%Y'), tickInterval => 24 * 3600 * 1000 * 356);
    $ratingsChart->legend = array('enabled' => false);
    $ratingsChart->tooltip = array('formatter' => new HighchartJsExpr("function() {\n\t\t        return 'Challenge: <b>'+ this.point.name +'</b><br/>Date: '+\n\t\t        Highcharts.dateFormat('%e %b %Y', this.x) +'<br/>Rating: '+ this.y ;\n\t\t    }"));
    $ratingsChart->series[] = array('name' => 'Rating', 'color' => '#888888', "lineWidth" => 1, 'data' => $hseries);
    /* distribution chart */
    $distChart = new Highchart();
    $distChart->chart = array('renderTo' => 'chart_d_' . $handle, 'type' => 'column', 'marginRight' => 20, 'marginBottom' => 70, 'width' => 768);
    $distChart->credits = array('enabled' => false);
    $distChart->title = array('text' => null);
    $distChart->yAxis = array('title' => array('text' => null), 'plotLines' => array(array('value' => 0, 'width' => 1, 'color' => '#808080')));
    $distChart->xAxis = array('title' => array('text' => null), 'min' => 50, 'labels' => array('rotation' => 90, 'step' => 1, 'formatter' => new HighchartJsExpr("function() {\n\t\t\t\t\t\tvar vm = parseInt(this.value)-50;\n\t\t\t\t\t\tvar vMx =  parseInt(this.value)+49;\n\t\t\t\t\t\treturn vm+'-'+vMx;\n\t\t\t\t\t}"), 'y' => 18, 'x' => -4), tickPositioner => new HighchartJsExpr("function () {\n\t\t\t\tvar positions = [],\n\t\t\t\ttick = 50,\n\t\t\t\tincrement = 100;\n\t\t\t\n\t\t\t\tfor (; tick - increment <= this.dataMax; tick += increment) {\n\t\t\t\t\tpositions.push(tick);\n\t\t\t\t}\n\t\t\t\treturn positions;\n\t\t\t}"));
    $distChart->legend = array('enabled' => false);
    $distChart->tooltip = array('formatter' => new HighchartJsExpr("function() {\n\t\t        return this.y + (this.y==1?' Coder':' Coders');\n\t\t    }"));
    $distChart->series[] = array('name' => 'Distribution', 'color' => '#888888', "lineWidth" => 1, 'data' => $dseries);
    $html = "\n\t\t<div class='ratingChart distributionType' id='chart_d_{$handle}'></div>\n\t\t<div class='ratingChart historyType' id='chart_{$handle}'></div>\n\t";
    global $dev;
    $html .= "\n\t\t\t<script type='text/javascript'>\n\t\t\t\tvar chart_{$handle};\n\t\t\t\tvar chart_d_{$handle};\n\t\t\t\tvar currentDistChart;\n\t\t\t\tvar currentChart;\n\t\t\t\tvar ct = \$.trim(\$('.tabNavHead .isActive').text());\n\t\t\t\t\n\t\t\t\$(document).ready(function(){\n\t\t\t\t" . $ratingsChart->render('chart_' . $handle) . ";  \n\t\t\t\tcurrentChart = chart_{$handle};\n\t\t\t\t\t\t\n\t\t\t\t" . $distChart->render('chart_d_' . $handle) . ";  \n\t\t\t\tcurrentDistChart = chart_d_" . $handle . ";\n\t\t\t\t\n\t\t\t\t\t\t\n\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tcurrentDistChart.xAxis[0].addPlotLine({\n\t\t                value: " . $dev->rating . ",\n\t\t                color: '" . get_point_color($dev->rating) . "',\n\t\t                width: 2,\n                \t\tlabel : {\n\t\t\t\t\t\t\ttext: '" . $dev->rating . "',\n\t\t\t\t\t\t\tstyle:{'color': '" . get_point_color($dev->rating) . "'}\n\t\t\t\t\t\t}\n\t\t            });\n\t\t\t\t})\n\t\t                \t\n\t\t\t</script>\n\t\t\t";
    return $html;
}
include_once "../../../Highchart.php";
$chart = new Highchart();
$chart->chart->renderTo = "container";
$chart->title->text = "Logarithmic axis demo";
$chart->xAxis->tickInterval = 1;
$chart->yAxis->type = "logarithmic";
$chart->yAxis->minorTickInterval = 0.1;
$chart->tooltip->headerFormat = "<b>{series.name}</b><br />";
$chart->tooltip->pointFormat = "x = {point.x}, y = {point.y}";
$chart->series[] = array('data' => array(1, 2, 4, 8, 16, 32, 64, 128, 256, 512), 'pointStart' => 1);
?>

<html>
  <head>
    <title>Logarithmic axis</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php 
foreach ($chart->getScripts() as $script) {
    echo '<script type="text/javascript" src="' . $script . '"></script>';
}
?>
  </head>
  <body>
    <div id="container"></div>
    <script type="text/javascript">
    <?php 
echo $chart->render("chart1");
?>
    </script>
  </body>
</html>
Exemplo n.º 3
0
<?php

include_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Highchart.php';
$chart = new Highchart(Highchart::HIGHSTOCK);
$chart->chart->renderTo = "container";
$chart->rangeSelector->selected = 1;
$chart->title->text = "AAPL Stock Price";
$chart->series[] = array('name' => "AAPL", 'data' => new HighchartJsExpr("data"), 'tooltip' => array('valueDecimals' => 2));
?>

<html>
    <head>
        <title>Single line series</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <?php 
$chart->printScripts();
?>
    </head>
    <body>
        <div id="container"></div>
        <script type="text/javascript">
            $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
                // Create the chart
                window.chart = <?php 
echo $chart->render();
?>
;
            });
        </script>
    </body>
</html>
Exemplo n.º 4
0
            }

            function createDetail(masterChart) {
                // prepare the detail chart
                var detailData = [],
                    detailStart = Date.UTC(2008, 7, 1);

                jQuery.each(masterChart.series[0].data, function(i, point) {
                    if (point.x >= detailStart) {
                      detailData.push(point.y);
                    }
                });

                // create a detail chart referenced by a global variable
                detailChart = <?php 
echo $detailChart->render();
?>
;
            }

            var $container = $('#container').css('position', 'relative');

            var $detailContainer = $('<div id="detail-container">')
                .appendTo($container);

            var $masterContainer = $('<div id="master-container">')
                .css({ position: 'absolute', top: 300, height: 80, width: '100%' })
                .appendTo($container);

            // create master and in its callback, create the detail chart
            createMaster();
Exemplo n.º 5
0
function tc_ratings_chart_ds_function($atts, $content = null)
{
    extract(shortcode_atts(array("contest" => "", "handle" => ""), $atts));
    $url = "http://api.topcoder.com/v2/users/" . $handle . "/statistics/" . $contest;
    $args = array('httpversion' => get_option('httpversion'), 'timeout' => get_option('request_timeout'));
    $response = wp_remote_get($url, $args);
    if (is_wp_error($response) || !isset($response['body'])) {
        return "Error";
    }
    if ($response['response']['code'] == 200) {
        $data = json_decode($response['body']);
    }
    /* rating history data */
    $history = $data->History;
    // date format is like: 2005.09.07
    $hseries = array();
    foreach ($history as &$score) {
        $date = explode(".", $score->date);
        $dateExp = "Date.UTC(" . $date[0] . "," . $date[1] . "," . $date[2] . ")";
        $tTipName = "Contest Name:";
        $challengeName = $score->challengeName;
        if (empty($challengeName)) {
            $tTipName = "Contest Id:";
            $challengeName = $score->challengeId;
        }
        array_push($hseries, array('x' => new HighchartJsExpr($dateExp), 'y' => $score->rating, 'name' => $challengeName, 'marker' => array('fillColor' => get_point_color($score->rating), 'radius' => 4, 'lineWidth' => 0, 'lineColor' => '#666')));
    }
    $maxVal = -1;
    $hMax = "";
    $count = 0;
    foreach ($hseries as &$hVal) {
        if ($hVal['y'] > $maxVal) {
            $hMax = $count;
            $maxVal = $hVal['y'];
        }
        $count += 1;
    }
    $hseries[$hMax]['marker']['lineWidth'] = "2";
    $hseries[$hMax]['marker']['radius'] = "8";
    foreach ($hseries as $key => $row) {
        $x[$key] = $row['x'];
    }
    array_multisort($x, SORT_ASC, $hseries);
    /* Distribution data */
    $distribution = $data->Distribution;
    $dseries = array();
    foreach ($distribution as &$point) {
        $range = explode("-", $point->range);
        // explode($point->range);
        $mean = ((int) $range[0] + (int) $range[1]) / 2;
        array_push($dseries, array('x' => $mean, 'y' => $point->number == 0 ? null : $point->number, 'color' => get_point_color($mean)));
    }
    $cdata = array('hseries' => $hseries, 'dseries' => $dseries);
    $ratingsChart = new Highchart();
    $ratingsChart->chart = array('renderTo' => 'chart_' . $handle, 'type' => 'line', 'marginRight' => 20, 'marginBottom' => 20, 'width' => 768);
    $ratingsChart->credits = array('enabled' => false);
    $ratingsChart->title = array('text' => null);
    $ratingsChart->yAxis = array('title' => array('text' => null), 'plotLines' => array(array('value' => 0, 'width' => 1, 'color' => '#808080')), 'plotBands' => array(array("from" => 0, "to" => 899, "color" => "rgba(153, 153, 153, 0.2)"), array("from" => 900, "to" => 1199, "color" => "rgba(0, 169, 0, 0.2)"), array("from" => 1200, "to" => 1499, "color" => "rgba(102, 102, 255, 0.2)"), array("from" => 1500, "to" => 2199, "color" => "rgba(221, 204, 0, 0.2)"), array("from" => 2200, "to" => 10000, "color" => "rgba(238, 0, 0, 0.2)")));
    $ratingsChart->xAxis = array('type' => "datetime", 'title' => array('text' => null), dateTimeLabelFormats => array(year => '%Y'), tickInterval => 24 * 3600 * 1000 * 356);
    $ratingsChart->legend = array('enabled' => false);
    $ratingsChart->tooltip = array('formatter' => new HighchartJsExpr("function() {\n\t\t        return '" . $tTipName . " <b>'+ this.point.name +'</b><br/>Date: '+\n\t\t        Highcharts.dateFormat('%e %b %Y', this.x) +'<br/>Rating: '+ this.y ;\n\t\t    }"));
    $ratingsChart->series[] = array('name' => 'Rating', 'color' => '#888888', "lineWidth" => 1, 'data' => $hseries);
    /* distribution chart */
    $distChart = new Highchart();
    $distChart->chart = array('renderTo' => 'chart_d_' . $handle, 'type' => 'column', 'marginRight' => 20, 'marginBottom' => 70, 'width' => 768);
    $distChart->credits = array('enabled' => false);
    $distChart->title = array('text' => null);
    $distChart->plotOptions = array('series' => array('minPointLength' => 3));
    $distChart->yAxis = array('title' => array('text' => null), 'plotLines' => array(array('value' => 0, 'width' => 1, 'color' => '#808080')));
    $distChart->xAxis = array('title' => array('text' => null), 'min' => 50, 'labels' => array('rotation' => 90, 'step' => 1, 'formatter' => new HighchartJsExpr("function() {\n\t\t\t\t\t\tvar vm = parseInt(this.value)-50;\n\t\t\t\t\t\tvar vMx =  parseInt(this.value)+49;\n\t\t\t\t\t\treturn vm+'-'+vMx;\n\t\t\t\t\t}"), 'y' => 18, 'x' => -4), tickPositioner => new HighchartJsExpr("function () {\n\t\t\t\tvar positions = [],\n\t\t\t\ttick = 50,\n\t\t\t\tincrement = 100;\n\t\t\t\n\t\t\t\tfor (; tick - increment <= this.dataMax; tick += increment) {\n\t\t\t\t\tpositions.push(tick);\n\t\t\t\t}\n\t\t\t\treturn positions;\n\t\t\t}"));
    $distChart->legend = array('enabled' => false);
    $distChart->tooltip = array('formatter' => new HighchartJsExpr("function() {\n\t\t        return this.y + (this.y==1?' Coder':' Coders');\n\t\t    }"));
    $distChart->series[] = array('name' => 'Rating', 'color' => '#888888', "lineWidth" => 1, 'data' => $dseries);
    global $coder;
    $html = "\n\t\t<div class='ratingChart distributionType' id='chart_d_{$handle}'></div>\n\t\t<div class='ratingChart historyType' id='chart_{$handle}'></div>\n\t";
    $html .= "\n\t\t\t<script type='text/javascript'>\t\n\t\t\t\tvar chart_{$handle};\n\t\t\t\tvar chart_d_{$handle};\n\t\t\t\t\n\n\t\t\t\t\$(document).ready(function(){\n\t\t\t\t" . $ratingsChart->render('chart_' . $handle) . ";  var currentChart = chart_" . $handle . ";\n\t\t\t\t" . $distChart->render('chart_d_' . $handle) . ";  var currentDistChart = chart_d_" . $handle . ";\n\t\t\t\t\t\t\n\t\t\t\t\t\tcurrentDistChart.xAxis[0].addPlotLine({\n\t\t                value: " . $coder->rating . ",\n\t\t                color: '" . get_point_color($coder->rating) . "',\n\t\t                width: 2,\n                \t\tlabel : {\n\t\t\t\t\t\t\ttext: '" . $coder->rating . "',\n\t\t\t\t\t\t\tstyle:{'color': '" . get_point_color($coder->rating) . "'}\n\t\t\t\t\t\t}\n\t\t            });\n\t\t\t\t})\n\t\t\t</script>\n\t\t\t";
    return $html;
}
Exemplo n.º 6
0
                echo '<div id="container' . $i . '"></div><br/>';
                $chart->chart = array('renderTo' => 'container' . $i, 'type' => 'line', 'marginRight' => 130, 'marginBottom' => 50, 'spacingBottom' => 30);
                $chart->title = array('text' => $key, 'x' => -20);
                $chart->xAxis = array('categories' => $stat['time'], 'offset' => 20);
                $chart->yAxis = array('title' => array('text' => Yii::t('admin', 'Value')), 'min' => 0, 'plotLines' => array(array('value' => 0, 'width' => 1, 'color' => '#808080')));
                $chart->legend = array('layout' => 'vertical', 'align' => 'right', 'verticalAlign' => 'top', 'x' => -10, 'y' => 100, 'borderWidth' => 0);
                $chart->series = array();
                if ($key == 'rtmp_sessions') {
                    $chart->series[] = array('name' => 'sessions', 'data' => $value['sessions']);
                } elseif ($key == 'hdd') {
                    foreach ($value as $k => $v) {
                        $chart->series[] = array('name' => $k, 'data' => $v);
                    }
                } else {
                    $chart->series[] = array('name' => 'min', 'data' => $value['min']);
                    $chart->series[] = array('name' => 'max', 'data' => $value['max']);
                    $chart->series[] = array('name' => 'avg', 'data' => $value['avg']);
                }
                echo '<script type="text/javascript">' . $chart->render("chart") . '</script>';
                $i++;
            }
            break;
        default:
            # code...
            break;
    }
}
?>
        </div>
    </div>
</div>
Exemplo n.º 7
0
/**
 * renderChart
 *
 * display simple text on the web page
 *
 * @param 	Highchart 	$chart 			number of spaces
 * 			int			$id_chart		id of the chart in the div to display the content and render it
 * @return 	nothing						nothing
 */
function renderChart($chart, $id_chart)
{
    foreach ($chart->getScripts() as $script) {
        echo '<script type="text/javascript" src="' . $script . '"></script>';
    }
    echo '<script type="text/javascript">' . $chart->render($id_chart) . '</script>';
}
Exemplo n.º 8
0
								            <?php 
    echo $srmD2Chart->render("srmD2Chart");
    ?>
								        </script>
									</div>
									<div class="chartWrap chartYellow">
										<div id="srmChallenge" class="chart"></div>
										<div class="chartLbl">
											<em><?php 
    echo $srmClngeVal;
    ?>
%</em>Challenges
										</div>
										<script type="text/javascript">
								            <?php 
    echo $srmClnge->render("srmClnge");
    ?>
								        </script>
									</div>

								</div>
							</aside>
							<article class="mainTabStream">
								<div class="tableWrap">
									<table class="ratingTable">
										<caption>Division I Submission</caption>
										<thead>
											<tr>
												<th class="colProblem">Problem</th>
												<th>Submitted</th>
												<th>Failed Challenges</th>
Exemplo n.º 9
0
function open_risk_technology_pie()
{
    $chart = new Highchart();
    $chart->chart->renderTo = "open_risk_technology_pie";
    $chart->chart->plotBackgroundColor = null;
    $chart->chart->plotBorderWidth = null;
    $chart->chart->plotShadow = false;
    $chart->title->text = "Technologies";
    $chart->tooltip->formatter = new HighchartJsExpr("function() {\n        return '<b>'+ this.point.name +'</b>: '+ this.point.y; }");
    $chart->plotOptions->pie->allowPointSelect = 1;
    $chart->plotOptions->pie->cursor = "pointer";
    $chart->plotOptions->pie->dataLabels->enabled = false;
    $chart->plotOptions->pie->showInLegend = 1;
    $chart->credits->enabled = false;
    // Open the database connection
    $db = db_open();
    // Query the database
    $stmt = $db->prepare("SELECT b.name, COUNT(*) AS num FROM `risks` a INNER JOIN `technology` b ON a.technology = b.value GROUP BY b.name ORDER BY COUNT(*) DESC");
    $stmt->execute();
    // Store the list in the array
    $array = $stmt->fetchAll();
    // Close the database connection
    db_close($db);
    // Create the data array
    foreach ($array as $row) {
        $data[] = array($row['name'], (int) $row['num']);
    }
    $chart->series[] = array('type' => "pie", 'name' => "Status", 'data' => $data);
    echo "<div id=\"open_risk_technology_pie\"></div>\n";
    echo "<script type=\"text/javascript\">";
    echo $chart->render("open_risk_technology_pie");
    echo "</script>\n";
}