ldavis2019/ldavis.js
// updates vis when a term is selected via click or hover
updates vis when a term is selected via click or hover
updates vis when a term is selected via click or hover
function term_on(term) {
            if (term == null) return null;
            term.style["fontWeight"] = "bold";
            var d = term.__data__
            var Term = d.Term;
            var dat2 = mdsData3.filter(function(d2) {
                return d2.Term == Term
            });
            var k = dat2.length; 
            var radius = [];
            for (var i = 0; i < K; ++i) {
                radius[i] = 0;
            }
            for (i = 0; i < k; i++) {
                radius[dat2[i].Topic - 1] = dat2[i].Freq;
            }
            var size = [];
            for (var i = 0; i < K; ++i) {
                size[i] = 0;
            }
            for (i = 0; i < k; i++) {
                size[dat2[i].Topic - 1] = 11;
            }
            var rScaleCond = d3.scale.sqrt()
                .domain([0, 1]).range([0, rMax]);
            d3.selectAll(".dot")
                .data(radius)
                .transition()
                .attr("r", function(d) {
		    return (Math.sqrt(d*mdswidth*mdsheight*word_prop/Math.PI)); 
                });
            d3.selectAll(".dot")
                .data(mdsData)
            d3.selectAll(".txt")
                .data(size)
                .transition()
                .style("font-size", function(d) {
                    return +d;
                });
            d3.select(".circleGuideTitle")
                .text("Conditional topic distribution given term = '" + term.innerHTML + "'");
        }
function term_on ( term ) { if ( term == null ) return null ; term . style [ "fontWeight" ] = "bold" ; var d = term . __data__ var Term = d . Term ; var dat2 = mdsData3 . filter ( function ( d2 ) { return d2 . Term == Term } ) ; var k = dat2 . length ; var radius = [ ] ; for ( var i = 0 ; i < K ; ++ i ) { radius [ i ] = 0 ; } for ( i = 0 ; i < k ; i ++ ) { radius [ dat2 [ i ] . Topic - 1 ] = dat2 [ i ] . Freq ; } var size = [ ] ; for ( var i = 0 ; i < K ; ++ i ) { size [ i ] = 0 ; } for ( i = 0 ; i < k ; i ++ ) { size [ dat2 [ i ] . Topic - 1 ] = 11 ; } var rScaleCond = d3 . scale . sqrt ( ) . domain ( [ 0 , 1 ] ) . range ( [ 0 , rMax ] ) ; d3 . selectAll ( ".dot" ) . data ( radius ) . transition ( ) . attr ( "r" , function ( d ) { return ( Math . sqrt ( d * mdswidth * mdsheight * word_prop / Math . PI ) ) ; } ) ; d3 . selectAll ( ".dot" ) . data ( mdsData ) d3 . selectAll ( ".txt" ) . data ( size ) . transition ( ) . style ( "font-size" , function ( d ) { return + d ; } ) ; d3 . select ( ".circleGuideTitle" ) . text ( "Conditional topic distribution given term = '" + term . innerHTML + "'" ) ; }
updates vis when a term is selected via click or hover
updates vis when a term is selected via click or hover
// number of topics for this token with non-zero frequency // If we want to also re-size the topic number labels, do it here // 11 is the default, so leaving this as 11 won't change anything. // Change size of bubbles according to the word's distribution over topics //return (rScaleCond(d)); // re-bind mdsData so we can handle multiple selection // Change sizes of topic numbers: // Alter the guide