@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,1470 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
3
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
4
|
-
import { XyChartComponent } from '../charts/xy-chart/xy-chart.component';
|
|
5
|
-
import { ColorUtilities } from '../core/utilities/colors';
|
|
6
|
-
import { FillUtilities } from '../core/utilities/fill-utilities';
|
|
7
|
-
import { ValueUtilities } from '../core/utilities/values';
|
|
8
|
-
import { BarDatum, BarsComponent } from './bars.component';
|
|
9
|
-
import { VicBarsConfigBuilder } from './config/bars-builder';
|
|
10
|
-
import { BarsConfig } from './config/bars-config';
|
|
11
|
-
|
|
12
|
-
type Datum = { value: number; state: string; fruit: string };
|
|
13
|
-
|
|
14
|
-
const data = [
|
|
15
|
-
{ value: 1, state: 'AL', fruit: 'apple' },
|
|
16
|
-
{ value: 2, state: 'AK', fruit: 'avocado' },
|
|
17
|
-
{ value: 3, state: 'AZ', fruit: 'banana' },
|
|
18
|
-
{ value: 4, state: 'CA', fruit: 'cherry' },
|
|
19
|
-
{ value: 5, state: 'CO', fruit: 'date' },
|
|
20
|
-
{ value: 6, state: 'CO', fruit: 'durian' },
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
function horizontalConfig(): BarsConfig<Datum, string> {
|
|
24
|
-
return new VicBarsConfigBuilder<Datum, string>()
|
|
25
|
-
.data(data)
|
|
26
|
-
.horizontal((bars) =>
|
|
27
|
-
bars
|
|
28
|
-
.x((dimension) => dimension.valueAccessor((d) => d.value))
|
|
29
|
-
.y((dimension) => dimension.valueAccessor((d) => d.state))
|
|
30
|
-
)
|
|
31
|
-
.color((dimension) => dimension.valueAccessor((d) => d.fruit))
|
|
32
|
-
.labels((labels) => labels.noValueFunction(() => 'no value'))
|
|
33
|
-
.getConfig();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function verticalConfig(): BarsConfig<Datum, string> {
|
|
37
|
-
return new VicBarsConfigBuilder<Datum, string>()
|
|
38
|
-
.data(data)
|
|
39
|
-
.vertical((bars) =>
|
|
40
|
-
bars
|
|
41
|
-
.y((dimension) => dimension.valueAccessor((d) => d.value))
|
|
42
|
-
.x((dimension) => dimension.valueAccessor((d) => d.state))
|
|
43
|
-
)
|
|
44
|
-
.color((dimension) =>
|
|
45
|
-
dimension
|
|
46
|
-
.valueAccessor((d) => d.fruit)
|
|
47
|
-
.range(['red', 'blue', 'green', 'yellow', 'purple'])
|
|
48
|
-
)
|
|
49
|
-
.labels((labels) => labels.noValueFunction(() => 'no value'))
|
|
50
|
-
.getConfig();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
describe('BarsComponent', () => {
|
|
54
|
-
let component: BarsComponent<any, string>;
|
|
55
|
-
let fixture: ComponentFixture<BarsComponent<Datum, string>>;
|
|
56
|
-
|
|
57
|
-
beforeEach(async () => {
|
|
58
|
-
await TestBed.configureTestingModule({
|
|
59
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
60
|
-
imports: [BarsComponent],
|
|
61
|
-
providers: [XyChartComponent],
|
|
62
|
-
}).compileComponents();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
beforeEach(() => {
|
|
66
|
-
fixture = TestBed.createComponent(BarsComponent<Datum, string>);
|
|
67
|
-
component = fixture.componentInstance;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe('setChartScalesFromRanges', () => {
|
|
71
|
-
beforeEach(() => {
|
|
72
|
-
component.ranges = {
|
|
73
|
-
x: [1, 2],
|
|
74
|
-
y: [3, 4],
|
|
75
|
-
} as any;
|
|
76
|
-
component.chart = {
|
|
77
|
-
updateScales: jasmine.createSpy('updatesScales'),
|
|
78
|
-
} as any;
|
|
79
|
-
});
|
|
80
|
-
describe('chart is horizontal', () => {
|
|
81
|
-
beforeEach(() => {
|
|
82
|
-
component.config = horizontalConfig();
|
|
83
|
-
spyOn(component.config.color, 'getScale').and.returnValue(
|
|
84
|
-
'categorical scale' as any
|
|
85
|
-
);
|
|
86
|
-
spyOn(component.config.ordinal, 'getScaleFromRange').and.returnValue(
|
|
87
|
-
'ordinal scale' as any
|
|
88
|
-
);
|
|
89
|
-
spyOn(
|
|
90
|
-
component.config.quantitative,
|
|
91
|
-
'getScaleFromRange'
|
|
92
|
-
).and.returnValue('quantitative scale' as any);
|
|
93
|
-
});
|
|
94
|
-
it('calls the scale for x dimension once', () => {
|
|
95
|
-
component.setChartScalesFromRanges(true);
|
|
96
|
-
expect(
|
|
97
|
-
component.config.quantitative.getScaleFromRange
|
|
98
|
-
).toHaveBeenCalledOnceWith([1, 2]);
|
|
99
|
-
});
|
|
100
|
-
it('calls the scale for y dimension once', () => {
|
|
101
|
-
component.setChartScalesFromRanges(false);
|
|
102
|
-
expect(
|
|
103
|
-
component.config.ordinal.getScaleFromRange
|
|
104
|
-
).toHaveBeenCalledOnceWith([3, 4]);
|
|
105
|
-
});
|
|
106
|
-
it('calls updateScales once with the correct value', () => {
|
|
107
|
-
component.setChartScalesFromRanges(false);
|
|
108
|
-
expect(component.chart.updateScales).toHaveBeenCalledOnceWith({
|
|
109
|
-
x: 'quantitative scale',
|
|
110
|
-
y: 'ordinal scale',
|
|
111
|
-
useTransition: false,
|
|
112
|
-
} as any);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
describe('chart is vertical', () => {
|
|
116
|
-
beforeEach(() => {
|
|
117
|
-
component.config = verticalConfig();
|
|
118
|
-
spyOn(component.config.color, 'getScale').and.returnValue(
|
|
119
|
-
'categorical scale' as any
|
|
120
|
-
);
|
|
121
|
-
spyOn(component.config.ordinal, 'getScaleFromRange').and.returnValue(
|
|
122
|
-
'ordinal scale' as any
|
|
123
|
-
);
|
|
124
|
-
spyOn(
|
|
125
|
-
component.config.quantitative,
|
|
126
|
-
'getScaleFromRange'
|
|
127
|
-
).and.returnValue('quantitative scale' as any);
|
|
128
|
-
});
|
|
129
|
-
it('calls the scale for x dimension once', () => {
|
|
130
|
-
component.setChartScalesFromRanges(true);
|
|
131
|
-
expect(
|
|
132
|
-
component.config.ordinal.getScaleFromRange
|
|
133
|
-
).toHaveBeenCalledOnceWith([1, 2]);
|
|
134
|
-
});
|
|
135
|
-
it('calls the scale for y dimension once', () => {
|
|
136
|
-
component.setChartScalesFromRanges(false);
|
|
137
|
-
expect(
|
|
138
|
-
component.config.quantitative.getScaleFromRange
|
|
139
|
-
).toHaveBeenCalledOnceWith([3, 4]);
|
|
140
|
-
});
|
|
141
|
-
it('calls updateScales once with the correct value', () => {
|
|
142
|
-
component.setChartScalesFromRanges(false);
|
|
143
|
-
expect(component.chart.updateScales).toHaveBeenCalledOnceWith({
|
|
144
|
-
x: 'ordinal scale',
|
|
145
|
-
y: 'quantitative scale',
|
|
146
|
-
useTransition: false,
|
|
147
|
-
} as any);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
describe('drawMarks()', () => {
|
|
153
|
-
beforeEach(() => {
|
|
154
|
-
spyOn(component, 'drawBars');
|
|
155
|
-
spyOn(component, 'drawLabels');
|
|
156
|
-
spyOn(component, 'updateBarElements');
|
|
157
|
-
spyOn(component, 'getTransitionDuration').and.returnValue(100);
|
|
158
|
-
component.config = horizontalConfig();
|
|
159
|
-
});
|
|
160
|
-
it('calls drawBars once with the correct parameter', () => {
|
|
161
|
-
component.drawMarks();
|
|
162
|
-
expect(component.drawBars).toHaveBeenCalledOnceWith(100);
|
|
163
|
-
});
|
|
164
|
-
it('calls drawBarLabels if config.labels is truthy', () => {
|
|
165
|
-
component.drawMarks();
|
|
166
|
-
expect(component.drawLabels).toHaveBeenCalledOnceWith(100);
|
|
167
|
-
});
|
|
168
|
-
it('does not call drawBarLabels if config.labels is falsy', () => {
|
|
169
|
-
(component.config as any).labels = undefined;
|
|
170
|
-
component.drawMarks();
|
|
171
|
-
expect(component.drawLabels).not.toHaveBeenCalled();
|
|
172
|
-
});
|
|
173
|
-
it('calls updateBarElements', () => {
|
|
174
|
-
component.drawMarks();
|
|
175
|
-
expect(component.updateBarElements).toHaveBeenCalledTimes(1);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe('getBarDatumFromIndex()', () => {
|
|
180
|
-
beforeEach(() => {
|
|
181
|
-
component.config = horizontalConfig();
|
|
182
|
-
});
|
|
183
|
-
it('returns the correct value', () => {
|
|
184
|
-
expect(component.getBarDatumFromIndex(1)).toEqual({
|
|
185
|
-
index: 1,
|
|
186
|
-
quantitative: 2,
|
|
187
|
-
ordinal: 'AK',
|
|
188
|
-
color: 'avocado',
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
describe('getBarGroupTransform()', () => {
|
|
194
|
-
let datum: BarDatum<string>;
|
|
195
|
-
beforeEach(() => {
|
|
196
|
-
spyOn(component, 'getBarX').and.returnValue(1);
|
|
197
|
-
spyOn(component, 'getBarY').and.returnValue(10);
|
|
198
|
-
component.config = horizontalConfig();
|
|
199
|
-
datum = component.getBarDatumFromIndex(1);
|
|
200
|
-
});
|
|
201
|
-
it('calls getBarX once with the correct value', () => {
|
|
202
|
-
component.getBarGroupTransform(datum);
|
|
203
|
-
expect(component.getBarX).toHaveBeenCalledOnceWith(datum);
|
|
204
|
-
});
|
|
205
|
-
it('calls getBarY once with the correct value', () => {
|
|
206
|
-
component.getBarGroupTransform(datum);
|
|
207
|
-
expect(component.getBarY).toHaveBeenCalledOnceWith(datum);
|
|
208
|
-
});
|
|
209
|
-
it('returns the correct value', () => {
|
|
210
|
-
expect(component.getBarGroupTransform(datum)).toEqual('translate(1,10)');
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('getBarFill', () => {
|
|
215
|
-
let datum: BarDatum<string>;
|
|
216
|
-
beforeEach(() => {
|
|
217
|
-
spyOn(component, 'getBarColor').and.returnValue('bar color');
|
|
218
|
-
spyOn(component, 'getBarPattern').and.returnValue('bar pattern');
|
|
219
|
-
component.config = horizontalConfig();
|
|
220
|
-
datum = component.getBarDatumFromIndex(1);
|
|
221
|
-
});
|
|
222
|
-
it('returns the result of getBarColor if there are no pattern fills specified', () => {
|
|
223
|
-
expect(component.getBarFill(datum)).toEqual('bar color');
|
|
224
|
-
});
|
|
225
|
-
it('returns the result of getBarPattern if there are pattern fills specified', () => {
|
|
226
|
-
(component.config as any).customFills = [
|
|
227
|
-
{ defId: 'pattern', shouldApply: () => true },
|
|
228
|
-
];
|
|
229
|
-
expect(component.getBarFill(datum)).toEqual('bar pattern');
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
describe('getBarX()', () => {
|
|
234
|
-
let datum: BarDatum<string>;
|
|
235
|
-
beforeEach(() => {
|
|
236
|
-
spyOn(component, 'getBarXOrdinal').and.returnValue('ordinal' as any);
|
|
237
|
-
spyOn(component, 'getBarXQuantitative').and.returnValue(
|
|
238
|
-
'quantitative' as any
|
|
239
|
-
);
|
|
240
|
-
});
|
|
241
|
-
describe('x dimension is ordinal', () => {
|
|
242
|
-
beforeEach(() => {
|
|
243
|
-
component.config = verticalConfig();
|
|
244
|
-
datum = component.getBarDatumFromIndex(2);
|
|
245
|
-
});
|
|
246
|
-
it('calls getBarXOrdinal once with the correct value', () => {
|
|
247
|
-
component.getBarX(datum);
|
|
248
|
-
expect(component.getBarXOrdinal).toHaveBeenCalledOnceWith(datum);
|
|
249
|
-
});
|
|
250
|
-
it('does not call getBarXQuantitative', () => {
|
|
251
|
-
component.getBarX(datum);
|
|
252
|
-
expect(component.getBarXQuantitative).not.toHaveBeenCalled();
|
|
253
|
-
});
|
|
254
|
-
it('returns the correct value', () => {
|
|
255
|
-
expect(component.getBarX(datum)).toEqual('ordinal' as any);
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
describe('y dimension is ordinal', () => {
|
|
259
|
-
beforeEach(() => {
|
|
260
|
-
component.config = horizontalConfig();
|
|
261
|
-
datum = component.getBarDatumFromIndex(2);
|
|
262
|
-
});
|
|
263
|
-
it('calls getBarXQuantitative once with the correct value', () => {
|
|
264
|
-
component.getBarX(datum);
|
|
265
|
-
expect(component.getBarXQuantitative).toHaveBeenCalledOnceWith(datum);
|
|
266
|
-
});
|
|
267
|
-
it('does not call getBarXOrdinal', () => {
|
|
268
|
-
component.getBarX(datum);
|
|
269
|
-
expect(component.getBarXOrdinal).not.toHaveBeenCalled();
|
|
270
|
-
});
|
|
271
|
-
it('returns the correct value', () => {
|
|
272
|
-
expect(component.getBarX(datum)).toEqual('quantitative' as any);
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
describe('getBarXOrdinal()', () => {
|
|
278
|
-
let datum: BarDatum<string>;
|
|
279
|
-
let xSpy: jasmine.Spy;
|
|
280
|
-
beforeEach(() => {
|
|
281
|
-
xSpy = jasmine.createSpy('x').and.returnValue(10);
|
|
282
|
-
component.config = verticalConfig();
|
|
283
|
-
datum = component.getBarDatumFromIndex(2);
|
|
284
|
-
component.scales = {
|
|
285
|
-
x: xSpy,
|
|
286
|
-
} as any;
|
|
287
|
-
});
|
|
288
|
-
it('calls xScale once with the correct value', () => {
|
|
289
|
-
component.getBarXOrdinal(datum);
|
|
290
|
-
expect(component.scales.x).toHaveBeenCalledOnceWith(datum.ordinal);
|
|
291
|
-
});
|
|
292
|
-
it('returns the correct value', () => {
|
|
293
|
-
expect(component.getBarXOrdinal(datum)).toEqual(10);
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
describe('getBarXQuantitative()', () => {
|
|
298
|
-
let datum: BarDatum<string>;
|
|
299
|
-
let xSpy: jasmine.Spy;
|
|
300
|
-
beforeEach(() => {
|
|
301
|
-
xSpy = jasmine.createSpy('x').and.returnValue(10);
|
|
302
|
-
component.config = horizontalConfig();
|
|
303
|
-
datum = component.getBarDatumFromIndex(2);
|
|
304
|
-
component.scales = {
|
|
305
|
-
x: xSpy,
|
|
306
|
-
} as any;
|
|
307
|
-
spyOn(component, 'getQuantitativeDomainFromScale').and.returnValue([
|
|
308
|
-
2, 4,
|
|
309
|
-
]);
|
|
310
|
-
spyOn(component, 'getBarQuantitativeOrigin').and.returnValue(10);
|
|
311
|
-
});
|
|
312
|
-
it('calls xScale once', () => {
|
|
313
|
-
component.getBarXQuantitative(datum);
|
|
314
|
-
expect(component.scales.x).toHaveBeenCalledTimes(1);
|
|
315
|
-
});
|
|
316
|
-
it('calls xScale once with origin if quant value is not a number', () => {
|
|
317
|
-
datum.quantitative =
|
|
318
|
-
'oops it turns out there is a string in the users quant data' as any;
|
|
319
|
-
component.getBarXQuantitative(datum);
|
|
320
|
-
expect(component.scales.x).toHaveBeenCalledWith(10);
|
|
321
|
-
});
|
|
322
|
-
it('calls xScale once with the origin if quant value is 0', () => {
|
|
323
|
-
datum.quantitative = 0;
|
|
324
|
-
component.getBarXQuantitative(datum);
|
|
325
|
-
expect(component.scales.x).toHaveBeenCalledWith(10);
|
|
326
|
-
});
|
|
327
|
-
describe('hasNegativeValues is true', () => {
|
|
328
|
-
beforeEach(() => {
|
|
329
|
-
component.config.hasNegativeValues = true;
|
|
330
|
-
});
|
|
331
|
-
it('calls xScale once with quant value if quant value is less than 0', () => {
|
|
332
|
-
datum.quantitative = -1;
|
|
333
|
-
component.getBarXQuantitative(datum);
|
|
334
|
-
expect(component.scales.x).toHaveBeenCalledWith(-1);
|
|
335
|
-
});
|
|
336
|
-
it('calls xScale once with 0 if quant value is greater than 0', () => {
|
|
337
|
-
datum.quantitative = 3;
|
|
338
|
-
component.getBarXQuantitative(datum);
|
|
339
|
-
expect(component.scales.x).toHaveBeenCalledWith(0);
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
describe('hasNegativeValues is false', () => {
|
|
343
|
-
beforeEach(() => {
|
|
344
|
-
component.config.hasNegativeValues = false;
|
|
345
|
-
});
|
|
346
|
-
it('calls xScale once with the correct value if quant value is greater than 0', () => {
|
|
347
|
-
datum.quantitative = 3;
|
|
348
|
-
component.getBarXQuantitative(datum);
|
|
349
|
-
expect(component.scales.x).toHaveBeenCalledWith(2);
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
describe('getBarY()', () => {
|
|
355
|
-
let datum: BarDatum<string>;
|
|
356
|
-
beforeEach(() => {
|
|
357
|
-
spyOn(component, 'getBarYOrdinal').and.returnValue('ordinal' as any);
|
|
358
|
-
spyOn(component, 'getBarYQuantitative').and.returnValue(
|
|
359
|
-
'quantitative' as any
|
|
360
|
-
);
|
|
361
|
-
});
|
|
362
|
-
describe('chart is horizontal', () => {
|
|
363
|
-
beforeEach(() => {
|
|
364
|
-
component.config = horizontalConfig();
|
|
365
|
-
datum = component.getBarDatumFromIndex(2);
|
|
366
|
-
});
|
|
367
|
-
it('calls getBarYOrdinal with datum if chart is horizontal', () => {
|
|
368
|
-
component.config = horizontalConfig();
|
|
369
|
-
component.getBarY(datum);
|
|
370
|
-
expect(component.getBarYOrdinal).toHaveBeenCalledOnceWith(datum);
|
|
371
|
-
});
|
|
372
|
-
it('returns the correct value', () => {
|
|
373
|
-
expect(component.getBarY(datum)).toEqual('ordinal' as any);
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
describe('chart is vertical', () => {
|
|
377
|
-
beforeEach(() => {
|
|
378
|
-
component.config = verticalConfig();
|
|
379
|
-
datum = component.getBarDatumFromIndex(2);
|
|
380
|
-
});
|
|
381
|
-
it('calls getBarYQuantitative with datum if chart is vertical', () => {
|
|
382
|
-
component.getBarY(datum);
|
|
383
|
-
expect(component.getBarYQuantitative).toHaveBeenCalledOnceWith(datum);
|
|
384
|
-
});
|
|
385
|
-
it('returns the correct value', () => {
|
|
386
|
-
expect(component.getBarY(datum)).toEqual('quantitative' as any);
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
describe('getBarYOrdinal()', () => {
|
|
392
|
-
let datum: BarDatum<string>;
|
|
393
|
-
let ySpy: jasmine.Spy;
|
|
394
|
-
beforeEach(() => {
|
|
395
|
-
ySpy = jasmine.createSpy('y').and.returnValue(10);
|
|
396
|
-
component.config = horizontalConfig();
|
|
397
|
-
datum = component.getBarDatumFromIndex(2);
|
|
398
|
-
component.scales = {
|
|
399
|
-
y: ySpy,
|
|
400
|
-
} as any;
|
|
401
|
-
});
|
|
402
|
-
it('calls yScale once with the correct value', () => {
|
|
403
|
-
component.getBarYOrdinal(datum);
|
|
404
|
-
expect(component.scales.y).toHaveBeenCalledOnceWith(datum.ordinal);
|
|
405
|
-
});
|
|
406
|
-
it('returns the correct value', () => {
|
|
407
|
-
expect(component.getBarYOrdinal(datum)).toEqual(10);
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
describe('getBarYQuantitative()', () => {
|
|
412
|
-
let datum: BarDatum<string>;
|
|
413
|
-
let ySpy: jasmine.Spy;
|
|
414
|
-
beforeEach(() => {
|
|
415
|
-
ySpy = jasmine.createSpy('y').and.returnValue(10);
|
|
416
|
-
component.config = verticalConfig();
|
|
417
|
-
datum = component.getBarDatumFromIndex(2);
|
|
418
|
-
component.scales = {
|
|
419
|
-
y: ySpy,
|
|
420
|
-
} as any;
|
|
421
|
-
spyOn(component, 'getQuantitativeDomainFromScale').and.returnValue([
|
|
422
|
-
2, 4,
|
|
423
|
-
]);
|
|
424
|
-
spyOn(component, 'getBarQuantitativeOrigin').and.returnValue(10);
|
|
425
|
-
});
|
|
426
|
-
it('calls yScale once', () => {
|
|
427
|
-
component.getBarYQuantitative(datum);
|
|
428
|
-
expect(component.scales.y).toHaveBeenCalledTimes(1);
|
|
429
|
-
});
|
|
430
|
-
it('calls yScale once with origin if quant value is not a number', () => {
|
|
431
|
-
datum.quantitative = 'oops i am a string' as any;
|
|
432
|
-
component.getBarYQuantitative(datum);
|
|
433
|
-
expect(component.scales.y).toHaveBeenCalledWith(10);
|
|
434
|
-
});
|
|
435
|
-
it('calls yScale once with the origin if quant value is 0', () => {
|
|
436
|
-
datum.quantitative = 0;
|
|
437
|
-
component.getBarYQuantitative(datum);
|
|
438
|
-
expect(component.scales.y).toHaveBeenCalledWith(10);
|
|
439
|
-
});
|
|
440
|
-
describe('quantitative value is less than zero', () => {
|
|
441
|
-
beforeEach(() => {
|
|
442
|
-
datum.quantitative = -5;
|
|
443
|
-
});
|
|
444
|
-
it('calls yScale once with 0 if domainIncludesZero is true', () => {
|
|
445
|
-
component.config.quantitative.domainIncludesZero = true;
|
|
446
|
-
component.getBarYQuantitative(datum);
|
|
447
|
-
expect(component.scales.y).toHaveBeenCalledWith(0);
|
|
448
|
-
});
|
|
449
|
-
it('calls yScale once with the correct value if domainIncludesZero is false', () => {
|
|
450
|
-
component.config.quantitative.domainIncludesZero = false;
|
|
451
|
-
component.getBarYQuantitative(datum);
|
|
452
|
-
expect(component.scales.y).toHaveBeenCalledWith(4);
|
|
453
|
-
});
|
|
454
|
-
});
|
|
455
|
-
describe('quantitative value is greater than zero', () => {
|
|
456
|
-
it('calls yScale once with the quantitative value', () => {
|
|
457
|
-
component.getBarYQuantitative(datum);
|
|
458
|
-
expect(component.scales.y).toHaveBeenCalledWith(datum.quantitative);
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
describe('getQuantitativeDomainFromScale()', () => {
|
|
464
|
-
beforeEach(() => {
|
|
465
|
-
component.scales = {
|
|
466
|
-
x: { domain: () => [1, 2] },
|
|
467
|
-
y: { domain: () => [3, 4] },
|
|
468
|
-
} as any;
|
|
469
|
-
});
|
|
470
|
-
it('returns the x domain if bars are horizontal', () => {
|
|
471
|
-
component.config = horizontalConfig();
|
|
472
|
-
expect(component.getQuantitativeDomainFromScale()).toEqual([1, 2]);
|
|
473
|
-
});
|
|
474
|
-
it('returns the y domain if bars are vertical', () => {
|
|
475
|
-
component.config = verticalConfig();
|
|
476
|
-
expect(component.getQuantitativeDomainFromScale()).toEqual([3, 4]);
|
|
477
|
-
});
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
describe('getBarWidth()', () => {
|
|
481
|
-
let datum: BarDatum<string>;
|
|
482
|
-
beforeEach(() => {
|
|
483
|
-
spyOn(component, 'getBarDimensionQuantitative').and.returnValue(10);
|
|
484
|
-
spyOn(component, 'getBarWidthOrdinal').and.returnValue(20);
|
|
485
|
-
});
|
|
486
|
-
describe('bars are horizontal', () => {
|
|
487
|
-
beforeEach(() => {
|
|
488
|
-
component.config = horizontalConfig();
|
|
489
|
-
datum = component.getBarDatumFromIndex(2);
|
|
490
|
-
});
|
|
491
|
-
it('calls getBarDimensionQuantitative once with datum and x', () => {
|
|
492
|
-
component.getBarWidth(datum);
|
|
493
|
-
expect(component.getBarDimensionQuantitative).toHaveBeenCalledOnceWith(
|
|
494
|
-
datum,
|
|
495
|
-
'x'
|
|
496
|
-
);
|
|
497
|
-
});
|
|
498
|
-
it('returns the value from getBarDimensionQuantitative', () => {
|
|
499
|
-
expect(component.getBarWidth(datum)).toEqual(10);
|
|
500
|
-
});
|
|
501
|
-
});
|
|
502
|
-
describe('bars are vertical', () => {
|
|
503
|
-
beforeEach(() => {
|
|
504
|
-
component.config = verticalConfig();
|
|
505
|
-
datum = component.getBarDatumFromIndex(2);
|
|
506
|
-
});
|
|
507
|
-
it('calls getBarWidthOrdinal once with datum and y', () => {
|
|
508
|
-
component.getBarWidth(datum);
|
|
509
|
-
expect(component.getBarWidthOrdinal).toHaveBeenCalledTimes(1);
|
|
510
|
-
});
|
|
511
|
-
it('returns the value from getBarDimensionQuantitative', () => {
|
|
512
|
-
expect(component.getBarWidth(datum)).toEqual(20);
|
|
513
|
-
});
|
|
514
|
-
});
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
describe('getBarWidthOrdinal()', () => {
|
|
518
|
-
let bandwidthSpy: jasmine.Spy;
|
|
519
|
-
beforeEach(() => {
|
|
520
|
-
bandwidthSpy = jasmine.createSpy('bandwidth').and.returnValue(10);
|
|
521
|
-
component.scales = {
|
|
522
|
-
x: { bandwidth: bandwidthSpy },
|
|
523
|
-
} as any;
|
|
524
|
-
});
|
|
525
|
-
it('calls bandwidth on x scale once', () => {
|
|
526
|
-
component.getBarWidthOrdinal();
|
|
527
|
-
expect((component.scales.x as any).bandwidth).toHaveBeenCalledTimes(1);
|
|
528
|
-
});
|
|
529
|
-
it('returns the value from bandwidth', () => {
|
|
530
|
-
expect(component.getBarWidthOrdinal()).toEqual(10);
|
|
531
|
-
});
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
describe('getBarHeight', () => {
|
|
535
|
-
let datum: BarDatum<string>;
|
|
536
|
-
beforeEach(() => {
|
|
537
|
-
spyOn(component, 'getBarDimensionQuantitative').and.returnValue(10);
|
|
538
|
-
spyOn(component, 'getBarHeightOrdinal').and.returnValue(20);
|
|
539
|
-
});
|
|
540
|
-
describe('bars are horizontal', () => {
|
|
541
|
-
beforeEach(() => {
|
|
542
|
-
component.config = horizontalConfig();
|
|
543
|
-
datum = component.getBarDatumFromIndex(2);
|
|
544
|
-
});
|
|
545
|
-
it('calls getBarHeightOrdinal once with datum and y', () => {
|
|
546
|
-
component.getBarHeight(datum);
|
|
547
|
-
expect(component.getBarHeightOrdinal).toHaveBeenCalledTimes(1);
|
|
548
|
-
});
|
|
549
|
-
it('returns the value from getBarHeightOrdinal', () => {
|
|
550
|
-
expect(component.getBarHeight(datum)).toEqual(20);
|
|
551
|
-
});
|
|
552
|
-
});
|
|
553
|
-
describe('bars are vertical', () => {
|
|
554
|
-
beforeEach(() => {
|
|
555
|
-
component.config = verticalConfig();
|
|
556
|
-
datum = component.getBarDatumFromIndex(2);
|
|
557
|
-
});
|
|
558
|
-
it('calls getBarDimensionQuantitative once with datum and x', () => {
|
|
559
|
-
component.getBarHeight(datum);
|
|
560
|
-
expect(component.getBarDimensionQuantitative).toHaveBeenCalledOnceWith(
|
|
561
|
-
datum,
|
|
562
|
-
'y'
|
|
563
|
-
);
|
|
564
|
-
});
|
|
565
|
-
it('returns the value from getBarDimensionQuantitative', () => {
|
|
566
|
-
expect(component.getBarHeight(datum)).toEqual(10);
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
describe('getBarHeightOrdinal()', () => {
|
|
572
|
-
let bandwidthSpy: jasmine.Spy;
|
|
573
|
-
beforeEach(() => {
|
|
574
|
-
bandwidthSpy = jasmine.createSpy('bandwidth').and.returnValue(10);
|
|
575
|
-
component.scales = {
|
|
576
|
-
y: { bandwidth: bandwidthSpy },
|
|
577
|
-
} as any;
|
|
578
|
-
});
|
|
579
|
-
it('calls bandwidth on y scale once', () => {
|
|
580
|
-
component.getBarHeightOrdinal();
|
|
581
|
-
expect((component.scales.y as any).bandwidth).toHaveBeenCalledTimes(1);
|
|
582
|
-
});
|
|
583
|
-
it('returns the value from bandwidth', () => {
|
|
584
|
-
expect(component.getBarHeightOrdinal()).toEqual(10);
|
|
585
|
-
});
|
|
586
|
-
});
|
|
587
|
-
|
|
588
|
-
describe('getBarDimensionQuantitative()', () => {
|
|
589
|
-
let datum: BarDatum<string>;
|
|
590
|
-
let xSpy: jasmine.Spy;
|
|
591
|
-
let ySpy: jasmine.Spy;
|
|
592
|
-
beforeEach(() => {
|
|
593
|
-
component.config = horizontalConfig();
|
|
594
|
-
datum = component.getBarDatumFromIndex(2);
|
|
595
|
-
xSpy = jasmine.createSpy('x').and.returnValues(20, 50);
|
|
596
|
-
ySpy = jasmine.createSpy('y').and.returnValues(50, 100);
|
|
597
|
-
spyOn(component, 'getBarQuantitativeOrigin').and.returnValue(30);
|
|
598
|
-
component.scales = {
|
|
599
|
-
x: xSpy,
|
|
600
|
-
y: ySpy,
|
|
601
|
-
} as any;
|
|
602
|
-
});
|
|
603
|
-
it('returns zero if quantitative value is non-numeric', () => {
|
|
604
|
-
datum.quantitative = 'not a number' as any;
|
|
605
|
-
expect(component.getBarDimensionQuantitative(datum, 'x')).toEqual(0);
|
|
606
|
-
});
|
|
607
|
-
it('returns zero if quantitative value is zero', () => {
|
|
608
|
-
datum.quantitative = 0;
|
|
609
|
-
expect(component.getBarDimensionQuantitative(datum, 'y')).toEqual(0);
|
|
610
|
-
});
|
|
611
|
-
describe('dimension is x', () => {
|
|
612
|
-
it('calls x scale twice, once with the quantitative value and once the origin', () => {
|
|
613
|
-
component.getBarDimensionQuantitative(datum, 'x');
|
|
614
|
-
expect(xSpy).toHaveBeenCalledTimes(2);
|
|
615
|
-
});
|
|
616
|
-
it('calls x scale with the quantitative value and the origin', () => {
|
|
617
|
-
component.getBarDimensionQuantitative(datum, 'x');
|
|
618
|
-
expect(xSpy.calls.allArgs()).toEqual([[3], [30]]);
|
|
619
|
-
});
|
|
620
|
-
it('returns the absolute value of the difference between the two scales calls', () => {
|
|
621
|
-
expect(component.getBarDimensionQuantitative(datum, 'x')).toEqual(30);
|
|
622
|
-
});
|
|
623
|
-
});
|
|
624
|
-
describe('dimension is y', () => {
|
|
625
|
-
it('calls y scale twice, once with the quantitative value and once the origin', () => {
|
|
626
|
-
component.getBarDimensionQuantitative(datum, 'y');
|
|
627
|
-
expect(ySpy).toHaveBeenCalledTimes(2);
|
|
628
|
-
});
|
|
629
|
-
it('calls y scale once with the quantitative value and once the origin', () => {
|
|
630
|
-
component.getBarDimensionQuantitative(datum, 'y');
|
|
631
|
-
expect(ySpy.calls.allArgs()).toEqual([[3], [30]]);
|
|
632
|
-
});
|
|
633
|
-
it('returns the absolute value of the difference between the two scales calls', () => {
|
|
634
|
-
expect(component.getBarDimensionQuantitative(datum, 'y')).toEqual(50);
|
|
635
|
-
});
|
|
636
|
-
});
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
describe('getBarQuantitativeOrigin()', () => {
|
|
640
|
-
beforeEach(() => {
|
|
641
|
-
spyOn(component, 'getQuantitativeDomainFromScale').and.returnValue([
|
|
642
|
-
2, 4,
|
|
643
|
-
]);
|
|
644
|
-
component.config = horizontalConfig();
|
|
645
|
-
});
|
|
646
|
-
it('returns 0 if domain includes 0', () => {
|
|
647
|
-
component.config.quantitative.domainIncludesZero = true;
|
|
648
|
-
expect(component.getBarQuantitativeOrigin()).toEqual(0);
|
|
649
|
-
});
|
|
650
|
-
describe('domainIncludesZero is false', () => {
|
|
651
|
-
beforeEach(() => {
|
|
652
|
-
component.config.quantitative.domainIncludesZero = false;
|
|
653
|
-
});
|
|
654
|
-
it('returns the second domain value if hasNegativeValues is true', () => {
|
|
655
|
-
component.config.hasNegativeValues = true;
|
|
656
|
-
expect(component.getBarQuantitativeOrigin()).toEqual(4);
|
|
657
|
-
});
|
|
658
|
-
it('returns the first domain value if hasNegativeValues is false', () => {
|
|
659
|
-
component.config.hasNegativeValues = false;
|
|
660
|
-
expect(component.getBarQuantitativeOrigin()).toEqual(2);
|
|
661
|
-
});
|
|
662
|
-
});
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
describe('getBarPattern()', () => {
|
|
666
|
-
let datum: BarDatum<string>;
|
|
667
|
-
const customFill = {
|
|
668
|
-
defId: 'pattern1',
|
|
669
|
-
shouldApply: (d) => d.fruit === 'avocado',
|
|
670
|
-
};
|
|
671
|
-
beforeEach(() => {
|
|
672
|
-
spyOn(component, 'getBarColor').and.returnValue('blue');
|
|
673
|
-
spyOn(FillUtilities, 'getFill').and.returnValue('return-pattern');
|
|
674
|
-
component.config = horizontalConfig();
|
|
675
|
-
datum = component.getBarDatumFromIndex(2);
|
|
676
|
-
(component.config as any).customFills = [customFill];
|
|
677
|
-
});
|
|
678
|
-
it('calls getBarColor once with the datum', () => {
|
|
679
|
-
component.getBarPattern(datum);
|
|
680
|
-
expect(component.getBarColor).toHaveBeenCalledOnceWith(datum);
|
|
681
|
-
});
|
|
682
|
-
it('calls getPatternFill once with the correct values', () => {
|
|
683
|
-
component.getBarPattern(datum);
|
|
684
|
-
expect(FillUtilities.getFill).toHaveBeenCalledOnceWith(data[2], 'blue', [
|
|
685
|
-
customFill,
|
|
686
|
-
]);
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
describe('getBarColor()', () => {
|
|
691
|
-
let datum: BarDatum<string>;
|
|
692
|
-
let colorSpy: jasmine.Spy;
|
|
693
|
-
beforeEach(() => {
|
|
694
|
-
component.config = horizontalConfig();
|
|
695
|
-
datum = component.getBarDatumFromIndex(2);
|
|
696
|
-
colorSpy = jasmine.createSpy('color').and.returnValue('blue');
|
|
697
|
-
component.scales = {
|
|
698
|
-
color: colorSpy,
|
|
699
|
-
} as any;
|
|
700
|
-
});
|
|
701
|
-
it('calls categorical scale once with the correct value', () => {
|
|
702
|
-
component.getBarColor(datum);
|
|
703
|
-
expect(component.scales.color).toHaveBeenCalledOnceWith('banana');
|
|
704
|
-
});
|
|
705
|
-
it('returns the correct value', () => {
|
|
706
|
-
expect(component.getBarColor(datum)).toEqual('blue');
|
|
707
|
-
});
|
|
708
|
-
});
|
|
709
|
-
|
|
710
|
-
describe('getLabelText()', () => {
|
|
711
|
-
let datum: BarDatum<string>;
|
|
712
|
-
beforeEach(() => {
|
|
713
|
-
component.config = horizontalConfig();
|
|
714
|
-
datum = component.getBarDatumFromIndex(2);
|
|
715
|
-
spyOn(ValueUtilities, 'customFormat').and.returnValue(
|
|
716
|
-
'custom formatted value'
|
|
717
|
-
);
|
|
718
|
-
spyOn(ValueUtilities, 'd3Format').and.returnValue('d3 formatted value');
|
|
719
|
-
});
|
|
720
|
-
it('returns the correct value if value is not a number', () => {
|
|
721
|
-
datum.quantitative = 'not a number' as any;
|
|
722
|
-
expect(component.getLabelText(datum)).toEqual('no value');
|
|
723
|
-
});
|
|
724
|
-
it('calls customFormat once with full datum if formatFunction exists', () => {
|
|
725
|
-
(component.config.quantitative as any).formatFunction = (d) =>
|
|
726
|
-
d.quantitative + '!';
|
|
727
|
-
component.getLabelText(datum);
|
|
728
|
-
expect(ValueUtilities.customFormat).toHaveBeenCalledOnceWith(
|
|
729
|
-
data[2],
|
|
730
|
-
component.config.quantitative.formatFunction
|
|
731
|
-
);
|
|
732
|
-
});
|
|
733
|
-
it('calls formatValue once with the correct value if formatFunction does not exist', () => {
|
|
734
|
-
component.getLabelText(datum);
|
|
735
|
-
expect(ValueUtilities.d3Format).toHaveBeenCalledOnceWith(
|
|
736
|
-
3,
|
|
737
|
-
component.config.quantitative.formatSpecifier
|
|
738
|
-
);
|
|
739
|
-
});
|
|
740
|
-
it('returns the formatted value', () => {
|
|
741
|
-
expect(component.getLabelText(datum)).toEqual('d3 formatted value');
|
|
742
|
-
});
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
describe('getLabelTextAnchor()', () => {
|
|
746
|
-
let datum: BarDatum<string>;
|
|
747
|
-
let alignTextSpy: jasmine.Spy;
|
|
748
|
-
const bbox = { width: 0, height: 0 } as DOMRect;
|
|
749
|
-
beforeEach(() => {
|
|
750
|
-
component.config = horizontalConfig();
|
|
751
|
-
datum = component.getBarDatumFromIndex(2);
|
|
752
|
-
alignTextSpy = spyOn(component, 'alignTextInPositiveDirection');
|
|
753
|
-
});
|
|
754
|
-
it('returns middle if bars are vertical', () => {
|
|
755
|
-
component.config = verticalConfig();
|
|
756
|
-
expect(component.getLabelTextAnchor(datum, bbox)).toEqual('middle');
|
|
757
|
-
});
|
|
758
|
-
describe('bars are horizontal', () => {
|
|
759
|
-
beforeEach(() => {
|
|
760
|
-
component.config = horizontalConfig();
|
|
761
|
-
});
|
|
762
|
-
it('calls alignTextInPositiveDirection once', () => {
|
|
763
|
-
component.getLabelTextAnchor(datum, bbox);
|
|
764
|
-
expect(alignTextSpy).toHaveBeenCalledOnceWith(datum, bbox);
|
|
765
|
-
});
|
|
766
|
-
it('returns start if text should be aligned in positive direction', () => {
|
|
767
|
-
alignTextSpy.and.returnValue(true);
|
|
768
|
-
expect(component.getLabelTextAnchor(datum, bbox)).toEqual('start');
|
|
769
|
-
});
|
|
770
|
-
it('returns end if text should be aligned in negative direction', () => {
|
|
771
|
-
alignTextSpy.and.returnValue(false);
|
|
772
|
-
expect(component.getLabelTextAnchor(datum, bbox)).toEqual('end');
|
|
773
|
-
});
|
|
774
|
-
});
|
|
775
|
-
});
|
|
776
|
-
|
|
777
|
-
describe('getLabelDominantBaseline()', () => {
|
|
778
|
-
let datum: BarDatum<string>;
|
|
779
|
-
let alignTextSpy: jasmine.Spy;
|
|
780
|
-
const bbox = { width: 0, height: 0 } as DOMRect;
|
|
781
|
-
beforeEach(() => {
|
|
782
|
-
alignTextSpy = spyOn(component, 'alignTextInPositiveDirection');
|
|
783
|
-
});
|
|
784
|
-
it('returns central if bars are horizontal', () => {
|
|
785
|
-
component.config = horizontalConfig();
|
|
786
|
-
datum = component.getBarDatumFromIndex(2);
|
|
787
|
-
expect(component.getLabelDominantBaseline(datum, bbox)).toEqual(
|
|
788
|
-
'central'
|
|
789
|
-
);
|
|
790
|
-
});
|
|
791
|
-
describe('bars are vertical', () => {
|
|
792
|
-
beforeEach(() => {
|
|
793
|
-
component.config = verticalConfig();
|
|
794
|
-
datum = component.getBarDatumFromIndex(2);
|
|
795
|
-
});
|
|
796
|
-
it('calls alignTextInPositiveDirection once', () => {
|
|
797
|
-
component.getLabelDominantBaseline(datum, bbox);
|
|
798
|
-
expect(alignTextSpy).toHaveBeenCalledOnceWith(datum, bbox);
|
|
799
|
-
});
|
|
800
|
-
it('returns text-after-edge if text should be aligned in positive direction', () => {
|
|
801
|
-
alignTextSpy.and.returnValue(true);
|
|
802
|
-
expect(component.getLabelDominantBaseline(datum, bbox)).toEqual(
|
|
803
|
-
'text-after-edge'
|
|
804
|
-
);
|
|
805
|
-
});
|
|
806
|
-
it('returns text-before-edge if text should be aligned in negative direction', () => {
|
|
807
|
-
alignTextSpy.and.returnValue(false);
|
|
808
|
-
expect(component.getLabelDominantBaseline(datum, bbox)).toEqual(
|
|
809
|
-
'text-before-edge'
|
|
810
|
-
);
|
|
811
|
-
});
|
|
812
|
-
});
|
|
813
|
-
});
|
|
814
|
-
|
|
815
|
-
describe('alignTextInPositiveDirection()', () => {
|
|
816
|
-
let datum: BarDatum<string>;
|
|
817
|
-
let zeroOrNonNumericSpy: jasmine.Spy;
|
|
818
|
-
let fitsOutsideSpy: jasmine.Spy;
|
|
819
|
-
const bbox = { width: 0, height: 0 } as DOMRect;
|
|
820
|
-
beforeEach(() => {
|
|
821
|
-
zeroOrNonNumericSpy = spyOn(
|
|
822
|
-
component,
|
|
823
|
-
'positionZeroOrNonNumericValueLabelInPositiveDirection'
|
|
824
|
-
);
|
|
825
|
-
fitsOutsideSpy = spyOn(component, 'labelFitsOutsideBar');
|
|
826
|
-
component.config = horizontalConfig();
|
|
827
|
-
datum = component.getBarDatumFromIndex(2);
|
|
828
|
-
});
|
|
829
|
-
describe('quantitative value is zero or non-numeric', () => {
|
|
830
|
-
it('calls positionZeroOrNonNumericValueLabelInPositiveDirection once - value is 0', () => {
|
|
831
|
-
datum.quantitative = 0;
|
|
832
|
-
component.alignTextInPositiveDirection(datum, bbox);
|
|
833
|
-
expect(zeroOrNonNumericSpy).toHaveBeenCalledTimes(1);
|
|
834
|
-
});
|
|
835
|
-
it('calls positionZeroOrNonNumericValueLabelInPositiveDirection once - value is non-numeric', () => {
|
|
836
|
-
datum.quantitative = 'not a number' as any;
|
|
837
|
-
component.alignTextInPositiveDirection(datum, bbox);
|
|
838
|
-
expect(zeroOrNonNumericSpy).toHaveBeenCalledTimes(1);
|
|
839
|
-
});
|
|
840
|
-
it('returns the return value from positionZeroOrNonNumericValueLabelInPositiveDirection if quant value is non-numeric', () => {
|
|
841
|
-
datum.quantitative = 'not a number' as any;
|
|
842
|
-
zeroOrNonNumericSpy.and.returnValue(true);
|
|
843
|
-
component.alignTextInPositiveDirection(datum, bbox);
|
|
844
|
-
expect(component.alignTextInPositiveDirection(datum, bbox)).toEqual(
|
|
845
|
-
true
|
|
846
|
-
);
|
|
847
|
-
});
|
|
848
|
-
});
|
|
849
|
-
describe('quantitative value is not zero or non-numeric', () => {
|
|
850
|
-
it('calls barLabelFitsOutsideBar once', () => {
|
|
851
|
-
component.alignTextInPositiveDirection(datum, bbox);
|
|
852
|
-
expect(fitsOutsideSpy).toHaveBeenCalledOnceWith(datum, bbox);
|
|
853
|
-
});
|
|
854
|
-
describe('barLabelFitsOutsideBar returns true', () => {
|
|
855
|
-
it('returns true if value is higher than 0', () => {
|
|
856
|
-
fitsOutsideSpy.and.returnValue(true);
|
|
857
|
-
expect(component.alignTextInPositiveDirection(datum, bbox)).toEqual(
|
|
858
|
-
true
|
|
859
|
-
);
|
|
860
|
-
});
|
|
861
|
-
it('returns false if value is lower than 0', () => {
|
|
862
|
-
datum.quantitative = -1;
|
|
863
|
-
fitsOutsideSpy.and.returnValue(true);
|
|
864
|
-
expect(component.alignTextInPositiveDirection(datum, bbox)).toEqual(
|
|
865
|
-
false
|
|
866
|
-
);
|
|
867
|
-
});
|
|
868
|
-
});
|
|
869
|
-
describe('barLabelFitsOutsideBar returns false', () => {
|
|
870
|
-
it('returns false if value is higher than 0', () => {
|
|
871
|
-
fitsOutsideSpy.and.returnValue(false);
|
|
872
|
-
expect(component.alignTextInPositiveDirection(datum, bbox)).toEqual(
|
|
873
|
-
false
|
|
874
|
-
);
|
|
875
|
-
});
|
|
876
|
-
it('returns true if value is lower than 0', () => {
|
|
877
|
-
datum.quantitative = -1;
|
|
878
|
-
fitsOutsideSpy.and.returnValue(false);
|
|
879
|
-
expect(component.alignTextInPositiveDirection(datum, bbox)).toEqual(
|
|
880
|
-
true
|
|
881
|
-
);
|
|
882
|
-
});
|
|
883
|
-
});
|
|
884
|
-
});
|
|
885
|
-
});
|
|
886
|
-
|
|
887
|
-
describe('getLabelColor()', () => {
|
|
888
|
-
let datum: BarDatum<string>;
|
|
889
|
-
let fitsOutsideSpy: jasmine.Spy;
|
|
890
|
-
let higherContrastSpy: jasmine.Spy;
|
|
891
|
-
const bbox = { width: 0, height: 0 } as DOMRect;
|
|
892
|
-
beforeEach(() => {
|
|
893
|
-
fitsOutsideSpy = spyOn(component, 'labelFitsOutsideBar');
|
|
894
|
-
spyOn(component, 'getBarColor').and.returnValue('blue');
|
|
895
|
-
higherContrastSpy = spyOn(
|
|
896
|
-
ColorUtilities,
|
|
897
|
-
'getHigherContrastColorForBackground'
|
|
898
|
-
);
|
|
899
|
-
component.config = horizontalConfig();
|
|
900
|
-
datum = component.getBarDatumFromIndex(2);
|
|
901
|
-
});
|
|
902
|
-
it('returns the default color if quant value is non-numeric', () => {
|
|
903
|
-
datum.quantitative = 'not a number' as any;
|
|
904
|
-
expect(component.getLabelColor(datum, bbox)).toEqual(
|
|
905
|
-
component.config.labels.color.default
|
|
906
|
-
);
|
|
907
|
-
});
|
|
908
|
-
it('returns the default color if quant value is 0', () => {
|
|
909
|
-
datum.quantitative = 0;
|
|
910
|
-
expect(component.getLabelColor(datum, bbox)).toEqual(
|
|
911
|
-
component.config.labels.color.default
|
|
912
|
-
);
|
|
913
|
-
});
|
|
914
|
-
describe('quant value is not 0 or non-numeric', () => {
|
|
915
|
-
it('calls barLabelFitsOutsideBar once if', () => {
|
|
916
|
-
component.getLabelColor(datum, bbox);
|
|
917
|
-
expect(fitsOutsideSpy).toHaveBeenCalledTimes(1);
|
|
918
|
-
});
|
|
919
|
-
it('returns the default color if barLabelFitsOutsideBar returns true', () => {
|
|
920
|
-
fitsOutsideSpy.and.returnValue(true);
|
|
921
|
-
expect(component.getLabelColor(datum, bbox)).toEqual(
|
|
922
|
-
component.config.labels.color.default
|
|
923
|
-
);
|
|
924
|
-
});
|
|
925
|
-
describe('barLabelFitsOutsideBar returns false', () => {
|
|
926
|
-
beforeEach(() => {
|
|
927
|
-
fitsOutsideSpy.and.returnValue(false);
|
|
928
|
-
});
|
|
929
|
-
it('calls getBarColor once with the datum', () => {
|
|
930
|
-
component.getLabelColor(datum, bbox);
|
|
931
|
-
expect(component.getBarColor).toHaveBeenCalledOnceWith(datum);
|
|
932
|
-
});
|
|
933
|
-
it('calls getHigherContrastColorForBackground once with the correct values', () => {
|
|
934
|
-
component.getLabelColor(datum, bbox);
|
|
935
|
-
expect(
|
|
936
|
-
ColorUtilities.getHigherContrastColorForBackground
|
|
937
|
-
).toHaveBeenCalledOnceWith(
|
|
938
|
-
'blue',
|
|
939
|
-
component.config.labels.color.default,
|
|
940
|
-
component.config.labels.color.withinBarAlternative
|
|
941
|
-
);
|
|
942
|
-
});
|
|
943
|
-
it('returns the result of getHigherContrastColorForBackground', () => {
|
|
944
|
-
higherContrastSpy.and.returnValue('higher contrast');
|
|
945
|
-
expect(component.getLabelColor(datum, bbox)).toEqual(
|
|
946
|
-
'higher contrast'
|
|
947
|
-
);
|
|
948
|
-
});
|
|
949
|
-
});
|
|
950
|
-
});
|
|
951
|
-
});
|
|
952
|
-
|
|
953
|
-
describe('labelFitsOutsideBar()', () => {
|
|
954
|
-
let datum: BarDatum<string>;
|
|
955
|
-
let xSpy: jasmine.Spy;
|
|
956
|
-
let ySpy: jasmine.Spy;
|
|
957
|
-
const bbox = { width: 0, height: 0 } as DOMRect;
|
|
958
|
-
beforeEach(() => {
|
|
959
|
-
xSpy = jasmine.createSpy('x').and.returnValue(10);
|
|
960
|
-
ySpy = jasmine.createSpy('y').and.returnValue(20);
|
|
961
|
-
spyOn(component, 'getBarToChartEdgeDistance').and.returnValue(10);
|
|
962
|
-
component.ranges = { x: [1, 2], y: [3, 4] };
|
|
963
|
-
component.scales = {
|
|
964
|
-
x: xSpy,
|
|
965
|
-
y: ySpy,
|
|
966
|
-
} as any;
|
|
967
|
-
});
|
|
968
|
-
describe('bars are horizontal', () => {
|
|
969
|
-
beforeEach(() => {
|
|
970
|
-
component.config = horizontalConfig();
|
|
971
|
-
(component.config as any).labels = { offset: 4 };
|
|
972
|
-
datum = component.getBarDatumFromIndex(2);
|
|
973
|
-
});
|
|
974
|
-
it('calls getBarToChartEdgeDistance once with the correct values - quant value is positive', () => {
|
|
975
|
-
component.labelFitsOutsideBar(datum, bbox);
|
|
976
|
-
expect(component.getBarToChartEdgeDistance).toHaveBeenCalledOnceWith(
|
|
977
|
-
true,
|
|
978
|
-
[1, 2],
|
|
979
|
-
10
|
|
980
|
-
);
|
|
981
|
-
});
|
|
982
|
-
it('calls getBarToChartEdgeDistance once with the correct values - quant value is negative', () => {
|
|
983
|
-
datum.quantitative = -1;
|
|
984
|
-
component.labelFitsOutsideBar(datum, bbox);
|
|
985
|
-
expect(component.getBarToChartEdgeDistance).toHaveBeenCalledOnceWith(
|
|
986
|
-
false,
|
|
987
|
-
[1, 2],
|
|
988
|
-
10
|
|
989
|
-
);
|
|
990
|
-
});
|
|
991
|
-
it('returns true if the distance is greater than the label width and offset', () => {
|
|
992
|
-
bbox.width = 5;
|
|
993
|
-
expect(component.labelFitsOutsideBar(datum, bbox)).toEqual(true);
|
|
994
|
-
});
|
|
995
|
-
it('returns false if the distance is less than the label width and offset', () => {
|
|
996
|
-
bbox.width = 20;
|
|
997
|
-
expect(component.labelFitsOutsideBar(datum, bbox)).toEqual(false);
|
|
998
|
-
});
|
|
999
|
-
});
|
|
1000
|
-
describe('bars are vertical', () => {
|
|
1001
|
-
beforeEach(() => {
|
|
1002
|
-
component.config = verticalConfig();
|
|
1003
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1004
|
-
});
|
|
1005
|
-
it('calls getBarToChartEdgeDistance once with the correct values - quant value is positive', () => {
|
|
1006
|
-
component.labelFitsOutsideBar(datum, bbox);
|
|
1007
|
-
expect(component.getBarToChartEdgeDistance).toHaveBeenCalledOnceWith(
|
|
1008
|
-
true,
|
|
1009
|
-
[3, 4],
|
|
1010
|
-
20
|
|
1011
|
-
);
|
|
1012
|
-
});
|
|
1013
|
-
it('calls getBarToChartEdgeDistance once with the correct values - quant value is negative', () => {
|
|
1014
|
-
datum.quantitative = -1;
|
|
1015
|
-
component.labelFitsOutsideBar(datum, bbox);
|
|
1016
|
-
expect(component.getBarToChartEdgeDistance).toHaveBeenCalledOnceWith(
|
|
1017
|
-
false,
|
|
1018
|
-
[3, 4],
|
|
1019
|
-
20
|
|
1020
|
-
);
|
|
1021
|
-
});
|
|
1022
|
-
it('returns true if the distance is less than the label height + offset', () => {
|
|
1023
|
-
bbox.height = 5;
|
|
1024
|
-
expect(component.labelFitsOutsideBar(datum, bbox)).toEqual(true);
|
|
1025
|
-
});
|
|
1026
|
-
it('returns false if the distance is greater than the label height', () => {
|
|
1027
|
-
bbox.height = 20;
|
|
1028
|
-
expect(component.labelFitsOutsideBar(datum, bbox)).toEqual(false);
|
|
1029
|
-
});
|
|
1030
|
-
});
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1033
|
-
describe('getBarToChartEdgeDistance()', () => {
|
|
1034
|
-
let range: [number, number];
|
|
1035
|
-
describe('if range[0] < range[1] (horizontal)', () => {
|
|
1036
|
-
beforeEach(() => {
|
|
1037
|
-
range = [10, 100];
|
|
1038
|
-
});
|
|
1039
|
-
describe('positive value', () => {
|
|
1040
|
-
it('returns 0 if the bar is beyond the far edge of the chart', () => {
|
|
1041
|
-
expect(component.getBarToChartEdgeDistance(true, range, 110)).toEqual(
|
|
1042
|
-
0
|
|
1043
|
-
);
|
|
1044
|
-
});
|
|
1045
|
-
it('returns the correct value if the bar is within the chart', () => {
|
|
1046
|
-
expect(component.getBarToChartEdgeDistance(true, range, 90)).toEqual(
|
|
1047
|
-
10
|
|
1048
|
-
);
|
|
1049
|
-
});
|
|
1050
|
-
});
|
|
1051
|
-
describe('negative value', () => {
|
|
1052
|
-
it('returns 0 if the bar is beyond the close edge of the chart', () => {
|
|
1053
|
-
expect(component.getBarToChartEdgeDistance(false, range, 0)).toEqual(
|
|
1054
|
-
0
|
|
1055
|
-
);
|
|
1056
|
-
});
|
|
1057
|
-
it('returns the correct value if the bar is within the chart', () => {
|
|
1058
|
-
expect(component.getBarToChartEdgeDistance(false, range, 20)).toEqual(
|
|
1059
|
-
10
|
|
1060
|
-
);
|
|
1061
|
-
});
|
|
1062
|
-
});
|
|
1063
|
-
});
|
|
1064
|
-
describe('if range[1] > range[0] (vertical)', () => {
|
|
1065
|
-
beforeEach(() => {
|
|
1066
|
-
range = [100, 10];
|
|
1067
|
-
});
|
|
1068
|
-
describe('positive value', () => {
|
|
1069
|
-
it('returns 0 if the bar is beyond the far edge of the chart', () => {
|
|
1070
|
-
expect(component.getBarToChartEdgeDistance(true, range, 110)).toEqual(
|
|
1071
|
-
0
|
|
1072
|
-
);
|
|
1073
|
-
});
|
|
1074
|
-
it('returns the correct value if the bar is within the chart', () => {
|
|
1075
|
-
expect(component.getBarToChartEdgeDistance(true, range, 90)).toEqual(
|
|
1076
|
-
10
|
|
1077
|
-
);
|
|
1078
|
-
});
|
|
1079
|
-
});
|
|
1080
|
-
describe('negative value', () => {
|
|
1081
|
-
it('returns 0 if the bar is beyond the close edge of the chart', () => {
|
|
1082
|
-
expect(component.getBarToChartEdgeDistance(false, range, 0)).toEqual(
|
|
1083
|
-
0
|
|
1084
|
-
);
|
|
1085
|
-
});
|
|
1086
|
-
it('returns the correct value if the bar is within the chart', () => {
|
|
1087
|
-
expect(component.getBarToChartEdgeDistance(false, range, 20)).toEqual(
|
|
1088
|
-
10
|
|
1089
|
-
);
|
|
1090
|
-
});
|
|
1091
|
-
});
|
|
1092
|
-
});
|
|
1093
|
-
});
|
|
1094
|
-
|
|
1095
|
-
describe('getLabelX()', () => {
|
|
1096
|
-
let datum: BarDatum<string>;
|
|
1097
|
-
const bbox = { width: 0, height: 0 } as DOMRect;
|
|
1098
|
-
beforeEach(() => {
|
|
1099
|
-
spyOn(component, 'getBarWidthOrdinal').and.returnValue(10);
|
|
1100
|
-
spyOn(component, 'getLabelQuantitativeAxisPosition').and.returnValue(50);
|
|
1101
|
-
});
|
|
1102
|
-
describe('bars are horizontal', () => {
|
|
1103
|
-
beforeEach(() => {
|
|
1104
|
-
component.config = horizontalConfig();
|
|
1105
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1106
|
-
});
|
|
1107
|
-
it('calls getLabelQuantitativeAxisPosition once with datum', () => {
|
|
1108
|
-
component.getLabelX(datum, bbox);
|
|
1109
|
-
expect(
|
|
1110
|
-
component.getLabelQuantitativeAxisPosition
|
|
1111
|
-
).toHaveBeenCalledOnceWith(datum, bbox);
|
|
1112
|
-
});
|
|
1113
|
-
it('returns the correct value', () => {
|
|
1114
|
-
expect(component.getLabelX(datum, bbox)).toEqual(50);
|
|
1115
|
-
});
|
|
1116
|
-
});
|
|
1117
|
-
describe('bars are vertical', () => {
|
|
1118
|
-
beforeEach(() => {
|
|
1119
|
-
component.config = verticalConfig();
|
|
1120
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1121
|
-
});
|
|
1122
|
-
it('calls getBarWidthOrdinal once', () => {
|
|
1123
|
-
component.getLabelX(datum, bbox);
|
|
1124
|
-
expect(component.getBarWidthOrdinal).toHaveBeenCalledTimes(1);
|
|
1125
|
-
});
|
|
1126
|
-
it('returns the correct value', () => {
|
|
1127
|
-
expect(component.getLabelX(datum, bbox)).toEqual(5);
|
|
1128
|
-
});
|
|
1129
|
-
});
|
|
1130
|
-
});
|
|
1131
|
-
|
|
1132
|
-
describe('getLabelY()', () => {
|
|
1133
|
-
let datum: BarDatum<string>;
|
|
1134
|
-
const bbox = { width: 0, height: 0 } as DOMRect;
|
|
1135
|
-
beforeEach(() => {
|
|
1136
|
-
spyOn(component, 'getBarHeightOrdinal').and.returnValue(10);
|
|
1137
|
-
spyOn(component, 'getLabelQuantitativeAxisPosition').and.returnValue(50);
|
|
1138
|
-
});
|
|
1139
|
-
describe('bars are horizontal', () => {
|
|
1140
|
-
beforeEach(() => {
|
|
1141
|
-
component.config = horizontalConfig();
|
|
1142
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1143
|
-
});
|
|
1144
|
-
it('calls getBarHeightOrdinal once', () => {
|
|
1145
|
-
component.getLabelY(datum, bbox);
|
|
1146
|
-
expect(component.getBarHeightOrdinal).toHaveBeenCalledTimes(1);
|
|
1147
|
-
});
|
|
1148
|
-
it('returns the correct value', () => {
|
|
1149
|
-
expect(component.getLabelY(datum, bbox)).toEqual(5);
|
|
1150
|
-
});
|
|
1151
|
-
});
|
|
1152
|
-
describe('bars are vertical', () => {
|
|
1153
|
-
beforeEach(() => {
|
|
1154
|
-
component.config = verticalConfig();
|
|
1155
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1156
|
-
});
|
|
1157
|
-
it('calls getLabelQuantitativeAxisPosition once with datum', () => {
|
|
1158
|
-
component.getLabelY(datum, bbox);
|
|
1159
|
-
expect(
|
|
1160
|
-
component.getLabelQuantitativeAxisPosition
|
|
1161
|
-
).toHaveBeenCalledOnceWith(datum, bbox);
|
|
1162
|
-
});
|
|
1163
|
-
it('returns the correct value', () => {
|
|
1164
|
-
expect(component.getLabelY(datum, bbox)).toEqual(50);
|
|
1165
|
-
});
|
|
1166
|
-
});
|
|
1167
|
-
});
|
|
1168
|
-
|
|
1169
|
-
describe('getLabelQuantitativeAxisPosition()', () => {
|
|
1170
|
-
let datum: BarDatum<string>;
|
|
1171
|
-
let isZeroOrNonNumericSpy: jasmine.Spy;
|
|
1172
|
-
const bbox = { width: 0, height: 0 } as DOMRect;
|
|
1173
|
-
beforeEach(() => {
|
|
1174
|
-
spyOn(
|
|
1175
|
-
component,
|
|
1176
|
-
'getLabelPositionForZeroOrNonnumericValue'
|
|
1177
|
-
).and.returnValue(10);
|
|
1178
|
-
spyOn(component, 'getLabelPositionForNumericValue').and.returnValue(20);
|
|
1179
|
-
isZeroOrNonNumericSpy = spyOn(component, 'isZeroOrNonNumeric');
|
|
1180
|
-
component.config = horizontalConfig();
|
|
1181
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1182
|
-
});
|
|
1183
|
-
describe('quantitative value is zero or non-numeric', () => {
|
|
1184
|
-
beforeEach(() => {
|
|
1185
|
-
isZeroOrNonNumericSpy.and.returnValue(true);
|
|
1186
|
-
});
|
|
1187
|
-
it('calls isZeroOrNonNumeric once', () => {
|
|
1188
|
-
component.getLabelQuantitativeAxisPosition(datum, bbox);
|
|
1189
|
-
expect(component.isZeroOrNonNumeric).toHaveBeenCalledTimes(1);
|
|
1190
|
-
});
|
|
1191
|
-
it('calls getLabelPositionForZeroOrNonnumericValue once if value is zero', () => {
|
|
1192
|
-
isZeroOrNonNumericSpy.and.returnValue(true);
|
|
1193
|
-
component.getLabelQuantitativeAxisPosition(datum, bbox);
|
|
1194
|
-
expect(
|
|
1195
|
-
component.getLabelPositionForZeroOrNonnumericValue
|
|
1196
|
-
).toHaveBeenCalledTimes(1);
|
|
1197
|
-
});
|
|
1198
|
-
it('returns the value from getLabelPositionForZeroOrNonnumericValue', () => {
|
|
1199
|
-
expect(component.getLabelQuantitativeAxisPosition(datum, bbox)).toEqual(
|
|
1200
|
-
10
|
|
1201
|
-
);
|
|
1202
|
-
});
|
|
1203
|
-
});
|
|
1204
|
-
describe('quantitative value is numeric and not zero', () => {
|
|
1205
|
-
beforeEach(() => {
|
|
1206
|
-
isZeroOrNonNumericSpy.and.returnValue(false);
|
|
1207
|
-
});
|
|
1208
|
-
it('calls getLabelPositionForNumericValue once', () => {
|
|
1209
|
-
component.getLabelQuantitativeAxisPosition(datum, bbox);
|
|
1210
|
-
expect(
|
|
1211
|
-
component.getLabelPositionForNumericValue
|
|
1212
|
-
).toHaveBeenCalledOnceWith(datum, bbox);
|
|
1213
|
-
});
|
|
1214
|
-
it('returns the value from getLabelPositionForNumericValue', () => {
|
|
1215
|
-
expect(component.getLabelQuantitativeAxisPosition(datum, bbox)).toEqual(
|
|
1216
|
-
20
|
|
1217
|
-
);
|
|
1218
|
-
});
|
|
1219
|
-
});
|
|
1220
|
-
});
|
|
1221
|
-
|
|
1222
|
-
describe('getLabelPositionForZeroOrNonnumericValue()', () => {
|
|
1223
|
-
let positionSpy: jasmine.Spy;
|
|
1224
|
-
beforeEach(() => {
|
|
1225
|
-
positionSpy = spyOn(
|
|
1226
|
-
component,
|
|
1227
|
-
'positionZeroOrNonNumericValueLabelInPositiveDirection'
|
|
1228
|
-
);
|
|
1229
|
-
});
|
|
1230
|
-
describe('bars are horizontal', () => {
|
|
1231
|
-
beforeEach(() => {
|
|
1232
|
-
component.config = horizontalConfig();
|
|
1233
|
-
component.config.labels.offset = 20;
|
|
1234
|
-
});
|
|
1235
|
-
it('calls positionZeroOrNonNumericValueLabelInPositiveDirection once', () => {
|
|
1236
|
-
component.getLabelPositionForZeroOrNonnumericValue();
|
|
1237
|
-
expect(positionSpy).toHaveBeenCalledTimes(1);
|
|
1238
|
-
});
|
|
1239
|
-
it('returns config.labels.offset if positionInPositiveDirection is true', () => {
|
|
1240
|
-
positionSpy.and.returnValue(true);
|
|
1241
|
-
expect(component.getLabelPositionForZeroOrNonnumericValue()).toEqual(
|
|
1242
|
-
20
|
|
1243
|
-
);
|
|
1244
|
-
});
|
|
1245
|
-
it('returns -config.labels.offset if positionInPositiveDirection is false', () => {
|
|
1246
|
-
positionSpy.and.returnValue(false);
|
|
1247
|
-
expect(component.getLabelPositionForZeroOrNonnumericValue()).toEqual(
|
|
1248
|
-
-20
|
|
1249
|
-
);
|
|
1250
|
-
});
|
|
1251
|
-
});
|
|
1252
|
-
describe('bars are vertical', () => {
|
|
1253
|
-
beforeEach(() => {
|
|
1254
|
-
component.config = verticalConfig();
|
|
1255
|
-
component.config.labels.offset = 20;
|
|
1256
|
-
});
|
|
1257
|
-
it('calls positionZeroOrNonNumericValueLabelInPositiveDirection once', () => {
|
|
1258
|
-
component.getLabelPositionForZeroOrNonnumericValue();
|
|
1259
|
-
expect(positionSpy).toHaveBeenCalledTimes(1);
|
|
1260
|
-
});
|
|
1261
|
-
it('returns config.labels.offset if positionInPositiveDirection is false', () => {
|
|
1262
|
-
positionSpy.and.returnValue(false);
|
|
1263
|
-
expect(component.getLabelPositionForZeroOrNonnumericValue()).toEqual(
|
|
1264
|
-
20
|
|
1265
|
-
);
|
|
1266
|
-
});
|
|
1267
|
-
it('returns -config.labels.offset if positionInPositiveDirection is true', () => {
|
|
1268
|
-
positionSpy.and.returnValue(true);
|
|
1269
|
-
expect(component.getLabelPositionForZeroOrNonnumericValue()).toEqual(
|
|
1270
|
-
-20
|
|
1271
|
-
);
|
|
1272
|
-
});
|
|
1273
|
-
});
|
|
1274
|
-
});
|
|
1275
|
-
|
|
1276
|
-
describe('getLabelPositionForNumericValue()', () => {
|
|
1277
|
-
let datum: BarDatum<string>;
|
|
1278
|
-
let fitsOutsideSpy: jasmine.Spy;
|
|
1279
|
-
const bbox = { width: 0, height: 0 } as DOMRect;
|
|
1280
|
-
beforeEach(() => {
|
|
1281
|
-
spyOn(component, 'getLabelOrigin').and.returnValue(50);
|
|
1282
|
-
fitsOutsideSpy = spyOn(component, 'labelFitsOutsideBar');
|
|
1283
|
-
});
|
|
1284
|
-
describe('bars are horizontal', () => {
|
|
1285
|
-
beforeEach(() => {
|
|
1286
|
-
component.config = horizontalConfig();
|
|
1287
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1288
|
-
component.config.labels.offset = 20;
|
|
1289
|
-
});
|
|
1290
|
-
describe('quantitative value is positive', () => {
|
|
1291
|
-
it('calls barLabelFitsOutsideBar once', () => {
|
|
1292
|
-
component.getLabelPositionForNumericValue(datum, bbox);
|
|
1293
|
-
expect(component.getLabelOrigin).toHaveBeenCalledOnceWith(
|
|
1294
|
-
datum,
|
|
1295
|
-
true
|
|
1296
|
-
);
|
|
1297
|
-
});
|
|
1298
|
-
it('returns the origin plus the offset if the label fits outside the bar', () => {
|
|
1299
|
-
fitsOutsideSpy.and.returnValue(true);
|
|
1300
|
-
expect(
|
|
1301
|
-
component.getLabelPositionForNumericValue(datum, bbox)
|
|
1302
|
-
).toEqual(70);
|
|
1303
|
-
});
|
|
1304
|
-
it('returns the origin minus the offset if the label fits inside the bar', () => {
|
|
1305
|
-
fitsOutsideSpy.and.returnValue(false);
|
|
1306
|
-
expect(
|
|
1307
|
-
component.getLabelPositionForNumericValue(datum, bbox)
|
|
1308
|
-
).toEqual(30);
|
|
1309
|
-
});
|
|
1310
|
-
});
|
|
1311
|
-
describe('quantitative value is negative', () => {
|
|
1312
|
-
beforeEach(() => {
|
|
1313
|
-
datum.quantitative = -1;
|
|
1314
|
-
});
|
|
1315
|
-
it('calls barLabelFitsOutsideBar once', () => {
|
|
1316
|
-
component.getLabelPositionForNumericValue(datum, bbox);
|
|
1317
|
-
expect(component.getLabelOrigin).toHaveBeenCalledOnceWith(
|
|
1318
|
-
datum,
|
|
1319
|
-
false
|
|
1320
|
-
);
|
|
1321
|
-
});
|
|
1322
|
-
it('returns the origin minus the offset if the label fits outside the bar', () => {
|
|
1323
|
-
fitsOutsideSpy.and.returnValue(true);
|
|
1324
|
-
expect(
|
|
1325
|
-
component.getLabelPositionForNumericValue(datum, bbox)
|
|
1326
|
-
).toEqual(30);
|
|
1327
|
-
});
|
|
1328
|
-
it('returns the origin plus the offset if the label fits inside the bar', () => {
|
|
1329
|
-
fitsOutsideSpy.and.returnValue(false);
|
|
1330
|
-
expect(
|
|
1331
|
-
component.getLabelPositionForNumericValue(datum, bbox)
|
|
1332
|
-
).toEqual(70);
|
|
1333
|
-
});
|
|
1334
|
-
});
|
|
1335
|
-
});
|
|
1336
|
-
describe('bars are vertical', () => {
|
|
1337
|
-
beforeEach(() => {
|
|
1338
|
-
component.config = verticalConfig();
|
|
1339
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1340
|
-
component.config.labels.offset = 20;
|
|
1341
|
-
});
|
|
1342
|
-
describe('quantitative value is positive', () => {
|
|
1343
|
-
it('returns the origin minus the offset if the label fits outside the bar', () => {
|
|
1344
|
-
fitsOutsideSpy.and.returnValue(true);
|
|
1345
|
-
expect(
|
|
1346
|
-
component.getLabelPositionForNumericValue(datum, bbox)
|
|
1347
|
-
).toEqual(30);
|
|
1348
|
-
});
|
|
1349
|
-
it('returns the origin plus the offset if the label fits inside the bar', () => {
|
|
1350
|
-
fitsOutsideSpy.and.returnValue(false);
|
|
1351
|
-
expect(
|
|
1352
|
-
component.getLabelPositionForNumericValue(datum, bbox)
|
|
1353
|
-
).toEqual(70);
|
|
1354
|
-
});
|
|
1355
|
-
});
|
|
1356
|
-
describe('quantitative value is negative', () => {
|
|
1357
|
-
beforeEach(() => {
|
|
1358
|
-
datum.quantitative = -1;
|
|
1359
|
-
});
|
|
1360
|
-
it('returns the origin plus the offset if the label fits outside the bar', () => {
|
|
1361
|
-
fitsOutsideSpy.and.returnValue(true);
|
|
1362
|
-
expect(
|
|
1363
|
-
component.getLabelPositionForNumericValue(datum, bbox)
|
|
1364
|
-
).toEqual(70);
|
|
1365
|
-
});
|
|
1366
|
-
it('returns the origin minus the offset if the label fits inside the bar', () => {
|
|
1367
|
-
fitsOutsideSpy.and.returnValue(false);
|
|
1368
|
-
expect(
|
|
1369
|
-
component.getLabelPositionForNumericValue(datum, bbox)
|
|
1370
|
-
).toEqual(30);
|
|
1371
|
-
});
|
|
1372
|
-
});
|
|
1373
|
-
});
|
|
1374
|
-
});
|
|
1375
|
-
|
|
1376
|
-
describe('getLabelOrigin', () => {
|
|
1377
|
-
let datum: BarDatum<string>;
|
|
1378
|
-
beforeEach(() => {
|
|
1379
|
-
spyOn(component, 'getBarDimensionQuantitative').and.returnValue(10);
|
|
1380
|
-
});
|
|
1381
|
-
describe('if bars are horizontal', () => {
|
|
1382
|
-
beforeEach(() => {
|
|
1383
|
-
component.config = horizontalConfig();
|
|
1384
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1385
|
-
component.config.labels.offset = 20;
|
|
1386
|
-
});
|
|
1387
|
-
it('calls getBarDimensionQuantitative once with datum and x if value is positive', () => {
|
|
1388
|
-
component.getLabelOrigin(datum, true);
|
|
1389
|
-
expect(component.getBarDimensionQuantitative).toHaveBeenCalledOnceWith(
|
|
1390
|
-
datum,
|
|
1391
|
-
'x'
|
|
1392
|
-
);
|
|
1393
|
-
});
|
|
1394
|
-
it('returns the value from getBarHeightQuantitative for positive values', () => {
|
|
1395
|
-
expect(component.getLabelOrigin(datum, true)).toBe(10);
|
|
1396
|
-
});
|
|
1397
|
-
it('returns zero for values that are not positive', () => {
|
|
1398
|
-
expect(component.getLabelOrigin(datum, false)).toBe(0);
|
|
1399
|
-
});
|
|
1400
|
-
});
|
|
1401
|
-
describe('if bars are vertical', () => {
|
|
1402
|
-
beforeEach(() => {
|
|
1403
|
-
component.config = verticalConfig();
|
|
1404
|
-
datum = component.getBarDatumFromIndex(2);
|
|
1405
|
-
component.config.labels.offset = 20;
|
|
1406
|
-
});
|
|
1407
|
-
it('calls getBarDimensionQuantitative once with datum and y if value is negative', () => {
|
|
1408
|
-
component.getLabelOrigin(datum, false);
|
|
1409
|
-
expect(component.getBarDimensionQuantitative).toHaveBeenCalledOnceWith(
|
|
1410
|
-
datum,
|
|
1411
|
-
'y'
|
|
1412
|
-
);
|
|
1413
|
-
});
|
|
1414
|
-
it('returns zero for positive values', () => {
|
|
1415
|
-
expect(component.getLabelOrigin(datum, true)).toBe(0);
|
|
1416
|
-
});
|
|
1417
|
-
it('returns the value from getBarHeightQuantitative for negative values', () => {
|
|
1418
|
-
expect(component.getLabelOrigin(datum, false)).toBe(10);
|
|
1419
|
-
});
|
|
1420
|
-
});
|
|
1421
|
-
});
|
|
1422
|
-
|
|
1423
|
-
describe('positionZeroOrNonNumericValueLabelInPositiveDirection', () => {
|
|
1424
|
-
let quantDomainSpy: jasmine.Spy;
|
|
1425
|
-
beforeEach(() => {
|
|
1426
|
-
quantDomainSpy = spyOn(component, 'getQuantitativeDomainFromScale');
|
|
1427
|
-
component.config = horizontalConfig();
|
|
1428
|
-
});
|
|
1429
|
-
it('returns true if some values are positive', () => {
|
|
1430
|
-
expect(
|
|
1431
|
-
component.positionZeroOrNonNumericValueLabelInPositiveDirection()
|
|
1432
|
-
).toEqual(true);
|
|
1433
|
-
});
|
|
1434
|
-
describe('no values are positive', () => {
|
|
1435
|
-
it('returns true if the domain max is > 0 and all values are zero or non-numeric', () => {
|
|
1436
|
-
component.config.quantitative.values = [
|
|
1437
|
-
undefined,
|
|
1438
|
-
0,
|
|
1439
|
-
0,
|
|
1440
|
-
null,
|
|
1441
|
-
'hello',
|
|
1442
|
-
] as any;
|
|
1443
|
-
quantDomainSpy.and.returnValue([-10, 10]);
|
|
1444
|
-
expect(
|
|
1445
|
-
component.positionZeroOrNonNumericValueLabelInPositiveDirection()
|
|
1446
|
-
).toEqual(true);
|
|
1447
|
-
});
|
|
1448
|
-
it('returns false if domain max is >= 0 and all values are zero or non-numeric', () => {
|
|
1449
|
-
component.config.quantitative.values = [
|
|
1450
|
-
undefined,
|
|
1451
|
-
0,
|
|
1452
|
-
0,
|
|
1453
|
-
null,
|
|
1454
|
-
'hello',
|
|
1455
|
-
] as any;
|
|
1456
|
-
quantDomainSpy.and.returnValue([-10, -2]);
|
|
1457
|
-
expect(
|
|
1458
|
-
component.positionZeroOrNonNumericValueLabelInPositiveDirection()
|
|
1459
|
-
).toEqual(false);
|
|
1460
|
-
});
|
|
1461
|
-
it('returns false if the domain max is > 0 and values are not all zero or non-numeric', () => {
|
|
1462
|
-
component.config.quantitative.values = [-1, -2, -10, -8];
|
|
1463
|
-
quantDomainSpy.and.returnValue([-10, 2]);
|
|
1464
|
-
expect(
|
|
1465
|
-
component.positionZeroOrNonNumericValueLabelInPositiveDirection()
|
|
1466
|
-
).toEqual(false);
|
|
1467
|
-
});
|
|
1468
|
-
});
|
|
1469
|
-
});
|
|
1470
|
-
});
|