@mathstack/viz 2.0.3 → 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 -300
- 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,717 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
ElementRef,
|
|
5
|
-
inject,
|
|
6
|
-
InjectionToken,
|
|
7
|
-
NgZone,
|
|
8
|
-
ViewEncapsulation,
|
|
9
|
-
} from '@angular/core';
|
|
10
|
-
import { select, Transition } from 'd3';
|
|
11
|
-
import { Selection } from 'd3-selection';
|
|
12
|
-
import { BehaviorSubject, filter } from 'rxjs';
|
|
13
|
-
import { ChartComponent } from '../charts/chart/chart.component';
|
|
14
|
-
import {
|
|
15
|
-
XyChartComponent,
|
|
16
|
-
XyChartScales,
|
|
17
|
-
} from '../charts/xy-chart/xy-chart.component';
|
|
18
|
-
import { GenericScale } from '../core';
|
|
19
|
-
import { DataValue } from '../core/types/values';
|
|
20
|
-
import { ColorUtilities } from '../core/utilities/colors';
|
|
21
|
-
import { FillUtilities } from '../core/utilities/fill-utilities';
|
|
22
|
-
import { isNumber } from '../core/utilities/type-guards';
|
|
23
|
-
import { ValueUtilities } from '../core/utilities/values';
|
|
24
|
-
import { VIC_PRIMARY_MARKS } from '../marks/primary-marks/primary-marks';
|
|
25
|
-
import { VicXyPrimaryMarks } from '../marks/xy-marks/xy-primary-marks/xy-primary-marks';
|
|
26
|
-
import { BarsConfig } from './config/bars-config';
|
|
27
|
-
|
|
28
|
-
// Ideally we would be able to use generic T with the component, but Angular doesn't yet support this, so we use "unknown"
|
|
29
|
-
// https://github.com/angular/angular/issues/46815, https://github.com/angular/angular/pull/47461
|
|
30
|
-
export const BARS = new InjectionToken<BarsComponent<unknown, DataValue>>(
|
|
31
|
-
'BarsComponent'
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
export type BarGroupSelection = Selection<
|
|
35
|
-
SVGGElement,
|
|
36
|
-
number,
|
|
37
|
-
SVGSVGElement,
|
|
38
|
-
unknown
|
|
39
|
-
>;
|
|
40
|
-
export type BarSelection = Selection<
|
|
41
|
-
SVGRectElement,
|
|
42
|
-
number,
|
|
43
|
-
SVGGElement,
|
|
44
|
-
number
|
|
45
|
-
>;
|
|
46
|
-
export type BarLabelSelection = Selection<
|
|
47
|
-
SVGTextElement,
|
|
48
|
-
number,
|
|
49
|
-
SVGGElement,
|
|
50
|
-
number
|
|
51
|
-
>;
|
|
52
|
-
|
|
53
|
-
export type BarDatum<T> = {
|
|
54
|
-
index: number;
|
|
55
|
-
quantitative: number;
|
|
56
|
-
ordinal: T;
|
|
57
|
-
color: string;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export interface BarsTooltipDatum<Datum> {
|
|
61
|
-
datum: Datum;
|
|
62
|
-
color: string;
|
|
63
|
-
values: {
|
|
64
|
-
x: string;
|
|
65
|
-
y: string;
|
|
66
|
-
category: string;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
type BarsSvgElement = 'g' | 'bar' | 'label' | 'background';
|
|
71
|
-
|
|
72
|
-
@Component({
|
|
73
|
-
// eslint-disable-next-line @angular-eslint/component-selector
|
|
74
|
-
selector: '[vic-primary-marks-bars]',
|
|
75
|
-
template: '',
|
|
76
|
-
styleUrls: ['./bars.component.scss'],
|
|
77
|
-
encapsulation: ViewEncapsulation.None,
|
|
78
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
79
|
-
providers: [
|
|
80
|
-
{ provide: VIC_PRIMARY_MARKS, useExisting: BarsComponent },
|
|
81
|
-
{ provide: BARS, useExisting: BarsComponent },
|
|
82
|
-
{ provide: ChartComponent, useExisting: XyChartComponent },
|
|
83
|
-
],
|
|
84
|
-
host: {
|
|
85
|
-
'[class]': 'config.marksClass',
|
|
86
|
-
'[style.mixBlendMode]': 'config.mixBlendMode',
|
|
87
|
-
},
|
|
88
|
-
})
|
|
89
|
-
export class BarsComponent<
|
|
90
|
-
Datum,
|
|
91
|
-
TOrdinalValue extends DataValue,
|
|
92
|
-
> extends VicXyPrimaryMarks<Datum, BarsConfig<Datum, TOrdinalValue>> {
|
|
93
|
-
barGroups: BarGroupSelection;
|
|
94
|
-
bars: BehaviorSubject<BarSelection> = new BehaviorSubject(null);
|
|
95
|
-
bars$ = this.bars.asObservable().pipe(filter((s) => !!s));
|
|
96
|
-
labels: BehaviorSubject<BarLabelSelection> = new BehaviorSubject(null);
|
|
97
|
-
labels$ = this.bars.asObservable().pipe(filter((s) => !!s));
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
-
override scales: { color: GenericScale<any, any> } & XyChartScales = {
|
|
100
|
-
x: undefined,
|
|
101
|
-
y: undefined,
|
|
102
|
-
color: undefined,
|
|
103
|
-
useTransition: undefined,
|
|
104
|
-
};
|
|
105
|
-
protected zone = inject(NgZone);
|
|
106
|
-
public elRef = inject(ElementRef<SVGGElement>);
|
|
107
|
-
|
|
108
|
-
get class(): Record<BarsSvgElement, string> {
|
|
109
|
-
return {
|
|
110
|
-
g: this.config.marksClass + '-group',
|
|
111
|
-
bar: this.config.marksClass + '-bar',
|
|
112
|
-
label: this.config.marksClass + '-label',
|
|
113
|
-
background: this.config.marksClass + '-background',
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
setChartScalesFromRanges(useTransition: boolean): void {
|
|
118
|
-
const x = this.config[this.config.dimensions.x].getScaleFromRange(
|
|
119
|
-
this.ranges.x
|
|
120
|
-
);
|
|
121
|
-
const y = this.config[this.config.dimensions.y].getScaleFromRange(
|
|
122
|
-
this.ranges.y
|
|
123
|
-
);
|
|
124
|
-
this.scales.color = this.config.color.getScale();
|
|
125
|
-
this.chart.updateScales({
|
|
126
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
127
|
-
x: x as unknown as GenericScale<any, any>,
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
-
y: y as unknown as GenericScale<any, any>,
|
|
130
|
-
useTransition,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
drawMarks(): void {
|
|
135
|
-
const transitionDuration = this.getTransitionDuration();
|
|
136
|
-
this.drawBars(transitionDuration);
|
|
137
|
-
if (this.config.backgrounds) {
|
|
138
|
-
this.drawBackgrounds(transitionDuration);
|
|
139
|
-
}
|
|
140
|
-
if (this.config.labels) {
|
|
141
|
-
this.drawLabels(transitionDuration);
|
|
142
|
-
}
|
|
143
|
-
this.updateBarElements();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
drawBars(transitionDuration: number): void {
|
|
147
|
-
const t = select(this.chart.svgRef.nativeElement)
|
|
148
|
-
.transition()
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
|
-
.duration(transitionDuration) as Transition<SVGSVGElement, any, any, any>;
|
|
151
|
-
|
|
152
|
-
this.barGroups = select(this.elRef.nativeElement)
|
|
153
|
-
.selectAll<SVGGElement, number>(`.${this.class.g}`)
|
|
154
|
-
.data<number>(this.config.valueIndices, this.config.barsKeyFunction)
|
|
155
|
-
.join(
|
|
156
|
-
(enter) =>
|
|
157
|
-
enter
|
|
158
|
-
.append('g')
|
|
159
|
-
.attr('class', (i) =>
|
|
160
|
-
`${this.class.g} ${this.config.datumClass(this.config.data[i], i)}`.trim()
|
|
161
|
-
)
|
|
162
|
-
.attr('transform', (i) =>
|
|
163
|
-
this.getBarGroupTransform(this.getBarDatumFromIndex(i))
|
|
164
|
-
),
|
|
165
|
-
(update) =>
|
|
166
|
-
update
|
|
167
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
|
-
.transition(t as any)
|
|
169
|
-
.attr('transform', (i) =>
|
|
170
|
-
this.getBarGroupTransform(this.getBarDatumFromIndex(i))
|
|
171
|
-
),
|
|
172
|
-
(exit) => exit.remove()
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
this.barGroups
|
|
176
|
-
.selectAll<SVGRectElement, BarDatum<TOrdinalValue>>(`.${this.class.bar}`)
|
|
177
|
-
.data<BarDatum<TOrdinalValue>>((i) => [this.getBarDatumFromIndex(i)])
|
|
178
|
-
.join(
|
|
179
|
-
(enter) =>
|
|
180
|
-
enter
|
|
181
|
-
.append('rect')
|
|
182
|
-
.attr('class', this.class.bar)
|
|
183
|
-
.property('key', (d) => d.ordinal)
|
|
184
|
-
.attr('width', (d) => this.getBarWidth(d))
|
|
185
|
-
.attr('height', (d) => this.getBarHeight(d))
|
|
186
|
-
.attr('fill', (d) => this.getBarFill(d)),
|
|
187
|
-
(update) =>
|
|
188
|
-
update
|
|
189
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
190
|
-
.transition(t as any)
|
|
191
|
-
.attr('width', (d) => this.getBarWidth(d))
|
|
192
|
-
.attr('height', (d) => this.getBarHeight(d))
|
|
193
|
-
.attr('fill', (d) => this.getBarFill(d)),
|
|
194
|
-
(exit) => exit.remove()
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
drawBackgrounds(transitionDuration: number): void {
|
|
199
|
-
const t = select(this.chart.svgRef.nativeElement)
|
|
200
|
-
.transition()
|
|
201
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
|
-
.duration(transitionDuration) as Transition<SVGSVGElement, any, any, any>;
|
|
203
|
-
|
|
204
|
-
this.barGroups
|
|
205
|
-
.selectAll<SVGRectElement, number>(`.${this.class.background}`)
|
|
206
|
-
.data<BarDatum<TOrdinalValue>>((i) => [this.getBarDatumFromIndex(i)])
|
|
207
|
-
.join(
|
|
208
|
-
(enter) =>
|
|
209
|
-
enter
|
|
210
|
-
.append('rect')
|
|
211
|
-
.attr('class', this.class.background)
|
|
212
|
-
.attr('fill', this.config.backgrounds.color)
|
|
213
|
-
.attr('transform', (d) => this.getBackgroundTransform(d))
|
|
214
|
-
.attr('width', this.getBackgroundWidth())
|
|
215
|
-
.attr('height', this.getBackgroundBarHeight()),
|
|
216
|
-
(update) =>
|
|
217
|
-
update
|
|
218
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
219
|
-
.transition(t as any)
|
|
220
|
-
.attr('transform', (d) => this.getBackgroundTransform(d))
|
|
221
|
-
.attr('width', this.getBackgroundWidth())
|
|
222
|
-
.attr('height', this.getBackgroundBarHeight()),
|
|
223
|
-
(exit) => exit.remove()
|
|
224
|
-
)
|
|
225
|
-
.lower();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
229
|
-
getBarGroupColorClass(i: number): string {
|
|
230
|
-
return this.config.color.calculatedDomain.length > 1
|
|
231
|
-
? ValueUtilities.formatForHtmlAttribute(this.config.color.values[i])
|
|
232
|
-
: '';
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
getBarDatumFromIndex(i: number): BarDatum<TOrdinalValue> {
|
|
236
|
-
return {
|
|
237
|
-
index: i,
|
|
238
|
-
quantitative: this.config.quantitative.values[i],
|
|
239
|
-
ordinal: this.config.ordinal.values[i],
|
|
240
|
-
color: this.config.color.values[i],
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
getBarGroupTransform(datum: BarDatum<TOrdinalValue>): string {
|
|
245
|
-
const x = this.getBarX(datum);
|
|
246
|
-
const y = this.getBarY(datum);
|
|
247
|
-
return `translate(${x},${y})`;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
getBarFill(datum: BarDatum<TOrdinalValue>): string {
|
|
251
|
-
return this.config.customFills
|
|
252
|
-
? this.getBarPattern(datum)
|
|
253
|
-
: this.getBarColor(datum);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
drawLabels(transitionDuration: number): void {
|
|
257
|
-
const t = select(this.chart.svgRef.nativeElement)
|
|
258
|
-
.transition()
|
|
259
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
|
-
.duration(transitionDuration) as Transition<SVGSVGElement, any, any, any>;
|
|
261
|
-
|
|
262
|
-
this.barGroups
|
|
263
|
-
.selectAll<SVGTextElement, BarDatum<TOrdinalValue>>(
|
|
264
|
-
`.${this.class.label}`
|
|
265
|
-
)
|
|
266
|
-
.data<BarDatum<TOrdinalValue>>((i: number) => [
|
|
267
|
-
{
|
|
268
|
-
index: i,
|
|
269
|
-
quantitative: this.config.quantitative.values[i],
|
|
270
|
-
ordinal: this.config.ordinal.values[i],
|
|
271
|
-
color: this.config.color.values[i],
|
|
272
|
-
},
|
|
273
|
-
])
|
|
274
|
-
.join(
|
|
275
|
-
(enter) =>
|
|
276
|
-
enter
|
|
277
|
-
.append<SVGTextElement>('text')
|
|
278
|
-
.attr('class', this.class.label)
|
|
279
|
-
.style('display', this.config.labels.display ? null : 'none')
|
|
280
|
-
.text((d) => this.getLabelText(d))
|
|
281
|
-
.style('visiblity', 'hidden')
|
|
282
|
-
.call((selection) => {
|
|
283
|
-
selection.each((d, i, nodes) => {
|
|
284
|
-
const bbox = nodes[i].getBBox();
|
|
285
|
-
select<SVGTextElement, BarDatum<TOrdinalValue>>(nodes[i])
|
|
286
|
-
.style('fill', (d) => this.getLabelColor(d, bbox))
|
|
287
|
-
.attr('text-anchor', (d) => this.getLabelTextAnchor(d, bbox))
|
|
288
|
-
.attr('dominant-baseline', (d) =>
|
|
289
|
-
this.getLabelDominantBaseline(d, bbox)
|
|
290
|
-
)
|
|
291
|
-
.attr('x', this.getLabelX(d, bbox))
|
|
292
|
-
.attr('y', this.getLabelY(d, bbox))
|
|
293
|
-
.attr('visibility', 'visible');
|
|
294
|
-
});
|
|
295
|
-
}),
|
|
296
|
-
(update) =>
|
|
297
|
-
update
|
|
298
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
299
|
-
.transition(t as any)
|
|
300
|
-
.text((d) => this.getLabelText(d))
|
|
301
|
-
.style('visiblity', 'hidden')
|
|
302
|
-
.call((selection) => {
|
|
303
|
-
selection.each((d, i, nodes) => {
|
|
304
|
-
const bbox = nodes[i].getBBox();
|
|
305
|
-
select<SVGTextElement, BarDatum<TOrdinalValue>>(nodes[i])
|
|
306
|
-
.style('fill', (d) => this.getLabelColor(d, bbox))
|
|
307
|
-
.attr('text-anchor', (d) => this.getLabelTextAnchor(d, bbox))
|
|
308
|
-
.attr('dominant-baseline', (d) =>
|
|
309
|
-
this.getLabelDominantBaseline(d, bbox)
|
|
310
|
-
)
|
|
311
|
-
.attr('x', this.getLabelX(d, bbox))
|
|
312
|
-
.attr('y', this.getLabelY(d, bbox))
|
|
313
|
-
.attr('visibility', 'visible');
|
|
314
|
-
});
|
|
315
|
-
}),
|
|
316
|
-
(exit) => exit.remove()
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
getBarX(d: BarDatum<TOrdinalValue>): number {
|
|
321
|
-
if (this.config.dimensions.x === 'ordinal') {
|
|
322
|
-
return this.getBarXOrdinal(d);
|
|
323
|
-
}
|
|
324
|
-
return this.getBarXQuantitative(d);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
getBarXOrdinal(d: BarDatum<TOrdinalValue>): number {
|
|
328
|
-
return this.scales.x(d.ordinal);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
getBarXQuantitative(d: BarDatum<TOrdinalValue>): number {
|
|
332
|
-
if (this.isZeroOrNonNumeric(d.quantitative)) {
|
|
333
|
-
const origin = this.getBarQuantitativeOrigin();
|
|
334
|
-
return this.scales.x(origin);
|
|
335
|
-
} else if (this.config.hasNegativeValues) {
|
|
336
|
-
if (d.quantitative < 0) {
|
|
337
|
-
return this.scales.x(d.quantitative);
|
|
338
|
-
}
|
|
339
|
-
return this.scales.x(0);
|
|
340
|
-
}
|
|
341
|
-
return this.scales.x(this.getQuantitativeDomainFromScale()[0]);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
getBarY(d: BarDatum<TOrdinalValue>): number {
|
|
345
|
-
if (this.config.dimensions.y === 'ordinal') {
|
|
346
|
-
return this.getBarYOrdinal(d);
|
|
347
|
-
}
|
|
348
|
-
return this.getBarYQuantitative(d);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
getBarYOrdinal(d: BarDatum<TOrdinalValue>): number {
|
|
352
|
-
return this.scales.y(d.ordinal);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
getBarYQuantitative(d: BarDatum<TOrdinalValue>): number {
|
|
356
|
-
if (this.isZeroOrNonNumeric(d.quantitative)) {
|
|
357
|
-
const origin = this.getBarQuantitativeOrigin();
|
|
358
|
-
return this.scales.y(origin);
|
|
359
|
-
} else if (d.quantitative < 0) {
|
|
360
|
-
if (this.config.quantitative.domainIncludesZero) {
|
|
361
|
-
return this.scales.y(0);
|
|
362
|
-
}
|
|
363
|
-
return this.scales.y(this.getQuantitativeDomainFromScale()[1]);
|
|
364
|
-
}
|
|
365
|
-
return this.scales.y(d.quantitative);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
getQuantitativeDomainFromScale(): number[] {
|
|
369
|
-
return this.scales[this.config.dimensions.quantitative].domain();
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
getBarWidth(d: BarDatum<TOrdinalValue>): number {
|
|
373
|
-
if (this.config.dimensions.quantitativeDimension === 'width') {
|
|
374
|
-
return this.getBarDimensionQuantitative(d, 'x');
|
|
375
|
-
}
|
|
376
|
-
return this.getBarWidthOrdinal();
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
getBarWidthOrdinal(): number {
|
|
380
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
381
|
-
return (this.scales.x as any).bandwidth();
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
getBarHeight(d: BarDatum<TOrdinalValue>): number {
|
|
385
|
-
if (this.config.dimensions.quantitativeDimension === 'height') {
|
|
386
|
-
return this.getBarDimensionQuantitative(d, 'y');
|
|
387
|
-
}
|
|
388
|
-
return this.getBarHeightOrdinal();
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
getBarHeightOrdinal(): number {
|
|
392
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
393
|
-
return (this.scales.y as any).bandwidth();
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
getBackgroundTransform(d: BarDatum<TOrdinalValue>): string | null {
|
|
397
|
-
if (this.config.dimensions.quantitativeDimension === 'width') {
|
|
398
|
-
const range = this.scales.x.range();
|
|
399
|
-
const offsetFromLeft =
|
|
400
|
-
d.quantitative < 0 ? this.scales.x(d.quantitative) : this.scales.x(0);
|
|
401
|
-
return `translate(${range[0] - offsetFromLeft},0)`;
|
|
402
|
-
}
|
|
403
|
-
const range = this.scales.y.range();
|
|
404
|
-
const offsetFromBottom =
|
|
405
|
-
d.quantitative < 0 ? this.scales.y(0) : this.scales.y(d.quantitative);
|
|
406
|
-
return `translate(0,${range[1] - offsetFromBottom})`;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
getBackgroundWidth(): number {
|
|
410
|
-
if (this.config.dimensions.quantitativeDimension === 'width') {
|
|
411
|
-
const range = this.scales.x.range();
|
|
412
|
-
return range[1] - range[0];
|
|
413
|
-
}
|
|
414
|
-
return this.getBarWidthOrdinal();
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
getBackgroundBarHeight(): number {
|
|
418
|
-
if (this.config.dimensions.quantitativeDimension === 'height') {
|
|
419
|
-
const range = this.scales.y.range();
|
|
420
|
-
return range[0] - range[1];
|
|
421
|
-
} else {
|
|
422
|
-
return this.getBarHeightOrdinal();
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
getBarDimensionQuantitative(
|
|
427
|
-
d: BarDatum<TOrdinalValue>,
|
|
428
|
-
dimension: 'x' | 'y'
|
|
429
|
-
): number {
|
|
430
|
-
if (this.isZeroOrNonNumeric(d.quantitative)) {
|
|
431
|
-
return 0;
|
|
432
|
-
}
|
|
433
|
-
const origin = this.getBarQuantitativeOrigin();
|
|
434
|
-
return Math.abs(
|
|
435
|
-
this.scales[dimension](d.quantitative) - this.scales[dimension](origin)
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
getBarQuantitativeOrigin(): number {
|
|
440
|
-
if (this.config.quantitative.domainIncludesZero) {
|
|
441
|
-
return 0;
|
|
442
|
-
}
|
|
443
|
-
const domain = this.getQuantitativeDomainFromScale();
|
|
444
|
-
return this.config.hasNegativeValues ? domain[1] : domain[0];
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
getBarPattern(d: BarDatum<TOrdinalValue>): string {
|
|
448
|
-
const color = this.getBarColor(d);
|
|
449
|
-
return FillUtilities.getFill(
|
|
450
|
-
this.config.data[d.index],
|
|
451
|
-
color,
|
|
452
|
-
this.config.customFills
|
|
453
|
-
);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
getBarColor(d: BarDatum<TOrdinalValue>): string {
|
|
457
|
-
return this.scales.color(d.color);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
getLabelText(d: BarDatum<TOrdinalValue>): string {
|
|
461
|
-
const datum = this.config.data[d.index];
|
|
462
|
-
if (!isNumber(d.quantitative)) {
|
|
463
|
-
return this.config.labels.noValueFunction(datum);
|
|
464
|
-
}
|
|
465
|
-
return this.config.quantitative.formatFunction
|
|
466
|
-
? ValueUtilities.customFormat(
|
|
467
|
-
datum,
|
|
468
|
-
this.config.quantitative.formatFunction
|
|
469
|
-
)
|
|
470
|
-
: ValueUtilities.d3Format(
|
|
471
|
-
d.quantitative,
|
|
472
|
-
this.config.quantitative.formatSpecifier
|
|
473
|
-
);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
getLabelTextAnchor(
|
|
477
|
-
d: BarDatum<TOrdinalValue>,
|
|
478
|
-
labelBbox: DOMRect
|
|
479
|
-
): 'start' | 'middle' | 'end' {
|
|
480
|
-
if (this.config.dimensions.isVertical) {
|
|
481
|
-
return 'middle';
|
|
482
|
-
}
|
|
483
|
-
return this.alignTextInPositiveDirection(d, labelBbox) ? 'start' : 'end';
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
getLabelDominantBaseline(
|
|
487
|
-
d: BarDatum<TOrdinalValue>,
|
|
488
|
-
labelBbox: DOMRect
|
|
489
|
-
): 'text-after-edge' | 'text-before-edge' | 'central' {
|
|
490
|
-
if (this.config.dimensions.isHorizontal) {
|
|
491
|
-
return 'central';
|
|
492
|
-
}
|
|
493
|
-
return this.alignTextInPositiveDirection(d, labelBbox)
|
|
494
|
-
? 'text-after-edge'
|
|
495
|
-
: 'text-before-edge';
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
alignTextInPositiveDirection(
|
|
499
|
-
d: BarDatum<TOrdinalValue>,
|
|
500
|
-
labelBbox: DOMRect
|
|
501
|
-
): boolean {
|
|
502
|
-
if (this.isZeroOrNonNumeric(d.quantitative)) {
|
|
503
|
-
return this.positionZeroOrNonNumericValueLabelInPositiveDirection();
|
|
504
|
-
}
|
|
505
|
-
const placeLabelOutsideBar = this.labelFitsOutsideBar(d, labelBbox);
|
|
506
|
-
const isPositiveValue = d.quantitative > 0;
|
|
507
|
-
return placeLabelOutsideBar ? isPositiveValue : !isPositiveValue;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
getLabelColor(d: BarDatum<TOrdinalValue>, labelBbox: DOMRect): string {
|
|
511
|
-
if (
|
|
512
|
-
this.isZeroOrNonNumeric(d.quantitative) ||
|
|
513
|
-
this.labelFitsOutsideBar(d, labelBbox)
|
|
514
|
-
) {
|
|
515
|
-
if (this.config.backgrounds) {
|
|
516
|
-
// try to use the default label color if it has enough contrast
|
|
517
|
-
if (
|
|
518
|
-
ColorUtilities.getContrastRatio(
|
|
519
|
-
this.config.labels.color.default,
|
|
520
|
-
this.config.backgrounds.color
|
|
521
|
-
) >= 4.5
|
|
522
|
-
) {
|
|
523
|
-
return this.config.labels.color.default;
|
|
524
|
-
}
|
|
525
|
-
// if it doesn't, user the color with the higher contrast against the background
|
|
526
|
-
return ColorUtilities.getHigherContrastColorForBackground(
|
|
527
|
-
this.config.backgrounds.color,
|
|
528
|
-
this.config.labels.color.default,
|
|
529
|
-
this.config.labels.color.withinBarAlternative
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
return this.config.labels.color.default;
|
|
533
|
-
}
|
|
534
|
-
const barColor = this.getBarColor(d);
|
|
535
|
-
return ColorUtilities.getHigherContrastColorForBackground(
|
|
536
|
-
barColor,
|
|
537
|
-
this.config.labels.color.default,
|
|
538
|
-
this.config.labels.color.withinBarAlternative
|
|
539
|
-
);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
labelFitsOutsideBar(d: BarDatum<TOrdinalValue>, labelBbox: DOMRect): boolean {
|
|
543
|
-
const isPositiveValue = d.quantitative > 0;
|
|
544
|
-
// This approach assumes that the bar labels do not wrap.
|
|
545
|
-
const distanceToChartEdge = this.getBarToChartEdgeDistance(
|
|
546
|
-
isPositiveValue,
|
|
547
|
-
this.ranges[this.config.dimensions.quantitative],
|
|
548
|
-
this.scales[this.config.dimensions.quantitative](d.quantitative)
|
|
549
|
-
);
|
|
550
|
-
|
|
551
|
-
if (this.config.dimensions.isHorizontal) {
|
|
552
|
-
return distanceToChartEdge > labelBbox.width + this.config.labels.offset;
|
|
553
|
-
}
|
|
554
|
-
return distanceToChartEdge > labelBbox.height + this.config.labels.offset;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
getBarToChartEdgeDistance(
|
|
558
|
-
isPositiveValue: boolean,
|
|
559
|
-
range: [number, number],
|
|
560
|
-
endOfBarPosition: number
|
|
561
|
-
): number {
|
|
562
|
-
const [min, max] = range[0] < range[1] ? range : [range[1], range[0]];
|
|
563
|
-
|
|
564
|
-
if (endOfBarPosition <= min || endOfBarPosition >= max) {
|
|
565
|
-
return 0;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
return isPositiveValue ? max - endOfBarPosition : endOfBarPosition - min;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
getLabelDomRect(d: BarDatum<TOrdinalValue>): DOMRect {
|
|
572
|
-
const selection = this.barGroups
|
|
573
|
-
.selectAll<
|
|
574
|
-
SVGTextElement,
|
|
575
|
-
BarDatum<TOrdinalValue>
|
|
576
|
-
>(`.${this.class.label}`)
|
|
577
|
-
.filter((datum) => datum.index === d.index);
|
|
578
|
-
return selection.node().getBoundingClientRect();
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
getLabelX(d: BarDatum<TOrdinalValue>, bbox: DOMRect): number {
|
|
582
|
-
if (this.config.dimensions.x === 'ordinal') {
|
|
583
|
-
return this.getBarWidthOrdinal() / 2;
|
|
584
|
-
}
|
|
585
|
-
return this.getLabelQuantitativeAxisPosition(d, bbox);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
getLabelY(d: BarDatum<TOrdinalValue>, bbox: DOMRect): number {
|
|
589
|
-
if (this.config.dimensions.y === 'ordinal') {
|
|
590
|
-
return this.getBarHeightOrdinal() / 2;
|
|
591
|
-
}
|
|
592
|
-
return this.getLabelQuantitativeAxisPosition(d, bbox);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
getLabelQuantitativeAxisPosition(
|
|
596
|
-
d: BarDatum<TOrdinalValue>,
|
|
597
|
-
bbox: DOMRect
|
|
598
|
-
): number {
|
|
599
|
-
if (this.isZeroOrNonNumeric(d.quantitative)) {
|
|
600
|
-
return this.getLabelPositionForZeroOrNonnumericValue();
|
|
601
|
-
}
|
|
602
|
-
return this.getLabelPositionForNumericValue(d, bbox);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
getLabelPositionForZeroOrNonnumericValue(): number {
|
|
606
|
-
const positionInPositiveDirection =
|
|
607
|
-
this.positionZeroOrNonNumericValueLabelInPositiveDirection();
|
|
608
|
-
return (positionInPositiveDirection &&
|
|
609
|
-
this.config.dimensions.isHorizontal) ||
|
|
610
|
-
(!positionInPositiveDirection && this.config.dimensions.isVertical)
|
|
611
|
-
? this.config.labels.offset
|
|
612
|
-
: -this.config.labels.offset;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
getLabelPositionForNumericValue(
|
|
616
|
-
d: BarDatum<TOrdinalValue>,
|
|
617
|
-
bbox: DOMRect
|
|
618
|
-
): number {
|
|
619
|
-
const isPositiveValue = d.quantitative > 0;
|
|
620
|
-
const origin = this.getLabelOrigin(d, isPositiveValue);
|
|
621
|
-
const placeLabelOutsideBar = this.labelFitsOutsideBar(d, bbox);
|
|
622
|
-
if (
|
|
623
|
-
(this.config.dimensions.isVertical && placeLabelOutsideBar) ||
|
|
624
|
-
(this.config.dimensions.isHorizontal && !placeLabelOutsideBar)
|
|
625
|
-
) {
|
|
626
|
-
return isPositiveValue
|
|
627
|
-
? origin - this.config.labels.offset
|
|
628
|
-
: origin + this.config.labels.offset;
|
|
629
|
-
}
|
|
630
|
-
return isPositiveValue
|
|
631
|
-
? origin + this.config.labels.offset
|
|
632
|
-
: origin - this.config.labels.offset;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
getLabelOrigin(d: BarDatum<TOrdinalValue>, isPositiveValue: boolean): number {
|
|
636
|
-
if (this.config.dimensions.isHorizontal) {
|
|
637
|
-
return isPositiveValue ? this.getBarDimensionQuantitative(d, 'x') : 0;
|
|
638
|
-
}
|
|
639
|
-
return isPositiveValue ? 0 : this.getBarDimensionQuantitative(d, 'y');
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
positionZeroOrNonNumericValueLabelInPositiveDirection(): boolean {
|
|
643
|
-
const quantitativeValues = this.config.quantitative.values;
|
|
644
|
-
const someValuesArePositive = quantitativeValues.some((x) => x > 0);
|
|
645
|
-
if (someValuesArePositive) {
|
|
646
|
-
return true;
|
|
647
|
-
}
|
|
648
|
-
const domainMaxIsGreaterThanZero =
|
|
649
|
-
this.getQuantitativeDomainFromScale()[1] > 0;
|
|
650
|
-
const everyValueIsEitherZeroOrNonnumeric = quantitativeValues.every((x) =>
|
|
651
|
-
this.isZeroOrNonNumeric(x)
|
|
652
|
-
);
|
|
653
|
-
return domainMaxIsGreaterThanZero && everyValueIsEitherZeroOrNonnumeric;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
isZeroOrNonNumeric(value: unknown): boolean {
|
|
657
|
-
return value === 0 || !isNumber(value);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
updateBarElements(): void {
|
|
661
|
-
const barEventElementsSelector = this.config.backgrounds?.events
|
|
662
|
-
? `.${this.class.bar}, .${this.class.background}`
|
|
663
|
-
: `.${this.class.bar}`;
|
|
664
|
-
const bars = select(this.elRef.nativeElement).selectAll<
|
|
665
|
-
SVGRectElement,
|
|
666
|
-
number
|
|
667
|
-
>(barEventElementsSelector);
|
|
668
|
-
const labels = select(this.elRef.nativeElement).selectAll<
|
|
669
|
-
SVGTextElement,
|
|
670
|
-
number
|
|
671
|
-
>(`.${this.class.label}`);
|
|
672
|
-
this.bars.next(bars);
|
|
673
|
-
this.labels.next(labels);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
getTooltipData(datum: Datum): BarsTooltipDatum<Datum> {
|
|
677
|
-
const ordinalValue = this.config.ordinal.formatFunction
|
|
678
|
-
? ValueUtilities.customFormat(datum, this.config.ordinal.formatFunction)
|
|
679
|
-
: this.config.ordinal.valueAccessor(datum).toString();
|
|
680
|
-
const quantitativeValue = this.config.quantitative.formatFunction
|
|
681
|
-
? ValueUtilities.customFormat(
|
|
682
|
-
datum,
|
|
683
|
-
this.config.quantitative.formatFunction
|
|
684
|
-
)
|
|
685
|
-
: ValueUtilities.d3Format(
|
|
686
|
-
this.config.quantitative.valueAccessor(datum),
|
|
687
|
-
this.config.quantitative.formatSpecifier
|
|
688
|
-
);
|
|
689
|
-
const category = this.config.color.valueAccessor(datum);
|
|
690
|
-
const tooltipData: BarsTooltipDatum<Datum> = {
|
|
691
|
-
datum,
|
|
692
|
-
color: this.scales.color(category),
|
|
693
|
-
values: {
|
|
694
|
-
x:
|
|
695
|
-
this.config.dimensions.x === 'ordinal'
|
|
696
|
-
? ordinalValue
|
|
697
|
-
: quantitativeValue,
|
|
698
|
-
y:
|
|
699
|
-
this.config.dimensions.y === 'ordinal'
|
|
700
|
-
? ordinalValue
|
|
701
|
-
: quantitativeValue,
|
|
702
|
-
category,
|
|
703
|
-
},
|
|
704
|
-
};
|
|
705
|
-
return tooltipData;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
getSourceDatumFromBarDatum(barDatum: BarDatum<TOrdinalValue>): Datum {
|
|
709
|
-
return this.config.data.find(
|
|
710
|
-
(d) =>
|
|
711
|
-
this.config.ordinal.values[barDatum.index] ===
|
|
712
|
-
this.config.ordinal.valueAccessor(d) &&
|
|
713
|
-
this.config.quantitative.values[barDatum.index] ===
|
|
714
|
-
this.config.quantitative.valueAccessor(d)
|
|
715
|
-
);
|
|
716
|
-
}
|
|
717
|
-
}
|