dropped flot and adopted chart.js in code_folder.php and code_file.php
This commit is contained in:
parent
f11910ca46
commit
277af9bb4a
@ -34,7 +34,7 @@ class Graph extends CI_Controller
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
$this->load->model ('SubversionModel', 'subversion');
|
||||
|
||||
$login = $this->login->getUser ();
|
||||
$login = $this->login->getUser();
|
||||
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
|
||||
redirect (CODEPOT_SIGNIN_REDIR_PATH . $this->converter->AsciiTohex(current_url()));
|
||||
$data['login'] = $login;
|
||||
@ -73,7 +73,7 @@ class Graph extends CI_Controller
|
||||
{
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
|
||||
$login = $this->login->getUser ();
|
||||
$login = $this->login->getUser();
|
||||
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
|
||||
{
|
||||
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
||||
@ -116,7 +116,7 @@ class Graph extends CI_Controller
|
||||
{
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
|
||||
$login = $this->login->getUser ();
|
||||
$login = $this->login->getUser();
|
||||
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
|
||||
{
|
||||
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
||||
@ -144,7 +144,7 @@ class Graph extends CI_Controller
|
||||
{
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
|
||||
$login = $this->login->getUser ();
|
||||
$login = $this->login->getUser();
|
||||
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
|
||||
{
|
||||
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
||||
@ -172,7 +172,7 @@ class Graph extends CI_Controller
|
||||
{
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
|
||||
$login = $this->login->getUser ();
|
||||
$login = $this->login->getUser();
|
||||
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
|
||||
{
|
||||
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
||||
@ -200,7 +200,7 @@ class Graph extends CI_Controller
|
||||
{
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
|
||||
$login = $this->login->getUser ();
|
||||
$login = $this->login->getUser();
|
||||
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
|
||||
{
|
||||
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
||||
|
@ -1596,10 +1596,9 @@ class SubversionModel extends CodeRepoModel
|
||||
if ($info === FALSE || $info === NULL || count($info) != 1) continue;
|
||||
}
|
||||
|
||||
if ($info[0]['kind'] == SVN_NODE_FILE) return FALSE;
|
||||
$info0 = &$info[0];
|
||||
if ($info[0]['kind'] == SVN_NODE_FILE) continue;
|
||||
|
||||
$list = @svn_ls ($workurl, $rev, FALSE, TRUE);
|
||||
$list = @svn_ls($workurl, $rev, FALSE, TRUE);
|
||||
if ($list === FALSE) return FALSE;
|
||||
|
||||
foreach ($list as $key => $value)
|
||||
@ -1609,21 +1608,26 @@ class SubversionModel extends CodeRepoModel
|
||||
{
|
||||
$obj = new stdClass();
|
||||
//$obj->name = $key;
|
||||
$obj->name = $full_path;
|
||||
//$obj->name = $full_path;
|
||||
$obj->name = substr($full_path, strlen($path) + 1); // relative path
|
||||
|
||||
$text = @svn_cat ("{$orgurl}/{$key}{$trailer}", $rev);
|
||||
if ($text === FALSE) $obj->size = 0;
|
||||
$text = @svn_cat("{$orgurl}/{$key}{$trailer}", $rev);
|
||||
if ($text === FALSE)
|
||||
{
|
||||
$obj->lines = 0;
|
||||
$obj->bytes = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$text_len = strlen($text);
|
||||
$obj->size = substr_count($text, "\n");
|
||||
if ($text_len > 0 && $text[$text_len - 1] != "\n") $obj->size++;
|
||||
$obj->lines = substr_count($text, "\n");
|
||||
if ($text_len > 0 && $text[$text_len - 1] != "\n") $obj->lines++;
|
||||
$obj->bytes = $text_len;
|
||||
}
|
||||
|
||||
$obj->language = substr(strrchr($key, '.'), 1); // file extension
|
||||
if ($obj->language === FALSE) $obj->language = '';
|
||||
|
||||
|
||||
array_push ($current_cloc->children, $obj);
|
||||
}
|
||||
else
|
||||
@ -1634,11 +1638,11 @@ class SubversionModel extends CodeRepoModel
|
||||
// other same base name in a different directory.
|
||||
// let's use a full path. it's anyway clearer.
|
||||
//$obj->name = $key;
|
||||
$obj->name = $full_path;
|
||||
//$obj->name = $full_path;
|
||||
$obj->name = substr($full_path, strlen($path) + 1); // relativte path
|
||||
|
||||
$obj->children = array();
|
||||
array_push ($current_cloc->children, $obj);
|
||||
|
||||
array_push ($stack, $full_path);
|
||||
array_push ($stack, $obj);
|
||||
}
|
||||
|
@ -102,9 +102,7 @@
|
||||
<script type="text/javascript" src="<?php print base_url_make('/js/jquery-ui.min.js')?>"></script>
|
||||
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" />
|
||||
|
||||
<!--[if lte IE 8]><script type="text/javascript" src="<?php print base_url_make('/js/excanvas.min.js')?>"></script><![endif]-->
|
||||
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.flot.min.js')?>"></script>
|
||||
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.flot.pie.min.js')?>"></script>
|
||||
<script type="text/javascript" src="<?php print base_url_make('/js/chart.min.js')?>"></script>
|
||||
|
||||
<script type="text/javascript" src="<?php print base_url_make('/js/vis.min.js')?>"></script>
|
||||
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/vis.min.css')?>" />
|
||||
@ -404,6 +402,10 @@ var GraphApp = (function ()
|
||||
self.resizeGraph ();
|
||||
});
|
||||
|
||||
this.graph_container.on ("dialogclose", function (evt, ui) {
|
||||
self.closeGraph ();
|
||||
});
|
||||
|
||||
this.graph_button.button().click (function ()
|
||||
{
|
||||
open_graph.call (self);
|
||||
@ -441,6 +443,11 @@ var GraphApp = (function ()
|
||||
/* SHOULD BE IMPLEMENTED BY INHERITER */
|
||||
}
|
||||
|
||||
App.prototype.closeGraph = function ()
|
||||
{
|
||||
/* SHOULD BE IMPLEMENTED BY INHERITER */
|
||||
}
|
||||
|
||||
return App;
|
||||
})();
|
||||
|
||||
@ -558,15 +565,18 @@ var LocGraphApp = (function ()
|
||||
function App (top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title)
|
||||
{
|
||||
GraphApp.call (this, top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title);
|
||||
this.chart = null;
|
||||
this.plot_dataset = null;
|
||||
this.plot_options = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
App.prototype = Object.create(GraphApp.prototype);
|
||||
App.prototype.constructor = App;
|
||||
|
||||
App.prototype.renderGraph = function (data)
|
||||
{
|
||||
if (!data.hasOwnProperty('SUM'))
|
||||
if (!("SUM" in data))
|
||||
{
|
||||
this.showMessage ('No data to show');
|
||||
return;
|
||||
@ -579,36 +589,38 @@ var LocGraphApp = (function ()
|
||||
|
||||
this.clearMessage ();
|
||||
|
||||
// files, blank, comment, code
|
||||
// files is always 1.
|
||||
this.plot_dataset = [
|
||||
{ label: "<?php print $this->lang->line('Blank')?>", data: data.SUM[1] },
|
||||
{ label: "<?php print $this->lang->line('Comment')?>", data: data.SUM[2] },
|
||||
{ label: "<?php print $this->lang->line('Code')?>", data: data.SUM[3] }
|
||||
var labels = [
|
||||
"<?php print $this->lang->line('Blank')?>",
|
||||
"<?php print $this->lang->line('Comment')?>",
|
||||
"<?php print $this->lang->line('Code')?>"
|
||||
];
|
||||
|
||||
this.plot_options =
|
||||
// data.SUM[] => files, blank, comment, code
|
||||
// files is always 1.
|
||||
this.plot_dataset = {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
series: {
|
||||
shadowSize: 0,
|
||||
pie: {
|
||||
show: true,
|
||||
innerRadius: 0.1,
|
||||
label: {
|
||||
show: true,
|
||||
radius: 0.9,
|
||||
formatter: function labelFormatter(label, series)
|
||||
{
|
||||
return "<div style='font-size:8pt; text-align:center; padding:2px; '>" + label + "<br/>" + series.data[0][1] + "(" + Math.round(series.percent) + "%)</div>";
|
||||
},
|
||||
backgraound: { opacity: 0.8 }
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
data: [data.SUM[1], data.SUM[2], data.SUM[3]],
|
||||
backgroundColor: [
|
||||
'rgb(255, 99, 132)',
|
||||
'rgb(54, 162, 235)',
|
||||
'rgb(255, 205, 86)'
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.plot_options = {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false
|
||||
};
|
||||
|
||||
this.chart = new Chart(this.graph_canvas[0].getContext('2d'), {
|
||||
type: 'doughnut',
|
||||
data: this.plot_dataset,
|
||||
options: this.plot_options
|
||||
});
|
||||
}
|
||||
|
||||
App.prototype.resizeGraph = function ()
|
||||
@ -617,7 +629,15 @@ var LocGraphApp = (function ()
|
||||
{
|
||||
this.graph_canvas.width (this.graph_container.width() - 5);
|
||||
this.graph_canvas.height (this.graph_container.height() - 10);
|
||||
$.plot(this.graph_canvas, this.plot_dataset, this.plot_options);
|
||||
}
|
||||
}
|
||||
|
||||
App.prototype.closeGraph = function ()
|
||||
{
|
||||
if (this.chart != null)
|
||||
{
|
||||
this.chart.destroy();
|
||||
this.chart = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -982,7 +1002,8 @@ $this->load->view (
|
||||
</div>
|
||||
|
||||
<div id="code_file_loc_graph_container">
|
||||
<div id="code_file_loc_graph"></div>
|
||||
<!-- <div id="code_file_loc_graph"></div> -->
|
||||
<canvas id="code_file_loc_graph"></canvas>
|
||||
<div id="code_file_loc_graph_error"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -28,8 +28,6 @@
|
||||
<script type="text/javascript" src="<?php print base_url_make('/js/jqueryui-editable.min.js')?>"></script>
|
||||
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jqueryui-editable.css')?>" />
|
||||
|
||||
<!--[if lte IE 8]><script type="text/javascript" src="<?php print base_url_make('/js/excanvas.min.js')?>"></script><![endif]-->
|
||||
|
||||
<script type="text/javascript" src="<?php print base_url_make('/js/chart.min.js')?>"></script>
|
||||
|
||||
<script type="text/javascript" src="<?php print base_url_make('/js/vis.min.js')?>"></script>
|
||||
@ -448,6 +446,7 @@ var LocLangApp = (function ()
|
||||
this.chart = null;
|
||||
}
|
||||
}
|
||||
|
||||
return App;
|
||||
})();
|
||||
|
||||
@ -472,35 +471,55 @@ var LocFileApp = (function ()
|
||||
|
||||
this.clearMessage ();
|
||||
|
||||
var gen_color = function() {
|
||||
var letters = '0123456789ABCDEF'.split('');
|
||||
var color = '#';
|
||||
for (var i = 0; i < 6; i++) color += letters[Math.floor(Math.random() * 16)];
|
||||
return color;
|
||||
};
|
||||
//var gen_color = function() {
|
||||
// var letters = '0123456789ABCDEF'.split('');
|
||||
// var color = '#';
|
||||
// for (var i = 0; i < 6; i++) color += letters[Math.floor(Math.random() * 16)];
|
||||
// return color;
|
||||
//};
|
||||
|
||||
var labels = [];
|
||||
var dataset = [];
|
||||
var dataset_lines = [];
|
||||
var dataset_bytes = [];
|
||||
var bgcolors = [];
|
||||
for (var key in loc.children) {
|
||||
var size = loc.children[key].size;
|
||||
if (size == null) size = 0;
|
||||
|
||||
var name = loc.children[key].name;
|
||||
name = name.split('/').reverse()[0];
|
||||
labels.push (name);
|
||||
dataset.push (size);
|
||||
var add_items = function(items)
|
||||
{
|
||||
for (var key in items) {
|
||||
var item = items[key];
|
||||
if ('children' in item)
|
||||
{
|
||||
// directory item.
|
||||
add_items (item.children);
|
||||
}
|
||||
else
|
||||
{
|
||||
// plain file item
|
||||
var lines = item.lines;
|
||||
if (lines == null) lines = 0;
|
||||
var size = item.size;
|
||||
if (size == null) lines = 0;
|
||||
labels.push (item.name);
|
||||
dataset_lines.push (item.lines == null? 0: item.lines);
|
||||
dataset_bytes.push (item.bytes == null? 0: item.bytes);
|
||||
//bgcolors.push(gen_color());
|
||||
}
|
||||
}
|
||||
};
|
||||
add_items (loc.children);
|
||||
|
||||
this.plot_dataset = {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'LOC',
|
||||
data: dataset,
|
||||
label: 'Lines',
|
||||
data: dataset_lines
|
||||
//backgroundColor: bgcolors
|
||||
}
|
||||
}/*,
|
||||
{
|
||||
label: 'Bytes',
|
||||
data: dataset_bytes
|
||||
}*/
|
||||
]
|
||||
};
|
||||
this.plot_options = {
|
||||
@ -508,7 +527,8 @@ var LocFileApp = (function ()
|
||||
maintainAspectRatio: false,
|
||||
scales: {
|
||||
x: {
|
||||
grid: { display: false }
|
||||
grid: { display: false },
|
||||
stacked: true
|
||||
},
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
|
Loading…
Reference in New Issue
Block a user