1.2.24 • Published 2 months ago

nutsdorlingcartogram v1.2.24

Weekly downloads
2
License
ISC
Repository
github
Last release
2 months ago

NutsDorlingCartogram

Dorling cartograms from NUTS regions with Eurostat statistics

npm bundle size npm license

Installation

npm install nutsdorlingcartogram

then

NutsDorlingCartogram = require('nutsdorlingcartogram')

or

<script src="https://unpkg.com/nutsdorlingcartogram/build/dorling.min.js"></script>

Usage

NutsDorlingCartogram.dorling()
    .containerId('containerDiv')
    .nutsLevel(2)
    .colors(['#2d50a0', '#6487c3', '#aab9e1', '#f0cd91', '#e6a532', '#d76e2d'])
    .thresholdValues([-15, -10, 0, 10, 15, 20])
    .sizeDatasetCode('demo_r_pjangrp3')
    .sizeDatasetFilters('sex=T&age=TOTAL&unit=NR&time=2019')
    .colorDatasetCode('demo_r_gind3')
    .colorDatasetFilters('indic_de=GROWRT&time=2018')
    .maxCircleRadius({
        0: 50, // Country level
        1: 30, // NUTS 1
        2: 30, // NUTS 2
        3: 20, // NUTS 3
    })
    .showBorders(false)
    .seaColor('white')
    .tooltip({
        colorLabel: 'Population change',
        colorUnit: 'per 1 000 inhabitants',
        sizeLabel: 'Total population',
        shareLabel: 'Share of national population',
    })
    .build();

Check out this notebook for an interactive example.

Cartogram Definition

Accessible methods and their respective parameters. Where possible, values can be defined for each NUTS level; whereby a change in NUTS level using the NUTS selector will rebuild the visualization using the parameters corresponding to the new NUTS level.

MethodDescriptionTypeRequiredDefault Value
dorling.containerIdIdentifier of the container upon which the cartogram will be appendedstringtruenull
dorling.widthSVG viewbox width attributenumberfalse1000
dorling.heightSVG viewbox height attributenumberfalse1000
dorling.standaloneWhether the visualisation is a standalone version or not. Standalone versions include share buttons, modals and a eurostat logo.Booleanfalsefalse
dorling.nutsLevelNUTS levelnumberfalse2
dorling.sizeDatasetCodeEurostat database dataset identifier used to determine circle sizesstringfalse"demo_r_pjangrp3"
dorling.sizeDatasetFiltersURL parameter string to apply to the sizeDataset requeststringfalse"sex=T&age=TOTAL&unit=NR&time=2018"
dorling.colorDatasetCodeEurostat dataset identifier used to determine circle colorsnumberfalse200
dorling.colorDatasetFiltersURL parameter string to apply to the colorDataset requeststringfalse"indic_de=GROWRT&time=2018"
dorling.mixNutsPermits filling in data gaps using data from different NUTS levels. For example: this adds NUTS region "DE1" of NUTS level 1 to the NUTS 2 data: { 2: {level: 1, ids: "DE1" } }{ nutsLevel: {nutsLevelToBeAdded: number, ids: [] } }falsenull
dorling.excludeExclude countries from the data shown. e.g .exclude("MK", "ME", "TR", "AL", "RS")stringfalsenull
dorling.colorIsPercentageWhether or not the values used for the colours should be percentages. If true, the percentages are calculated using colorPercentageCalcDatasetCode and colorPercentageCalcDatasetFiltersbooleanfalsefalse
dorling.colorPercentageCalcDatasetCodeDataset code for the retrieval of the totals that will be used to calculate the percentages of the colour values. See agriculture example (specific cereal production / all cereal production)stringfalsenull
dorling.colorPercentageCalcDatasetFiltersURL parameter string to apply to the colorPercentageCalcDataset requeststringfalsenull
dorling.colorSchemed3 scale chromatic function name. Only used when a 'colors' array is not specified (see below)stringfalse"interpolateRdYlBu"
dorling.colorsAn array of hex values to use for colouring the circles[]stringfalsenull
dorling.thresholdValuesAn array of threshold values to use for classifying the data[]numberfalsenull
dorling.zoomEnable d3 zoom functionality using zoom buttonsbooleanfalsetrue
dorling.showNutsSelectorwhether or not to show the radio buttons which allow the user to change between NUTS levelsbooleanfalsetrue;
dorling.nutsAvailableDefines which NUTS levels will be shown in the NUTS level selectorarrayfalse0,1,2,3;
dorling.nutsSelectorTranslateYY-axis translation applied to the NUTS level selector node{'nutsLevel':number}false{ 0: 375, 1: 375, 2: 375, 3: 375 }
dorling.minCircleRadiusMinimum circle radius allowed when scaling the circles (for each NUTS level){'nutsLevel':number}false{ '0': 1.5, '1': 1.5, '2': 1.5, '3': 1.5 }
dorling.maxCircleRadiusMaximum circle radius allowed when scaling the circles (for each NUTS level){'nutsLevel':number}false{ '0': 20, '1': 20, '2': 20, '3': 20 }
dorling.positionStrengthThe strength of the forces used to maintain the circle at its original position.numberfalse0.7
dorling.collisionStrengthThe strength of the collisions between circle during the d3 force simulationnumberfalse0.1
dorling.scaled3-geo projection.scale() valuenumberfalse0.0002065379208173783
dorling.translateXd3-geo projection.translate() X valuenumberfalse-390
dorling.translateYd3-geo projection.translate() Y valuenumberfalse1126
dorling.showSourceshow links to the source datasets for the colour and size databooleanfalsetrue
dorling.footnotesTextFootnote text shown below the mapstringfalsenull

