/soc/2012/sanket/www-statscollector: dd4f94c69bab: Refactor Appl...
Sanket Agarwal
sanket at soc.pidgin.im
Tue Jul 10 04:23:33 EDT 2012
Changeset: dd4f94c69babc66450bbb34de6fa3f424d754fa7
Author: Sanket Agarwal <sanket at soc.pidgin.im>
Date: 2012-07-10 13:52 +0530
Branch: default
URL: http://hg.pidgin.im/soc/2012/sanket/www-statscollector/rev/dd4f94c69bab
Description:
Refactor Application Bitness chart
The Application Bitness chart was lying around in index.html
and now has been moved to charts.js. With this all the JS
is now stored in two external files: media/js/charts.js and
media/js/stats.js.
TODO: Change the structure of JSON objects pased to bitChart(..)
so that the JSON object does not needs to be indexed as it is
currently.
diffstat:
pidgin_stats_collector/display/views.py | 2 +-
pidgin_stats_collector/media/js/charts.js | 62 +++++++++++++++++
pidgin_stats_collector/templates/display/index.html | 74 +--------------------
3 files changed, 65 insertions(+), 73 deletions(-)
diffs (170 lines):
diff --git a/pidgin_stats_collector/display/views.py b/pidgin_stats_collector/display/views.py
--- a/pidgin_stats_collector/display/views.py
+++ b/pidgin_stats_collector/display/views.py
@@ -57,7 +57,7 @@
# App bitness
- stats_d[APP_BIT_STR] = dict(zip(APP_BIT, [0]*len(APP_BIT)))
+ stats_d[APP_BIT_STR] = {}
# OS bitness
stats_d[OS_BIT_STR] = {}
diff --git a/pidgin_stats_collector/media/js/charts.js b/pidgin_stats_collector/media/js/charts.js
--- a/pidgin_stats_collector/media/js/charts.js
+++ b/pidgin_stats_collector/media/js/charts.js
@@ -188,4 +188,66 @@
}]
});
+}
+
+function bitChart(app_bit, os_bit, e) {
+ var chart;
+ chart = new Highcharts.Chart({
+ chart: {
+ renderTo: e,
+ type: 'bar'
+ },
+ title: {
+ text: 'Bitness of application'
+ },
+
+ xAxis: {
+ categories: ['Application', 'Operating System'],
+ title: {
+ text: 'Application/OS Bitness'
+ }
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: '32/64 Bitness',
+ align: 'high'
+ }
+ },
+ tooltip: {
+ formatter: function() {
+ return ''+
+ this.series.name +': '+ this.y +' %';
+ }
+ },
+ plotOptions: {
+ bar: {
+ dataLabels: {
+ enabled: true,
+ },
+ stacking: 'percent'
+ }
+ },
+ legend: {
+ layout: 'vertical',
+ align: 'right',
+ verticalAlign: 'top',
+ x: -100,
+ y: 100,
+ floating: true,
+ borderWidth: 1,
+ backgroundColor: '#FFFFFF',
+ shadow: true
+ },
+ credits: {
+ enabled: false
+ },
+ series: [{
+ name: '32 bit',
+ data: [app_bit[0], os_bit[0]]
+ }, {
+ name: '64 bit',
+ data: [app_bit[1], os_bit[1]]
+ }]
+ });
}
\ No newline at end of file
diff --git a/pidgin_stats_collector/templates/display/index.html b/pidgin_stats_collector/templates/display/index.html
--- a/pidgin_stats_collector/templates/display/index.html
+++ b/pidgin_stats_collector/templates/display/index.html
@@ -187,80 +187,10 @@
drawChart({{ plugin_cat_top|safe }}, {{ plugin_dat_top|safe }}, 'plugins', 'purple top plugins');
drawChart({{ purple_p_cat|safe }}, {{purple_p_dat|safe }}, 'purple-protocols', 'purple protocols');
drawChart({{ purple_p_u_cat|safe }}, {{ purple_p_u_dat|safe }}, 'purple-buddy-protocols', 'buddy list size');
- pluginDetailchart({{ plugin_cat|safe }},{{ plugin_dat|safe }}, 'plugins-detail', 'Plugins detail');
+ pluginDetailChart({{ plugin_cat|safe }},{{ plugin_dat|safe }}, 'plugins-detail', 'Plugins detail');
+ bitChart({{ app_bit }}, {{ os_bit }}, 'app-bit');
});
</script>
-<script type="text/javascript"> <!-- Application bitness -->
-$(function () {
- var chart;
- $(document).ready(function() {
- chart = new Highcharts.Chart({
- chart: {
- renderTo: 'app-bit',
- type: 'bar'
- },
- title: {
- text: 'Bitness of application'
- },
-
- xAxis: {
- categories: ['Application', 'Operating System'],
- title: {
- text: null
- }
- },
- yAxis: {
- min: 0,
- title: {
- text: '32/64 Bitness',
- align: 'high'
- }
- },
- tooltip: {
- formatter: function() {
- return ''+
- this.series.name +': '+ this.y +' %';
- }
- },
- plotOptions: {
- bar: {
- dataLabels: {
- enabled: true,
- },
- stacking: 'percent'
- }
- },
- legend: {
- layout: 'vertical',
- align: 'right',
- verticalAlign: 'top',
- x: -100,
- y: 100,
- floating: true,
- borderWidth: 1,
- backgroundColor: '#FFFFFF',
- shadow: true
- },
- credits: {
- enabled: false
- },
- series: [{
- name: '32 bit',
- data: [{{ app_bit.0 }}, {{ os_bit.0 }}]
- }, {
- name: '64 bit',
- data: [{{ app_bit.1 }}, {{ os_bit.1 }}]
- }, {
- name: 'unknown',
- data: [{{ app_bit.2 }}, {{ os_bit.2 }}]
- }]
- });
- });
-
-});
-</script>
-
-
</body></html>
\ No newline at end of file
More information about the Commits
mailing list