@mathstack/viz 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/mathstack-viz.mjs +11024 -0
- package/fesm2022/mathstack-viz.mjs.map +1 -0
- package/package.json +14 -5
- package/types/mathstack-viz.d.ts +5830 -0
- package/CHANGELOG.md +0 -0
- package/cypress/fixtures/example.json +0 -5
- package/cypress/fixtures/usMap.json +0 -13511
- package/cypress/support/commands.ts +0 -104
- package/cypress/support/component-index.html +0 -12
- package/cypress/support/component.ts +0 -33
- package/cypress.config.ts +0 -9
- package/karma.conf.js +0 -62
- package/ng-package.json +0 -8
- package/project.json +0 -97
- package/src/.eslintrc.json +0 -35
- package/src/.prettierrc +0 -31
- package/src/lib/axes/base/config/xy-axis-builder.ts +0 -68
- package/src/lib/axes/base/config/xy-axis-config.ts +0 -35
- package/src/lib/axes/base/config/xy-axis-options.ts +0 -11
- package/src/lib/axes/base/xy-axis-base.spec.ts +0 -114
- package/src/lib/axes/base/xy-axis-base.ts +0 -305
- package/src/lib/axes/base/xy-axis-domain-lines.cy.ts +0 -511
- package/src/lib/axes/baseline/axis-baseline-builder.ts +0 -77
- package/src/lib/axes/baseline/axis-baseline-options.ts +0 -4
- package/src/lib/axes/baseline/axis-baseline.ts +0 -11
- package/src/lib/axes/grid/grid-builder.ts +0 -74
- package/src/lib/axes/grid/grid-config.ts +0 -13
- package/src/lib/axes/grid/grid-options.ts +0 -7
- package/src/lib/axes/index.ts +0 -40
- package/src/lib/axes/label/axis-label-builder.ts +0 -140
- package/src/lib/axes/label/axis-label-options.ts +0 -12
- package/src/lib/axes/label/axis-label.ts +0 -18
- package/src/lib/axes/label/axis-labels.cy.ts +0 -303
- package/src/lib/axes/ordinal/ordinal-axis-config.ts +0 -31
- package/src/lib/axes/ordinal/ordinal-axis.spec.ts +0 -30
- package/src/lib/axes/ordinal/ordinal-axis.ts +0 -26
- package/src/lib/axes/quantitative/quantitative-axis-config.ts +0 -39
- package/src/lib/axes/quantitative/quantitative-axis-ticks.cy.ts +0 -748
- package/src/lib/axes/quantitative/quantitative-axis.spec.ts +0 -537
- package/src/lib/axes/quantitative/quantitative-axis.ts +0 -191
- package/src/lib/axes/ticks/tick-wrap/tick-wrap-builder.ts +0 -141
- package/src/lib/axes/ticks/tick-wrap/tick-wrap-options.ts +0 -11
- package/src/lib/axes/ticks/tick-wrap/tick-wrap.cy.ts +0 -360
- package/src/lib/axes/ticks/tick-wrap/tick-wrap.ts +0 -21
- package/src/lib/axes/ticks/ticks-builder.ts +0 -370
- package/src/lib/axes/ticks/ticks-options.ts +0 -24
- package/src/lib/axes/ticks/ticks.ts +0 -33
- package/src/lib/axes/x/x-axis-config.ts +0 -48
- package/src/lib/axes/x/x-axis.spec.ts +0 -90
- package/src/lib/axes/x/x-axis.ts +0 -109
- package/src/lib/axes/x-ordinal/x-ordinal-axis-builder.ts +0 -75
- package/src/lib/axes/x-ordinal/x-ordinal-axis-config.ts +0 -27
- package/src/lib/axes/x-ordinal/x-ordinal-axis.component.ts +0 -33
- package/src/lib/axes/x-quantitative/x-quantitative-axis-builder.ts +0 -74
- package/src/lib/axes/x-quantitative/x-quantitative-axis-config.ts +0 -32
- package/src/lib/axes/x-quantitative/x-quantitative-axis.component.ts +0 -40
- package/src/lib/axes/xy-axis.module.ts +0 -20
- package/src/lib/axes/y/y-axis-config.ts +0 -47
- package/src/lib/axes/y/y-axis.spec.ts +0 -92
- package/src/lib/axes/y/y-axis.ts +0 -161
- package/src/lib/axes/y-ordinal/y-ordinal-axis-builder.ts +0 -76
- package/src/lib/axes/y-ordinal/y-ordinal-axis-config.ts +0 -29
- package/src/lib/axes/y-ordinal/y-ordinal-axis.component.ts +0 -33
- package/src/lib/axes/y-quantitative-axis/y-quantitative-axis-builder.ts +0 -74
- package/src/lib/axes/y-quantitative-axis/y-quantitative-axis-config.ts +0 -34
- package/src/lib/axes/y-quantitative-axis/y-quantitative-axis.component.ts +0 -40
- package/src/lib/bars/bars.component.scss +0 -0
- package/src/lib/bars/bars.component.spec.ts +0 -1470
- package/src/lib/bars/bars.component.ts +0 -717
- package/src/lib/bars/bars.cy.ts +0 -829
- package/src/lib/bars/bars.module.ts +0 -9
- package/src/lib/bars/config/backgrounds/bars-backgrounds-builder.ts +0 -51
- package/src/lib/bars/config/backgrounds/bars-backgrounds-options.ts +0 -4
- package/src/lib/bars/config/backgrounds/bars-backgrounds.ts +0 -11
- package/src/lib/bars/config/bars-builder.ts +0 -340
- package/src/lib/bars/config/bars-config.spec.ts +0 -132
- package/src/lib/bars/config/bars-config.ts +0 -70
- package/src/lib/bars/config/bars-dimensions.ts +0 -29
- package/src/lib/bars/config/bars-options.ts +0 -20
- package/src/lib/bars/config/labels/bars-labels-builder.ts +0 -89
- package/src/lib/bars/config/labels/bars-labels-options.ts +0 -6
- package/src/lib/bars/config/labels/bars-labels.cy.ts +0 -781
- package/src/lib/bars/config/labels/bars-labels.ts +0 -13
- package/src/lib/bars/events/actions/bars-click-actions.ts +0 -23
- package/src/lib/bars/events/actions/bars-hover-actions.ts +0 -43
- package/src/lib/bars/events/actions/bars-hover-move-actions.ts +0 -21
- package/src/lib/bars/events/bars-events.directive.spec.ts +0 -186
- package/src/lib/bars/events/bars-events.directive.ts +0 -235
- package/src/lib/bars/events/bars-interaction-output.ts +0 -17
- package/src/lib/bars/events/bars-tooltip-positioner.ts +0 -24
- package/src/lib/bars/index.ts +0 -18
- package/src/lib/charts/chart/chart-scaling.cy.ts +0 -323
- package/src/lib/charts/chart/chart.component.html +0 -45
- package/src/lib/charts/chart/chart.component.scss +0 -37
- package/src/lib/charts/chart/chart.component.ts +0 -243
- package/src/lib/charts/chart/chart.token.ts +0 -4
- package/src/lib/charts/chart/chart.ts +0 -5
- package/src/lib/charts/chart/config/chart-builder.ts +0 -194
- package/src/lib/charts/chart/config/chart-config.ts +0 -21
- package/src/lib/charts/chart/config/chart-options.ts +0 -11
- package/src/lib/charts/chart.module.ts +0 -10
- package/src/lib/charts/index.ts +0 -9
- package/src/lib/charts/map-chart/map-chart.component.scss +0 -0
- package/src/lib/charts/map-chart/map-chart.component.spec.ts +0 -35
- package/src/lib/charts/map-chart/map-chart.component.ts +0 -61
- package/src/lib/charts/xy-chart/xy-chart.component.spec.ts +0 -34
- package/src/lib/charts/xy-chart/xy-chart.component.ts +0 -65
- package/src/lib/core/common-behaviors/constructor.ts +0 -7
- package/src/lib/core/index.ts +0 -11
- package/src/lib/core/pipes/resize-chart-height.pipe.spec.ts +0 -23
- package/src/lib/core/pipes/resize-chart-height.pipe.ts +0 -20
- package/src/lib/core/styles/_spacing.scss +0 -4
- package/src/lib/core/types/layout.ts +0 -28
- package/src/lib/core/types/scale.ts +0 -6
- package/src/lib/core/types/utility.ts +0 -11
- package/src/lib/core/types/values.ts +0 -10
- package/src/lib/core/utilities/colors.spec.ts +0 -57
- package/src/lib/core/utilities/colors.ts +0 -42
- package/src/lib/core/utilities/fill-utilities.spec.ts +0 -25
- package/src/lib/core/utilities/fill-utilities.ts +0 -21
- package/src/lib/core/utilities/type-guards.spec.ts +0 -55
- package/src/lib/core/utilities/type-guards.ts +0 -33
- package/src/lib/core/utilities/value-format.ts +0 -21
- package/src/lib/core/utilities/values.spec.ts +0 -954
- package/src/lib/core/utilities/values.ts +0 -189
- package/src/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position-builder.ts +0 -105
- package/src/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position-options.ts +0 -24
- package/src/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position.spec.ts +0 -66
- package/src/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position.ts +0 -72
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/concrete-domain-padding.ts +0 -10
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/domain-padding.ts +0 -76
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/domain-test-utility.ts +0 -130
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/percent-over/percent-over-options.ts +0 -3
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/percent-over/percent-over.ts +0 -37
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/pixel/pixel-options.ts +0 -3
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/pixel/pixel.ts +0 -73
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/quantitative-domain-padding.cy.ts +0 -978
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-interval/round-to-interval-options.ts +0 -3
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-interval/round-to-interval.ts +0 -27
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-sig-fig/round-to-sig-fig-options.ts +0 -3
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-sig-fig/round-to-sig-fig.ts +0 -30
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position-builder.ts +0 -183
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position-options.ts +0 -8
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position.spec.ts +0 -28
- package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position.ts +0 -62
- package/src/lib/data-dimensions/continuous-quantitative/number-dimension/number-dimension-options.ts +0 -15
- package/src/lib/data-dimensions/continuous-quantitative/number-dimension/number-dimension.spec.ts +0 -155
- package/src/lib/data-dimensions/continuous-quantitative/number-dimension/number-dimension.ts +0 -57
- package/src/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value-builder.ts +0 -166
- package/src/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value-options.ts +0 -10
- package/src/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value.spec.ts +0 -34
- package/src/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value.ts +0 -57
- package/src/lib/data-dimensions/dimension-builder.ts +0 -45
- package/src/lib/data-dimensions/dimension-options.ts +0 -12
- package/src/lib/data-dimensions/dimension.ts +0 -30
- package/src/lib/data-dimensions/index.ts +0 -31
- package/src/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position-builder.ts +0 -122
- package/src/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position-options.ts +0 -12
- package/src/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position.spec.ts +0 -83
- package/src/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position.ts +0 -101
- package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value-builder.ts +0 -108
- package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value-options.ts +0 -12
- package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value.cy.ts +0 -384
- package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value.spec.ts +0 -63
- package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value.ts +0 -79
- package/src/lib/data-export/data-export-config.ts +0 -98
- package/src/lib/data-export/data-export.spec.ts +0 -33
- package/src/lib/data-export/data-export.ts +0 -87
- package/src/lib/data-export/index.ts +0 -2
- package/src/lib/dots/config/dots-builder.ts +0 -442
- package/src/lib/dots/config/dots-config.spec.ts +0 -123
- package/src/lib/dots/config/dots-config.ts +0 -81
- package/src/lib/dots/config/dots-options.ts +0 -32
- package/src/lib/dots/dots.component.scss +0 -0
- package/src/lib/dots/dots.component.spec.ts +0 -143
- package/src/lib/dots/dots.component.ts +0 -291
- package/src/lib/dots/dots.cy.ts +0 -594
- package/src/lib/dots/dots.module.ts +0 -9
- package/src/lib/dots/events/actions/dots-hover-actions.ts +0 -19
- package/src/lib/dots/events/actions/dots-hover-move-actions.ts +0 -38
- package/src/lib/dots/events/dots-events.directive.ts +0 -214
- package/src/lib/dots/events/dots-interaction-output.ts +0 -15
- package/src/lib/dots/events/dots-tooltip-positioner.ts +0 -24
- package/src/lib/dots/index.ts +0 -10
- package/src/lib/events/events.directive.ts +0 -184
- package/src/lib/events/events.types.ts +0 -57
- package/src/lib/events/index.ts +0 -4
- package/src/lib/events/interaction-output.ts +0 -34
- package/src/lib/events/tooltip-positioner.ts +0 -15
- package/src/lib/fill-definitions/fill-definitions.ts +0 -4
- package/src/lib/fill-definitions/index.ts +0 -1
- package/src/lib/geographies/config/geographies-builder.ts +0 -224
- package/src/lib/geographies/config/geographies-config.spec.ts +0 -100
- package/src/lib/geographies/config/geographies-config.ts +0 -81
- package/src/lib/geographies/config/geographies-options.ts +0 -37
- package/src/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer-builder.ts +0 -212
- package/src/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer-options.ts +0 -26
- package/src/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer.spec.ts +0 -119
- package/src/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer.ts +0 -148
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data/attribute-data-dimension-builder.ts +0 -65
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data/attribute-data-dimension-options.ts +0 -15
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data/attribute-data-dimension.ts +0 -32
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data-bin-enums.ts +0 -10
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data-bin-types.ts +0 -15
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins-builder.ts +0 -18
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins-options.ts +0 -8
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins.spec.ts +0 -60
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins.ts +0 -34
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins-builder.ts +0 -46
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins-options.ts +0 -8
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins.cy.ts +0 -437
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins.spec.ts +0 -105
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins.ts +0 -54
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins-builder.ts +0 -65
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins-options.ts +0 -9
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins.spec.ts +0 -82
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins.ts +0 -81
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks.cy.ts +0 -378
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins-builder.ts +0 -50
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins-options.ts +0 -8
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins.cy.ts +0 -362
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins.spec.ts +0 -72
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins.ts +0 -56
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins-builder.ts +0 -60
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins-options.ts +0 -9
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins.cy.ts +0 -307
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins.spec.ts +0 -104
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins.ts +0 -89
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins-builder.ts +0 -62
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins-options.ts +0 -8
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins.cy.ts +0 -265
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins.spec.ts +0 -42
- package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins.ts +0 -42
- package/src/lib/geographies/config/layers/geographies-layer/geographies-layer-builder.ts +0 -116
- package/src/lib/geographies/config/layers/geographies-layer/geographies-layer-options.ts +0 -20
- package/src/lib/geographies/config/layers/geographies-layer/geographies-layer.ts +0 -104
- package/src/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer-builder.ts +0 -111
- package/src/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer-options.ts +0 -19
- package/src/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer.spec.ts +0 -41
- package/src/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer.ts +0 -67
- package/src/lib/geographies/config/layers/labels/geographies-labels-builder.ts +0 -269
- package/src/lib/geographies/config/layers/labels/geographies-labels-options.ts +0 -45
- package/src/lib/geographies/config/layers/labels/geographies-labels.ts +0 -38
- package/src/lib/geographies/events/actions/geographies-click-actions.ts +0 -21
- package/src/lib/geographies/events/actions/geographies-hover-actions.ts +0 -17
- package/src/lib/geographies/events/actions/geographies-hover-move-actions.ts +0 -19
- package/src/lib/geographies/events/geographies-events.directive.spec.ts +0 -225
- package/src/lib/geographies/events/geographies-events.directive.ts +0 -235
- package/src/lib/geographies/events/geographies-interaction-output.ts +0 -17
- package/src/lib/geographies/events/geographies-tooltip-positioner.ts +0 -23
- package/src/lib/geographies/geographies-feature.ts +0 -16
- package/src/lib/geographies/geographies.component.html +0 -1
- package/src/lib/geographies/geographies.component.scss +0 -0
- package/src/lib/geographies/geographies.component.spec.ts +0 -148
- package/src/lib/geographies/geographies.component.ts +0 -318
- package/src/lib/geographies/geographies.cy.ts +0 -640
- package/src/lib/geographies/geographies.module.ts +0 -9
- package/src/lib/geographies/index.ts +0 -32
- package/src/lib/grouped-bars/config/grouped-bars-builder.ts +0 -66
- package/src/lib/grouped-bars/config/grouped-bars-config.ts +0 -41
- package/src/lib/grouped-bars/config/grouped-bars-options.ts +0 -9
- package/src/lib/grouped-bars/events/grouped-bars-events.directive.ts +0 -221
- package/src/lib/grouped-bars/grouped-bars.component.scss +0 -0
- package/src/lib/grouped-bars/grouped-bars.component.spec.ts +0 -25
- package/src/lib/grouped-bars/grouped-bars.component.ts +0 -94
- package/src/lib/grouped-bars/grouped-bars.module.ts +0 -9
- package/src/lib/grouped-bars/index.ts +0 -10
- package/src/lib/image-download/image-download-config.ts +0 -57
- package/src/lib/image-download/image-download-enums.ts +0 -7
- package/src/lib/image-download/image-download-options.ts +0 -14
- package/src/lib/image-download/image-download.service.ts +0 -70
- package/src/lib/image-download/index.ts +0 -4
- package/src/lib/lines/config/area-fills/area-fills-builder.ts +0 -87
- package/src/lib/lines/config/area-fills/area-fills-options.ts +0 -8
- package/src/lib/lines/config/area-fills/area-fills.ts +0 -14
- package/src/lib/lines/config/lines-builder.ts +0 -242
- package/src/lib/lines/config/lines-config.spec.ts +0 -52
- package/src/lib/lines/config/lines-config.ts +0 -96
- package/src/lib/lines/config/lines-options.ts +0 -19
- package/src/lib/lines/config/stroke/lines-stroke-builder.ts +0 -135
- package/src/lib/lines/config/stroke/lines-stroke-options.ts +0 -6
- package/src/lib/lines/config/stroke/lines-stroke.ts +0 -15
- package/src/lib/lines/events/actions/lines-click-actions.ts +0 -17
- package/src/lib/lines/events/actions/lines-hover-move-actions.ts +0 -113
- package/src/lib/lines/events/actions/lines-marker-click-actions.ts +0 -29
- package/src/lib/lines/events/lines-events.directive.spec.ts +0 -152
- package/src/lib/lines/events/lines-events.directive.ts +0 -310
- package/src/lib/lines/events/lines-interaction-output.ts +0 -17
- package/src/lib/lines/events/lines-tooltip-positioner.ts +0 -24
- package/src/lib/lines/index.ts +0 -17
- package/src/lib/lines/lines.component.scss +0 -0
- package/src/lib/lines/lines.component.spec.ts +0 -95
- package/src/lib/lines/lines.component.ts +0 -425
- package/src/lib/lines/lines.cy.ts +0 -738
- package/src/lib/lines/lines.module.ts +0 -9
- package/src/lib/map-legend/continuous-legend/continuous-legend.component.html +0 -28
- package/src/lib/map-legend/continuous-legend/continuous-legend.component.scss +0 -76
- package/src/lib/map-legend/continuous-legend/continuous-legend.component.spec.ts +0 -61
- package/src/lib/map-legend/continuous-legend/continuous-legend.component.ts +0 -82
- package/src/lib/map-legend/discontinuous-legend/discontinuous-legend.component.html +0 -40
- package/src/lib/map-legend/discontinuous-legend/discontinuous-legend.component.scss +0 -141
- package/src/lib/map-legend/discontinuous-legend/discontinuous-legend.component.spec.ts +0 -75
- package/src/lib/map-legend/discontinuous-legend/discontinuous-legend.component.ts +0 -57
- package/src/lib/map-legend/index.ts +0 -2
- package/src/lib/map-legend/map-legend-base.spec.ts +0 -190
- package/src/lib/map-legend/map-legend-base.ts +0 -99
- package/src/lib/map-legend/map-legend.component.html +0 -24
- package/src/lib/map-legend/map-legend.component.scss +0 -0
- package/src/lib/map-legend/map-legend.component.spec.ts +0 -125
- package/src/lib/map-legend/map-legend.component.ts +0 -80
- package/src/lib/map-legend/map-legend.module.ts +0 -8
- package/src/lib/marks/aux-marks/aux-marks.ts +0 -18
- package/src/lib/marks/aux-marks/config/aux-marks-builder.ts +0 -25
- package/src/lib/marks/aux-marks/config/aux-marks-config.ts +0 -6
- package/src/lib/marks/config/marks-config.ts +0 -14
- package/src/lib/marks/config/marks-options.ts +0 -9
- package/src/lib/marks/index.ts +0 -15
- package/src/lib/marks/map-marks/map-aux-marks/map-aux-marks.spec.ts +0 -74
- package/src/lib/marks/map-marks/map-aux-marks/map-aux-marks.ts +0 -40
- package/src/lib/marks/map-marks/map-primary-marks/map-primary-marks.spec.ts +0 -79
- package/src/lib/marks/map-marks/map-primary-marks/map-primary-marks.ts +0 -63
- package/src/lib/marks/marks.ts +0 -39
- package/src/lib/marks/primary-marks/config/primary-marks-builder.ts +0 -75
- package/src/lib/marks/primary-marks/config/primary-marks-config.ts +0 -9
- package/src/lib/marks/primary-marks/primary-marks-base.spec.ts +0 -58
- package/src/lib/marks/primary-marks/primary-marks.ts +0 -43
- package/src/lib/marks/xy-marks/xy-aux-marks/xy-aux-marks.ts +0 -40
- package/src/lib/marks/xy-marks/xy-marks-config.ts +0 -5
- package/src/lib/marks/xy-marks/xy-marks.ts +0 -10
- package/src/lib/marks/xy-marks/xy-primary-marks/xy-primary-marks-config.ts +0 -7
- package/src/lib/marks/xy-marks/xy-primary-marks/xy-primary-marks.spec.ts +0 -186
- package/src/lib/marks/xy-marks/xy-primary-marks/xy-primary-marks.ts +0 -72
- package/src/lib/point-markers/index.ts +0 -3
- package/src/lib/point-markers/point-markers-builder.ts +0 -93
- package/src/lib/point-markers/point-markers-options.ts +0 -6
- package/src/lib/point-markers/point-markers.ts +0 -13
- package/src/lib/quantitative-rules/config/labels/quantitative-rules-labels-builder.ts +0 -162
- package/src/lib/quantitative-rules/config/labels/quantitative-rules-labels-options.ts +0 -17
- package/src/lib/quantitative-rules/config/labels/quantitative-rules-labels.ts +0 -26
- package/src/lib/quantitative-rules/config/quantitative-rules-builder.ts +0 -134
- package/src/lib/quantitative-rules/config/quantitative-rules-config.ts +0 -21
- package/src/lib/quantitative-rules/config/quantitative-rules-dimensions.ts +0 -20
- package/src/lib/quantitative-rules/config/quantitative-rules-options.ts +0 -13
- package/src/lib/quantitative-rules/index.ts +0 -6
- package/src/lib/quantitative-rules/quantitative-rules.component.scss +0 -3
- package/src/lib/quantitative-rules/quantitative-rules.component.spec.ts +0 -50
- package/src/lib/quantitative-rules/quantitative-rules.component.ts +0 -224
- package/src/lib/quantitative-rules/quantitative-rules.cy.ts +0 -549
- package/src/lib/quantitative-rules/quantitative-rules.module.ts +0 -8
- package/src/lib/stacked-area/config/stacked-area-builder.ts +0 -264
- package/src/lib/stacked-area/config/stacked-area-config.spec.ts +0 -107
- package/src/lib/stacked-area/config/stacked-area-config.ts +0 -109
- package/src/lib/stacked-area/config/stacked-area-options.ts +0 -28
- package/src/lib/stacked-area/events/actions/stacked-area-hover-move-actions.ts +0 -17
- package/src/lib/stacked-area/events/stacked-area-events.directive.spec.ts +0 -168
- package/src/lib/stacked-area/events/stacked-area-events.directive.ts +0 -272
- package/src/lib/stacked-area/events/stacked-area-interaction-output.ts +0 -33
- package/src/lib/stacked-area/events/stacked-area-tooltip-positioner.ts +0 -37
- package/src/lib/stacked-area/index.ts +0 -7
- package/src/lib/stacked-area/stacked-area.component.scss +0 -0
- package/src/lib/stacked-area/stacked-area.component.spec.ts +0 -41
- package/src/lib/stacked-area/stacked-area.component.ts +0 -241
- package/src/lib/stacked-area/stacked-area.module.ts +0 -9
- package/src/lib/stacked-bars/config/stacked-bars-builder.ts +0 -109
- package/src/lib/stacked-bars/config/stacked-bars-config.spec.ts +0 -122
- package/src/lib/stacked-bars/config/stacked-bars-config.ts +0 -79
- package/src/lib/stacked-bars/config/stacked-bars-options.ts +0 -16
- package/src/lib/stacked-bars/events/actions/stacked-bars-click-actions.ts +0 -23
- package/src/lib/stacked-bars/events/actions/stacked-bars-hover-actions.ts +0 -22
- package/src/lib/stacked-bars/events/actions/stacked-bars-hover-move-actions.ts +0 -21
- package/src/lib/stacked-bars/events/stacked-bars-events.directive.spec.ts +0 -266
- package/src/lib/stacked-bars/events/stacked-bars-events.directive.ts +0 -240
- package/src/lib/stacked-bars/index.ts +0 -10
- package/src/lib/stacked-bars/stacked-bars.component.scss +0 -0
- package/src/lib/stacked-bars/stacked-bars.component.spec.ts +0 -25
- package/src/lib/stacked-bars/stacked-bars.component.ts +0 -158
- package/src/lib/stacked-bars/stacked-bars.module.ts +0 -9
- package/src/lib/stroke/base/stroke-base-options.ts +0 -7
- package/src/lib/stroke/base/stroke-base.ts +0 -9
- package/src/lib/stroke/index.ts +0 -5
- package/src/lib/stroke/stroke-builder.ts +0 -103
- package/src/lib/stroke/stroke-options.ts +0 -5
- package/src/lib/stroke/stroke.ts +0 -12
- package/src/lib/svg-text-wrap/index.ts +0 -3
- package/src/lib/svg-text-wrap/svg-text-wrap-builder.ts +0 -105
- package/src/lib/svg-text-wrap/svg-text-wrap-options.ts +0 -8
- package/src/lib/svg-text-wrap/svg-text-wrap.ts +0 -137
- package/src/lib/testing/data/continent-population-year-data.ts +0 -126
- package/src/lib/testing/data/country-area-continent.ts +0 -59
- package/src/lib/testing/data/state-population-income-year-data.ts +0 -123
- package/src/lib/testing/stubs/bars.component.stub.ts +0 -12
- package/src/lib/testing/stubs/chart.component.stub.ts +0 -6
- package/src/lib/testing/stubs/click.directive.stub.ts +0 -15
- package/src/lib/testing/stubs/core/destroy-ref.stub.ts +0 -9
- package/src/lib/testing/stubs/core/overlay-ref.stub.ts +0 -13
- package/src/lib/testing/stubs/core/overlay.stub.ts +0 -8
- package/src/lib/testing/stubs/event.directive.stub.ts +0 -10
- package/src/lib/testing/stubs/hover-move.directive.stub.ts +0 -17
- package/src/lib/testing/stubs/hover.directive.stub.ts +0 -14
- package/src/lib/testing/stubs/input-event.directive.stub.ts +0 -9
- package/src/lib/testing/stubs/lines.component.stub.ts +0 -13
- package/src/lib/testing/stubs/map-aux-marks.stub.ts +0 -10
- package/src/lib/testing/stubs/map-chart.component.stub.ts +0 -3
- package/src/lib/testing/stubs/map-legend-content.stub.ts +0 -16
- package/src/lib/testing/stubs/map-legend.component.stub.ts +0 -10
- package/src/lib/testing/stubs/map-primary-marks.stub.ts +0 -16
- package/src/lib/testing/stubs/ordinal-axis.stub.ts +0 -18
- package/src/lib/testing/stubs/primary-marks.stub.ts +0 -18
- package/src/lib/testing/stubs/quantitative-axis.stub.ts +0 -18
- package/src/lib/testing/stubs/services/main.service.stub.ts +0 -5
- package/src/lib/testing/stubs/services/utilities.service.stub.ts +0 -7
- package/src/lib/testing/stubs/stacked-area.component.stub.ts +0 -13
- package/src/lib/testing/stubs/x-axis.stub.ts +0 -10
- package/src/lib/testing/stubs/xy-axis.class.stub.ts +0 -20
- package/src/lib/testing/stubs/xy-axis.stub.ts +0 -44
- package/src/lib/testing/stubs/xy-chart.component.stub.ts +0 -5
- package/src/lib/testing/stubs/xy-data-marks.stub.ts +0 -15
- package/src/lib/testing/stubs/y-axis.stub.ts +0 -15
- package/src/lib/tooltips/config/tooltip.ts +0 -11
- package/src/lib/tooltips/html-tooltip/config/html-tooltip-builder.ts +0 -134
- package/src/lib/tooltips/html-tooltip/config/html-tooltip-config.ts +0 -21
- package/src/lib/tooltips/html-tooltip/config/html-tooltip-options.ts +0 -12
- package/src/lib/tooltips/html-tooltip/config/position/tooltip-position-builder.ts +0 -191
- package/src/lib/tooltips/html-tooltip/config/position/tooltip-position.ts +0 -42
- package/src/lib/tooltips/html-tooltip/config/size/tooltip-size-builder.ts +0 -75
- package/src/lib/tooltips/html-tooltip/config/size/tooltip-size-options.ts +0 -8
- package/src/lib/tooltips/html-tooltip/config/size/tooltip-size.ts +0 -15
- package/src/lib/tooltips/html-tooltip/html-tooltip.directive.spec.ts +0 -537
- package/src/lib/tooltips/html-tooltip/html-tooltip.directive.ts +0 -210
- package/src/lib/tooltips/html-tooltip/html-tooltip.module.ts +0 -16
- package/src/lib/tooltips/html-tooltip/tooltip-triangle/tooltip-triangle.component.html +0 -41
- package/src/lib/tooltips/html-tooltip/tooltip-triangle/tooltip-triangle.component.scss +0 -63
- package/src/lib/tooltips/html-tooltip/tooltip-triangle/tooltip-triangle.component.ts +0 -19
- package/src/lib/tooltips/index.ts +0 -11
- package/src/lib/tooltips/svg-tooltip/config/svg-tooltip.ts +0 -5
- package/src/lib/xy-background/index.ts +0 -2
- package/src/lib/xy-background/xy-background.component.html +0 -10
- package/src/lib/xy-background/xy-background.component.scss +0 -0
- package/src/lib/xy-background/xy-background.component.spec.ts +0 -24
- package/src/lib/xy-background/xy-background.component.ts +0 -19
- package/src/lib/xy-background/xy-background.module.ts +0 -8
- package/src/public-api.ts +0 -26
- package/src/test.ts +0 -15
- package/tsconfig.doc.json +0 -4
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -23
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -10
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @angular-eslint/prefer-standalone */
|
|
2
|
-
import { Component, Input } from '@angular/core';
|
|
3
|
-
import {
|
|
4
|
-
ChartConfig,
|
|
5
|
-
GeographiesConfig,
|
|
6
|
-
VicChartConfigBuilder,
|
|
7
|
-
VicChartModule,
|
|
8
|
-
VicGeographiesConfigBuilder,
|
|
9
|
-
VicGeographiesModule,
|
|
10
|
-
} from '@mathstack/viz';
|
|
11
|
-
import { ascending, max } from 'd3';
|
|
12
|
-
import {
|
|
13
|
-
FeatureCollection,
|
|
14
|
-
GeoJsonProperties,
|
|
15
|
-
MultiPolygon,
|
|
16
|
-
Polygon,
|
|
17
|
-
} from 'geojson';
|
|
18
|
-
import { beforeEach, cy, describe, expect, it } from 'local-cypress';
|
|
19
|
-
import { uniqBy } from 'lodash-es';
|
|
20
|
-
import * as topojson from 'topojson-client';
|
|
21
|
-
import { GeometryCollection, Objects, Topology } from 'topojson-specification';
|
|
22
|
-
import {
|
|
23
|
-
StateIncomePopulationYearDatum,
|
|
24
|
-
stateIncomePopulationYearData,
|
|
25
|
-
} from '../../../../../../testing/data/state-population-income-year-data';
|
|
26
|
-
|
|
27
|
-
const margin = { top: 36, right: 36, bottom: 36, left: 36 };
|
|
28
|
-
const chartHeight = 400;
|
|
29
|
-
const chartWidth = 600;
|
|
30
|
-
const attributeData = stateIncomePopulationYearData
|
|
31
|
-
.filter((x) => x.year === 2020)
|
|
32
|
-
.filter((x) => x.state !== 'Puerto Rico');
|
|
33
|
-
|
|
34
|
-
interface TestMapGeometryProperties extends GeoJsonProperties {
|
|
35
|
-
name: string;
|
|
36
|
-
id: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface TestMapObjects extends Objects {
|
|
40
|
-
country: GeometryCollection<TestMapGeometryProperties>;
|
|
41
|
-
states: GeometryCollection<TestMapGeometryProperties>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
type TestUsMapTopology = Topology<TestMapObjects>;
|
|
45
|
-
|
|
46
|
-
// ***********************************************************
|
|
47
|
-
// Geographies component set up
|
|
48
|
-
// ***********************************************************
|
|
49
|
-
@Component({
|
|
50
|
-
// eslint-disable-next-line @angular-eslint/component-selector
|
|
51
|
-
selector: 'app-test-geographies',
|
|
52
|
-
template: `
|
|
53
|
-
<vic-map-chart [config]="chartConfig">
|
|
54
|
-
<svg:g
|
|
55
|
-
vic-primary-marks-geographies
|
|
56
|
-
svg-elements
|
|
57
|
-
[config]="geographiesConfig"
|
|
58
|
-
[vicGeographiesHoversActions]="hoverActions"
|
|
59
|
-
(vicGeographiesHoverOutput)="updateTooltipForNewOutput($event)"
|
|
60
|
-
></svg:g>
|
|
61
|
-
</vic-map-chart>
|
|
62
|
-
`,
|
|
63
|
-
styles: [],
|
|
64
|
-
imports: [VicChartModule, VicGeographiesModule],
|
|
65
|
-
})
|
|
66
|
-
class TestGeographiesComponent {
|
|
67
|
-
@Input() geographiesConfig: GeographiesConfig<
|
|
68
|
-
StateIncomePopulationYearDatum,
|
|
69
|
-
TestMapGeometryProperties
|
|
70
|
-
>;
|
|
71
|
-
chartConfig: ChartConfig = new VicChartConfigBuilder()
|
|
72
|
-
.margin(margin)
|
|
73
|
-
.maxWidth(chartWidth)
|
|
74
|
-
.maxHeight(chartHeight)
|
|
75
|
-
.scalingStrategy('responsive-width')
|
|
76
|
-
.getConfig();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const mountGeographiesComponent = (
|
|
80
|
-
geographiesConfig: GeographiesConfig<
|
|
81
|
-
StateIncomePopulationYearDatum,
|
|
82
|
-
TestMapGeometryProperties
|
|
83
|
-
>
|
|
84
|
-
): void => {
|
|
85
|
-
cy.mount(TestGeographiesComponent, {
|
|
86
|
-
componentProperties: {
|
|
87
|
-
geographiesConfig: geographiesConfig,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// ***********************************************************
|
|
93
|
-
// Test dimension
|
|
94
|
-
// ***********************************************************
|
|
95
|
-
describe('the Equal Frequencies Bins Attribute Data dimension', () => {
|
|
96
|
-
let geographiesConfig: GeographiesConfig<
|
|
97
|
-
StateIncomePopulationYearDatum,
|
|
98
|
-
TestMapGeometryProperties
|
|
99
|
-
>;
|
|
100
|
-
beforeEach(() => {
|
|
101
|
-
geographiesConfig = undefined;
|
|
102
|
-
});
|
|
103
|
-
it('Uses dimension defaults and creates bins in the data and colors values accordingly with default colors', () => {
|
|
104
|
-
cy.fixture('usMap.json').then((response) => {
|
|
105
|
-
const usMap: TestUsMapTopology = response;
|
|
106
|
-
const usBoundary = topojson.feature(
|
|
107
|
-
usMap,
|
|
108
|
-
usMap.objects.country
|
|
109
|
-
) as FeatureCollection<MultiPolygon, TestMapGeometryProperties>;
|
|
110
|
-
const states = topojson.feature(
|
|
111
|
-
usMap,
|
|
112
|
-
usMap.objects.states
|
|
113
|
-
) as FeatureCollection<MultiPolygon | Polygon, TestMapGeometryProperties>;
|
|
114
|
-
geographiesConfig = new VicGeographiesConfigBuilder<
|
|
115
|
-
StateIncomePopulationYearDatum,
|
|
116
|
-
TestMapGeometryProperties
|
|
117
|
-
>()
|
|
118
|
-
.boundary(usBoundary)
|
|
119
|
-
.featureIndexAccessor((d) => d.properties.name)
|
|
120
|
-
.attributeDataLayer((dimension) =>
|
|
121
|
-
dimension
|
|
122
|
-
.data(attributeData)
|
|
123
|
-
.class((d) => d.name.split(' ').join('-'))
|
|
124
|
-
.geographies(states.features)
|
|
125
|
-
.geographyIndexAccessor((d) => d.state)
|
|
126
|
-
.equalFrequenciesBins((bins) => bins.valueAccessor((d) => d.income))
|
|
127
|
-
)
|
|
128
|
-
.getConfig();
|
|
129
|
-
mountGeographiesComponent(geographiesConfig);
|
|
130
|
-
// see https://d3js.org/d3-scale/quantile#quantile_domain for how d3 quantile works
|
|
131
|
-
const sortedAttributeData = attributeData
|
|
132
|
-
.filter((x) => {
|
|
133
|
-
const coerced = Number(x.income);
|
|
134
|
-
return !(isNaN(coerced) || coerced === null || coerced === undefined);
|
|
135
|
-
})
|
|
136
|
-
.sort((a, b) => ascending(Number(a.income), Number(b.income)));
|
|
137
|
-
const binMaxValues = [
|
|
138
|
-
...geographiesConfig.attributeDataLayer.attributeDimension
|
|
139
|
-
.getScale()
|
|
140
|
-
['quantiles'](),
|
|
141
|
-
max(sortedAttributeData.map((x) => x.income)),
|
|
142
|
-
];
|
|
143
|
-
const statesByBin = sortedAttributeData.reduce((acc, d) => {
|
|
144
|
-
const binNumber = binMaxValues.reduce((acc, maxValue, i) => {
|
|
145
|
-
if (
|
|
146
|
-
(d.income < maxValue || i === binMaxValues.length - 1) &&
|
|
147
|
-
acc === null
|
|
148
|
-
) {
|
|
149
|
-
acc = i;
|
|
150
|
-
return acc;
|
|
151
|
-
} else {
|
|
152
|
-
return acc;
|
|
153
|
-
}
|
|
154
|
-
}, null);
|
|
155
|
-
if (!acc[binNumber]) {
|
|
156
|
-
acc[binNumber] = [];
|
|
157
|
-
}
|
|
158
|
-
acc[binNumber].push(d.state);
|
|
159
|
-
return acc;
|
|
160
|
-
}, []);
|
|
161
|
-
cy.get('.vic-geographies-group path').then((states) => {
|
|
162
|
-
// get unique bin colors for geographies in attribute data
|
|
163
|
-
const binColors = uniqBy(
|
|
164
|
-
states
|
|
165
|
-
.filter(
|
|
166
|
-
(i, el) =>
|
|
167
|
-
!!attributeData.find(
|
|
168
|
-
(x) => x.state.split(' ').join('-') === el.classList[0]
|
|
169
|
-
)
|
|
170
|
-
)
|
|
171
|
-
.map((i, el) => {
|
|
172
|
-
const rg = el.getAttribute('fill').split('(')[1].split(',');
|
|
173
|
-
return { r: rg[0].trim(), g: rg[1].trim() };
|
|
174
|
-
}),
|
|
175
|
-
(x) => x.r
|
|
176
|
-
)
|
|
177
|
-
.sort((a, b) => b.r - a.r)
|
|
178
|
-
.map((x) => `rgb(${x.r}, ${x.g}, 255)`);
|
|
179
|
-
binColors.forEach((color, i) => {
|
|
180
|
-
// check that the states in each bin have the same color
|
|
181
|
-
statesByBin[i].forEach((state) => {
|
|
182
|
-
cy.get(
|
|
183
|
-
`.vic-geographies-group.${state.split(' ').join('-')} path`
|
|
184
|
-
).then((path) => {
|
|
185
|
-
expect(path.attr('fill')).to.eq(color);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('Colors the data with provided range when a user provides a range of the same length as num bins', () => {
|
|
194
|
-
const range = ['red', 'orange', 'yellow', 'green', 'blue'];
|
|
195
|
-
cy.fixture('usMap.json').then((response) => {
|
|
196
|
-
const usMap: TestUsMapTopology = response;
|
|
197
|
-
const usBoundary = topojson.feature(
|
|
198
|
-
usMap,
|
|
199
|
-
usMap.objects.country
|
|
200
|
-
) as FeatureCollection<MultiPolygon, TestMapGeometryProperties>;
|
|
201
|
-
const states = topojson.feature(
|
|
202
|
-
usMap,
|
|
203
|
-
usMap.objects.states
|
|
204
|
-
) as FeatureCollection<MultiPolygon | Polygon, TestMapGeometryProperties>;
|
|
205
|
-
geographiesConfig = new VicGeographiesConfigBuilder<
|
|
206
|
-
StateIncomePopulationYearDatum,
|
|
207
|
-
TestMapGeometryProperties
|
|
208
|
-
>()
|
|
209
|
-
.boundary(usBoundary)
|
|
210
|
-
.featureIndexAccessor((d) => d.properties.name)
|
|
211
|
-
.attributeDataLayer((dimension) =>
|
|
212
|
-
dimension
|
|
213
|
-
.data(attributeData)
|
|
214
|
-
.class((d) => d.name.split(' ').join('-'))
|
|
215
|
-
.geographies(states.features)
|
|
216
|
-
.geographyIndexAccessor((d) => d.state)
|
|
217
|
-
.equalFrequenciesBins((bins) =>
|
|
218
|
-
bins
|
|
219
|
-
.valueAccessor((d) => d.income)
|
|
220
|
-
.numBins(5)
|
|
221
|
-
.range(range)
|
|
222
|
-
)
|
|
223
|
-
)
|
|
224
|
-
.getConfig();
|
|
225
|
-
mountGeographiesComponent(geographiesConfig);
|
|
226
|
-
// see https://d3js.org/d3-scale/quantile#quantile_domain for how d3 quantile works
|
|
227
|
-
const sortedAttributeData = attributeData
|
|
228
|
-
.filter((x) => {
|
|
229
|
-
const coerced = Number(x.income);
|
|
230
|
-
return !(isNaN(coerced) || coerced === null || coerced === undefined);
|
|
231
|
-
})
|
|
232
|
-
.sort((a, b) => ascending(Number(a.income), Number(b.income)));
|
|
233
|
-
const binMaxValues = [
|
|
234
|
-
...geographiesConfig.attributeDataLayer.attributeDimension
|
|
235
|
-
.getScale()
|
|
236
|
-
['quantiles'](),
|
|
237
|
-
max(sortedAttributeData.map((x) => x.income)),
|
|
238
|
-
];
|
|
239
|
-
const statesByBin = sortedAttributeData.reduce((acc, d) => {
|
|
240
|
-
const binNumber = binMaxValues.reduce((acc, maxValue, i) => {
|
|
241
|
-
if (
|
|
242
|
-
(d.income < maxValue || i === binMaxValues.length - 1) &&
|
|
243
|
-
acc === null
|
|
244
|
-
) {
|
|
245
|
-
acc = i;
|
|
246
|
-
return acc;
|
|
247
|
-
} else {
|
|
248
|
-
return acc;
|
|
249
|
-
}
|
|
250
|
-
}, null);
|
|
251
|
-
if (!acc[binNumber]) {
|
|
252
|
-
acc[binNumber] = [];
|
|
253
|
-
}
|
|
254
|
-
acc[binNumber].push(d.state);
|
|
255
|
-
return acc;
|
|
256
|
-
}, []);
|
|
257
|
-
range.forEach((color, i) => {
|
|
258
|
-
// check that the states in each bin have the same color
|
|
259
|
-
statesByBin[i].forEach((state) => {
|
|
260
|
-
cy.get(
|
|
261
|
-
`.vic-geographies-group.${state.split(' ').join('-')} path`
|
|
262
|
-
).then((path) => {
|
|
263
|
-
expect(path.attr('fill')).to.eq(color);
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('Colors the data with interpolated colors when a user provides a range of lesser length than num bins', () => {
|
|
271
|
-
const range = ['red', 'white'];
|
|
272
|
-
const numBins = 5;
|
|
273
|
-
cy.fixture('usMap.json').then((response) => {
|
|
274
|
-
const usMap: TestUsMapTopology = response;
|
|
275
|
-
const usBoundary = topojson.feature(
|
|
276
|
-
usMap,
|
|
277
|
-
usMap.objects.country
|
|
278
|
-
) as FeatureCollection<MultiPolygon, TestMapGeometryProperties>;
|
|
279
|
-
const states = topojson.feature(
|
|
280
|
-
usMap,
|
|
281
|
-
usMap.objects.states
|
|
282
|
-
) as FeatureCollection<MultiPolygon | Polygon, TestMapGeometryProperties>;
|
|
283
|
-
geographiesConfig = new VicGeographiesConfigBuilder<
|
|
284
|
-
StateIncomePopulationYearDatum,
|
|
285
|
-
TestMapGeometryProperties
|
|
286
|
-
>()
|
|
287
|
-
.boundary(usBoundary)
|
|
288
|
-
.featureIndexAccessor((d) => d.properties.name)
|
|
289
|
-
.attributeDataLayer((dimension) =>
|
|
290
|
-
dimension
|
|
291
|
-
.data(attributeData)
|
|
292
|
-
.class((d) => d.name.split(' ').join('-'))
|
|
293
|
-
.geographies(states.features)
|
|
294
|
-
.geographyIndexAccessor((d) => d.state)
|
|
295
|
-
.equalFrequenciesBins((bins) =>
|
|
296
|
-
bins
|
|
297
|
-
.valueAccessor((d) => d.income)
|
|
298
|
-
.numBins(numBins)
|
|
299
|
-
.range(range)
|
|
300
|
-
)
|
|
301
|
-
)
|
|
302
|
-
.getConfig();
|
|
303
|
-
mountGeographiesComponent(geographiesConfig);
|
|
304
|
-
// see https://d3js.org/d3-scale/quantile#quantile_domain for how d3 quantile works
|
|
305
|
-
const sortedAttributeData = attributeData
|
|
306
|
-
.filter((x) => {
|
|
307
|
-
const coerced = Number(x.income);
|
|
308
|
-
return !(isNaN(coerced) || coerced === null || coerced === undefined);
|
|
309
|
-
})
|
|
310
|
-
.sort((a, b) => ascending(Number(a.income), Number(b.income)));
|
|
311
|
-
const binMaxValues = [
|
|
312
|
-
...geographiesConfig.attributeDataLayer.attributeDimension
|
|
313
|
-
.getScale()
|
|
314
|
-
['quantiles'](),
|
|
315
|
-
max(sortedAttributeData.map((x) => x.income)),
|
|
316
|
-
];
|
|
317
|
-
const statesByBin = sortedAttributeData.reduce((acc, d) => {
|
|
318
|
-
const binNumber = binMaxValues.reduce((acc, maxValue, i) => {
|
|
319
|
-
if (
|
|
320
|
-
(d.income < maxValue || i === binMaxValues.length - 1) &&
|
|
321
|
-
acc === null
|
|
322
|
-
) {
|
|
323
|
-
acc = i;
|
|
324
|
-
return acc;
|
|
325
|
-
} else {
|
|
326
|
-
return acc;
|
|
327
|
-
}
|
|
328
|
-
}, null);
|
|
329
|
-
if (!acc[binNumber]) {
|
|
330
|
-
acc[binNumber] = [];
|
|
331
|
-
}
|
|
332
|
-
acc[binNumber].push(d.state);
|
|
333
|
-
return acc;
|
|
334
|
-
}, []);
|
|
335
|
-
let colors = [];
|
|
336
|
-
cy.get('.vic-geographies-group path').then((paths) => {
|
|
337
|
-
paths.each((i, el) => {
|
|
338
|
-
const path = el as unknown as SVGPathElement;
|
|
339
|
-
const fill = path.getAttribute('fill');
|
|
340
|
-
if (!colors.includes(fill)) {
|
|
341
|
-
colors.push(fill);
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
expect(colors).to.have.lengthOf(numBins + 1);
|
|
345
|
-
colors = colors.filter((x) => x[0] === 'r'); // filter out null color 'whitesmoke'
|
|
346
|
-
colors.sort((a, b) =>
|
|
347
|
-
ascending(a.split(',')[1].trim(), b.split(',')[1].trim())
|
|
348
|
-
);
|
|
349
|
-
paths.each((i, el) => {
|
|
350
|
-
const path = el as unknown as SVGPathElement;
|
|
351
|
-
const state = path.parentElement.classList[1].split('-').join(' ');
|
|
352
|
-
const binIndex = statesByBin.findIndex((bin) => bin.includes(state));
|
|
353
|
-
if (binIndex > -1) {
|
|
354
|
-
expect(path.getAttribute('fill')).to.eq(colors[binIndex]);
|
|
355
|
-
} else {
|
|
356
|
-
expect(path.getAttribute('fill')).to.eq('whitesmoke');
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { EqualFrequenciesAttributeDataDimension } from './equal-frequencies-bins';
|
|
3
|
-
import { EqualFrequenciesAttributeDataDimensionBuilder } from './equal-frequencies-bins-builder';
|
|
4
|
-
|
|
5
|
-
describe('VicEqualNumObservationsBins', () => {
|
|
6
|
-
let dimension: EqualFrequenciesAttributeDataDimension<any, string>;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
dimension = new EqualFrequenciesAttributeDataDimensionBuilder<any, string>()
|
|
9
|
-
.numBins(4)
|
|
10
|
-
.range(['red', 'blue', 'yellow', 'green'])
|
|
11
|
-
.valueAccessor((d) => d)
|
|
12
|
-
.nullColor('black')
|
|
13
|
-
._build();
|
|
14
|
-
});
|
|
15
|
-
describe('setPropertiesFromData', () => {
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
spyOn(dimension as any, 'setDomain');
|
|
18
|
-
spyOn(dimension as any, 'setNumBins');
|
|
19
|
-
spyOn(dimension as any, 'setRange');
|
|
20
|
-
});
|
|
21
|
-
it('calls setDomain once', () => {
|
|
22
|
-
dimension.setPropertiesFromData([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
23
|
-
expect((dimension as any).setDomain).toHaveBeenCalledOnceWith([
|
|
24
|
-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
|
25
|
-
]);
|
|
26
|
-
});
|
|
27
|
-
it('calls setNumBins once', () => {
|
|
28
|
-
dimension.setPropertiesFromData([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
29
|
-
expect((dimension as any).setNumBins).toHaveBeenCalledTimes(1);
|
|
30
|
-
});
|
|
31
|
-
it('calls setRange once', () => {
|
|
32
|
-
dimension.setPropertiesFromData([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
33
|
-
expect((dimension as any).setRange).toHaveBeenCalledTimes(1);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe('integration: setDomain', () => {
|
|
38
|
-
it('sets the domain to the values', () => {
|
|
39
|
-
dimension.setPropertiesFromData([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
40
|
-
expect((dimension as any).calculatedDomain).toEqual([
|
|
41
|
-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
|
42
|
-
]);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe('integration: setNumBins', () => {
|
|
47
|
-
it('sets the calculatedNumBins correctly', () => {
|
|
48
|
-
dimension.setPropertiesFromData([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
49
|
-
expect((dimension as any).calculatedNumBins).toEqual(4);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe('integration: getScale', () => {
|
|
54
|
-
let scale: any;
|
|
55
|
-
beforeEach(() => {
|
|
56
|
-
dimension.setPropertiesFromData([0, 2, 4, 6]);
|
|
57
|
-
scale = dimension.getScale();
|
|
58
|
-
});
|
|
59
|
-
it('correctly sets the domain', () => {
|
|
60
|
-
expect(scale.domain()).toEqual([0, 2, 4, 6]);
|
|
61
|
-
});
|
|
62
|
-
it('correctly sets the range', () => {
|
|
63
|
-
expect(scale.range()).toEqual(['red', 'blue', 'yellow', 'green']);
|
|
64
|
-
});
|
|
65
|
-
it('correctly scales a value in the domain', () => {
|
|
66
|
-
expect(scale(2)).toEqual('blue');
|
|
67
|
-
});
|
|
68
|
-
it('correctly scales a value out of the domain', () => {
|
|
69
|
-
expect(scale(null)).toEqual('black');
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { safeAssign } from '@mathstack/app-kit';
|
|
2
|
-
import { BinStrategy } from '../attribute-data-bin-enums';
|
|
3
|
-
import { CalculatedBinsAttributeDataDimension } from '../calculated-bins/calculated-bins';
|
|
4
|
-
import { EqualFrequenciesAttributeDataDimensionOptions } from './equal-frequencies-bins-options';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Configuration object for attribute data that is quantitative and will be binned into equal number of observations. For example, if the data is [0, 1, 2, 4, 60, 100] and numBins is 2, the bin ranges will be [0, 2] and [4, 100].
|
|
8
|
-
*
|
|
9
|
-
* The generic parameter is the type of the attribute data.
|
|
10
|
-
*/
|
|
11
|
-
export class EqualFrequenciesAttributeDataDimension<
|
|
12
|
-
Datum,
|
|
13
|
-
RangeValue extends string | number = string,
|
|
14
|
-
>
|
|
15
|
-
extends CalculatedBinsAttributeDataDimension<Datum, RangeValue>
|
|
16
|
-
implements EqualFrequenciesAttributeDataDimensionOptions<Datum, RangeValue>
|
|
17
|
-
{
|
|
18
|
-
override readonly binType: BinStrategy.equalFrequencies;
|
|
19
|
-
private calculatedDomain: number[];
|
|
20
|
-
readonly numBins: number;
|
|
21
|
-
|
|
22
|
-
constructor(
|
|
23
|
-
options: EqualFrequenciesAttributeDataDimensionOptions<Datum, RangeValue>
|
|
24
|
-
) {
|
|
25
|
-
super('number');
|
|
26
|
-
this.binType = BinStrategy.equalFrequencies;
|
|
27
|
-
safeAssign(this, options);
|
|
28
|
-
if (!this.valueAccessor) {
|
|
29
|
-
console.error(
|
|
30
|
-
'Value accessor is required for EqualNumObservationsAttributeDataDimension'
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
setPropertiesFromData(data: Datum[]): void {
|
|
36
|
-
const values = data.map(this.valueAccessor);
|
|
37
|
-
this.setDomain(values);
|
|
38
|
-
this.setNumBins();
|
|
39
|
-
this.setRange();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected setDomain(values: number[]): void {
|
|
43
|
-
this.calculatedDomain = values;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private setNumBins(): void {
|
|
47
|
-
this.calculatedNumBins = this.numBins;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getScale() {
|
|
51
|
-
return this.scale()
|
|
52
|
-
.domain(this.calculatedDomain)
|
|
53
|
-
.range(this.range)
|
|
54
|
-
.unknown(this.nullColor);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { safeAssign } from '@mathstack/app-kit';
|
|
2
|
-
import { interpolateLab, scaleQuantize } from 'd3';
|
|
3
|
-
import { CalculatedBinsAttributeDataDimensionBuilder } from '../calculated-bins/calculated-bins-builder';
|
|
4
|
-
import { EqualValueRangesAttributeDataDimension } from './equal-value-ranges-bins';
|
|
5
|
-
|
|
6
|
-
const DEFAULT = {
|
|
7
|
-
_interpolator: interpolateLab,
|
|
8
|
-
_nullColor: 'whitesmoke',
|
|
9
|
-
_numBins: 3,
|
|
10
|
-
_range: ['white', 'pink', 'red'],
|
|
11
|
-
_scale: scaleQuantize,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export class EqualValueRangesBinsBuilder<
|
|
15
|
-
Datum,
|
|
16
|
-
RangeValue extends string | number = string,
|
|
17
|
-
> extends CalculatedBinsAttributeDataDimensionBuilder<Datum, RangeValue> {
|
|
18
|
-
private _domain: [number, number];
|
|
19
|
-
private _numBins: number;
|
|
20
|
-
|
|
21
|
-
constructor() {
|
|
22
|
-
super();
|
|
23
|
-
safeAssign(this, DEFAULT);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* OPTIONAL. The domain of the scale. If not set, the domain will be inferred from the data.
|
|
28
|
-
*/
|
|
29
|
-
domain(domain: [number, number]): this {
|
|
30
|
-
this._domain = domain;
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* OPTIONAL. The number of bins to create.
|
|
36
|
-
*
|
|
37
|
-
* @default 3
|
|
38
|
-
*/
|
|
39
|
-
numBins(numBins: number): this {
|
|
40
|
-
this._numBins = numBins;
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @internal This method is not intended to be used by consumers of this library.
|
|
46
|
-
*/
|
|
47
|
-
_build(): EqualValueRangesAttributeDataDimension<Datum, RangeValue> {
|
|
48
|
-
return new EqualValueRangesAttributeDataDimension({
|
|
49
|
-
domain: this._domain,
|
|
50
|
-
formatFunction: this._formatFunction,
|
|
51
|
-
formatSpecifier: this._formatSpecifier,
|
|
52
|
-
interpolator: this._interpolator,
|
|
53
|
-
nullColor: this._nullColor,
|
|
54
|
-
numBins: this._numBins,
|
|
55
|
-
range: this._range,
|
|
56
|
-
scale: this._scale,
|
|
57
|
-
valueAccessor: this._valueAccessor,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CalculatedBinsAttributeDataDimensionOptions } from '../calculated-bins/calculated-bins-options';
|
|
2
|
-
|
|
3
|
-
export interface EqualValueRangesAttributeDataDimensionOptions<
|
|
4
|
-
Datum,
|
|
5
|
-
RangeValue extends string | number = string,
|
|
6
|
-
> extends CalculatedBinsAttributeDataDimensionOptions<Datum, RangeValue> {
|
|
7
|
-
domain: [number, number];
|
|
8
|
-
numBins: number;
|
|
9
|
-
}
|