metreex-analysis.js
/**
 * Creates a legend based on the given authors and color axis and appends it to the given div
 * @param {String} legendTarget HTML div that the legend should be appended to
 * @param {Array} authors Array of authors to be added to the legend
 * @param {Object} coloraxis d3 ScaleOrdinal object associating the authors to their colors
 */
Creates a legend based on the given authors and color axis and appends it to the given div
@param {String} legendTarget HTML div that the legend should be appended to
@param {Array} authors Array of authors to be added to the legend
@param {Object} coloraxis d3 ScaleOrdinal object associating the authors to their colors
Creates a legend based on the given authors and color axis and appends it to the given div @param { String } legendTarget HTML div that the legend should be appended to @param { Array } authors Array of authors to be added to the legend @param { Object } coloraxis d3 ScaleOrdinal object associating the authors to their colors
function createAuthorToColorLegend(legendTarget, authors, coloraxis){
    var legend = d3.select(legendTarget).append("svg")
        .attr("width", 140)
        .attr("height", authors.length*22);
    legend.selectAll("rect")
        .data(authors)
        .enter()
        .append("rect")
        .attr("x", 10)
        .attr("y", function(elem, index){return index * 22 + 5;})
        .attr("width", 15)
        .attr("height", 10)
        .style("fill", function(elem){return coloraxis(elem);})
        .on("mouseover", function (elem) {
            d3.selectAll("." + elem.toString().replace(/ /g,"."))
                .style("fill", "#666")
                .each(function () {
                    this.parentNode.appendChild(this);
                })
        })
        .on("mouseout", function (elem) {
            d3.selectAll("." + elem.toString().replace(/ /g,"."))
                .style("fill", coloraxis(elem))
                .each(function () {
                    this.parentNode.insertBefore(this, this.parentNode.firstChild);
                })
        });
    legend.selectAll("text")
        .data(authors)
        .enter()
        .append("text")
        .attr("x", 30)
        .attr("y", function(elem, index){return index * 22 + 15;})
        .attr("class", "legend")
        .text(function(elem){return elem;});
}
function createAuthorToColorLegend ( legendTarget , authors , coloraxis ) { var legend = d3 . select ( legendTarget ) . append ( "svg" ) . attr ( "width" , 140 ) . attr ( "height" , authors . length * 22 ) ; legend . selectAll ( "rect" ) . data ( authors ) . enter ( ) . append ( "rect" ) . attr ( "x" , 10 ) . attr ( "y" , function ( elem , index ) { return index * 22 + 5 ; } ) . attr ( "width" , 15 ) . attr ( "height" , 10 ) . style ( "fill" , function ( elem ) { return coloraxis ( elem ) ; } ) . on ( "mouseover" , function ( elem ) { d3 . selectAll ( "." + elem . toString ( ) . replace ( / / g , "." ) ) . style ( "fill" , "#666" ) . each ( function ( ) { this . parentNode . appendChild ( this ) ; } ) } ) . on ( "mouseout" , function ( elem ) { d3 . selectAll ( "." + elem . toString ( ) . replace ( / / g , "." ) ) . style ( "fill" , coloraxis ( elem ) ) . each ( function ( ) { this . parentNode . insertBefore ( this , this . parentNode . firstChild ) ; } ) } ) ; legend . selectAll ( "text" ) . data ( authors ) . enter ( ) . append ( "text" ) . attr ( "x" , 30 ) . attr ( "y" , function ( elem , index ) { return index * 22 + 15 ; } ) . attr ( "class" , "legend" ) . text ( function ( elem ) { return elem ; } ) ; }
Creates a legend based on the given authors and color axis and appends it to the given div
 @param {String} legendTarget HTML div that the legend should be appended to
 @param {Array} authors Array of authors to be added to the legend
 @param {Object} coloraxis d3 ScaleOrdinal object associating the authors to their colors
Creates a legend based on the given authors and color axis and appends it to the given div @param { String } legendTarget HTML div that the legend should be appended to @param { Array } authors Array of authors to be added to the legend @param { Object } coloraxis d3 ScaleOrdinal object associating the authors to their colors