gridviz icon indicating copy to clipboard operation
gridviz copied to clipboard

Migrating LegoStyle tFun to V3

Open joewdavies opened this issue 1 year ago • 0 comments
trafficstars

How would I migrate Lego Style tFun to V3? the only example i could find uses thresholds:

    // get dataset if havent already
    if (!layer.dataset) getDataset(layer)

    //define style
    const styles = LegoStyle.get((cell) => cell[DATAFIELD], [100, 200, 500, 1000, 2000], ['#ffffd4', '#fee391', '#fec44f', '#fe9929', '#d95f0e', '#993404'])

    //define layer
    const gridLayer = new GridLayer(layer.dataset, styles, { minPixelsPerCell: 5, cellInfoHTML: TOOLTIPFUNCTION })

    //add layer to map
    gridvizMap.layers = [gridLayer]

    // redraw gridviz
    gridvizMap.redraw()

but the previous code did this:

    app.addLayerFromDataset(
        layer.dataset,
        LegoStyle.get(DATAFIELD, {
            tFun: (v, r, s, zf) => (v == 0 ? 0 : sExpRev((v - s.min) / (s.max - s.min), -7)),
            //colors: d3.schemeRdYlGn[10].reverse()
        }),
        {
            pixNb: 7,
            cellInfoHTML: TOOLTIPFUNCTION,
        }
    )

joewdavies avatar Nov 20 '24 10:11 joewdavies