Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit cd48cb1

Browse files
committed
ENH: refs #0339. Add download maps widget (gmaps) to item statistics page
1 parent 915c994 commit cd48cb1

File tree

2 files changed

+76
-39
lines changed

2 files changed

+76
-39
lines changed
Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
1-
$(document).ready(function() {
2-
3-
var errors = json.stats.downloads;
4-
jQuery.each(errors, function(i, val) {
5-
errors[i][1] = parseInt(errors[i][1]);
1+
$(document).ready(function() {
2+
var tabs = $("#tabsGeneric").tabs({
3+
select: function(event, ui) { }
64
});
7-
8-
var plotErrors = $.jqplot('chartDownloads', [errors], {
9-
title:'Number of downloads',
10-
gridPadding:{right:35},
11-
axes:{
12-
xaxis:{
13-
renderer:$.jqplot.DateAxisRenderer,
14-
tickOptions:{formatString:'%b %#d'},
15-
tickInterval:'1 day'
16-
}
17-
},
18-
series:[{lineWidth:4, markerOptions:{style:'square'}}]
5+
$('#tabsGeneric').show();
6+
$('img.tabsLoading').hide();
7+
$("#tabsGeneric").bind('tabsshow', function(event, ui) {
8+
if (plotErrors._drawCount == 0) {
9+
plotErrors.replot();
10+
}
1911
});
20-
21-
12+
var errors = json.stats.downloads;
13+
jQuery.each(errors, function(i, val) {
14+
errors[i][1] = parseInt(errors[i][1]);
2215
});
16+
17+
var plotErrors = $.jqplot('chartDownloads', [errors], {
18+
title:'Number of downloads',
19+
gridPadding:{right:35},
20+
axes:{
21+
xaxis:{
22+
renderer:$.jqplot.DateAxisRenderer,
23+
tickOptions:{formatString:'%b %#d'},
24+
tickInterval:'1 day'
25+
}
26+
},
27+
series:[{lineWidth:4, markerOptions:{style:'square'}}]
28+
});
29+
30+
var latlng = new google.maps.LatLng(0, 0);
31+
var myOptions = {
32+
zoom: 2,
33+
center: latlng,
34+
mapTypeId: google.maps.MapTypeId.ROADMAP
35+
};
36+
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
37+
placeDownloadPins(map);
38+
});

modules/statistics/views/item/index.phtml

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,56 @@ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
1010
PURPOSE. See the above copyright notices for more information.
1111
=========================================================================*/
1212

13-
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/item/index.index.js');
14-
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/jquery.jqplot.js');
15-
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/jqplot/jqplot.dateAxisRenderer.min.js');
16-
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/jqplot/jqplot.pieRenderer.min.js');
13+
$this->headScript()->appendFile('http://maps.googleapis.com/maps/api/js?sensor=false');
14+
$this->headScript()->appendFile($this->moduleWebroot.'/public/js/item/index.index.js');
15+
$this->headScript()->appendFile($this->moduleWebroot.'/public/js/jquery.jqplot.js');
16+
$this->headScript()->appendFile($this->moduleWebroot.'/public/js/jqplot/jqplot.dateAxisRenderer.min.js');
17+
$this->headScript()->appendFile($this->moduleWebroot.'/public/js/jqplot/jqplot.pieRenderer.min.js');
1718
?>
1819
<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="<?php echo $this->moduleWebroot?>/public/js/excanvas.min.js"></script><![endif]-->
1920
<link rel="stylesheet" type="text/css" href="<?php echo $this->moduleWebroot?>/public/css/jquery.jqplot.css" />
2021

2122
<link type="text/css" rel="stylesheet" href="<?php echo $this->moduleWebroot?>/public/css/item/index.index.css" />
2223
<link type="text/css" rel="stylesheet" href="<?php echo $this->coreWebroot?>/public/css/common/common.genericPage.css" />
24+
<link type="text/css" rel="stylesheet" href="<?php echo $this->moduleWebroot?>/public/css/index/index.index.css" />
2325
<div class="viewMain">
2426
<div class ="genericWrapperTopRight">
25-
<?php
26-
echo '<div style="float:right;margin-right:2px;" class="genericBigButton ">';
27-
echo "<a href='{$this->webroot}/item/".$this->itemDao->getKey()."'><img style='float:left;margin-right:2px;' alt='' src='{$this->coreWebroot}/public/images/icons/back.png'/>";
28-
echo $this->t('Back');
29-
echo "</a>";
30-
echo '</div>';
31-
32-
?>
33-
</div>
27+
<?php
28+
echo '<div style="float:right;margin-right:2px;" class="genericBigButton ">';
29+
echo "<a href='{$this->webroot}/item/".$this->itemDao->getKey()."'><img style='float:left;margin-right:2px;' alt='' src='{$this->coreWebroot}/public/images/icons/back.png'/>";
30+
echo $this->t('Back');
31+
echo "</a>";
32+
echo '</div>';
33+
?>
34+
</div>
3435
<h3>Statistics - <?php echo $this->itemDao->getName()?></h3>
3536

36-
37-
<div id="chartDownloads" style="height:450px;width:800px; "></div>
38-
37+
<img class="tabsLoading" alt="" src="<?php echo $this->coreWebroot?>/public/images/icons/loading.gif" />
38+
<div class="tabs" id='tabsGeneric'>
39+
<ul>
40+
<li><a href="#tabs-map">Download Map</a></li>
41+
<li><a href="#tabs-chart">Daily Totals</a></li>
42+
</ul>
43+
<div id="tabs-map">
44+
<div id="map_canvas" style="width:800px; height:450px;"></div>
45+
</div>
46+
<div id="tabs-chart">
47+
<div id="chartDownloads" style="height:450px; width:800px;"></div>
48+
</div>
3949
</div>
4050

41-
<div class="viewSideBar">
42-
43-
44-
</div>
51+
<!-- START! -->
52+
<script type="text/javascript">
53+
function placeDownloadPins(theMap)
54+
{
55+
var myLatlng = new google.maps.LatLng(35, -100.044922);
56+
57+
var marker = new google.maps.Marker({
58+
position: myLatlng,
59+
map: theMap,
60+
title:"Hello World!!"
61+
});
62+
}
63+
</script>
64+
<!-- END -->
65+
</div>

0 commit comments

Comments
 (0)