carte = {
let container = DOM.element('div', { style: `width:${width}px;height:${width/1.6}px` });
yield container;
let myApp = new gridviz.App(container, {legendDivId: 'legendContainer'})
.setGeoCenter({ x: 3763437, y: 2891045 })
.setZoomFactor(50.1)
.addMultiScaleTiledGridLayer(
[200, 400, 1000, 2000, 5000, 10000, 20000, 50000],
(r) =>
'https://raw.githubusercontent.com/jgaffuri/tiledgrids/main/data/france/filosofi/ind/2017/' +
r +
'm/',
[
new gridviz.ShapeColorSizeStyle({
sizeCol: 'Ind',
size: (v, r, s, zf) => 1.4 * r * gridviz.sPow(v / s.max, 0.13),
colorCol: 'age_ratio',
color: (v, r, s) => d3.interpolateSpectral(1 - v),
shape: () => 'circle',
}),
],
{
pixNb: 6,
preprocess: (c) => {
const yyy = +c.Ind_0_3 + +c.Ind_4_5 + +c.Ind_6_10 + +c.Ind_11_17 + +c.Ind_18_24
const ooo = +c.Ind_65_79 + +c.Ind_80p
c.age_ratio = yyy + ooo == 0 ? 0 : (yyy - ooo) / (yyy + ooo)
c.age_ratio = c.age_ratio * 0.5 + 0.5
},
}
)
myApp.layers[0].styles[0].legends.push(
new gridviz.SizeLegend({
title: 'Number of inhabitants',
exaggerationFactor: 0.8,
shape: 'circle',
fillColor: '#e54f37',
})
)
myApp.layers[0].styles[0].legends.push(
new gridviz.ColorLegend({
title: 'Age Ratio',
width: 400,
ticks: 5,
colorRamp: d3.interpolateSpectral,
fun: (v, r, s) => d3.interpolateSpectral(1 - v),
})
)
}