Skip to content

Instantly share code, notes, and snippets.

@steveoni
Created January 22, 2024 16:49
Show Gist options
  • Save steveoni/cea2b3ba96d342e60609649be6d10882 to your computer and use it in GitHub Desktop.
Save steveoni/cea2b3ba96d342e60609649be6d10882 to your computer and use it in GitHub Desktop.
{resources: [
        {
            description: '',
            resourceId: 'e1c26bc8-1e49-43ab-bcf6-04f99199604e',
            url: '',
            format: 'Layer',
            title: 'Example title',
            type: 'layer',
            schema: [],
            layerObj: {
                name: '2015 Human Development Index',
                slug: '2015-Human-Development-Index_5',
                default: false,
                published: false,
                protected: false,
                env: 'staging',
                application: ['data-explorer'],
                description:
                    'A composite index measuring average achievement in 3 basic dimensions of human development: a long and healthy life, knowledge, and a decent standard of living. 2015 Index scores are displayed.',
                provider: 'cartodb',
                type: 'layer',
                iso: [],
                layerConfig: {
                    type: {
                        value: 'vector',
                        label: 'Vector',
                    },
                    source: {
                        provider: {
                            type: {
                                value: 'carto',
                                label: 'Carto',
                            },
                            account: 'wri-rw',
                            layers: [
                                {
                                    options: {
                                        sql: 'SELECT wri.cartodb_id, wri.the_geom_webmercator, data.rw_country_name, data.rw_country_code, data.datetime, data.yr_data FROM soc_004_human_development_index data LEFT OUTER JOIN wri_countries_a wri ON data.rw_country_code = wri.iso_a3 WHERE EXTRACT(YEAR FROM data.datetime) = 2015 and data.yr_data is not null',
                                        type: 'cartodb',
                                    },
                                },
                            ],
                        },
                    },
                    render: {
                        layers: [
                            {
                                type: {
                                    value: 'fill',
                                    label: 'Fill',
                                },
                                'source-layer': 'layer0',
                                paint: {
                                    'fill-color': {
                                        type: {
                                            value: 'step',
                                            label: 'Steps',
                                        },
                                        interpolationType: null,
                                        input: {
                                            coercion: 'to-number',
                                            operation: 'get',
                                            column: {
                                                value: 'yr_data',
                                                label: 'yr_data',
                                            },
                                        },
                                        output: [
                                            {
                                                color: '#ffffcc',
                                                value: 0.5,
                                            },
                                            {
                                                color: '#a1dab4',
                                                value: 0.7,
                                            },
                                            {
                                                color: '#41b6c4',
                                                value: 0.75,
                                            },
                                            {
                                                color: '#2c7fb8',
                                                value: 0.85,
                                            },
                                            {
                                                color: '#253494',
                                            },
                                        ],
                                    },
                                    'fill-opacity': 1,
                                },
                                filter: ['all'],
                            },
                            {
                                type: {
                                    value: 'line',
                                    label: 'Line',
                                },
                                'source-layer': 'layer0',
                                paint: {
                                    'line-color': '#fff',
                                    'line-opacity': 0.8,
                                    'line-width': 0.5,
                                },
                                filter: ['all'],
                            },
                        ],
                    },
                },
                connectorUrl:
                    'https://wri-rw.carto.com:443/api/v2/sql?q=SELECT wri.cartodb_id, wri.the_geom_webmercator, data.rw_country_name, data.rw_country_code, data.datetime, data.yr_data FROM soc_004_human_development_index data LEFT OUTER JOIN wri_countries_a wri ON data.rw_country_code = wri.iso_a3 WHERE EXTRACT(YEAR FROM data.datetime) = 2015 and data.yr_data is not null',
                legendConfig: {
                    type: 'choropleth',
                    items: [
                        {
                            color: '#ffffcc',
                            name: '<0.5',
                        },
                        {
                            color: '#a1dab4',
                            name: '<0.7',
                        },
                        {
                            color: '#41b6c4',
                            name: '<0.75',
                        },
                        {
                            color: '#2c7fb8',
                            name: '<0.85',
                        },
                        {
                            color: '#253494',
                            name: '<0.95',
                        },
                    ],
                },
                interactionConfig: {
                    output: [
                        {
                            column: 'rw_country_name',
                            format: '',
                            prefix: '',
                            property: '',
                            suffix: '',
                            type: '',
                            enabled: true,
                        },
                        {
                            column: 'yr_data',
                            format: '',
                            prefix: '',
                            property: '2015 Human Development Index',
                            suffix: '',
                            type: 'number',
                            enabled: true,
                        },
                    ],
                },
            },
        },
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment