<commit_before>{% extends "base.html" %}



{% block content %}

    <div class="row">

        <!-- Button trigger modal -->
        <button class="btn btn-info col-md-1 col-md-offset-1" data-toggle="modal" data-target="#info-modal">
            <i class="fa fa-info"></i>&emsp;Info
        </button>

        <!-- Modal -->
        <div class="modal fade" id="info-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">Topic evolution</h4>
                    </div>

                    <div class="modal-body">
                        <p>
                            This chart shows the evolution in the number of doctoral thesis dissertations tagged as the provided topic since 1977.
                        </p>

                        <p>
                            If the topic is considered a high level category, a selector allows to change to other high-level topics, rendering its tendency over the years. Otherwise, just the name of the sub-topic appears.
                        </p>

                        <p>
                            When changing between topics, take care of the y-axis scale, which may change.
                        </p>

                        <p>
                            If a solid point is missing for a given year, there is no recorded data for that particular year, so the tendency line is maintained, but no data is displayed.
                        </p>

                        <p>
                            <strong>Note:</strong> In every chart a decreasing tendency can be observed between 2002 and 2004. As the <a href="{{ url_for('theses_gender_distribution') }}">number of total theses</a> doesn't show this particular patter, we suppose there was a loss of dissertation tagging information.
                        </p>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-4">
            {% if low_level_topic %}
                <h5>
                    {{ topic }}
                </h5>
            {% else %}
                <select id="topic-selector" class="form-control">
                    {% for topic in topics %}
                        <option value="{{ topic|slugify }}">{{ topic }}</option>
                    {% endfor %}
                </select>
            {% endif %}
        </div>

        <div class="col-md-2 col-md-offset-4">
            <a id="gender_distribution" class="btn btn-primary" href="/topic_gender_distribution/{{ topic_slug }}">
                Gender distribution
            </a>
        </div>
    </div>

    <br>

    <div id="svg" class="centered"></div>

{% endblock %}



