<script>
    plot_data = {
    "contigs":{
        "gold": {{data.rank_counts.gold.total_contig}},
        "silver": {{data.rank_counts.silver.total_contig}},
        "bronze": {{data.rank_counts.bronze.total_contig}},
        "excluded": {{data.rank_counts.fail.total_contig}}
    },
    "coverage":{
        "gold": {{data.rank_counts.gold.coverage}},
        "silver": {{data.rank_counts.silver.coverage}},
        "bronze": {{data.rank_counts.bronze.coverage}},
        "excluded": {{data.rank_counts.fail.coverage}}
    },
    "n50": {
        "gold": {{data.rank_counts.gold.n50_contig_length}},
        "silver": {{data.rank_counts.silver.n50_contig_length}},
        "bronze": {{data.rank_counts.bronze.n50_contig_length}},
        "excluded": {{data.rank_counts.fail.n50_contig_length}}
    }
    };
    layouts = {
    "contigs": {
        yaxis: {title: "Total Contig Count"},
        xaxis: {title: "Group"}
    },
    "coverage": {
        yaxis: {title: "Estimated Coverage (x)"},
        xaxis: {title: "Group"}
    },
    "n50": {
        yaxis: {title: "N50 Size (bp)"},
        xaxis: {title: "Group"}
    }
    }

    for (var plot_name in plot_data) {
        var plot_obj = plot_data[plot_name];
        var data = [];
        for (var group in plot_obj) {
        data.push({
            y: plot_obj[group],
            type: 'box',
            name: group[0].toUpperCase() + group.substring(1),
            boxmean: true,
            boxpoints: false
        });
        }
        var layout = layouts[plot_name]
        Plotly.newPlot('plot-' + plot_name, data, layout, {responsive: true});
    }

</script>