{% extends "PackagistWebBundle::layout.html.twig" %}

{% set showSearchDesc = 'hide' %}

{% block content %}
    {% set packageCount = 0 %}

    <h2 class="title">Statistics</h2>

    <section class="row">
        <div class="col-lg-12">
            <h3>Packages/versions over time</h3>

            <p class="row">
                <svg class="chart col-xs-12" width="500" height="200" data-labels="{{ chart.months|join(',') }}" data-scale="1000" data-values="Versions:{{ chart.versions|join(',') }}|Packages:{{ chart.packages|join(',') }}">
                    Sorry, the graph can't be displayed because your browser doesn't support &lt;svg&gt; html element.
                </svg>
            </p>
            <p>The last data point is for the current month and shows partial data.</p>

            {% if downloadsChart %}
                <h3>Packages installed in the last 30 days</h3>
                <p class="row">
                    <svg class="chart col-xs-12" width="500" height="200" data-labels="{{ downloadsChart.labels|join(',') }}" data-scale="1000" data-values="Installs:{{ downloadsChart.values|join(',') }}">
                        Sorry, the graph can't be displayed because your browser doesn't support &lt;svg&gt; html element.
                    </svg>
                </p>
            {% endif %}
            {% if downloadsChartMonthly %}
                <h3>Packages installed per month</h3>
                <p class="row">
                    <svg class="chart col-xs-12" width="500" height="200" data-labels="{{ downloadsChartMonthly.labels|join(',') }}" data-scale="1000000" data-values="Installs:{{ downloadsChartMonthly.values|join(',') }}">
                        Sorry, the graph can't be displayed because your browser doesn't support &lt;svg&gt; html element.
                    </svg>
                </p>
                <p>The last data point is for the current month and shows partial data.</p>
            {% endif %}

            <h3>Totals</h3>
            <dl class="dl-horizontal">
                <dt class="font-normal">Packages registered</dt>
                <dd class="font-normal">{{ packages|number_format(0, '.', "&#8201;")|raw }}</dd>

                <dt class="font-normal">Versions available</dt>
                <dd class="font-normal">{{ versions|number_format(0, '.', "&#8201;")|raw }}</dd>

                <dt class="font-normal">Packages installed<br><small>(since {{ downloadsStartDate }})</small></dt>
                <dd class="font-normal">{% if downloads == 'N/A' %}{{ downloads }}{% else %}{{ downloads|number_format(0, '.', "&#8201;")|raw }}{% endif %}</dd>
            </dl>
        </div>
    </section>
{% endblock %}

{% block stylesheets %}
    <link href="https://cdn.rawgit.com/novus/nvd3/v1.7.1/build/nv.d3.css" rel="stylesheet">
{% endblock %}

{% block scripts %}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
    <script src="https://cdn.rawgit.com/novus/nvd3/v1.7.1/build/nv.d3.min.js"></script>
    <script src="{{ asset('bundles/packagistweb/js/charts.js') }}"></script>
{% endblock %}