{% block scripts %}

    <script type="text/javascript" src="{{ url_for('static', filename='js/d3.min.js') }}"></script>
    <script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
    <script type="text/javascript" src="{{ url_for('static', filename='js/underscore.min.js') }}"></script>

    <script type="text/javascript" src="{{ url_for('static', filename='js/handlebars-v1.3.0.js') }}"></script>

    {% raw %}
    <script id="percentage-tooltip-template" type="text/x-handlebars-template">
        <h1>Year {{ year }}</h1>

        <p>
            {{ count }} theses tagged
        </p>
    </script>
    {% endraw %}

    <script>
        var page_width = $(".container").width();

        var margin = {top: 40, right: 50, bottom: 50, left: 50},
            width = page_width - margin.left - margin.right,
            height = 500 - margin.top - margin.bottom;

        var year_format = d3.time.format("%y");

        var xScale = d3.scale.ordinal().rangeRoundBands([0, width], 1);

        var xAxis = d3.svg.axis()
            .scale(xScale)
            .orient("bottom");

        var yScale = d3.scale.linear().range([height, 0]);

        var yAxis = d3.svg.axis()
            .scale(yScale)
            .orient("left");

        var svg = d3.select("#svg").append("svg")
            .attr("width", width + margin.left + margin.right)
            .attr("height", height + margin.top + margin.bottom)
            .append("g")
            .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

        var topic;

        {% if topic != None %}
            topic = '{{ topic }}';
            $('#topic-selector').val('{{ topic_slug }}');
        {% else %}
            topic = "ANTROPOLOGIA";
        {% endif %}
        drawChart();

        $('#topic-selector').change(function() {
            topic = $( "#topic-selector option:selected" ).text();
            var url = "{{ url_for('topic_gender_distribution', topic='topic_slug') }}";
            var topic_slug = replaceAll(" ", "-", topic).toLowerCase();
            url = url.replace("topic_slug", topic_slug);
            $('#gender_distribution').attr('href', url);
            drawChart();
        });

        function replaceAll(find, replace, str) {
            return str.replace(new RegExp(find, 'g'), replace);
        };

        function drawChart() {
            svg.selectAll(".axis").remove();
            svg.selectAll(".circle").remove();
            svg.selectAll(".missing-circle").remove();
            svg.selectAll(".line").remove();
            svg.selectAll("line.horizontalGrid").remove();

            var years = [];
            var data = [];
            var lineData = [];
            {% if low_level_topic %}
                $.getJSON("{{ url_for('static', filename='data/areas_temporal.json') }}", function(json) {
            {% else %}
                $.getJSON("{{ url_for('static', filename='data/first_level_areas_temporal.json') }}", function(json) {
            {% endif %}
                for (var element in json) {
                    if (element > 1976) {
                        var data_obj = {
                            "year": element,
                            "count": json[element][String(topic)]
                        };

                        years.push({"year": data_obj.year});

                        if (typeof data_obj.count != 'undefined') {
                            data.push(data_obj);
                            lineData.push([parseInt(data_obj.year), data_obj.count]);
                        }
                    };
                }

                xScale.domain(years.map(function(d) { return d.year; }));
                var max = d3.max(data, function(d) { return d.count });
                var units = (max > 250) ? 100 : 10;
                yScale.domain([0, Math.ceil(max / units) * units]);

                svg.append("g")
                    .attr("class", "x axis ev-axis")<commit_msg>Removed hardcoded init variable<commit_after>{% extends "base.html" %}



{% block content %}

    <div class="row">

        <!-- Button trigger modal -->
        <button class="btn btn-info col-md-1 col-md-offset-1" data-toggle="modal" data-target="#info-modal">
            <i class="fa fa-info"></i>&emsp;Info
        </button>

        <!-- Modal -->
        <div class="modal fade" id="info-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">Topic evolution</h4>
                    </div>

                    <div class="modal-body">
                        <p>
                            This chart shows the evolution in the number of doctoral thesis dissertations tagged as the provided topic since 1977.
                        </p>

                        <p>
                            If the topic is considered a high level category, a selector allows to change to other high-level topics, rendering its tendency over the years. Otherwise, just the name of the sub-topic appears.
                        </p>

                        <p>
                            When changing between topics, take care of the y-axis scale, which may change.
                        </p>

                        <p>
                            If a solid point is missing for a given year, there is no recorded data for that particular year, so the tendency line is maintained, but no data is displayed.
                        </p>

                        <p>
                            <strong>Note:</strong> In every chart a decreasing tendency can be observed between 2002 and 2004. As the <a href="{{ url_for('theses_gender_distribution') }}">number of total theses</a> doesn't show this particular patter, we suppose there was a loss of dissertation tagging information.
                        </p>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-4">
            {% if low_level_topic %}
                <h5>
                    {{ topic }}
                </h5>
            {% else %}
                <select id="topic-selector" class="form-control">
                    {% for topic in topics %}
                        <option value="{{ topic|slugify }}">{{ topic }}</option>
                    {% endfor %}
                </select>
            {% endif %}
        </div>

        <div class="col-md-2 col-md-offset-4">
            <a id="gender_distribution" class="btn btn-primary" href="/topic_gender_distribution/{{ topic_slug }}">
                Gender distribution
            </a>
        </div>
    </div>

    <br>

    <div id="svg" class="centered"></div>

{% endblock %}



{% block scripts %}

    <script type="text/javascript" src="{{ url_for('static', filename='js/d3.min.js') }}"></script>
    <script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
    <script type="text/javascript" src="{{ url_for('static', filename='js/underscore.min.js') }}"></script>

    <script type="text/javascript" src="{{ url_for('static', filename='js/handlebars-v1.3.0.js') }}"></script>

    {% raw %}
    <script id="percentage-tooltip-template" type="text/x-handlebars-template">
        <h1>Year {{ year }}</h1>

        <p>
            {{ count }} theses tagged
        </p>
    </script>
    {% endraw %}

    <script>
        var page_width = $(".container").width();

        var margin = {top: 40, right: 50, bottom: 50, left: 50},
            width = page_width - margin.left - margin.right,
            height = 500 - margin.top - margin.bottom;

        var year_format = d3.time.format("%y");

        var xScale = d3.scale.ordinal().rangeRoundBands([0, width], 1);

        var xAxis = d3.svg.axis()
            .scale(xScale)
            .orient("bottom");

        var yScale = d3.scale.linear().range([height, 0]);

        var yAxis = d3.svg.axis()
            .scale(yScale)
            .orient("left");

        var svg = d3.select("#svg").append("svg")
            .attr("width", width + margin.left + margin.right)
            .attr("height", height + margin.top + margin.bottom)
            .append("g")
            .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

        var topic;

        topic = '{{ topic }}';
        $('#topic-selector').val('{{ topic_slug }}');

        drawChart();

        $('#topic-selector').change(function() {
            topic = $( "#topic-selector option:selected" ).text();
            var url = "{{ url_for('topic_gender_distribution', topic='topic_slug') }}";
            var topic_slug = replaceAll(" ", "-", topic).toLowerCase();
            url = url.replace("topic_slug", topic_slug);
            $('#gender_distribution').attr('href', url);
            drawChart();
        });

        function replaceAll(find, replace, str) {
            return str.replace(new RegExp(find, 'g'), replace);
        };

        function drawChart() {
            svg.selectAll(".axis").remove();
            svg.selectAll(".circle").remove();
            svg.selectAll(".missing-circle").remove();
            svg.selectAll(".line").remove();
            svg.selectAll("line.horizontalGrid").remove();

            var years = [];
            var data = [];
            var lineData = [];
            {% if low_level_topic %}
                $.getJSON("{{ url_for('static', filename='data/areas_temporal.json') }}", function(json) {
            {% else %}
                $.getJSON("{{ url_for('static', filename='data/first_level_areas_temporal.json') }}", function(json) {
            {% endif %}
                for (var element in json) {
                    if (element > 1976) {
                        var data_obj = {
                            "year": element,
                            "count": json[element][topic]
                        };

                        years.push({"year": data_obj.year});

                        if (typeof data_obj.count != 'undefined') {
                            data.push(data_obj);
                            lineData.push([parseInt(data_obj.year), data_obj.count]);
                        }
                    };
                }

                xScale.domain(years.map(function(d) { return d.year; }));
                var max = d3.max(data, function(d) { return d.count });
                var units = (max > 250) ? 100 : 10;
                yScale.domain([0, Math.ceil(max / units) * units]);

                svg.append("g")
                    .attr("class", "x axis ev-axis")
{'fraction_non_alphanumeric': 0.14965890709613897, 'fraction_numerical': 0.009424010127294465, 'mean_word_length': 1.5566343042071198, 'pattern_counts': {'":': 6, '<': 143, '<?xml version=': 0, '>': 147, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7055506', 'n_tokens_mistral': 4018, 'n_tokens_neox': 3672, 'n_words': 905}