{# This template adds attributes unique
   to lineChart #}

{% extends "content.html" %}
{% block body %}
    {% block data %}
        data_{{ chart.name }}={{ chart.series_js|striptags }};
    {% endblock data %}


    {% block init %}
        {{super()}}
    {% endblock init %}
    {% block rendering_opts %}
        {{super()}}
    {% endblock rendering_opts %}
    {% block axes %}
        {{super()}}
    {% endblock axes %}
    {% block tooltip %}
        {{super()}}
    {% endblock tooltip %}

    chart.showLegend({{chart.show_legend|lower}});

    {# add custom chart attributes #}
    {% for attr, value in chart.chart_attr.items() %}
        {% if value is string and value.startswith(".") %}:
            chart.{{ attr }}{{ value }};
        {% else %}
            chart.{{ attr }}({{ value }});
        {% endif %}
    {% endfor %}

    {% if chart.x_axis_format == 'AM_PM' %}
        function get_am_pm(d){
            if (d > 12) {
                d = d - 12; return (String(d) + 'PM');
            }
            else {
                return (String(d) + 'AM');
            }
        };
    {% else %}
        chart.x(function(d,i) { return i });
    {% endif %}

    {% if chart.resize %}
        nv.utils.windowResize(chart.update);
    {% endif %}
    {% block inject %}
    {{super()}}
    {% endblock inject %}

    {% block close %}
    });
    {% endblock close %}

{% endblock body %}
