# Copyright 2014 Canonical Ltd. # Author: Colin Watson # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Show charts using YUI.""" from textwrap import dedent def make_chart_header(chart_name="chart", width=960, height=550): """Return HTML to declare the chart style and load YUI. This should be included in the element. """ params = {"chart_name": chart_name, "width": width, "height": height} return dedent("""\ """) % params def make_chart(source, keys, chart_name="chart"): """Return HTML to render a chart.""" params = { "source": source, "chart_name": chart_name, "series_keys": ", ".join('"%s"' % key for key in keys), "series_styles": ", ".join( '"%s": { line: { weight: "2mm" } }' % key for key in keys), "series_schema_fields": ", ".join( '{key: "%s", parser: parseNum}' % key for key in keys), } return dedent("""\
""") % params