<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="resources/boxplots.css">
    <script src="resources/d3.min.js" charset="utf-8"></script>
    <title>MRIQC: group {{ qctype }}
report</title>
</head>
<body>
    <h1>MRIQC: group {{ qctype }}
report</h1>
<h2>Summary</h2>
<ul class="simple">
<li>Date and time: {{ timestamp }}.</li>
<li>MRIQC version: {{ version }}.</li>
{% if failed %}
<li><span class="text-warning">Some individual reports failed</span>:
{% for f in failed %}
<span class="text-warning">{{ f }}</span>{% if loop.last %}.{% else %}, {% endif %}
{% endfor %}
</li>
{% endif %}
</ul>

<script src="resources/boxplots.js" charset="utf-8"></script>
{% for data_csv in csv_groups %}
<div class="chart-wrapper" id="chart-group{{ loop.index0 }}"></div>
<pre class="csvdata" id="data-csv{{ loop.index0 }}" style="display: none">
{{ data_csv }}</pre>
{% endfor %}


<script type="text/javascript">
    var chart1;
    function add(a, b) {
        return a + b;
    };

    function plotData(group) {
        data = d3.csv.parse(d3.select("#data-csv" + group).text(), function(d) {
            return {
                iqm: d.iqm,
                value: +d.value,
                label: d.label,
                units: d.units
            }
        });

        var a = {};
        var nIQMs = 0;
        data.forEach(function(d) {
            if(!a.hasOwnProperty(d.iqm)){
                a[d.iqm] = 1
                nIQMs += 1
            }

        });

        chart1 = makeDistroChart({
            data:data,
            xName:'iqm',
            yName:'value',
            selector:"#chart-group" + group,
            chartSize:{height:300, width:100 + 60 * nIQMs},
            constrainExtremes:true,
            qctype: '{{ qctype }}'
        });
        chart1.renderDataPlots();
        chart1.dataPlots.change({showPlot:true, plotType:20, padding: 20, showBeanLines:false});
        chart1.renderBoxPlot();
        chart1.boxPlots.show({showWhiskers:true,showOutliers:false,boxWidth:15,lineWidth:15,
            padding: -10, colors:['#555']});

        // chart1.renderNotchBoxes({showNotchBox:false});
        // chart1.renderViolinPlot({showViolinPlot:false});
        // chart1.violinPlots.show({reset:true,clamp:0});
        // chart1.dataPlots.show({showPlot:false,showBeanLines:true, colors:['#555']})

        //chart1.notchBoxes.hide();
        //chart1.boxPlots.hide();
    }

    {% for data_csv in csv_groups %}
    plotData({{ loop.index0 }});
    {% endfor %}
</script>
</body>
</html>