diff --git a/examples/NO.html b/examples/NO.html index abec1a47a..b6a0233bf 100644 --- a/examples/NO.html +++ b/examples/NO.html @@ -30,10 +30,19 @@ in
+ + +
+ + Population change +
+
+
@@ -47,6 +56,7 @@ + @@ -159,6 +169,62 @@ }) ) + } else if (layCode === 'popS') { + + //get selected year + const y = document.querySelector('#year').value + + //get smoothing sigma + const sig = document.querySelector('#sigma').value + + //define color ramp and number of classes + const colR = d3.interpolateYlOrRd + const nb = 5 + + app.addLayerFromDataset( + //set dataset: population dataset on year y + ds["pop" + y], + [ + new gviz_sm.KernelSmoothingStyle({ + value: (c) => +c.p, + filterSm: (v) => v > 0.001, + sigma: (r, zf) => (r * +sig) / 10, + factor: 2, + styles: [ + new gviz.SquareColorWGLStyle({ + colorCol: 'ksmval', + color: colR, + //stretching: { fun: 'expRev', alpha: -7 }, + tFun: (v, r, s) => { + const v_ = gviz.sExp(v / s.max, -35) + const cl = Math.floor(nb * v_) / nb + return cl + }, + //set alpha and blend operation + //alpha: (zf) => zf < 70 ? 0.75 : 1.0, + blendOperation: (zf) => zf < 50 ? "multiply" : "normal" + }) + ] + }), + ], + { + pixNb: 1.5, + cellInfoHTML: (c) => '' + c.p + ' person' + (+c.p == 1 ? '' : 's') + } + ) + + //legend + app.layers[0].styles[0].styles[0].legends.push( + new gviz.ColorLegend({ + title: 'Population', + colorRamp: (t) => colR(Math.floor(t * nb) / nb), + width: 200, + ticks: 2, + tickFormat: 'text', + fun: (t, r, s) => (t == 0 ? 'Low' : t == 1 ? 'High' : 'X'), + }) + ) + } else if (layCode === 'popTS') { //define time series list of years @@ -198,6 +264,8 @@ document.getElementById('layer').addEventListener('change', update) //on year selection change, update map document.getElementById('year').addEventListener('change', update) + //on sigma selection change, update map + document.getElementById('sigma').oninput = update // show/hide labels document.getElementById('label').addEventListener('change', function () {