class AnalyticsDownloadPlugin(AnalyticsBaseTrackingPlugin): """ A tracking plugin to track file downloads. """ __call__ = ViewPageTemplateFile('download.pt') file_extensions = json_serialize(FILE_EXTENSION_CHOICES)
def _getOptions(self): """ Returns a javascript object containing the options for the visualization. """ options = self.options.copy() # Set the width of the visualization to the container width if it # if not already set. if not 'width' in self.options.keys(): options['width'] = js_literal('container_width') if options: return json_serialize(options) return 'null'
def render(self): """ Returns the markup and javascript to create the visualization. """ template_file = os.path.join(os.path.dirname(__file__), 'visualization.tpl') template = Template(open(template_file).read()) template_vars = { 'package_name': self.report.viz_type.lower(), 'columns': self._getColumns(), 'data': json_serialize(self.rows), 'chart_type': self.report.viz_type, 'id': self.id(), 'options': self._getOptions() } return template.substitute(template_vars)