vis_files/generate_plots.js
/// Initialises maps show they can be clicked (or hovered over)
Initialises maps show they can be clicked (or hovered over)
Initialises maps show they can be clicked ( or hovered over )
function init_clickable_map()
{
	var b = visjson.boundaries;
	visjson.inter = [];
	visjson.click_bound_range=[];
	for(c = 0; c < b.length; c++){
		var xmin = large, xmax = -large, ymin = large, ymax = -large; 
		var xav = 0, yav = 0, nav = 0; 
		for(p = 0; p < b[c].length; p++){          
			for(k = 0; k < b[c][p].length; k++){
				var x = b[c][p][k][0], y = b[c][p][k][1];
				if(x > xmax) xmax = x; if(x < xmin) xmin = x;
				if(y > ymax) ymax = y; if(y < ymin) ymin = y;
				xav += x; yav += y; nav++;
			}
		}
		visjson.click_bound_range[c] = {xmin:xmin, xmax:xmax, ymin:ymin, ymax:ymax, xav:xav/nav, yav:yav/nav};
		visjson.inter[c] = [];
		for(yi = Math.floor(clickline*ymin); yi <= Math.floor(clickline*ymax); yi++){
			visjson.inter[c][yi]=[];
		}
		for(p = 0; p < b[c].length; p++){          
			for(k = 0; k < b[c][p].length; k++){
				var po = b[c][p][k];
				xi = b[c][p][k][0];
				xf = b[c][p][(k+1)%b[c][p].length][0];
				bx = xf-xi; 
				yi = clickline*b[c][p][k][1];
				yf = clickline*b[c][p][(k+1)%b[c][p].length][1];
				by = yf-yi;
				if(by > 0){
					for(j = Math.floor(yi+1); j < yf; j++) visjson.inter[c][j].push(xi + bx*(j-yi)/by);
				}
				if(by < 0){
					for(j = Math.floor(yi); j > yf; j--) visjson.inter[c][j].push(xi + bx*(j-yi)/by);
				}
			}
		}
	}	
}
function init_clickable_map ( ) { var b = visjson . boundaries ; visjson . inter = [ ] ; visjson . click_bound_range = [ ] ; for ( c = 0 ; c < b . length ; c ++ ) { var xmin = large , xmax = - large , ymin = large , ymax = - large ; var xav = 0 , yav = 0 , nav = 0 ; for ( p = 0 ; p < b [ c ] . length ; p ++ ) { for ( k = 0 ; k < b [ c ] [ p ] . length ; k ++ ) { var x = b [ c ] [ p ] [ k ] [ 0 ] , y = b [ c ] [ p ] [ k ] [ 1 ] ; if ( x > xmax ) xmax = x ; if ( x < xmin ) xmin = x ; if ( y > ymax ) ymax = y ; if ( y < ymin ) ymin = y ; xav += x ; yav += y ; nav ++ ; } } visjson . click_bound_range [ c ] = { xmin : xmin , xmax : xmax , ymin : ymin , ymax : ymax , xav : xav / nav , yav : yav / nav } ; visjson . inter [ c ] = [ ] ; for ( yi = Math . floor ( clickline * ymin ) ; yi <= Math . floor ( clickline * ymax ) ; yi ++ ) { visjson . inter [ c ] [ yi ] = [ ] ; } for ( p = 0 ; p < b [ c ] . length ; p ++ ) { for ( k = 0 ; k < b [ c ] [ p ] . length ; k ++ ) { var po = b [ c ] [ p ] [ k ] ; xi = b [ c ] [ p ] [ k ] [ 0 ] ; xf = b [ c ] [ p ] [ ( k + 1 ) % b [ c ] [ p ] . length ] [ 0 ] ; bx = xf - xi ; yi = clickline * b [ c ] [ p ] [ k ] [ 1 ] ; yf = clickline * b [ c ] [ p ] [ ( k + 1 ) % b [ c ] [ p ] . length ] [ 1 ] ; by = yf - yi ; if ( by > 0 ) { for ( j = Math . floor ( yi + 1 ) ; j < yf ; j ++ ) visjson . inter [ c ] [ j ] . push ( xi + bx * ( j - yi ) / by ) ; } if ( by < 0 ) { for ( j = Math . floor ( yi ) ; j > yf ; j -- ) visjson . inter [ c ] [ j ] . push ( xi + bx * ( j - yi ) / by ) ; } } } } }
Initialises maps show they can be clicked (or hovered over)
Initialises maps show they can be clicked ( or hovered over )
//if(by == 0) visjson.inter[c][Math.floor(yi)].push(xi);