--- a/ckanext/ga_report/templates/ga_report/ga_util.html +++ b/ckanext/ga_report/templates/ga_report/ga_util.html @@ -30,6 +30,42 @@ </table> +<div py:def="rickshaw_graph(items_json,id,mode='line',colorscheme='munin')"> + <div id="chart_container_$id" class="rickshaw_chart_container"> + <div id="y_axis_$id" class="rickshaw_y_axis"></div> + <div id="chart_$id" class="rickshaw_chart"></div> + <div id="legend_$id" class="rickshaw_legend"></div> + <script type="text/javascript"> + $(function() { + var all_series = ${items_json}; + var palette = new Rickshaw.Color.Palette( { scheme: '$colorscheme' } ); + $.each(all_series, function(i, object) { + object['color'] = palette.color(); + }); + var graph = new Rickshaw.Graph( { + element: document.querySelector("#chart_$id"), + renderer: '$mode', + series: all_series , + height: 328 + }); + var x_axis = new Rickshaw.Graph.Axis.Time( { graph: graph } ); + var y_axis = new Rickshaw.Graph.Axis.Y( { + graph: graph, + orientation: 'left', + tickFormat: Rickshaw.Fixtures.Number.formatKMBT, + element: document.getElementById('y_axis_$id'), + } ); + var legend = new Rickshaw.Graph.Legend( { + element: document.querySelector('#legend_$id'), + graph: graph + } ); + graph.render(); + }); + </script> + </div> +</div> + + <table py:def="stat_table(items, title='Views')" class="table table-condensed table-bordered table-striped"> <tr> <th>Name</th> @@ -38,23 +74,6 @@ <py:for each="name, value in items"> <tr> <td>${name}</td> - <td>${value}</td> - </tr> - </py:for> - </table> - - -<table py:def="downloads_table(items)" class="table table-condensed table-bordered table-striped"> - <tr> - <th>Dataset and resource</th> - <th>Downloads</th> - </tr> - <py:for each="resource, value in items"> - <tr> - <td> - <strong>${resource.resource_group.package.title}</strong><br/> - ${h.link_to((resource.name or resource.description).strip() or "No name", h.url_for(controller='package', action='resource_read', id=resource.resource_group.package.name, resource_id=resource.id))}<br/> - </td> <td>${value}</td> </tr> </py:for> @@ -72,9 +91,6 @@ <li py:attrs="{'class': 'active' if active_name=='Datasets' else None}"> <a py:attrs="{'class': 'active' if active_name=='Datasets' else None}" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='read')}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Datasets</a> </li> - <li py:attrs="{'class': 'active' if active_name=='Downloads' else None}"> - <a py:attrs="{'class': 'active' if active_name=='Downloads' else None}" href="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='downloads')}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Downloads</a> - </li> </ul> </div> </div>