agora_analytica/flask/static/graph.js
/** 
 * Update topics to follow node link directions.
 */
Update topics to follow node link directions.
Update topics to follow node link directions .
function align_topic_texts(el) {
    d3.select(el).attr("transform", function(d) {
        if(d3.select(this).style("display") == "none") return
        const source = graph.nodes.find((x) => x.id == d.source)
        const target = graph.nodes.find((x) => x.id == d.target)
        const atan = Math.atan2(source.y - target.y, source.x - target.x)
        const w = this.getBBox();
        const s = Math.sin(atan)
        const c = Math.cos(atan)
        let y = s * (graph.node_radius)
        let x = c * (graph.node_radius)
        y += w.height / 2;
        x -= w.width / 2;
        y += w.height / 2 * s;
        x += w.width / 2 * c;
        return "translate("+ x +","+ y +")"
    });
}
function align_topic_texts ( el ) { d3 . select ( el ) . attr ( "transform" , function ( d ) { if ( d3 . select ( this ) . style ( "display" ) == "none" ) return const source = graph . nodes . find ( ( x ) => x . id == d . source ) const target = graph . nodes . find ( ( x ) => x . id == d . target ) const atan = Math . atan2 ( source . y - target . y , source . x - target . x ) const w = this . getBBox ( ) ; const s = Math . sin ( atan ) const c = Math . cos ( atan ) let y = s * ( graph . node_radius ) let x = c * ( graph . node_radius ) y += w . height / 2 ; x -= w . width / 2 ; y += w . height / 2 * s ; x += w . width / 2 * c ; return "translate(" + x + "," + y + ")" } ) ; }
Update topics to follow node link directions.
Update topics to follow node link directions .
// Align // Center point is bottom left, make it "center" // Push outside regarding box size