Index: trunk/extensions/MetricsReporting/frontend/proof_of_concept/reportcardModules.html |
— | — | @@ -4,28 +4,28 @@ |
5 | 5 | <head> |
6 | 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
7 | 7 | <style type="text/css"> |
8 | | - .reportCardChart { |
9 | | - background-color:#EEE; |
10 | | - border-style:solid; |
11 | | - border-width:1px; |
12 | | - border-color:#000; |
13 | | - margin:10px; |
14 | | - width:800px; |
| 8 | + .reportCardChart { |
| 9 | + background-color:#EEE; |
| 10 | + border-style:solid; |
| 11 | + border-width:1px; |
| 12 | + border-color:#000; |
| 13 | + margin:10px; |
| 14 | + width:800px; |
15 | 15 | height:400px; |
16 | 16 | } |
17 | 17 | </style> |
18 | 18 | <title>Report Card Prototype</title> |
19 | 19 | <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]--> |
20 | | - |
| 20 | + |
21 | 21 | <link rel="stylesheet" type="text/css" href="../reportCard/jqplot/jquery.jqplot.css" /> |
22 | 22 | <link rel="stylesheet" type="text/css" href="../reportCard/jqplot/jquery-ui-1.8.14.custom.css" /> |
23 | 23 | <link rel="stylesheet" type="text/css" href="examples.css" /> |
24 | | - |
| 24 | + |
25 | 25 | <!-- BEGIN: load jquery --> |
26 | 26 | <script language="javascript" type="text/javascript" src="../reportCard/jqplot/jquery.min.js"></script> |
27 | 27 | <script language="javascript" type="text/javascript" src="../reportCard/jqplot/jquery-ui-1.8.14.custom.min.js"></script> |
28 | 28 | <!-- END: load jquery --> |
29 | | - |
| 29 | + |
30 | 30 | <!-- BEGIN: load jqplot --> |
31 | 31 | <script language="javascript" type="text/javascript" src="../reportCard/jqplot/jquery.jqplot.js"></script> |
32 | 32 | <script language="javascript" type="text/javascript" src="../reportCard/jqplot/plugins/jqplot.dateAxisRenderer.js"></script> |
— | — | @@ -51,56 +51,56 @@ |
52 | 52 | <!-- make tabs --> |
53 | 53 | <script language="javascript" type="text/javascript"> |
54 | 54 | $(document).ready(function(){ |
55 | | - $.jqplot.config.enablePlugins = true; |
56 | | - |
| 55 | + $.jqplot.config.enablePlugins = true; |
| 56 | + |
57 | 57 | //load tab0 |
58 | 58 | lazyLoad(activeEditors); |
59 | | - |
| 59 | + |
60 | 60 | $("#tabs").tabs(); |
61 | 61 | $('#tabs').bind('tabsshow', function(event, ui) { |
62 | | - if (ui.index == 0) { |
63 | | - lazyLoad(activeEditors); |
64 | | - } |
65 | | - else if (ui.index == 1) { |
66 | | - lazyLoad(uniqueVisitors); |
67 | | - } |
68 | | - else if (ui.index == 2) { |
69 | | - lazyLoad(reachPercentage); |
70 | | - } |
71 | | - else if (ui.index == 3) { |
72 | | - lazyLoad(mobileViews); |
73 | | - } |
74 | | - else if (ui.index == 4){ |
75 | | - lazyLoad(editorsByGeography); |
76 | | - } |
77 | | - }); |
| 62 | + if (ui.index == 0) { |
| 63 | + lazyLoad(activeEditors); |
| 64 | + } |
| 65 | + else if (ui.index == 1) { |
| 66 | + lazyLoad(uniqueVisitors); |
| 67 | + } |
| 68 | + else if (ui.index == 2) { |
| 69 | + lazyLoad(reachPercentage); |
| 70 | + } |
| 71 | + else if (ui.index == 3) { |
| 72 | + lazyLoad(mobileViews); |
| 73 | + } |
| 74 | + else if (ui.index == 4){ |
| 75 | + lazyLoad(editorsByGeography); |
| 76 | + } |
| 77 | + }); |
78 | 78 | }); |
79 | 79 | </script> |
80 | 80 | </head> |
81 | 81 | <body> |
82 | 82 | <div id="tabs"> |
83 | 83 | <ul> |
84 | | - <li id="activeEditorTab"><a href="#tabs-0">Active Editors</a></li> |
85 | | - <li id="uniqueVisitorTab"><a href="#tabs-1">Unique Visitors</a></li> |
86 | | - <li id="reachPercentageTab"><a href="#tabs-2">Reach Percentage</a></li> |
87 | | - <li id="mobileViewsTab"><a href="#tabs-3">Page Views</a></li> |
88 | | - <li id="editorsByGeographyTab"><a href="#tabs-4">Editors By Geography</a></li> |
| 84 | + <li id="activeEditorTab"><a href="#tabs-0">Active Editors</a></li> |
| 85 | + <li id="uniqueVisitorTab"><a href="#tabs-1">Unique Visitors</a></li> |
| 86 | + <li id="reachPercentageTab"><a href="#tabs-2">Reach Percentage</a></li> |
| 87 | + <li id="mobileViewsTab"><a href="#tabs-3">Page Views</a></li> |
| 88 | + <li id="editorsByGeographyTab"><a href="#tabs-4">Editors By Geography</a></li> |
89 | 89 | </ul> |
90 | 90 | <div id="tabs-0"> |
91 | | - <div id="chartActiveEditors" class="reportCardChart"></div> |
| 91 | + <div id="chartActiveEditors" class="reportCardChart"></div> |
92 | 92 | </div> |
93 | 93 | <div id="tabs-1"> |
94 | | - <div id="chartUniqueVisitors" class="reportCardChart"></div> |
| 94 | + <div id="chartUniqueVisitors" class="reportCardChart"></div> |
95 | 95 | </div> |
96 | 96 | <div id="tabs-2"> |
97 | | - <div id="chartreachPercentage" class="reportCardChart"></div> |
| 97 | + <div id="chartreachPercentage" class="reportCardChart"></div> |
98 | 98 | </div> |
99 | 99 | <div id="tabs-3"> |
100 | | - <div id="chartMobileViews" class="reportCardChart"></div> |
| 100 | + <div id="chartMobileViews" class="reportCardChart"></div> |
101 | 101 | </div> |
102 | 102 | <div id="tabs-4"> |
103 | | - <div id="chartEditorsByGeography" class="reportCardChart"></div> |
| 103 | + <div id="chartEditorsByGeography" class="reportCardChart"></div> |
104 | 104 | </div> |
105 | | -</div> |
| 105 | +</div> |
106 | 106 | </body> |
107 | 107 | </html> |
Index: trunk/extensions/MetricsReporting/frontend/proof_of_concept/charts/activeEditors.js |
— | — | @@ -8,82 +8,81 @@ |
9 | 9 | editorTargets: "../wiki/api.php?action=analytics&metric=editortargets&startmonth=2008-05&endmonth=2011-08&format=json" |
10 | 10 | }, |
11 | 11 | plotData: function(apiDataArray){ |
12 | | - var scaleYfunction = function(Y){return Y;} |
13 | | - var edit5data = p_getDataOnly(apiDataArray.edit5, "SUM(editors_ge_5)", true, scaleYfunction); |
14 | | - var edit100data = p_getDataOnly(apiDataArray.edit100, "SUM(editors_ge_100)", true, scaleYfunction); |
15 | | - var editorTargets = p_getDataSimple(apiDataArray.editorTargets,"value", true, scaleYfunction); |
16 | | - |
17 | | - var labels = ["SUM(editors_ge_5)", "SUM(editors_ge_100)", "editorTargets"]; |
18 | | - |
19 | | - seriesArray = new Array(labels.length); |
| 12 | + var scaleYfunction = function(Y){return Y;} |
| 13 | + var edit5data = p_getDataOnly(apiDataArray.edit5, "SUM(editors_ge_5)", true, scaleYfunction); |
| 14 | + var edit100data = p_getDataOnly(apiDataArray.edit100, "SUM(editors_ge_100)", true, scaleYfunction); |
| 15 | + var editorTargets = p_getDataSimple(apiDataArray.editorTargets,"value", true, scaleYfunction); |
20 | 16 | |
21 | | - for(var i = 0; i < seriesArray.length; i++){ |
22 | | - if(seriesOptions[labels[i]]){ |
23 | | - seriesArray[i] = seriesOptions[labels[i]]; |
24 | | - } |
25 | | - else{ |
26 | | - seriesArray[i] = {}; |
27 | | - } |
28 | | - } |
29 | | - |
30 | | - |
31 | | - //var paddedEdData = padWithZeroes(edit100data.data[0], editorTargets.data[0]); |
32 | | - //console.dir(paddedEdData); |
33 | | - //console.log("BLA"); |
34 | | - //console.log( $.merge(edit100data.data, paddedEdData) ); |
35 | | - |
36 | | - $('#' + this.divTarget ).empty(); |
37 | | - this.plotVar = $.jqplot(this.divTarget,$.merge(edit5data.data, $.merge(edit100data.data, editorTargets.data)),{ |
38 | | - title: this.title, |
39 | | - legend: {show: true, placement: "outsideGrid"} , |
40 | | - series: seriesArray, |
41 | | - cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
42 | | - grid: { |
43 | | - background: "#FFF", |
44 | | - borderColor: "#CCC", |
45 | | - borderWidth: 1, |
46 | | - shadow: false, |
47 | | - gridLineWidth: 1.0 |
48 | | - }, |
49 | | - seriesDefaults: { |
50 | | - fill: false, |
51 | | - shadow: false, |
52 | | - showMarker : false |
53 | | - //markerOptions: { |
54 | | - //size: 5, |
55 | | - //} |
56 | | - }, |
57 | | - axes: { |
58 | | - xaxis: { |
59 | | - renderer: $.jqplot.DateAxisRenderer, |
60 | | - min: edit5data.minDate, |
61 | | - tickInterval: '90 days', |
62 | | - tickOptions: |
63 | | - { |
64 | | - formatString:'%b %y', |
65 | | - fontSize: '7pt', |
66 | | - textColor: "#000" |
67 | | - }, |
68 | | - max: edit5data.maxDate, |
69 | | - showMinorTicks: true, |
70 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
71 | | - labelOptions: { |
72 | | - fontSize: '14pt', |
73 | | - textColor: '#F44' |
74 | | - } |
75 | | - }, |
76 | | - yaxis: { |
77 | | - min: 0 |
78 | | - /*max: parsedData.maxY, |
79 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
80 | | - tickOptions: { |
81 | | - formatString: ' %d', |
82 | | - textColor: "#000" , |
83 | | - }, |
84 | | - tickInterval: parsedData.maxY / 4, */ |
85 | | - } |
86 | | - } |
87 | | - }); |
88 | | - |
| 17 | + var labels = ["SUM(editors_ge_5)", "SUM(editors_ge_100)", "editorTargets"]; |
| 18 | + |
| 19 | + seriesArray = new Array(labels.length); |
| 20 | + |
| 21 | + for(var i = 0; i < seriesArray.length; i++){ |
| 22 | + if(seriesOptions[labels[i]]){ |
| 23 | + seriesArray[i] = seriesOptions[labels[i]]; |
| 24 | + } |
| 25 | + else{ |
| 26 | + seriesArray[i] = {}; |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + //var paddedEdData = padWithZeroes(edit100data.data[0], editorTargets.data[0]); |
| 31 | + //console.dir(paddedEdData); |
| 32 | + //console.log("BLA"); |
| 33 | + //console.log( $.merge(edit100data.data, paddedEdData) ); |
| 34 | + |
| 35 | + $('#' + this.divTarget ).empty(); |
| 36 | + this.plotVar = $.jqplot(this.divTarget,$.merge(edit5data.data, $.merge(edit100data.data, editorTargets.data)),{ |
| 37 | + title: this.title, |
| 38 | + legend: {show: true, placement: "outsideGrid"} , |
| 39 | + series: seriesArray, |
| 40 | + cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
| 41 | + grid: { |
| 42 | + background: "#FFF", |
| 43 | + borderColor: "#CCC", |
| 44 | + borderWidth: 1, |
| 45 | + shadow: false, |
| 46 | + gridLineWidth: 1.0 |
| 47 | + }, |
| 48 | + seriesDefaults: { |
| 49 | + fill: false, |
| 50 | + shadow: false, |
| 51 | + showMarker : false |
| 52 | + //markerOptions: { |
| 53 | + //size: 5, |
| 54 | + //} |
| 55 | + }, |
| 56 | + axes: { |
| 57 | + xaxis: { |
| 58 | + renderer: $.jqplot.DateAxisRenderer, |
| 59 | + min: edit5data.minDate, |
| 60 | + tickInterval: '90 days', |
| 61 | + tickOptions: |
| 62 | + { |
| 63 | + formatString:'%b %y', |
| 64 | + fontSize: '7pt', |
| 65 | + textColor: "#000" |
| 66 | + }, |
| 67 | + max: edit5data.maxDate, |
| 68 | + showMinorTicks: true, |
| 69 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 70 | + labelOptions: { |
| 71 | + fontSize: '14pt', |
| 72 | + textColor: '#F44' |
| 73 | + } |
| 74 | + }, |
| 75 | + yaxis: { |
| 76 | + min: 0 |
| 77 | + /*max: parsedData.maxY, |
| 78 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 79 | + tickOptions: { |
| 80 | + formatString: ' %d', |
| 81 | + textColor: "#000" , |
| 82 | + }, |
| 83 | + tickInterval: parsedData.maxY / 4, */ |
| 84 | + } |
| 85 | + } |
| 86 | + }); |
| 87 | + |
89 | 88 | } |
90 | | -}; //activeEditors |
\ No newline at end of file |
| 89 | +}; //activeEditors |
Index: trunk/extensions/MetricsReporting/frontend/proof_of_concept/charts/mobileViews.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -var mobileViews = { |
| 2 | +var mobileViews = { |
3 | 3 | divTarget: "chartMobileViews", |
4 | 4 | title: 'Page Views (millions)', |
5 | 5 | plotVar: {}, |
— | — | @@ -8,79 +8,79 @@ |
9 | 9 | }, |
10 | 10 | plotData: function(apiDataArray){ |
11 | 11 | var data = apiDataArray.pageViews; |
12 | | - var scaleYfunction = function(Y){return Y/1000000;} |
| 12 | + var scaleYfunction = function(Y){return Y/1000000;} |
13 | 13 | var scaleYfunctionThousand = function(Y){return Y/1000;} |
14 | | - |
| 14 | + |
15 | 15 | var mobileData = p_getDataSimple(data, "SUM(views_mobile_normalized)", true, scaleYfunction); |
16 | 16 | var nonMobileData = p_getDataSimple(data, "SUM(views_non_mobile_normalized)", true, scaleYfunction); |
17 | 17 | var mobileOnly = p_getDataSimple(apiDataArray.mobileViews,"value", true, scaleYfunctionThousand); |
18 | | - |
19 | | - var labels = ["SUM(views_mobile_normalized)", "SUM(views_non_mobile_normalized)", "mobile_only"]; |
20 | | - |
21 | | - //parsedData.maxY = maxYaxis (parsedData.maxY) ; |
22 | | - |
23 | | - seriesArray = new Array(labels.length); |
24 | | - for(var i = 0; i < seriesArray.length; i++){ |
25 | | - if(seriesOptions[labels[i]]){ |
26 | | - seriesArray[i] = seriesOptions[labels[i]]; |
27 | | - } |
28 | | - else{ |
29 | | - seriesArray[i] = {}; |
30 | | - } |
31 | | - } |
32 | | - |
33 | | - $('#' + this.divTarget ).empty(); |
34 | | - this.plotVar = $.jqplot(this.divTarget,$.merge(mobileData.data, $.merge(nonMobileData.data, mobileOnly.data)),{ |
35 | | - title: this.title, |
36 | | - legend: {show: true, placement: "outsideGrid"} , |
37 | | - series: seriesArray, |
38 | | - cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
39 | | - grid: { |
40 | | - background: "#FFF", |
41 | | - borderColor: "#CCC", |
42 | | - borderWidth: 1, |
43 | | - shadow: false, |
44 | | - gridLineWidth: 1.0, |
45 | | - }, |
46 | | - seriesDefaults: { |
47 | | - fill: false, |
48 | | - shadow: false, |
49 | | - showMarker : false, |
50 | | - // markerOptions: { |
51 | | - // size: 5, |
52 | | - // } |
53 | | - }, |
54 | | - axes: { |
55 | | - xaxis: { |
56 | | - renderer: $.jqplot.DateAxisRenderer, |
57 | | - min: mobileData.minDate, |
58 | | - tickInterval: '90 days', |
59 | | - tickOptions: |
60 | | - { |
61 | | - formatString:'%b %y', |
62 | | - fontSize: '7pt', |
63 | | - textColor: "#000" |
64 | | - }, |
65 | | - max: mobileData.maxDate, |
66 | | - showMinorTicks: true, |
67 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
68 | | - labelOptions: { |
69 | | - fontSize: '14pt', |
70 | | - textColor: '#F44', |
71 | | - } |
72 | | - }, |
73 | | - yaxis: { |
74 | | - min: 0, |
75 | | - //max: parsedData.maxY, |
76 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
77 | | - tickOptions: { |
78 | | - formatString: ' %d', |
79 | | - textColor: "#000" , |
80 | | - }//, |
81 | | - //tickInterval: parsedData.maxY / 4, |
82 | | - } |
83 | | - } |
84 | | - }); |
85 | | - |
| 18 | + |
| 19 | + var labels = ["SUM(views_mobile_normalized)", "SUM(views_non_mobile_normalized)", "mobile_only"]; |
| 20 | + |
| 21 | + //parsedData.maxY = maxYaxis (parsedData.maxY) ; |
| 22 | + |
| 23 | + seriesArray = new Array(labels.length); |
| 24 | + for(var i = 0; i < seriesArray.length; i++){ |
| 25 | + if(seriesOptions[labels[i]]){ |
| 26 | + seriesArray[i] = seriesOptions[labels[i]]; |
| 27 | + } |
| 28 | + else{ |
| 29 | + seriesArray[i] = {}; |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + $('#' + this.divTarget ).empty(); |
| 34 | + this.plotVar = $.jqplot(this.divTarget,$.merge(mobileData.data, $.merge(nonMobileData.data, mobileOnly.data)),{ |
| 35 | + title: this.title, |
| 36 | + legend: {show: true, placement: "outsideGrid"} , |
| 37 | + series: seriesArray, |
| 38 | + cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
| 39 | + grid: { |
| 40 | + background: "#FFF", |
| 41 | + borderColor: "#CCC", |
| 42 | + borderWidth: 1, |
| 43 | + shadow: false, |
| 44 | + gridLineWidth: 1.0, |
| 45 | + }, |
| 46 | + seriesDefaults: { |
| 47 | + fill: false, |
| 48 | + shadow: false, |
| 49 | + showMarker : false, |
| 50 | + // markerOptions: { |
| 51 | + // size: 5, |
| 52 | + // } |
| 53 | + }, |
| 54 | + axes: { |
| 55 | + xaxis: { |
| 56 | + renderer: $.jqplot.DateAxisRenderer, |
| 57 | + min: mobileData.minDate, |
| 58 | + tickInterval: '90 days', |
| 59 | + tickOptions: |
| 60 | + { |
| 61 | + formatString:'%b %y', |
| 62 | + fontSize: '7pt', |
| 63 | + textColor: "#000" |
| 64 | + }, |
| 65 | + max: mobileData.maxDate, |
| 66 | + showMinorTicks: true, |
| 67 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 68 | + labelOptions: { |
| 69 | + fontSize: '14pt', |
| 70 | + textColor: '#F44', |
| 71 | + } |
| 72 | + }, |
| 73 | + yaxis: { |
| 74 | + min: 0, |
| 75 | + //max: parsedData.maxY, |
| 76 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 77 | + tickOptions: { |
| 78 | + formatString: ' %d', |
| 79 | + textColor: "#000" , |
| 80 | + }//, |
| 81 | + //tickInterval: parsedData.maxY / 4, |
| 82 | + } |
| 83 | + } |
| 84 | + }); |
| 85 | + |
86 | 86 | } |
87 | 87 | }; //mobileViews |
Index: trunk/extensions/MetricsReporting/frontend/proof_of_concept/charts/uniqueVisitors-old.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -var uniqueVisitors = { |
| 2 | +var uniqueVisitors = { |
3 | 3 | divTarget: "chartUniqueVisitors", |
4 | 4 | title: 'comScore unique visitors (millions)', |
5 | 5 | plotVar: {}, |
— | — | @@ -8,79 +8,79 @@ |
9 | 9 | }, |
10 | 10 | plotData: function(apiDataArray){ |
11 | 11 | var data = apiDataArray.uniqueVisitors; |
12 | | - var scaleYfunction = function(Y){return Y/1000000;} |
| 12 | + var scaleYfunction = function(Y){return Y/1000000;} |
13 | 13 | var parsedData = p_getData(data, "region_code", "visitors", true, scaleYfunction); |
14 | | - var offlineData = p_getDataSimple(apiDataArray.offlineEstimate, "readers", true, scaleYfunction); |
| 14 | + var offlineData = p_getDataSimple(apiDataArray.offlineEstimate, "readers", true, scaleYfunction); |
15 | 15 | |
16 | | - |
17 | | - var labels = parsedData.labels; |
18 | | - labels.push("OfflineEst"); |
19 | | - |
20 | | - parsedData.maxY = maxYaxis (parsedData.maxY) ; |
21 | | - |
22 | | - seriesArray = new Array(labels.length); |
23 | | - for(var i = 0; i < seriesArray.length; i++){ |
24 | | - if(seriesOptions[labels[i]]){ |
25 | | - seriesArray[i] = seriesOptions[labels[i]]; |
26 | | - } |
27 | | - else{ |
28 | | - seriesArray[i] = {}; |
29 | | - } |
30 | | - } |
31 | | - |
32 | | - |
33 | | - $('#' + this.divTarget ).empty(); |
34 | | - this.plotVar = $.jqplot(this.divTarget,$.merge(parsedData.data, offlineData.data),{ |
35 | | - title: this.title, |
36 | | - legend: {show: true, placement: "outsideGrid"} , |
37 | | - series: seriesArray, |
38 | | - cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
39 | | - grid: { |
40 | | - background: "#FFF", |
41 | | - borderColor: "#CCC", |
42 | | - borderWidth: 1, |
43 | | - shadow: false, |
44 | | - gridLineWidth: 1.0, |
45 | | - }, |
46 | | - seriesDefaults: { |
47 | | - fill: false, |
48 | | - shadow: false, |
49 | | - showMarker : false, |
50 | | - // markerOptions: { |
51 | | - // size: 5, |
52 | | - // } |
53 | | - }, |
54 | | - axes: { |
55 | | - xaxis: { |
56 | | - renderer: $.jqplot.DateAxisRenderer, |
57 | | - min: parsedData.minDate, |
58 | | - tickInterval: '90 days', |
59 | | - tickOptions: |
60 | | - { |
61 | | - formatString:'%b %y', |
62 | | - fontSize: '7pt', |
63 | | - textColor: "#000" |
64 | | - }, |
65 | | - max: parsedData.maxDate, |
66 | | - showMinorTicks: true, |
67 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
68 | | - labelOptions: { |
69 | | - fontSize: '14pt', |
70 | | - textColor: '#F44', |
71 | | - } |
72 | | - }, |
73 | | - yaxis: { |
74 | | - min: 0, |
75 | | - max: parsedData.maxY, |
76 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
77 | | - tickOptions: { |
78 | | - formatString: ' %d', |
79 | | - textColor: "#000" , |
80 | | - }, |
81 | | - tickInterval: parsedData.maxY / 4, |
82 | | - } |
83 | | - } |
84 | | - }); |
85 | | - |
| 16 | + |
| 17 | + var labels = parsedData.labels; |
| 18 | + labels.push("OfflineEst"); |
| 19 | + |
| 20 | + parsedData.maxY = maxYaxis (parsedData.maxY) ; |
| 21 | + |
| 22 | + seriesArray = new Array(labels.length); |
| 23 | + for(var i = 0; i < seriesArray.length; i++){ |
| 24 | + if(seriesOptions[labels[i]]){ |
| 25 | + seriesArray[i] = seriesOptions[labels[i]]; |
| 26 | + } |
| 27 | + else{ |
| 28 | + seriesArray[i] = {}; |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + |
| 33 | + $('#' + this.divTarget ).empty(); |
| 34 | + this.plotVar = $.jqplot(this.divTarget,$.merge(parsedData.data, offlineData.data),{ |
| 35 | + title: this.title, |
| 36 | + legend: {show: true, placement: "outsideGrid"} , |
| 37 | + series: seriesArray, |
| 38 | + cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
| 39 | + grid: { |
| 40 | + background: "#FFF", |
| 41 | + borderColor: "#CCC", |
| 42 | + borderWidth: 1, |
| 43 | + shadow: false, |
| 44 | + gridLineWidth: 1.0, |
| 45 | + }, |
| 46 | + seriesDefaults: { |
| 47 | + fill: false, |
| 48 | + shadow: false, |
| 49 | + showMarker : false, |
| 50 | + // markerOptions: { |
| 51 | + // size: 5, |
| 52 | + // } |
| 53 | + }, |
| 54 | + axes: { |
| 55 | + xaxis: { |
| 56 | + renderer: $.jqplot.DateAxisRenderer, |
| 57 | + min: parsedData.minDate, |
| 58 | + tickInterval: '90 days', |
| 59 | + tickOptions: |
| 60 | + { |
| 61 | + formatString:'%b %y', |
| 62 | + fontSize: '7pt', |
| 63 | + textColor: "#000" |
| 64 | + }, |
| 65 | + max: parsedData.maxDate, |
| 66 | + showMinorTicks: true, |
| 67 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 68 | + labelOptions: { |
| 69 | + fontSize: '14pt', |
| 70 | + textColor: '#F44', |
| 71 | + } |
| 72 | + }, |
| 73 | + yaxis: { |
| 74 | + min: 0, |
| 75 | + max: parsedData.maxY, |
| 76 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 77 | + tickOptions: { |
| 78 | + formatString: ' %d', |
| 79 | + textColor: "#000" , |
| 80 | + }, |
| 81 | + tickInterval: parsedData.maxY / 4, |
| 82 | + } |
| 83 | + } |
| 84 | + }); |
| 85 | + |
86 | 86 | } |
87 | 87 | }; //unique visitors |
Index: trunk/extensions/MetricsReporting/frontend/proof_of_concept/charts/globalIncludes.js |
— | — | @@ -6,35 +6,35 @@ |
7 | 7 | "MA": { "label": "Middle-East/Africa", "color": "#e61d0a"},// "#99445e"}, |
8 | 8 | "NA": { "label": "North America", "color": "#0a0aa4"},//"#5e9944"}, //green! |
9 | 9 | "W" : { "label": "World", "color": "#5cc3f0",//"#448899"//theme |
10 | | - "lineWidth": 1, //5, |
11 | | - "fillColor":"#F0F" |
12 | | - }, |
13 | | - "us" : { "label" : "United States", "color" : "blue"}, |
14 | | - "ca" : { "label" : "Canada", "color": "red" }, |
15 | | - //us, de, gb, fr, jp, it, au, ca, es, in |
16 | | - "de" : { "label" : "Germany"}, |
17 | | - "gb" : { "label" : "UK"}, |
18 | | - "fr" : { "label" : "France"}, |
19 | | - "jp" : { "label" : "Japan"}, |
20 | | - "it" : { "label" : "Italy"}, |
21 | | - "au" : { "label" : "Australia"}, |
22 | | - "es" : { "label" : "Spain"}, |
23 | | - "in" : { "label" : "India"}, |
24 | | - "SUM(editors_ge_5)": { "label":"At least 5 edits", "color":"#448899" }, |
25 | | - "SUM(editors_ge_100)": { "label":"At least 100 edits", "color": "#e61d0a" }, |
26 | | - "OfflineEst" : { "label": "Offline Estimate", "color": "black"}, |
27 | | - "SUM(views_mobile_raw)": { "label":"Mobile Views to Gateway", "color":"#448899" }, |
28 | | - "SUM(views_non_mobile_raw)": { "label":"Non Mobile Views", "color":"#e61d0a" }, |
29 | | - "SUM(views_mobile_normalized)": { "label":"Mobile Views to Gateway", "color":"#448899" }, |
30 | | - "SUM(views_non_mobile_normalized)": { "label":"Non Mobile Views", "color":"#e61d0a" }, |
31 | | - "mobile_only": {"label": "Total Mobile Views", "color": "#804499"}, |
32 | | - "editorTargets": { "label": "Editor Targets"} |
33 | | - |
34 | | -}; |
| 10 | + "lineWidth": 1, //5, |
| 11 | + "fillColor":"#F0F" |
| 12 | + }, |
| 13 | + "us" : { "label" : "United States", "color" : "blue"}, |
| 14 | + "ca" : { "label" : "Canada", "color": "red" }, |
| 15 | + //us, de, gb, fr, jp, it, au, ca, es, in |
| 16 | + "de" : { "label" : "Germany"}, |
| 17 | + "gb" : { "label" : "UK"}, |
| 18 | + "fr" : { "label" : "France"}, |
| 19 | + "jp" : { "label" : "Japan"}, |
| 20 | + "it" : { "label" : "Italy"}, |
| 21 | + "au" : { "label" : "Australia"}, |
| 22 | + "es" : { "label" : "Spain"}, |
| 23 | + "in" : { "label" : "India"}, |
| 24 | + "SUM(editors_ge_5)": { "label":"At least 5 edits", "color":"#448899" }, |
| 25 | + "SUM(editors_ge_100)": { "label":"At least 100 edits", "color": "#e61d0a" }, |
| 26 | + "OfflineEst" : { "label": "Offline Estimate", "color": "black"}, |
| 27 | + "SUM(views_mobile_raw)": { "label":"Mobile Views to Gateway", "color":"#448899" }, |
| 28 | + "SUM(views_non_mobile_raw)": { "label":"Non Mobile Views", "color":"#e61d0a" }, |
| 29 | + "SUM(views_mobile_normalized)": { "label":"Mobile Views to Gateway", "color":"#448899" }, |
| 30 | + "SUM(views_non_mobile_normalized)": { "label":"Non Mobile Views", "color":"#e61d0a" }, |
| 31 | + "mobile_only": {"label": "Total Mobile Views", "color": "#804499"}, |
| 32 | + "editorTargets": { "label": "Editor Targets"} |
35 | 33 | |
| 34 | +}; |
36 | 35 | |
| 36 | + |
37 | 37 | /* |
38 | | -* makes API calls based |
| 38 | +* makes API calls based |
39 | 39 | */ |
40 | 40 | function makeAPICall(plotObj){ |
41 | 41 | var apiDataReturns = {}; |
— | — | @@ -63,37 +63,37 @@ |
64 | 64 | * Function to lazy load chart objects |
65 | 65 | */ |
66 | 66 | function lazyLoad(llobj){ |
67 | | - if(jQuery.isEmptyObject(llobj.plotVar)){ |
68 | | - makeAPICall(llobj); |
69 | | - } else { |
70 | | - llobj.plotVar.replot(); |
71 | | - } |
| 67 | + if(jQuery.isEmptyObject(llobj.plotVar)){ |
| 68 | + makeAPICall(llobj); |
| 69 | + } else { |
| 70 | + llobj.plotVar.replot(); |
| 71 | + } |
72 | 72 | } |
73 | | - |
74 | 73 | |
| 74 | + |
75 | 75 | /* |
76 | 76 | * Function to get Y axis max |
77 | 77 | */ |
78 | 78 | function maxYaxis(yaxis_max) { |
79 | | - mult = 1 ; |
80 | | - while (yaxis_max > 1) { |
81 | | - yaxis_max /= 10 ; |
82 | | - mult *= 10 ; |
83 | | - } |
84 | | - if (yaxis_max < 0.1) { |
85 | | - yaxis_max = 0.1 ; |
86 | | - } else |
87 | | - if (yaxis_max < 0.2) { |
88 | | - yaxis_max = 0.2 ; |
89 | | - } else |
90 | | - if (yaxis_max < 0.5) { |
91 | | - yaxis_max = 0.5 ; |
92 | | - } |
93 | | - else { |
94 | | - yaxis_max = 1 ; |
95 | | - } |
96 | | - yaxis_max *= mult ; |
97 | | - return (yaxis_max) ; |
| 79 | + mult = 1 ; |
| 80 | + while (yaxis_max > 1) { |
| 81 | + yaxis_max /= 10 ; |
| 82 | + mult *= 10 ; |
| 83 | + } |
| 84 | + if (yaxis_max < 0.1) { |
| 85 | + yaxis_max = 0.1 ; |
| 86 | + } else |
| 87 | + if (yaxis_max < 0.2) { |
| 88 | + yaxis_max = 0.2 ; |
| 89 | + } else |
| 90 | + if (yaxis_max < 0.5) { |
| 91 | + yaxis_max = 0.5 ; |
| 92 | + } |
| 93 | + else { |
| 94 | + yaxis_max = 1 ; |
| 95 | + } |
| 96 | + yaxis_max *= mult ; |
| 97 | + return (yaxis_max) ; |
98 | 98 | } |
99 | 99 | |
100 | 100 | /* |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | } |
112 | 112 | return retval; |
113 | 113 | } |
114 | | - |
| 114 | + |
115 | 115 | /* |
116 | 116 | * get labels from API return object |
117 | 117 | */ |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | } |
127 | 127 | return retval; |
128 | 128 | } |
129 | | - |
| 129 | + |
130 | 130 | /* |
131 | 131 | * go from MW date format to date format used by jqplot |
132 | 132 | */ |
— | — | @@ -133,147 +133,147 @@ |
134 | 134 | date = date+""; |
135 | 135 | return date.substring(0,4)+"-"+date.substring(4,6)+"-"+date.substring(6,8); |
136 | 136 | } |
137 | | - |
138 | 137 | |
139 | | -// provisional: get Data function |
| 138 | + |
| 139 | +// provisional: get Data function |
140 | 140 | function p_getData(apiReturnObj, labelName, dataName, isInt, scaleYfunction, returnDate){ |
141 | | - var apiData; |
142 | | - for(var robj in apiReturnObj){ |
143 | | - apiData = apiReturnObj[robj]; |
144 | | - } |
145 | | - var labels = new Array(); |
146 | | - var dataArray = new Array(); |
147 | | - var minDate = "9999"; |
148 | | - var maxDate = ""; |
149 | | - |
| 141 | + var apiData; |
| 142 | + for(var robj in apiReturnObj){ |
| 143 | + apiData = apiReturnObj[robj]; |
| 144 | + } |
| 145 | + var labels = new Array(); |
| 146 | + var dataArray = new Array(); |
| 147 | + var minDate = "9999"; |
| 148 | + var maxDate = ""; |
| 149 | + |
150 | 150 | var yaxis_min = 9999999999 ; |
151 | 151 | var yaxis_max = -9999999999 ; |
152 | | - |
| 152 | + |
153 | 153 | var findYaxisMinMax = function(value){ |
154 | | - if (value < yaxis_min) |
155 | | - { yaxis_min = value ; } |
156 | | - if (value > yaxis_max) |
157 | | - { yaxis_max = value ; } |
| 154 | + if (value < yaxis_min) |
| 155 | + { yaxis_min = value ; } |
| 156 | + if (value > yaxis_max) |
| 157 | + { yaxis_max = value ; } |
158 | 158 | return (value) ; |
159 | 159 | }; |
160 | | - |
161 | | - for(var i in apiData){ |
162 | | - var tempDataArray = new Array(); |
163 | | - labels.push(apiData[i][labelName]); |
164 | | - for(var j in apiData[i].data){ |
165 | | - |
166 | | - if(apiData[i].data[j].date < minDate){ |
167 | | - minDate = apiData[i].data[j].date; |
168 | | - } |
169 | | - if(apiData[i].data[j].date > maxDate){ |
170 | | - maxDate = apiData[i].data[j].date; |
171 | | - } |
172 | | - |
173 | | - var YVal = parseFloat(apiData[i].data[j][dataName]); |
174 | | - |
175 | | - if(isInt){ |
176 | | - YVal = parseInt(apiData[i].data[j][dataName]); |
177 | | - } |
178 | | - YVal = findYaxisMinMax (scaleYfunction(YVal)); |
179 | | - if(returnDate){ |
180 | | - tempDataArray.push( [apiData[i].data[j].date, YVal]); |
181 | | - } |
182 | | - else{ |
183 | | - tempDataArray.push(YVal); |
184 | | - } |
185 | | - } |
186 | | - dataArray.push(tempDataArray); |
187 | | - } |
188 | | - |
189 | | - maxDate = maxDate.substr(0,8)+'01' ; // last month is outside range |
190 | | - var returnObj = { "labels": labels, "data": dataArray, |
191 | | - "minDate": minDate, "maxDate": maxDate, |
192 | | - "minY": yaxis_min, "maxY": yaxis_max }; |
193 | | - return returnObj; |
194 | | - |
| 160 | + |
| 161 | + for(var i in apiData){ |
| 162 | + var tempDataArray = new Array(); |
| 163 | + labels.push(apiData[i][labelName]); |
| 164 | + for(var j in apiData[i].data){ |
| 165 | + |
| 166 | + if(apiData[i].data[j].date < minDate){ |
| 167 | + minDate = apiData[i].data[j].date; |
| 168 | + } |
| 169 | + if(apiData[i].data[j].date > maxDate){ |
| 170 | + maxDate = apiData[i].data[j].date; |
| 171 | + } |
| 172 | + |
| 173 | + var YVal = parseFloat(apiData[i].data[j][dataName]); |
| 174 | + |
| 175 | + if(isInt){ |
| 176 | + YVal = parseInt(apiData[i].data[j][dataName]); |
| 177 | + } |
| 178 | + YVal = findYaxisMinMax (scaleYfunction(YVal)); |
| 179 | + if(returnDate){ |
| 180 | + tempDataArray.push( [apiData[i].data[j].date, YVal]); |
| 181 | + } |
| 182 | + else{ |
| 183 | + tempDataArray.push(YVal); |
| 184 | + } |
| 185 | + } |
| 186 | + dataArray.push(tempDataArray); |
| 187 | + } |
| 188 | + |
| 189 | + maxDate = maxDate.substr(0,8)+'01' ; // last month is outside range |
| 190 | + var returnObj = { "labels": labels, "data": dataArray, |
| 191 | + "minDate": minDate, "maxDate": maxDate, |
| 192 | + "minY": yaxis_min, "maxY": yaxis_max }; |
| 193 | + return returnObj; |
| 194 | + |
195 | 195 | } |
196 | 196 | |
197 | 197 | function p_getDataDefault(apiReturnObj, labelName, dataName, isInt){ |
198 | 198 | var defaultScale = function(Y){return Y;}; |
199 | | - return p_getData(apiReturnObj, labelName, dataName, isInt, defaultScale , true); |
| 199 | + return p_getData(apiReturnObj, labelName, dataName, isInt, defaultScale , true); |
200 | 200 | } |
201 | 201 | |
202 | 202 | |
203 | 203 | function p_getDataDate(apiReturnObj, labelName, dataName, isInt, scaleYfunction){ |
204 | | - return p_getData(apiReturnObj, labelName, dataName, isInt, scaleYfunction, true); |
| 204 | + return p_getData(apiReturnObj, labelName, dataName, isInt, scaleYfunction, true); |
205 | 205 | } |
206 | 206 | |
207 | | - |
| 207 | + |
208 | 208 | /* provisional: get data only function (labels set in the function that draws the chart) */ |
209 | 209 | function p_getDataOnly(apiReturnObj, dataName, isInt, scaleYfunction){ |
210 | | - var apiData; |
211 | | - for(var robj in apiReturnObj){ |
212 | | - apiData = apiReturnObj[robj]; |
213 | | - } |
214 | | - var dataArray = new Array(); |
215 | | - var minDate = "9999"; |
216 | | - var maxDate = ""; |
217 | | - |
218 | | - for(var i in apiData){ |
219 | | - var tempDataArray = new Array(); |
220 | | - for(var j in apiData[i].data){ |
221 | | - |
222 | | - if(apiData[i].data[j].date < minDate){ |
223 | | - minDate = apiData[i].data[j].date; |
224 | | - } |
225 | | - if(apiData[i].data[j].date > maxDate){ |
226 | | - maxDate = apiData[i].data[j].date; |
227 | | - } |
228 | | - if(isInt){ |
229 | | - tempDataArray.push( [apiData[i].data[j].date, scaleYfunction(parseInt(apiData[i].data[j][dataName])) ]); |
230 | | - }else{ |
231 | | - tempDataArray.push( [apiData[i].data[j].date, scaleYfunction(parseFloat(apiData[i].data[j][dataName])) ]); |
232 | | - } |
233 | | - } |
234 | | - dataArray.push(tempDataArray); |
235 | | - } |
236 | | - var returnObj = {"data": dataArray, "minDate": minDate, "maxDate": maxDate}; |
237 | | - return returnObj; |
238 | | - |
| 210 | + var apiData; |
| 211 | + for(var robj in apiReturnObj){ |
| 212 | + apiData = apiReturnObj[robj]; |
| 213 | + } |
| 214 | + var dataArray = new Array(); |
| 215 | + var minDate = "9999"; |
| 216 | + var maxDate = ""; |
| 217 | + |
| 218 | + for(var i in apiData){ |
| 219 | + var tempDataArray = new Array(); |
| 220 | + for(var j in apiData[i].data){ |
| 221 | + |
| 222 | + if(apiData[i].data[j].date < minDate){ |
| 223 | + minDate = apiData[i].data[j].date; |
| 224 | + } |
| 225 | + if(apiData[i].data[j].date > maxDate){ |
| 226 | + maxDate = apiData[i].data[j].date; |
| 227 | + } |
| 228 | + if(isInt){ |
| 229 | + tempDataArray.push( [apiData[i].data[j].date, scaleYfunction(parseInt(apiData[i].data[j][dataName])) ]); |
| 230 | + }else{ |
| 231 | + tempDataArray.push( [apiData[i].data[j].date, scaleYfunction(parseFloat(apiData[i].data[j][dataName])) ]); |
| 232 | + } |
| 233 | + } |
| 234 | + dataArray.push(tempDataArray); |
| 235 | + } |
| 236 | + var returnObj = {"data": dataArray, "minDate": minDate, "maxDate": maxDate}; |
| 237 | + return returnObj; |
| 238 | + |
239 | 239 | } |
240 | 240 | |
241 | 241 | // provisional: get data simple, for unformatted API data |
242 | 242 | function p_getDataSimple(apiData, dataName, isInt, scaleYfunction){ |
243 | | - var dataArray = new Array(); |
244 | | - var minDate = "9999"; |
245 | | - var maxDate = ""; |
246 | | - |
247 | | - for(var i in apiData){ |
248 | | - var tempDataArray = new Array(); |
249 | | - for(var j in apiData[i]){ |
250 | | - |
251 | | - if(apiData[i][j].date < minDate){ |
252 | | - minDate = apiData[i][j].date; |
253 | | - } |
254 | | - if(apiData[i][j].date > maxDate){ |
255 | | - maxDate = apiData[i][j].date; |
256 | | - } |
257 | | - if(isInt){ |
258 | | - tempDataArray.push( [apiData[i][j].date, scaleYfunction(parseInt(apiData[i][j][dataName])) ]); |
259 | | - }else{ |
260 | | - tempDataArray.push( [apiData[i][j].date, scaleYfunction(parseFloat(apiData[i][j][dataName])) ]); |
261 | | - } |
262 | | - } |
263 | | - dataArray.push(tempDataArray); |
264 | | - } |
265 | | - var returnObj = {"data": dataArray, "minDate": minDate, "maxDate": maxDate}; |
266 | | - return returnObj; |
267 | | - |
| 243 | + var dataArray = new Array(); |
| 244 | + var minDate = "9999"; |
| 245 | + var maxDate = ""; |
| 246 | + |
| 247 | + for(var i in apiData){ |
| 248 | + var tempDataArray = new Array(); |
| 249 | + for(var j in apiData[i]){ |
| 250 | + |
| 251 | + if(apiData[i][j].date < minDate){ |
| 252 | + minDate = apiData[i][j].date; |
| 253 | + } |
| 254 | + if(apiData[i][j].date > maxDate){ |
| 255 | + maxDate = apiData[i][j].date; |
| 256 | + } |
| 257 | + if(isInt){ |
| 258 | + tempDataArray.push( [apiData[i][j].date, scaleYfunction(parseInt(apiData[i][j][dataName])) ]); |
| 259 | + }else{ |
| 260 | + tempDataArray.push( [apiData[i][j].date, scaleYfunction(parseFloat(apiData[i][j][dataName])) ]); |
| 261 | + } |
| 262 | + } |
| 263 | + dataArray.push(tempDataArray); |
| 264 | + } |
| 265 | + var returnObj = {"data": dataArray, "minDate": minDate, "maxDate": maxDate}; |
| 266 | + return returnObj; |
| 267 | + |
268 | 268 | } |
269 | | - |
270 | | - |
271 | | - |
272 | | - |
| 269 | + |
| 270 | + |
| 271 | + |
| 272 | + |
273 | 273 | function buildErrorBand(originalSeries, errorSeriesWrapped){ |
274 | 274 | var errorSeries = errorSeriesWrapped[0]; |
275 | 275 | var bandedHi = new Array(originalSeries.length); |
276 | 276 | var bandedLo = new Array(originalSeries.length); |
277 | | - |
| 277 | + |
278 | 278 | var j = 0; |
279 | 279 | var endFound = false; |
280 | 280 | for(var i = 0; i < originalSeries.length; i++){ |
— | — | @@ -291,9 +291,9 @@ |
292 | 292 | bandedLo[i] = [originalSeries[i][0], originalSeries[i][1]]; |
293 | 293 | originalSeries[i][1] = originalSeries[i][1] + errorSeries[j][1]/2; |
294 | 294 | j++; |
295 | | - } |
| 295 | + } |
296 | 296 | } |
297 | | - return [bandedHi, bandedLo]; |
| 297 | + return [bandedHi, bandedLo]; |
298 | 298 | } |
299 | 299 | |
300 | 300 | function padWithZeroes(originalSeries, seriesToPad){ |
— | — | @@ -315,7 +315,7 @@ |
316 | 316 | returnSeries[i] = 0; |
317 | 317 | } |
318 | 318 | j++; |
319 | | - } |
| 319 | + } |
320 | 320 | } |
321 | 321 | return [returnSeries]; |
322 | 322 | } |
Index: trunk/extensions/MetricsReporting/frontend/proof_of_concept/charts/uniqueVisitors.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -var uniqueVisitors = { |
| 2 | +var uniqueVisitors = { |
3 | 3 | divTarget: "chartUniqueVisitors", |
4 | 4 | title: 'comScore unique visitors (millions)', |
5 | 5 | plotVar: {}, |
— | — | @@ -8,95 +8,93 @@ |
9 | 9 | }, |
10 | 10 | plotData: function(apiDataArray){ |
11 | 11 | var data = apiDataArray.uniqueVisitors; |
12 | | - var scaleYfunction = function(Y){return Y/1000000;} |
| 12 | + var scaleYfunction = function(Y){return Y/1000000;} |
13 | 13 | var parsedData = p_getData(data, "region_code", "visitors", true, scaleYfunction, true); |
14 | | - var offlineData = p_getDataSimple(apiDataArray.offlineEstimate, "readers", true, scaleYfunction); |
| 14 | + var offlineData = p_getDataSimple(apiDataArray.offlineEstimate, "readers", true, scaleYfunction); |
15 | 15 | |
16 | | - |
17 | | - var labels = parsedData.labels; |
18 | | - labels.push("OfflineEst"); |
19 | | - |
20 | | - parsedData.maxY = maxYaxis (parsedData.maxY) ; |
21 | | - |
22 | | - |
23 | | - var worldIndex = labels.indexOf("W"); |
24 | | - |
25 | | - offlineData.bandedSeries = buildErrorBand( parsedData.data[worldIndex], offlineData.data ); |
26 | | - |
27 | | - seriesArray = new Array(labels.length); |
28 | | - for(var i = 0; i < seriesArray.length; i++){ |
29 | | - if(seriesOptions[labels[i]]){ |
30 | | - seriesArray[i] = seriesOptions[labels[i]]; |
31 | | - } |
32 | | - else{ |
33 | | - seriesArray[i] = {}; |
34 | | - } |
35 | | - } |
36 | | - |
37 | | - seriesArray[worldIndex].rendererOptions = { |
38 | | - bands: { |
39 | | - // draw bands at 1.7 "units" above and below line. |
40 | | - interval: 9 |
41 | | - }, |
42 | | - //bandData: offlineData.bandedSeries, |
43 | | - // turn on smoothing |
44 | | - smooth: true |
45 | | - }; |
46 | | - console.log(seriesArray); |
47 | | - |
48 | | - |
49 | | - $('#' + this.divTarget ).empty(); |
50 | | - this.plotVar = $.jqplot(this.divTarget,$.merge(parsedData.data, offlineData.data),{ |
51 | | - title: this.title, |
52 | | - legend: {show: true, placement: "outsideGrid"} , |
53 | | - series: seriesArray, |
54 | | - cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
55 | | - grid: { |
56 | | - background: "#FFF", |
57 | | - borderColor: "#CCC", |
58 | | - borderWidth: 1, |
59 | | - shadow: false, |
60 | | - gridLineWidth: 1.0, |
61 | | - }, |
62 | | - seriesDefaults: { |
63 | | - fill: false, |
64 | | - shadow: false, |
65 | | - showMarker : false |
66 | | - // markerOptions: { |
67 | | - // size: 5, |
68 | | - // } |
69 | | - }, |
70 | | - axes: { |
71 | | - xaxis: { |
72 | | - renderer: $.jqplot.DateAxisRenderer, |
73 | | - min: parsedData.minDate, |
74 | | - tickInterval: '90 days', |
75 | | - tickOptions: |
76 | | - { |
77 | | - formatString:'%b %y', |
78 | | - fontSize: '7pt', |
79 | | - textColor: "#000" |
80 | | - }, |
81 | | - max: parsedData.maxDate, |
82 | | - showMinorTicks: true, |
83 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
84 | | - labelOptions: { |
85 | | - fontSize: '14pt', |
86 | | - textColor: '#F44' |
87 | | - } |
88 | | - }, |
89 | | - yaxis: { |
90 | | - min: 0, |
91 | | - max: parsedData.maxY, |
92 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
93 | | - tickOptions: { |
94 | | - formatString: ' %d', |
95 | | - textColor: "#000" |
96 | | - }, |
97 | | - tickInterval: parsedData.maxY / 4, |
98 | | - } |
99 | | - } |
100 | | - }); |
101 | | - |
| 16 | + var labels = parsedData.labels; |
| 17 | + labels.push("OfflineEst"); |
| 18 | + |
| 19 | + parsedData.maxY = maxYaxis (parsedData.maxY) ; |
| 20 | + |
| 21 | + var worldIndex = labels.indexOf("W"); |
| 22 | + |
| 23 | + offlineData.bandedSeries = buildErrorBand( parsedData.data[worldIndex], offlineData.data ); |
| 24 | + |
| 25 | + seriesArray = new Array(labels.length); |
| 26 | + for(var i = 0; i < seriesArray.length; i++){ |
| 27 | + if(seriesOptions[labels[i]]){ |
| 28 | + seriesArray[i] = seriesOptions[labels[i]]; |
| 29 | + } |
| 30 | + else{ |
| 31 | + seriesArray[i] = {}; |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + seriesArray[worldIndex].rendererOptions = { |
| 36 | + bands: { |
| 37 | + // draw bands at 1.7 "units" above and below line. |
| 38 | + interval: 9 |
| 39 | + }, |
| 40 | + //bandData: offlineData.bandedSeries, |
| 41 | + // turn on smoothing |
| 42 | + smooth: true |
| 43 | + }; |
| 44 | + console.log(seriesArray); |
| 45 | + |
| 46 | + |
| 47 | + $('#' + this.divTarget ).empty(); |
| 48 | + this.plotVar = $.jqplot(this.divTarget,$.merge(parsedData.data, offlineData.data),{ |
| 49 | + title: this.title, |
| 50 | + legend: {show: true, placement: "outsideGrid"} , |
| 51 | + series: seriesArray, |
| 52 | + cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
| 53 | + grid: { |
| 54 | + background: "#FFF", |
| 55 | + borderColor: "#CCC", |
| 56 | + borderWidth: 1, |
| 57 | + shadow: false, |
| 58 | + gridLineWidth: 1.0, |
| 59 | + }, |
| 60 | + seriesDefaults: { |
| 61 | + fill: false, |
| 62 | + shadow: false, |
| 63 | + showMarker : false |
| 64 | + // markerOptions: { |
| 65 | + // size: 5, |
| 66 | + // } |
| 67 | + }, |
| 68 | + axes: { |
| 69 | + xaxis: { |
| 70 | + renderer: $.jqplot.DateAxisRenderer, |
| 71 | + min: parsedData.minDate, |
| 72 | + tickInterval: '90 days', |
| 73 | + tickOptions: |
| 74 | + { |
| 75 | + formatString:'%b %y', |
| 76 | + fontSize: '7pt', |
| 77 | + textColor: "#000" |
| 78 | + }, |
| 79 | + max: parsedData.maxDate, |
| 80 | + showMinorTicks: true, |
| 81 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 82 | + labelOptions: { |
| 83 | + fontSize: '14pt', |
| 84 | + textColor: '#F44' |
| 85 | + } |
| 86 | + }, |
| 87 | + yaxis: { |
| 88 | + min: 0, |
| 89 | + max: parsedData.maxY, |
| 90 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 91 | + tickOptions: { |
| 92 | + formatString: ' %d', |
| 93 | + textColor: "#000" |
| 94 | + }, |
| 95 | + tickInterval: parsedData.maxY / 4, |
| 96 | + } |
| 97 | + } |
| 98 | + }); |
| 99 | + |
102 | 100 | } |
103 | 101 | }; //unique visitors |
Index: trunk/extensions/MetricsReporting/frontend/proof_of_concept/charts/editorsByGeography.js |
— | — | @@ -1,8 +1,8 @@ |
2 | | -var editorsByGeography = { |
| 2 | +var editorsByGeography = { |
3 | 3 | divTarget: "chartEditorsByGeography", |
4 | 4 | title: 'Active Editors by Geography', |
5 | 5 | plotVar: {}, |
6 | | - apiCalls: { |
| 6 | + apiCalls: { |
7 | 7 | //us, de, gb, fr, jp, it, au, ca, es, in |
8 | 8 | editorsByGeographyUS: "../wiki/api.php?action=analytics&metric=editorsbygeography&startmonth=2004-08&selectcountries=us&endmonth=2011-07&format=json", |
9 | 9 | editorsByGeographyDE: "../wiki/api.php?action=analytics&metric=editorsbygeography&startmonth=2004-08&selectcountries=de&endmonth=2011-07&format=json", |
— | — | @@ -16,110 +16,109 @@ |
17 | 17 | editorsByGeographyIN: "../wiki/api.php?action=analytics&metric=editorsbygeography&startmonth=2004-08&selectcountries=in&endmonth=2011-07&format=json" |
18 | 18 | }, |
19 | 19 | plotData: function(apiDataArray){ |
20 | | - |
21 | | - var data = apiDataArray.editorsByGeographyUS; |
22 | | - var scaleYfunction = function(Y){return Y;} |
23 | | - var parsedData = p_getData(data, "country_code", "value", true, scaleYfunction, false); |
24 | | - |
25 | | - var parsedData2 = p_getData(apiDataArray.editorsByGeographyDE, "country_code", "value", true, scaleYfunction, false); |
26 | | - var parsedData3 = p_getData(apiDataArray.editorsByGeographyGB, "country_code", "value", true, scaleYfunction, false); |
27 | | - var parsedData4 = p_getData(apiDataArray.editorsByGeographyFR, "country_code", "value", true, scaleYfunction, false); |
28 | | - var parsedData5 = p_getData(apiDataArray.editorsByGeographyJP, "country_code", "value", true, scaleYfunction, false); |
29 | | - var parsedData6 = p_getData(apiDataArray.editorsByGeographyIT, "country_code", "value", true, scaleYfunction, false); |
30 | | - var parsedData7 = p_getData(apiDataArray.editorsByGeographyAU, "country_code", "value", true, scaleYfunction, false); |
31 | | - var parsedData8 = p_getData(apiDataArray.editorsByGeographyCA, "country_code", "value", true, scaleYfunction, false); |
32 | | - var parsedData9 = p_getData(apiDataArray.editorsByGeographyES, "country_code", "value", true, scaleYfunction, false); |
33 | | - var parsedData10 = p_getData(apiDataArray.editorsByGeographyIN, "country_code", "value", true, scaleYfunction, false); |
34 | | - |
35 | | - parsedData.minY -= parsedData.minY % 5 ; |
36 | | - if (parsedData.maxY % 5 != 0) |
37 | | - { parsedData.maxY += 5 - (parsedData.maxY % 5) ; } |
38 | | - |
39 | | - var labels = parsedData.labels; |
| 20 | + |
| 21 | + var data = apiDataArray.editorsByGeographyUS; |
| 22 | + var scaleYfunction = function(Y){return Y;} |
| 23 | + var parsedData = p_getData(data, "country_code", "value", true, scaleYfunction, false); |
| 24 | + |
| 25 | + var parsedData2 = p_getData(apiDataArray.editorsByGeographyDE, "country_code", "value", true, scaleYfunction, false); |
| 26 | + var parsedData3 = p_getData(apiDataArray.editorsByGeographyGB, "country_code", "value", true, scaleYfunction, false); |
| 27 | + var parsedData4 = p_getData(apiDataArray.editorsByGeographyFR, "country_code", "value", true, scaleYfunction, false); |
| 28 | + var parsedData5 = p_getData(apiDataArray.editorsByGeographyJP, "country_code", "value", true, scaleYfunction, false); |
| 29 | + var parsedData6 = p_getData(apiDataArray.editorsByGeographyIT, "country_code", "value", true, scaleYfunction, false); |
| 30 | + var parsedData7 = p_getData(apiDataArray.editorsByGeographyAU, "country_code", "value", true, scaleYfunction, false); |
| 31 | + var parsedData8 = p_getData(apiDataArray.editorsByGeographyCA, "country_code", "value", true, scaleYfunction, false); |
| 32 | + var parsedData9 = p_getData(apiDataArray.editorsByGeographyES, "country_code", "value", true, scaleYfunction, false); |
| 33 | + var parsedData10 = p_getData(apiDataArray.editorsByGeographyIN, "country_code", "value", true, scaleYfunction, false); |
| 34 | + |
| 35 | + parsedData.minY -= parsedData.minY % 5 ; |
| 36 | + if (parsedData.maxY % 5 != 0) |
| 37 | + { parsedData.maxY += 5 - (parsedData.maxY % 5) ; } |
| 38 | + |
| 39 | + var labels = parsedData.labels; |
40 | 40 | labels = labels.concat(['de','gb','fr','jp','it','au','ca','es','in']); |
41 | 41 | |
42 | | - |
43 | | - var seriesArray = new Array(labels.length); |
44 | | - for(var i = 0; i < seriesArray.length; i++){ |
45 | | - if(seriesOptions[labels[i]]){ |
46 | | - seriesArray[i] = seriesOptions[labels[i]]; |
47 | | - } |
48 | | - else{ |
49 | | - seriesArray[i] = {}; |
50 | | - } |
51 | | - } |
52 | | - $('#' + this.divTarget ).empty(); |
53 | | - |
54 | | - var allData = $.merge(parsedData.data, $.merge(parsedData2.data,$.merge(parsedData3.data,$.merge(parsedData4.data,$.merge(parsedData5.data,$.merge(parsedData6.data,$.merge(parsedData7.data,$.merge(parsedData8.data,$.merge(parsedData9.data, parsedData10.data))))))))); |
55 | | - |
56 | | - var ticks = ['June', 'July']; |
57 | | - this.plotVar = $.jqplot(this.divTarget, allData ,{ |
58 | | - title: this.title, |
59 | | - legend: {show: true, placement: "outsideGrid"} , |
60 | | - series: seriesArray, |
61 | | - cursor: {show: true, zoom:false, showTooltip:true, dblClickReset:true, zoom:false}, |
62 | | - highlighter:{show:false}, |
63 | | - grid: { |
64 | | - background: "#FFF", |
65 | | - borderColor: "#CCC", |
66 | | - borderWidth: 1, |
67 | | - shadow: false, |
68 | | - gridLineWidth: 1.0, |
69 | | - }, |
70 | | - seriesDefaults: { |
71 | | - renderer:$.jqplot.BarRenderer, |
72 | | - //fill: false, |
73 | | - //shadow: false, |
74 | | - //showMarker : false, |
75 | | - //markerOptions: { |
76 | | - //size: 5, |
77 | | - //} |
78 | | - rendererOptions: { |
79 | | - barDirection: 'horizontal', |
80 | | - highlightMouseOver: false, |
81 | | - highlightMouseDown: true, |
82 | | - barPadding: 0 |
| 42 | + var seriesArray = new Array(labels.length); |
| 43 | + for(var i = 0; i < seriesArray.length; i++){ |
| 44 | + if(seriesOptions[labels[i]]){ |
| 45 | + seriesArray[i] = seriesOptions[labels[i]]; |
| 46 | + } |
| 47 | + else{ |
| 48 | + seriesArray[i] = {}; |
| 49 | + } |
| 50 | + } |
| 51 | + $('#' + this.divTarget ).empty(); |
83 | 52 | |
84 | | - } |
85 | | - }, |
86 | | - axes:{ |
87 | | - yaxis: { |
88 | | - renderer: $.jqplot.CategoryAxisRenderer, |
89 | | - ticks: ticks |
90 | | - }} |
91 | | - |
92 | | - |
93 | | - /*axes: { |
94 | | - xaxis: { |
95 | | - renderer: $.jqplot.DateAxisRenderer, |
96 | | - min: parsedData.minDate, |
97 | | - tickInterval: '90 days', |
98 | | - tickOptions: |
99 | | - { |
100 | | - formatString:'%b %y', |
101 | | - fontSize: '7pt', |
102 | | - textColor: "#000" |
103 | | - }, |
104 | | - max: parsedData.maxDate, |
105 | | - showMinorTicks: true, |
106 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
107 | | - labelOptions: { |
108 | | - fontSize: '14pt', |
109 | | - textColor: '#F44', |
110 | | - } |
111 | | - }, |
112 | | - yaxis: { |
113 | | - min: parsedData.minY, |
114 | | - max: parsedData.maxY, |
115 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
116 | | - // tickOptions: { |
117 | | - // formatString: ' %d\%', |
118 | | - // textColor: "#000" , |
119 | | - //}, |
120 | | - tickInterval:5 |
121 | | - } |
122 | | - }*/ |
123 | | - }); |
124 | | - |
| 53 | + var allData = $.merge(parsedData.data, $.merge(parsedData2.data,$.merge(parsedData3.data,$.merge(parsedData4.data,$.merge(parsedData5.data,$.merge(parsedData6.data,$.merge(parsedData7.data,$.merge(parsedData8.data,$.merge(parsedData9.data, parsedData10.data))))))))); |
| 54 | + |
| 55 | + var ticks = ['June', 'July']; |
| 56 | + this.plotVar = $.jqplot(this.divTarget, allData ,{ |
| 57 | + title: this.title, |
| 58 | + legend: {show: true, placement: "outsideGrid"} , |
| 59 | + series: seriesArray, |
| 60 | + cursor: {show: true, zoom:false, showTooltip:true, dblClickReset:true, zoom:false}, |
| 61 | + highlighter:{show:false}, |
| 62 | + grid: { |
| 63 | + background: "#FFF", |
| 64 | + borderColor: "#CCC", |
| 65 | + borderWidth: 1, |
| 66 | + shadow: false, |
| 67 | + gridLineWidth: 1.0, |
| 68 | + }, |
| 69 | + seriesDefaults: { |
| 70 | + renderer:$.jqplot.BarRenderer, |
| 71 | + //fill: false, |
| 72 | + //shadow: false, |
| 73 | + //showMarker : false, |
| 74 | + //markerOptions: { |
| 75 | + //size: 5, |
| 76 | + //} |
| 77 | + rendererOptions: { |
| 78 | + barDirection: 'horizontal', |
| 79 | + highlightMouseOver: false, |
| 80 | + highlightMouseDown: true, |
| 81 | + barPadding: 0 |
| 82 | + |
| 83 | + } |
| 84 | + }, |
| 85 | + axes:{ |
| 86 | + yaxis: { |
| 87 | + renderer: $.jqplot.CategoryAxisRenderer, |
| 88 | + ticks: ticks |
| 89 | + }} |
| 90 | + |
| 91 | + |
| 92 | + /*axes: { |
| 93 | + xaxis: { |
| 94 | + renderer: $.jqplot.DateAxisRenderer, |
| 95 | + min: parsedData.minDate, |
| 96 | + tickInterval: '90 days', |
| 97 | + tickOptions: |
| 98 | + { |
| 99 | + formatString:'%b %y', |
| 100 | + fontSize: '7pt', |
| 101 | + textColor: "#000" |
| 102 | + }, |
| 103 | + max: parsedData.maxDate, |
| 104 | + showMinorTicks: true, |
| 105 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 106 | + labelOptions: { |
| 107 | + fontSize: '14pt', |
| 108 | + textColor: '#F44', |
| 109 | + } |
| 110 | + }, |
| 111 | + yaxis: { |
| 112 | + min: parsedData.minY, |
| 113 | + max: parsedData.maxY, |
| 114 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 115 | + // tickOptions: { |
| 116 | + // formatString: ' %d\%', |
| 117 | + // textColor: "#000" , |
| 118 | + //}, |
| 119 | + tickInterval:5 |
| 120 | + } |
| 121 | + }*/ |
| 122 | + }); |
| 123 | + |
125 | 124 | } |
126 | | -}; //reachPercentage |
\ No newline at end of file |
| 125 | +}; //reachPercentage |
Index: trunk/extensions/MetricsReporting/frontend/proof_of_concept/charts/reachPercentage.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -var reachPercentage = { |
| 2 | +var reachPercentage = { |
3 | 3 | divTarget: "chartreachPercentage", |
4 | 4 | title: 'comScore Reach Percentage by Region', |
5 | 5 | plotVar: {}, |
— | — | @@ -6,80 +6,80 @@ |
7 | 7 | reachPercentage: "../wiki/api.php?action=analytics&metric=comscorereachpercentage&startmonth=2008-04&endmonth=2011-08&selectregions=AS,EU,LA,MA,NA,US,W&reportlanguage=en&format=json" |
8 | 8 | }, |
9 | 9 | plotData: function(apiDataArray){ |
10 | | - |
11 | | - var data = apiDataArray.reachPercentage; |
12 | | - var scaleYfunction = function(Y){return Y;} |
13 | | - var parsedData = p_getData(data, "region_code", "reach", true, scaleYfunction, true); |
14 | | - |
15 | | - |
16 | | - parsedData.minY -= parsedData.minY % 5 ; |
17 | | - if (parsedData.maxY % 5 != 0) |
18 | | - { parsedData.maxY += 5 - (parsedData.maxY % 5) ; } |
19 | | - |
20 | | - var labels = parsedData.labels; |
21 | 10 | |
22 | | - |
23 | | - var seriesArray = new Array(labels.length); |
24 | | - for(var i = 0; i < seriesArray.length; i++){ |
25 | | - if(seriesOptions[labels[i]]){ |
26 | | - seriesArray[i] = seriesOptions[labels[i]]; |
27 | | - } |
28 | | - else{ |
29 | | - seriesArray[i] = {}; |
30 | | - } |
31 | | - } |
32 | | - $('#' + this.divTarget ).empty(); |
33 | | - this.plotVar = $.jqplot(this.divTarget, parsedData.data ,{ |
34 | | - title: this.title, |
35 | | - legend: {show: true, placement: "outsideGrid"} , |
36 | | - series: seriesArray, |
37 | | - cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
38 | | - grid: { |
39 | | - background: "#FFF", |
40 | | - borderColor: "#CCC", |
41 | | - borderWidth: 1, |
42 | | - shadow: false, |
43 | | - gridLineWidth: 1.0, |
44 | | - }, |
45 | | - seriesDefaults: { |
46 | | - fill: false, |
47 | | - shadow: false, |
48 | | - showMarker : false, |
49 | | - // markerOptions: { |
50 | | - // size: 5, |
51 | | - // } |
52 | | - }, |
53 | | - axes: { |
54 | | - xaxis: { |
55 | | - renderer: $.jqplot.DateAxisRenderer, |
56 | | - min: parsedData.minDate, |
57 | | - tickInterval: '90 days', |
58 | | - tickOptions: |
59 | | - { |
60 | | - formatString:'%b %y', |
61 | | - fontSize: '7pt', |
62 | | - textColor: "#000" |
63 | | - }, |
64 | | - max: parsedData.maxDate, |
65 | | - showMinorTicks: true, |
66 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
67 | | - labelOptions: { |
68 | | - fontSize: '14pt', |
69 | | - textColor: '#F44', |
70 | | - } |
71 | | - }, |
72 | | - yaxis: { |
73 | | - min: parsedData.minY, |
74 | | - max: parsedData.maxY, |
75 | | - labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
76 | | - tickOptions: { |
77 | | - formatString: ' %d\%', |
78 | | - textColor: "#000" , |
79 | | - }, |
80 | | - tickInterval:5 |
81 | | - } |
82 | | - } |
83 | | - }); |
84 | | - |
| 11 | + var data = apiDataArray.reachPercentage; |
| 12 | + var scaleYfunction = function(Y){return Y;} |
| 13 | + var parsedData = p_getData(data, "region_code", "reach", true, scaleYfunction, true); |
| 14 | + |
| 15 | + |
| 16 | + parsedData.minY -= parsedData.minY % 5 ; |
| 17 | + if (parsedData.maxY % 5 != 0) |
| 18 | + { parsedData.maxY += 5 - (parsedData.maxY % 5) ; } |
| 19 | + |
| 20 | + var labels = parsedData.labels; |
| 21 | + |
| 22 | + |
| 23 | + var seriesArray = new Array(labels.length); |
| 24 | + for(var i = 0; i < seriesArray.length; i++){ |
| 25 | + if(seriesOptions[labels[i]]){ |
| 26 | + seriesArray[i] = seriesOptions[labels[i]]; |
| 27 | + } |
| 28 | + else{ |
| 29 | + seriesArray[i] = {}; |
| 30 | + } |
| 31 | + } |
| 32 | + $('#' + this.divTarget ).empty(); |
| 33 | + this.plotVar = $.jqplot(this.divTarget, parsedData.data ,{ |
| 34 | + title: this.title, |
| 35 | + legend: {show: true, placement: "outsideGrid"} , |
| 36 | + series: seriesArray, |
| 37 | + cursor: {show: true, zoom:false, showTooltip:false, dblClickReset:true, zoom:true}, |
| 38 | + grid: { |
| 39 | + background: "#FFF", |
| 40 | + borderColor: "#CCC", |
| 41 | + borderWidth: 1, |
| 42 | + shadow: false, |
| 43 | + gridLineWidth: 1.0, |
| 44 | + }, |
| 45 | + seriesDefaults: { |
| 46 | + fill: false, |
| 47 | + shadow: false, |
| 48 | + showMarker : false, |
| 49 | + // markerOptions: { |
| 50 | + // size: 5, |
| 51 | + // } |
| 52 | + }, |
| 53 | + axes: { |
| 54 | + xaxis: { |
| 55 | + renderer: $.jqplot.DateAxisRenderer, |
| 56 | + min: parsedData.minDate, |
| 57 | + tickInterval: '90 days', |
| 58 | + tickOptions: |
| 59 | + { |
| 60 | + formatString:'%b %y', |
| 61 | + fontSize: '7pt', |
| 62 | + textColor: "#000" |
| 63 | + }, |
| 64 | + max: parsedData.maxDate, |
| 65 | + showMinorTicks: true, |
| 66 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 67 | + labelOptions: { |
| 68 | + fontSize: '14pt', |
| 69 | + textColor: '#F44', |
| 70 | + } |
| 71 | + }, |
| 72 | + yaxis: { |
| 73 | + min: parsedData.minY, |
| 74 | + max: parsedData.maxY, |
| 75 | + labelRenderer: $.jqplot.CanvasAxisLabelRenderer, |
| 76 | + tickOptions: { |
| 77 | + formatString: ' %d\%', |
| 78 | + textColor: "#000" , |
| 79 | + }, |
| 80 | + tickInterval:5 |
| 81 | + } |
| 82 | + } |
| 83 | + }); |
| 84 | + |
85 | 85 | } |
86 | | -}; //reachPercentage |
\ No newline at end of file |
| 86 | +}; //reachPercentage |
Index: trunk/extensions/MetricsReporting/frontend/proof_of_concept/charts/globalIncludes-old.js |
— | — | @@ -6,22 +6,22 @@ |
7 | 7 | "MA": { "label": "Middle-East/Africa", "color": "#e61d0a"},// "#99445e"}, |
8 | 8 | "NA": { "label": "North America", "color": "#0a0aa4"},//"#5e9944"}, //green! |
9 | 9 | "W" : { "label": "World", "color": "#5cc3f0",//"#448899"//theme |
10 | | - "lineWidth": 1, //5, |
11 | | - "fillColor":"#F0F" |
12 | | - }, |
13 | | - "us" : { "label" : "United States", "color" : "blue" |
14 | | - }, |
15 | | - "ca" : { "label" : "Canada", "color": "red" }, |
16 | | - "SUM(editors_ge_5)": { "label":"At least 5 edits", "color":"#448899" }, |
17 | | - "SUM(editors_ge_100)": { "label":"At least 100 edits", "color": "#e61d0a" }, |
18 | | - "OfflineEst" : { "label": "Offline Estimate", "color": "black"}, |
19 | | - "SUM(views_mobile_raw)": { "label":"Mobile Views", "color":"#448899" }, |
20 | | - "SUM(views_non_mobile_raw)": { "label":"Non Mobile Views", "color":"#e61d0a" } |
21 | | -}; |
| 10 | + "lineWidth": 1, //5, |
| 11 | + "fillColor":"#F0F" |
| 12 | + }, |
| 13 | + "us" : { "label" : "United States", "color" : "blue" |
| 14 | + }, |
| 15 | + "ca" : { "label" : "Canada", "color": "red" }, |
| 16 | + "SUM(editors_ge_5)": { "label":"At least 5 edits", "color":"#448899" }, |
| 17 | + "SUM(editors_ge_100)": { "label":"At least 100 edits", "color": "#e61d0a" }, |
| 18 | + "OfflineEst" : { "label": "Offline Estimate", "color": "black"}, |
| 19 | + "SUM(views_mobile_raw)": { "label":"Mobile Views", "color":"#448899" }, |
| 20 | + "SUM(views_non_mobile_raw)": { "label":"Non Mobile Views", "color":"#e61d0a" } |
| 21 | +}; |
22 | 22 | |
23 | 23 | |
24 | 24 | /* |
25 | | -* makes API calls based |
| 25 | +* makes API calls based |
26 | 26 | */ |
27 | 27 | function makeAPICall(plotObj){ |
28 | 28 | var apiDataReturns = {}; |
— | — | @@ -50,37 +50,37 @@ |
51 | 51 | * Function to lazy load chart objects |
52 | 52 | */ |
53 | 53 | function lazyLoad(llobj){ |
54 | | - if(jQuery.isEmptyObject(llobj.plotVar)){ |
55 | | - makeAPICall(llobj); |
56 | | - } else { |
57 | | - llobj.plotVar.replot(); |
58 | | - } |
| 54 | + if(jQuery.isEmptyObject(llobj.plotVar)){ |
| 55 | + makeAPICall(llobj); |
| 56 | + } else { |
| 57 | + llobj.plotVar.replot(); |
| 58 | + } |
59 | 59 | } |
60 | | - |
61 | 60 | |
| 61 | + |
62 | 62 | /* |
63 | 63 | * Function to get Y axis max |
64 | 64 | */ |
65 | 65 | function maxYaxis(yaxis_max) { |
66 | | - mult = 1 ; |
67 | | - while (yaxis_max > 1) { |
68 | | - yaxis_max /= 10 ; |
69 | | - mult *= 10 ; |
70 | | - } |
71 | | - if (yaxis_max < 0.1) { |
72 | | - yaxis_max = 0.1 ; |
73 | | - } else |
74 | | - if (yaxis_max < 0.2) { |
75 | | - yaxis_max = 0.2 ; |
76 | | - } else |
77 | | - if (yaxis_max < 0.5) { |
78 | | - yaxis_max = 0.5 ; |
79 | | - } |
80 | | - else { |
81 | | - yaxis_max = 1 ; |
82 | | - } |
83 | | - yaxis_max *= mult ; |
84 | | - return (yaxis_max) ; |
| 66 | + mult = 1 ; |
| 67 | + while (yaxis_max > 1) { |
| 68 | + yaxis_max /= 10 ; |
| 69 | + mult *= 10 ; |
| 70 | + } |
| 71 | + if (yaxis_max < 0.1) { |
| 72 | + yaxis_max = 0.1 ; |
| 73 | + } else |
| 74 | + if (yaxis_max < 0.2) { |
| 75 | + yaxis_max = 0.2 ; |
| 76 | + } else |
| 77 | + if (yaxis_max < 0.5) { |
| 78 | + yaxis_max = 0.5 ; |
| 79 | + } |
| 80 | + else { |
| 81 | + yaxis_max = 1 ; |
| 82 | + } |
| 83 | + yaxis_max *= mult ; |
| 84 | + return (yaxis_max) ; |
85 | 85 | } |
86 | 86 | |
87 | 87 | /* |
— | — | @@ -97,7 +97,7 @@ |
98 | 98 | } |
99 | 99 | return retval; |
100 | 100 | } |
101 | | - |
| 101 | + |
102 | 102 | /* |
103 | 103 | * get labels from API return object |
104 | 104 | */ |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | } |
114 | 114 | return retval; |
115 | 115 | } |
116 | | - |
| 116 | + |
117 | 117 | /* |
118 | 118 | * go from MW date format to date format used by jqplot |
119 | 119 | */ |
— | — | @@ -120,130 +120,130 @@ |
121 | 121 | date = date+""; |
122 | 122 | return date.substring(0,4)+"-"+date.substring(4,6)+"-"+date.substring(6,8); |
123 | 123 | } |
124 | | - |
125 | 124 | |
126 | | -// provisional: get Data function |
| 125 | + |
| 126 | +// provisional: get Data function |
127 | 127 | function p_getData(apiReturnObj, labelName, dataName, isInt, scaleYfunction){ |
128 | | - var apiData; |
129 | | - for(var robj in apiReturnObj){ |
130 | | - apiData = apiReturnObj[robj]; |
131 | | - } |
132 | | - var labels = new Array(); |
133 | | - var dataArray = new Array(); |
134 | | - var minDate = "9999"; |
135 | | - var maxDate = ""; |
136 | | - |
| 128 | + var apiData; |
| 129 | + for(var robj in apiReturnObj){ |
| 130 | + apiData = apiReturnObj[robj]; |
| 131 | + } |
| 132 | + var labels = new Array(); |
| 133 | + var dataArray = new Array(); |
| 134 | + var minDate = "9999"; |
| 135 | + var maxDate = ""; |
| 136 | + |
137 | 137 | var yaxis_min = 9999999999 ; |
138 | 138 | var yaxis_max = -9999999999 ; |
139 | | - |
| 139 | + |
140 | 140 | var findYaxisMinMax = function(value){ |
141 | | - if (value < yaxis_min) |
142 | | - { yaxis_min = value ; } |
143 | | - if (value > yaxis_max) |
144 | | - { yaxis_max = value ; } |
| 141 | + if (value < yaxis_min) |
| 142 | + { yaxis_min = value ; } |
| 143 | + if (value > yaxis_max) |
| 144 | + { yaxis_max = value ; } |
145 | 145 | return (value) ; |
146 | 146 | }; |
147 | | - |
148 | | - for(var i in apiData){ |
149 | | - var tempDataArray = new Array(); |
150 | | - labels.push(apiData[i][labelName]); |
151 | | - for(var j in apiData[i].data){ |
152 | | - |
153 | | - if(apiData[i].data[j].date < minDate){ |
154 | | - minDate = apiData[i].data[j].date; |
155 | | - } |
156 | | - if(apiData[i].data[j].date > maxDate){ |
157 | | - maxDate = apiData[i].data[j].date; |
158 | | - } |
159 | | - if(isInt){ |
160 | | - tempDataArray.push( [apiData[i].data[j].date, |
161 | | - findYaxisMinMax (scaleYfunction(parseInt(apiData[i].data[j][dataName]))) ]); |
162 | | - }else{ |
163 | | - tempDataArray.push( [apiData[i].data[j].date, |
164 | | - findYaxisMinMax (scaleYfunction(parseFloat(apiData[i].data[j][dataName]))) ]); |
165 | | - } |
166 | | - } |
167 | | - dataArray.push(tempDataArray); |
168 | | - } |
169 | | - |
170 | | - maxDate = maxDate.substr(0,8)+'01' ; // last month is outside range |
171 | | - var returnObj = { "labels": labels, "data": dataArray, |
172 | | - "minDate": minDate, "maxDate": maxDate, |
173 | | - "minY": yaxis_min, "maxY": yaxis_max }; |
174 | | - return returnObj; |
175 | | - |
| 147 | + |
| 148 | + for(var i in apiData){ |
| 149 | + var tempDataArray = new Array(); |
| 150 | + labels.push(apiData[i][labelName]); |
| 151 | + for(var j in apiData[i].data){ |
| 152 | + |
| 153 | + if(apiData[i].data[j].date < minDate){ |
| 154 | + minDate = apiData[i].data[j].date; |
| 155 | + } |
| 156 | + if(apiData[i].data[j].date > maxDate){ |
| 157 | + maxDate = apiData[i].data[j].date; |
| 158 | + } |
| 159 | + if(isInt){ |
| 160 | + tempDataArray.push( [apiData[i].data[j].date, |
| 161 | + findYaxisMinMax (scaleYfunction(parseInt(apiData[i].data[j][dataName]))) ]); |
| 162 | + }else{ |
| 163 | + tempDataArray.push( [apiData[i].data[j].date, |
| 164 | + findYaxisMinMax (scaleYfunction(parseFloat(apiData[i].data[j][dataName]))) ]); |
| 165 | + } |
| 166 | + } |
| 167 | + dataArray.push(tempDataArray); |
| 168 | + } |
| 169 | + |
| 170 | + maxDate = maxDate.substr(0,8)+'01' ; // last month is outside range |
| 171 | + var returnObj = { "labels": labels, "data": dataArray, |
| 172 | + "minDate": minDate, "maxDate": maxDate, |
| 173 | + "minY": yaxis_min, "maxY": yaxis_max }; |
| 174 | + return returnObj; |
| 175 | + |
176 | 176 | } |
177 | | - |
| 177 | + |
178 | 178 | /* provisional: get data only function (labels set in the function that draws the chart) */ |
179 | 179 | function p_getDataOnly(apiReturnObj, dataName, isInt, scaleYfunction){ |
180 | | - var apiData; |
181 | | - for(var robj in apiReturnObj){ |
182 | | - apiData = apiReturnObj[robj]; |
183 | | - } |
184 | | - var dataArray = new Array(); |
185 | | - var minDate = "9999"; |
186 | | - var maxDate = ""; |
187 | | - |
188 | | - for(var i in apiData){ |
189 | | - var tempDataArray = new Array(); |
190 | | - for(var j in apiData[i].data){ |
191 | | - |
192 | | - if(apiData[i].data[j].date < minDate){ |
193 | | - minDate = apiData[i].data[j].date; |
194 | | - } |
195 | | - if(apiData[i].data[j].date > maxDate){ |
196 | | - maxDate = apiData[i].data[j].date; |
197 | | - } |
198 | | - if(isInt){ |
199 | | - tempDataArray.push( [apiData[i].data[j].date, scaleYfunction(parseInt(apiData[i].data[j][dataName])) ]); |
200 | | - }else{ |
201 | | - tempDataArray.push( [apiData[i].data[j].date, scaleYfunction(parseFloat(apiData[i].data[j][dataName])) ]); |
202 | | - } |
203 | | - } |
204 | | - dataArray.push(tempDataArray); |
205 | | - } |
206 | | - var returnObj = {"data": dataArray, "minDate": minDate, "maxDate": maxDate}; |
207 | | - return returnObj; |
208 | | - |
| 180 | + var apiData; |
| 181 | + for(var robj in apiReturnObj){ |
| 182 | + apiData = apiReturnObj[robj]; |
| 183 | + } |
| 184 | + var dataArray = new Array(); |
| 185 | + var minDate = "9999"; |
| 186 | + var maxDate = ""; |
| 187 | + |
| 188 | + for(var i in apiData){ |
| 189 | + var tempDataArray = new Array(); |
| 190 | + for(var j in apiData[i].data){ |
| 191 | + |
| 192 | + if(apiData[i].data[j].date < minDate){ |
| 193 | + minDate = apiData[i].data[j].date; |
| 194 | + } |
| 195 | + if(apiData[i].data[j].date > maxDate){ |
| 196 | + maxDate = apiData[i].data[j].date; |
| 197 | + } |
| 198 | + if(isInt){ |
| 199 | + tempDataArray.push( [apiData[i].data[j].date, scaleYfunction(parseInt(apiData[i].data[j][dataName])) ]); |
| 200 | + }else{ |
| 201 | + tempDataArray.push( [apiData[i].data[j].date, scaleYfunction(parseFloat(apiData[i].data[j][dataName])) ]); |
| 202 | + } |
| 203 | + } |
| 204 | + dataArray.push(tempDataArray); |
| 205 | + } |
| 206 | + var returnObj = {"data": dataArray, "minDate": minDate, "maxDate": maxDate}; |
| 207 | + return returnObj; |
| 208 | + |
209 | 209 | } |
210 | 210 | |
211 | 211 | // provisional: get data simple, for unformatted API data |
212 | 212 | function p_getDataSimple(apiData, dataName, isInt, scaleYfunction){ |
213 | | - var dataArray = new Array(); |
214 | | - var minDate = "9999"; |
215 | | - var maxDate = ""; |
216 | | - |
217 | | - for(var i in apiData){ |
218 | | - var tempDataArray = new Array(); |
219 | | - for(var j in apiData[i]){ |
220 | | - |
221 | | - if(apiData[i][j].date < minDate){ |
222 | | - minDate = apiData[i][j].date; |
223 | | - } |
224 | | - if(apiData[i][j].date > maxDate){ |
225 | | - maxDate = apiData[i][j].date; |
226 | | - } |
227 | | - if(isInt){ |
228 | | - tempDataArray.push( [apiData[i][j].date, scaleYfunction(parseInt(apiData[i][j][dataName])) ]); |
229 | | - }else{ |
230 | | - tempDataArray.push( [apiData[i][j].date, scaleYfunction(parseFloat(apiData[i][j][dataName])) ]); |
231 | | - } |
232 | | - } |
233 | | - dataArray.push(tempDataArray); |
234 | | - } |
235 | | - var returnObj = {"data": dataArray, "minDate": minDate, "maxDate": maxDate}; |
236 | | - return returnObj; |
237 | | - |
| 213 | + var dataArray = new Array(); |
| 214 | + var minDate = "9999"; |
| 215 | + var maxDate = ""; |
| 216 | + |
| 217 | + for(var i in apiData){ |
| 218 | + var tempDataArray = new Array(); |
| 219 | + for(var j in apiData[i]){ |
| 220 | + |
| 221 | + if(apiData[i][j].date < minDate){ |
| 222 | + minDate = apiData[i][j].date; |
| 223 | + } |
| 224 | + if(apiData[i][j].date > maxDate){ |
| 225 | + maxDate = apiData[i][j].date; |
| 226 | + } |
| 227 | + if(isInt){ |
| 228 | + tempDataArray.push( [apiData[i][j].date, scaleYfunction(parseInt(apiData[i][j][dataName])) ]); |
| 229 | + }else{ |
| 230 | + tempDataArray.push( [apiData[i][j].date, scaleYfunction(parseFloat(apiData[i][j][dataName])) ]); |
| 231 | + } |
| 232 | + } |
| 233 | + dataArray.push(tempDataArray); |
| 234 | + } |
| 235 | + var returnObj = {"data": dataArray, "minDate": minDate, "maxDate": maxDate}; |
| 236 | + return returnObj; |
| 237 | + |
238 | 238 | } |
239 | | - |
240 | | - |
241 | | - |
242 | | - |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + |
243 | 243 | function buildErrorBand(originalSeries, errorSeriesWrapped){ |
244 | 244 | var errorSeries = errorSeriesWrapped[0]; |
245 | 245 | var bandedHi = new Array(originalSeries.length); |
246 | 246 | var bandedLo = new Array(originalSeries.length); |
247 | | - |
| 247 | + |
248 | 248 | var j = 0; |
249 | 249 | var endFound = false; |
250 | 250 | for(var i = 0; i < originalSeries.length; i++){ |
— | — | @@ -261,9 +261,9 @@ |
262 | 262 | bandedLo[i] = [originalSeries[i][0], originalSeries[i][1]]; |
263 | 263 | originalSeries[i][1] = originalSeries[i][1] + errorSeries[j][1]/2; |
264 | 264 | j++; |
265 | | - } |
| 265 | + } |
266 | 266 | } |
267 | | - return [bandedHi, bandedLo]; |
| 267 | + return [bandedHi, bandedLo]; |
268 | 268 | } |
269 | 269 | |
270 | 270 | |