Legend

MethodDescriptionTypeRequiredDefault Value
dorling.colorLegendObject which stores the configuration parameters for the circle-color legend. See here for more details on the following legend options.objectfalseSee here
   colorLegend.orientAccepted values: "vertical" or "horizontal"stringfalse"vertical"
   colorLegend.titleLegend title textstringfalse"Circle Colour"
   colorLegend.titleWidthWidth of the legend titlenumberfalse200
   colorLegend.cellsNumber of cells to be shown in the legendnumberfalse5
   colorLegend.shapeShape of the legend cells ("circle" or "rect")stringfalse"rect"
   colorLegend.shapeRadiusRadius of the circle when colorLegend.shape is set to "circle"stringfalsenull
   colorLegend.shapePaddingPadding to be applied to the legend cells for spacingnumberfalse5
   colorLegend.labelAlignAlignment of the legend cell labels.stringfalse"middle"
   colorLegend.labelOffsetDistance in pixels from legend label to its corresponding cellnumberfalse5
   colorLegend.titleYOffsetY-axis translation applied to the hover functionality explanation text{'nutsLevel':number}false{ 0: 330, 1: 330, 2: 330, 3: 330 }
dorling.sizeLegendObject which stores the configuration parameters for the circle-size legendobjectfalse
   sizeLegend.titleLegend titlestringfalse"Circle Size"
   sizeLegend.valuesArray of values used in the legend{'nutsLevel':array}falsemaxValue, maxValue / 2, maxValue / 10 for each NUTS level
   sizeLegend.textFunctionFunction used to manipulate legend labelsfunctionfalsefunction (value) { return value.toLocaleString() }
   sizeLegend.titleYOffsetY Offset in pixels applied to the legend's title{'nutsLevel':number}false{ '0': 10, '1': 10, '2': 10, '3': 10 }
   sizeLegend.titleXOffsetX Offset in pixels applied to the legend's title{'nutsLevel':number}false{ '0': 20, '1': 20, '2': 20, '3': 20 }
   sizeLegend.translateYY value to be applied to the translate transform of the size legend within the parent "legends" container{'nutsLevel':number}false{ '0': 0, '1': 0, '2': 0, '3': 0 }
   sizeLegend.bodyXOffsetLegend title{'nutsLevel':number}false{ '0': 50, '1': 50, '2': 50, '3': 50 }
   sizeLegend.bodyYOffsetLegend title{'nutsLevel':number}false{ '0': 90, '1': 90, '2': 90, '3': 90 }
   sizeLegend.labelsTranslateXX-axis translation applied to the labels of each size class{'nutsLevel':number}false{ '0': 90, '1': 90, '2': 90, '3': 90 }
   sizeLegend.labelsOffsetYY-axis offset applied to labels{'nutsLevel':number}false{ '0': 2, '1': 2, '2': 2, '3': 2 }

Tooltip

MethodDescriptionTypeRequiredDefault Value
dorling.tooltipObject which stores the configuration parameters for the circle-size legendobjectfalse
   tooltip.colorLabelLabel used to describe the color value of the featurestringfalse"Color value:"
   tooltip.colorUnitUnit label to be added after the color valuestringfalse""
   tooltip.sizeLabelLabel used to describe the size value of the featurestringfalse"Size value:"
   tooltip.sizeUnitUnit label to be added after the size valuestringfalse""
   tooltip.shareLabelLabel used to describe the percentage share value of the featurestringfalse"Share value:"
1.2.24

2 months ago

1.2.23

2 months ago

1.2.22

2 months ago

1.2.18

11 months ago

1.2.19

11 months ago

1.2.8

11 months ago

1.2.7

11 months ago

1.2.6

12 months ago

1.2.5

12 months ago

1.2.4

12 months ago

1.2.3

12 months ago

1.2.2

12 months ago

1.2.1

12 months ago

1.2.20

11 months ago

1.2.21

11 months ago

1.2.9

11 months ago

1.2.12

11 months ago

1.2.13

11 months ago

1.2.11

11 months ago

1.2.16

11 months ago

1.2.14

11 months ago

1.1.9

3 years ago

1.1.10

3 years ago

1.1.8

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago