@mathstack/viz 1.1.5 → 2.1.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.
Files changed (701) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/LICENSE +21 -21
  3. package/README.md +11 -11
  4. package/cypress/fixtures/example.json +5 -0
  5. package/cypress/fixtures/usMap.json +13511 -0
  6. package/cypress/support/commands.ts +104 -0
  7. package/cypress/support/component-index.html +12 -0
  8. package/cypress/support/component.ts +33 -0
  9. package/cypress.config.ts +9 -0
  10. package/karma.conf.js +62 -0
  11. package/ng-package.json +8 -0
  12. package/package.json +10 -19
  13. package/project.json +97 -0
  14. package/src/.eslintrc.json +35 -0
  15. package/src/.prettierrc +31 -0
  16. package/src/lib/axes/base/config/xy-axis-builder.ts +68 -0
  17. package/src/lib/axes/base/config/xy-axis-config.ts +35 -0
  18. package/{lib/axes/base/config/xy-axis-options.d.ts → src/lib/axes/base/config/xy-axis-options.ts} +11 -10
  19. package/src/lib/axes/base/xy-axis-base.spec.ts +114 -0
  20. package/src/lib/axes/base/xy-axis-base.ts +305 -0
  21. package/src/lib/axes/base/xy-axis-domain-lines.cy.ts +511 -0
  22. package/src/lib/axes/baseline/axis-baseline-builder.ts +77 -0
  23. package/src/lib/axes/baseline/axis-baseline-options.ts +4 -0
  24. package/src/lib/axes/baseline/axis-baseline.ts +11 -0
  25. package/src/lib/axes/grid/grid-builder.ts +74 -0
  26. package/src/lib/axes/grid/grid-config.ts +13 -0
  27. package/src/lib/axes/grid/grid-options.ts +7 -0
  28. package/src/lib/axes/index.ts +40 -0
  29. package/src/lib/axes/label/axis-label-builder.ts +140 -0
  30. package/src/lib/axes/label/axis-label-options.ts +12 -0
  31. package/src/lib/axes/label/axis-label.ts +18 -0
  32. package/src/lib/axes/label/axis-labels.cy.ts +303 -0
  33. package/src/lib/axes/ordinal/ordinal-axis-config.ts +31 -0
  34. package/src/lib/axes/ordinal/ordinal-axis.spec.ts +30 -0
  35. package/src/lib/axes/ordinal/ordinal-axis.ts +26 -0
  36. package/src/lib/axes/quantitative/quantitative-axis-config.ts +39 -0
  37. package/src/lib/axes/quantitative/quantitative-axis-ticks.cy.ts +748 -0
  38. package/src/lib/axes/quantitative/quantitative-axis.spec.ts +537 -0
  39. package/src/lib/axes/quantitative/quantitative-axis.ts +191 -0
  40. package/src/lib/axes/ticks/tick-wrap/tick-wrap-builder.ts +141 -0
  41. package/src/lib/axes/ticks/tick-wrap/tick-wrap-options.ts +11 -0
  42. package/src/lib/axes/ticks/tick-wrap/tick-wrap.cy.ts +360 -0
  43. package/src/lib/axes/ticks/tick-wrap/tick-wrap.ts +21 -0
  44. package/src/lib/axes/ticks/ticks-builder.ts +370 -0
  45. package/src/lib/axes/ticks/ticks-options.ts +24 -0
  46. package/src/lib/axes/ticks/ticks.ts +33 -0
  47. package/src/lib/axes/x/x-axis-config.ts +48 -0
  48. package/src/lib/axes/x/x-axis.spec.ts +90 -0
  49. package/src/lib/axes/x/x-axis.ts +109 -0
  50. package/src/lib/axes/x-ordinal/x-ordinal-axis-builder.ts +75 -0
  51. package/src/lib/axes/x-ordinal/x-ordinal-axis-config.ts +27 -0
  52. package/src/lib/axes/x-ordinal/x-ordinal-axis.component.ts +33 -0
  53. package/src/lib/axes/x-quantitative/x-quantitative-axis-builder.ts +74 -0
  54. package/src/lib/axes/x-quantitative/x-quantitative-axis-config.ts +32 -0
  55. package/src/lib/axes/x-quantitative/x-quantitative-axis.component.ts +40 -0
  56. package/src/lib/axes/xy-axis.module.ts +20 -0
  57. package/src/lib/axes/y/y-axis-config.ts +47 -0
  58. package/src/lib/axes/y/y-axis.spec.ts +92 -0
  59. package/src/lib/axes/y/y-axis.ts +161 -0
  60. package/src/lib/axes/y-ordinal/y-ordinal-axis-builder.ts +76 -0
  61. package/src/lib/axes/y-ordinal/y-ordinal-axis-config.ts +29 -0
  62. package/src/lib/axes/y-ordinal/y-ordinal-axis.component.ts +33 -0
  63. package/src/lib/axes/y-quantitative-axis/y-quantitative-axis-builder.ts +74 -0
  64. package/src/lib/axes/y-quantitative-axis/y-quantitative-axis-config.ts +34 -0
  65. package/src/lib/axes/y-quantitative-axis/y-quantitative-axis.component.ts +40 -0
  66. package/src/lib/bars/bars.component.scss +0 -0
  67. package/src/lib/bars/bars.component.spec.ts +1470 -0
  68. package/src/lib/bars/bars.component.ts +717 -0
  69. package/src/lib/bars/bars.cy.ts +829 -0
  70. package/src/lib/bars/bars.module.ts +9 -0
  71. package/src/lib/bars/config/backgrounds/bars-backgrounds-builder.ts +51 -0
  72. package/{lib/bars/config/backgrounds/bars-backgrounds-options.d.ts → src/lib/bars/config/backgrounds/bars-backgrounds-options.ts} +4 -4
  73. package/src/lib/bars/config/backgrounds/bars-backgrounds.ts +11 -0
  74. package/src/lib/bars/config/bars-builder.ts +340 -0
  75. package/src/lib/bars/config/bars-config.spec.ts +132 -0
  76. package/src/lib/bars/config/bars-config.ts +70 -0
  77. package/src/lib/bars/config/bars-dimensions.ts +29 -0
  78. package/{lib/bars/config/bars-options.d.ts → src/lib/bars/config/bars-options.ts} +20 -16
  79. package/src/lib/bars/config/labels/bars-labels-builder.ts +89 -0
  80. package/src/lib/bars/config/labels/bars-labels-options.ts +6 -0
  81. package/src/lib/bars/config/labels/bars-labels.cy.ts +781 -0
  82. package/src/lib/bars/config/labels/bars-labels.ts +13 -0
  83. package/src/lib/bars/events/actions/bars-click-actions.ts +23 -0
  84. package/src/lib/bars/events/actions/bars-hover-actions.ts +43 -0
  85. package/src/lib/bars/events/actions/bars-hover-move-actions.ts +21 -0
  86. package/src/lib/bars/events/bars-events.directive.spec.ts +186 -0
  87. package/src/lib/bars/events/bars-events.directive.ts +235 -0
  88. package/src/lib/bars/events/bars-interaction-output.ts +17 -0
  89. package/src/lib/bars/events/bars-tooltip-positioner.ts +24 -0
  90. package/{lib/bars/index.d.ts → src/lib/bars/index.ts} +18 -12
  91. package/src/lib/charts/chart/chart-scaling.cy.ts +323 -0
  92. package/src/lib/charts/chart/chart.component.html +45 -0
  93. package/src/lib/charts/chart/chart.component.scss +37 -0
  94. package/src/lib/charts/chart/chart.component.ts +243 -0
  95. package/{lib/charts/chart/chart.token.d.ts → src/lib/charts/chart/chart.token.ts} +4 -3
  96. package/src/lib/charts/chart/chart.ts +5 -0
  97. package/src/lib/charts/chart/config/chart-builder.ts +194 -0
  98. package/src/lib/charts/chart/config/chart-config.ts +21 -0
  99. package/src/lib/charts/chart/config/chart-options.ts +11 -0
  100. package/src/lib/charts/chart.module.ts +10 -0
  101. package/{lib/charts/index.d.ts → src/lib/charts/index.ts} +9 -8
  102. package/src/lib/charts/map-chart/map-chart.component.scss +0 -0
  103. package/src/lib/charts/map-chart/map-chart.component.spec.ts +35 -0
  104. package/src/lib/charts/map-chart/map-chart.component.ts +61 -0
  105. package/src/lib/charts/xy-chart/xy-chart.component.spec.ts +34 -0
  106. package/src/lib/charts/xy-chart/xy-chart.component.ts +65 -0
  107. package/src/lib/core/common-behaviors/constructor.ts +7 -0
  108. package/src/lib/core/index.ts +11 -0
  109. package/src/lib/core/pipes/resize-chart-height.pipe.spec.ts +23 -0
  110. package/src/lib/core/pipes/resize-chart-height.pipe.ts +20 -0
  111. package/src/lib/core/styles/_spacing.scss +4 -0
  112. package/src/lib/core/types/layout.ts +28 -0
  113. package/src/lib/core/types/scale.ts +6 -0
  114. package/src/lib/core/types/utility.ts +11 -0
  115. package/{lib/core/types/values.d.ts → src/lib/core/types/values.ts} +10 -7
  116. package/src/lib/core/utilities/colors.spec.ts +57 -0
  117. package/src/lib/core/utilities/colors.ts +42 -0
  118. package/src/lib/core/utilities/fill-utilities.spec.ts +25 -0
  119. package/src/lib/core/utilities/fill-utilities.ts +21 -0
  120. package/src/lib/core/utilities/type-guards.spec.ts +55 -0
  121. package/src/lib/core/utilities/type-guards.ts +33 -0
  122. package/src/lib/core/utilities/value-format.ts +21 -0
  123. package/src/lib/core/utilities/values.spec.ts +954 -0
  124. package/src/lib/core/utilities/values.ts +189 -0
  125. package/src/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position-builder.ts +105 -0
  126. package/src/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position-options.ts +24 -0
  127. package/src/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position.spec.ts +66 -0
  128. package/src/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position.ts +72 -0
  129. package/{lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/concrete-domain-padding.d.ts → src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/concrete-domain-padding.ts} +10 -5
  130. package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/domain-padding.ts +76 -0
  131. package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/domain-test-utility.ts +130 -0
  132. package/{lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/percent-over/percent-over-options.d.ts → src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/percent-over/percent-over-options.ts} +3 -3
  133. package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/percent-over/percent-over.ts +37 -0
  134. package/{lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/pixel/pixel-options.d.ts → src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/pixel/pixel-options.ts} +3 -3
  135. package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/pixel/pixel.ts +73 -0
  136. package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/quantitative-domain-padding.cy.ts +978 -0
  137. package/{lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-interval/round-to-interval-options.d.ts → src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-interval/round-to-interval-options.ts} +3 -3
  138. package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-interval/round-to-interval.ts +27 -0
  139. package/{lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-sig-fig/round-to-sig-fig-options.d.ts → src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-sig-fig/round-to-sig-fig-options.ts} +3 -3
  140. package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-sig-fig/round-to-sig-fig.ts +30 -0
  141. package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position-builder.ts +183 -0
  142. package/{lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position-options.d.ts → src/lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position-options.ts} +8 -5
  143. package/src/lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position.spec.ts +28 -0
  144. package/{lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position.d.ts → src/lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position.ts} +62 -30
  145. package/src/lib/data-dimensions/continuous-quantitative/number-dimension/number-dimension-options.ts +15 -0
  146. package/src/lib/data-dimensions/continuous-quantitative/number-dimension/number-dimension.spec.ts +155 -0
  147. package/src/lib/data-dimensions/continuous-quantitative/number-dimension/number-dimension.ts +57 -0
  148. package/src/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value-builder.ts +166 -0
  149. package/src/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value-options.ts +10 -0
  150. package/src/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value.spec.ts +34 -0
  151. package/{lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value.d.ts → src/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value.ts} +57 -29
  152. package/src/lib/data-dimensions/dimension-builder.ts +45 -0
  153. package/src/lib/data-dimensions/dimension-options.ts +12 -0
  154. package/src/lib/data-dimensions/dimension.ts +30 -0
  155. package/src/lib/data-dimensions/index.ts +31 -0
  156. package/src/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position-builder.ts +122 -0
  157. package/src/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position-options.ts +12 -0
  158. package/src/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position.spec.ts +83 -0
  159. package/src/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position.ts +101 -0
  160. package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value-builder.ts +108 -0
  161. package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value-options.ts +12 -0
  162. package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value.cy.ts +384 -0
  163. package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value.spec.ts +63 -0
  164. package/src/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value.ts +79 -0
  165. package/src/lib/data-export/data-export-config.ts +98 -0
  166. package/src/lib/data-export/data-export.spec.ts +33 -0
  167. package/src/lib/data-export/data-export.ts +87 -0
  168. package/{lib/data-export/index.d.ts → src/lib/data-export/index.ts} +2 -2
  169. package/src/lib/dots/config/dots-builder.ts +442 -0
  170. package/src/lib/dots/config/dots-config.spec.ts +123 -0
  171. package/src/lib/dots/config/dots-config.ts +81 -0
  172. package/{lib/dots/config/dots-options.d.ts → src/lib/dots/config/dots-options.ts} +32 -17
  173. package/src/lib/dots/dots.component.scss +0 -0
  174. package/src/lib/dots/dots.component.spec.ts +143 -0
  175. package/src/lib/dots/dots.component.ts +291 -0
  176. package/src/lib/dots/dots.cy.ts +594 -0
  177. package/src/lib/dots/dots.module.ts +9 -0
  178. package/src/lib/dots/events/actions/dots-hover-actions.ts +19 -0
  179. package/src/lib/dots/events/actions/dots-hover-move-actions.ts +38 -0
  180. package/src/lib/dots/events/dots-events.directive.ts +214 -0
  181. package/src/lib/dots/events/dots-interaction-output.ts +15 -0
  182. package/src/lib/dots/events/dots-tooltip-positioner.ts +24 -0
  183. package/{lib/dots/index.d.ts → src/lib/dots/index.ts} +10 -9
  184. package/src/lib/events/events.directive.ts +184 -0
  185. package/src/lib/events/events.types.ts +57 -0
  186. package/{lib/events/index.d.ts → src/lib/events/index.ts} +4 -4
  187. package/src/lib/events/interaction-output.ts +34 -0
  188. package/src/lib/events/tooltip-positioner.ts +15 -0
  189. package/src/lib/fill-definitions/fill-definitions.ts +4 -0
  190. package/{lib/fill-definitions/index.d.ts → src/lib/fill-definitions/index.ts} +1 -1
  191. package/src/lib/geographies/config/geographies-builder.ts +224 -0
  192. package/src/lib/geographies/config/geographies-config.spec.ts +100 -0
  193. package/src/lib/geographies/config/geographies-config.ts +81 -0
  194. package/src/lib/geographies/config/geographies-options.ts +37 -0
  195. package/src/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer-builder.ts +212 -0
  196. package/{lib/geographies/config/layers/attribute-data-layer/attribute-data-layer-options.d.ts → src/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer-options.ts} +26 -16
  197. package/src/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer.spec.ts +119 -0
  198. package/src/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer.ts +148 -0
  199. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data/attribute-data-dimension-builder.ts +65 -0
  200. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data/attribute-data-dimension-options.ts +15 -0
  201. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data/attribute-data-dimension.ts +32 -0
  202. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data-bin-enums.ts +10 -0
  203. package/{lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data-bin-types.d.ts → src/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data-bin-types.ts} +15 -8
  204. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins-builder.ts +18 -0
  205. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins-options.ts +8 -0
  206. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins.spec.ts +60 -0
  207. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins.ts +34 -0
  208. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins-builder.ts +46 -0
  209. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins-options.ts +8 -0
  210. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins.cy.ts +437 -0
  211. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins.spec.ts +105 -0
  212. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins.ts +54 -0
  213. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins-builder.ts +65 -0
  214. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins-options.ts +9 -0
  215. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins.spec.ts +82 -0
  216. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins.ts +81 -0
  217. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks.cy.ts +378 -0
  218. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins-builder.ts +50 -0
  219. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins-options.ts +8 -0
  220. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins.cy.ts +362 -0
  221. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins.spec.ts +72 -0
  222. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins.ts +56 -0
  223. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins-builder.ts +60 -0
  224. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins-options.ts +9 -0
  225. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins.cy.ts +307 -0
  226. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins.spec.ts +104 -0
  227. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins.ts +89 -0
  228. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins-builder.ts +62 -0
  229. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins-options.ts +8 -0
  230. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins.cy.ts +265 -0
  231. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins.spec.ts +42 -0
  232. package/src/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins.ts +42 -0
  233. package/src/lib/geographies/config/layers/geographies-layer/geographies-layer-builder.ts +116 -0
  234. package/{lib/geographies/config/layers/geographies-layer/geographies-layer-options.d.ts → src/lib/geographies/config/layers/geographies-layer/geographies-layer-options.ts} +20 -16
  235. package/src/lib/geographies/config/layers/geographies-layer/geographies-layer.ts +104 -0
  236. package/src/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer-builder.ts +111 -0
  237. package/src/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer-options.ts +19 -0
  238. package/src/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer.spec.ts +41 -0
  239. package/src/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer.ts +67 -0
  240. package/src/lib/geographies/config/layers/labels/geographies-labels-builder.ts +269 -0
  241. package/src/lib/geographies/config/layers/labels/geographies-labels-options.ts +45 -0
  242. package/src/lib/geographies/config/layers/labels/geographies-labels.ts +38 -0
  243. package/src/lib/geographies/events/actions/geographies-click-actions.ts +21 -0
  244. package/src/lib/geographies/events/actions/geographies-hover-actions.ts +17 -0
  245. package/src/lib/geographies/events/actions/geographies-hover-move-actions.ts +19 -0
  246. package/src/lib/geographies/events/geographies-events.directive.spec.ts +225 -0
  247. package/src/lib/geographies/events/geographies-events.directive.ts +235 -0
  248. package/src/lib/geographies/events/geographies-interaction-output.ts +17 -0
  249. package/src/lib/geographies/events/geographies-tooltip-positioner.ts +23 -0
  250. package/src/lib/geographies/geographies-feature.ts +16 -0
  251. package/src/lib/geographies/geographies.component.html +1 -0
  252. package/src/lib/geographies/geographies.component.scss +0 -0
  253. package/src/lib/geographies/geographies.component.spec.ts +148 -0
  254. package/src/lib/geographies/geographies.component.ts +318 -0
  255. package/src/lib/geographies/geographies.cy.ts +640 -0
  256. package/src/lib/geographies/geographies.module.ts +9 -0
  257. package/{lib/geographies/index.d.ts → src/lib/geographies/index.ts} +32 -32
  258. package/src/lib/grouped-bars/config/grouped-bars-builder.ts +66 -0
  259. package/src/lib/grouped-bars/config/grouped-bars-config.ts +41 -0
  260. package/src/lib/grouped-bars/config/grouped-bars-options.ts +9 -0
  261. package/src/lib/grouped-bars/events/grouped-bars-events.directive.ts +221 -0
  262. package/src/lib/grouped-bars/grouped-bars.component.scss +0 -0
  263. package/src/lib/grouped-bars/grouped-bars.component.spec.ts +25 -0
  264. package/src/lib/grouped-bars/grouped-bars.component.ts +94 -0
  265. package/src/lib/grouped-bars/grouped-bars.module.ts +9 -0
  266. package/{lib/grouped-bars/index.d.ts → src/lib/grouped-bars/index.ts} +10 -7
  267. package/src/lib/image-download/image-download-config.ts +57 -0
  268. package/src/lib/image-download/image-download-enums.ts +7 -0
  269. package/src/lib/image-download/image-download-options.ts +14 -0
  270. package/src/lib/image-download/image-download.service.ts +70 -0
  271. package/{lib/image-download/index.d.ts → src/lib/image-download/index.ts} +4 -4
  272. package/src/lib/lines/config/area-fills/area-fills-builder.ts +87 -0
  273. package/src/lib/lines/config/area-fills/area-fills-options.ts +8 -0
  274. package/src/lib/lines/config/area-fills/area-fills.ts +14 -0
  275. package/src/lib/lines/config/lines-builder.ts +242 -0
  276. package/src/lib/lines/config/lines-config.spec.ts +52 -0
  277. package/src/lib/lines/config/lines-config.ts +96 -0
  278. package/{lib/lines/config/lines-options.d.ts → src/lib/lines/config/lines-options.ts} +19 -18
  279. package/src/lib/lines/config/stroke/lines-stroke-builder.ts +135 -0
  280. package/{lib/lines/config/stroke/lines-stroke-options.d.ts → src/lib/lines/config/stroke/lines-stroke-options.ts} +6 -5
  281. package/src/lib/lines/config/stroke/lines-stroke.ts +15 -0
  282. package/src/lib/lines/events/actions/lines-click-actions.ts +17 -0
  283. package/src/lib/lines/events/actions/lines-hover-move-actions.ts +113 -0
  284. package/src/lib/lines/events/actions/lines-marker-click-actions.ts +29 -0
  285. package/src/lib/lines/events/lines-events.directive.spec.ts +152 -0
  286. package/src/lib/lines/events/lines-events.directive.ts +310 -0
  287. package/src/lib/lines/events/lines-interaction-output.ts +17 -0
  288. package/src/lib/lines/events/lines-tooltip-positioner.ts +24 -0
  289. package/{lib/lines/index.d.ts → src/lib/lines/index.ts} +17 -11
  290. package/src/lib/lines/lines.component.scss +0 -0
  291. package/src/lib/lines/lines.component.spec.ts +95 -0
  292. package/src/lib/lines/lines.component.ts +425 -0
  293. package/src/lib/lines/lines.cy.ts +738 -0
  294. package/src/lib/lines/lines.module.ts +9 -0
  295. package/src/lib/map-legend/continuous-legend/continuous-legend.component.html +28 -0
  296. package/src/lib/map-legend/continuous-legend/continuous-legend.component.scss +76 -0
  297. package/src/lib/map-legend/continuous-legend/continuous-legend.component.spec.ts +61 -0
  298. package/src/lib/map-legend/continuous-legend/continuous-legend.component.ts +82 -0
  299. package/src/lib/map-legend/discontinuous-legend/discontinuous-legend.component.html +40 -0
  300. package/src/lib/map-legend/discontinuous-legend/discontinuous-legend.component.scss +141 -0
  301. package/src/lib/map-legend/discontinuous-legend/discontinuous-legend.component.spec.ts +75 -0
  302. package/src/lib/map-legend/discontinuous-legend/discontinuous-legend.component.ts +57 -0
  303. package/{lib/map-legend/index.d.ts → src/lib/map-legend/index.ts} +2 -2
  304. package/src/lib/map-legend/map-legend-base.spec.ts +190 -0
  305. package/src/lib/map-legend/map-legend-base.ts +99 -0
  306. package/src/lib/map-legend/map-legend.component.html +24 -0
  307. package/src/lib/map-legend/map-legend.component.scss +0 -0
  308. package/src/lib/map-legend/map-legend.component.spec.ts +125 -0
  309. package/src/lib/map-legend/map-legend.component.ts +80 -0
  310. package/src/lib/map-legend/map-legend.module.ts +8 -0
  311. package/src/lib/marks/aux-marks/aux-marks.ts +18 -0
  312. package/src/lib/marks/aux-marks/config/aux-marks-builder.ts +25 -0
  313. package/{lib/marks/aux-marks/config/aux-marks-config.d.ts → src/lib/marks/aux-marks/config/aux-marks-config.ts} +6 -4
  314. package/src/lib/marks/config/marks-config.ts +14 -0
  315. package/src/lib/marks/config/marks-options.ts +9 -0
  316. package/{lib/marks/index.d.ts → src/lib/marks/index.ts} +15 -15
  317. package/src/lib/marks/map-marks/map-aux-marks/map-aux-marks.spec.ts +74 -0
  318. package/src/lib/marks/map-marks/map-aux-marks/map-aux-marks.ts +40 -0
  319. package/src/lib/marks/map-marks/map-primary-marks/map-primary-marks.spec.ts +79 -0
  320. package/src/lib/marks/map-marks/map-primary-marks/map-primary-marks.ts +63 -0
  321. package/src/lib/marks/marks.ts +39 -0
  322. package/src/lib/marks/primary-marks/config/primary-marks-builder.ts +75 -0
  323. package/src/lib/marks/primary-marks/config/primary-marks-config.ts +9 -0
  324. package/src/lib/marks/primary-marks/primary-marks-base.spec.ts +58 -0
  325. package/src/lib/marks/primary-marks/primary-marks.ts +43 -0
  326. package/src/lib/marks/xy-marks/xy-aux-marks/xy-aux-marks.ts +40 -0
  327. package/src/lib/marks/xy-marks/xy-marks-config.ts +5 -0
  328. package/src/lib/marks/xy-marks/xy-marks.ts +10 -0
  329. package/src/lib/marks/xy-marks/xy-primary-marks/xy-primary-marks-config.ts +7 -0
  330. package/src/lib/marks/xy-marks/xy-primary-marks/xy-primary-marks.spec.ts +186 -0
  331. package/src/lib/marks/xy-marks/xy-primary-marks/xy-primary-marks.ts +72 -0
  332. package/{lib/point-markers/index.d.ts → src/lib/point-markers/index.ts} +3 -2
  333. package/src/lib/point-markers/point-markers-builder.ts +93 -0
  334. package/src/lib/point-markers/point-markers-options.ts +6 -0
  335. package/src/lib/point-markers/point-markers.ts +13 -0
  336. package/src/lib/quantitative-rules/config/labels/quantitative-rules-labels-builder.ts +162 -0
  337. package/src/lib/quantitative-rules/config/labels/quantitative-rules-labels-options.ts +17 -0
  338. package/src/lib/quantitative-rules/config/labels/quantitative-rules-labels.ts +26 -0
  339. package/src/lib/quantitative-rules/config/quantitative-rules-builder.ts +134 -0
  340. package/src/lib/quantitative-rules/config/quantitative-rules-config.ts +21 -0
  341. package/src/lib/quantitative-rules/config/quantitative-rules-dimensions.ts +20 -0
  342. package/{lib/quantitative-rules/config/quantitative-rules-options.d.ts → src/lib/quantitative-rules/config/quantitative-rules-options.ts} +13 -10
  343. package/{lib/quantitative-rules/index.d.ts → src/lib/quantitative-rules/index.ts} +6 -6
  344. package/src/lib/quantitative-rules/quantitative-rules.component.scss +3 -0
  345. package/src/lib/quantitative-rules/quantitative-rules.component.spec.ts +50 -0
  346. package/src/lib/quantitative-rules/quantitative-rules.component.ts +224 -0
  347. package/src/lib/quantitative-rules/quantitative-rules.cy.ts +549 -0
  348. package/src/lib/quantitative-rules/quantitative-rules.module.ts +8 -0
  349. package/src/lib/stacked-area/config/stacked-area-builder.ts +264 -0
  350. package/src/lib/stacked-area/config/stacked-area-config.spec.ts +107 -0
  351. package/src/lib/stacked-area/config/stacked-area-config.ts +109 -0
  352. package/src/lib/stacked-area/config/stacked-area-options.ts +28 -0
  353. package/src/lib/stacked-area/events/actions/stacked-area-hover-move-actions.ts +17 -0
  354. package/src/lib/stacked-area/events/stacked-area-events.directive.spec.ts +168 -0
  355. package/src/lib/stacked-area/events/stacked-area-events.directive.ts +272 -0
  356. package/src/lib/stacked-area/events/stacked-area-interaction-output.ts +33 -0
  357. package/src/lib/stacked-area/events/stacked-area-tooltip-positioner.ts +37 -0
  358. package/{lib/stacked-area/index.d.ts → src/lib/stacked-area/index.ts} +7 -7
  359. package/src/lib/stacked-area/stacked-area.component.scss +0 -0
  360. package/src/lib/stacked-area/stacked-area.component.spec.ts +41 -0
  361. package/src/lib/stacked-area/stacked-area.component.ts +241 -0
  362. package/src/lib/stacked-area/stacked-area.module.ts +9 -0
  363. package/src/lib/stacked-bars/config/stacked-bars-builder.ts +109 -0
  364. package/src/lib/stacked-bars/config/stacked-bars-config.spec.ts +122 -0
  365. package/src/lib/stacked-bars/config/stacked-bars-config.ts +79 -0
  366. package/src/lib/stacked-bars/config/stacked-bars-options.ts +16 -0
  367. package/src/lib/stacked-bars/events/actions/stacked-bars-click-actions.ts +23 -0
  368. package/src/lib/stacked-bars/events/actions/stacked-bars-hover-actions.ts +22 -0
  369. package/src/lib/stacked-bars/events/actions/stacked-bars-hover-move-actions.ts +21 -0
  370. package/src/lib/stacked-bars/events/stacked-bars-events.directive.spec.ts +266 -0
  371. package/src/lib/stacked-bars/events/stacked-bars-events.directive.ts +240 -0
  372. package/{lib/stacked-bars/index.d.ts → src/lib/stacked-bars/index.ts} +10 -10
  373. package/src/lib/stacked-bars/stacked-bars.component.scss +0 -0
  374. package/src/lib/stacked-bars/stacked-bars.component.spec.ts +25 -0
  375. package/src/lib/stacked-bars/stacked-bars.component.ts +158 -0
  376. package/src/lib/stacked-bars/stacked-bars.module.ts +9 -0
  377. package/src/lib/stroke/base/stroke-base-options.ts +7 -0
  378. package/src/lib/stroke/base/stroke-base.ts +9 -0
  379. package/src/lib/stroke/index.ts +5 -0
  380. package/src/lib/stroke/stroke-builder.ts +103 -0
  381. package/{lib/stroke/stroke-options.d.ts → src/lib/stroke/stroke-options.ts} +5 -4
  382. package/src/lib/stroke/stroke.ts +12 -0
  383. package/{lib/svg-text-wrap/index.d.ts → src/lib/svg-text-wrap/index.ts} +3 -2
  384. package/src/lib/svg-text-wrap/svg-text-wrap-builder.ts +105 -0
  385. package/src/lib/svg-text-wrap/svg-text-wrap-options.ts +8 -0
  386. package/src/lib/svg-text-wrap/svg-text-wrap.ts +137 -0
  387. package/src/lib/testing/data/continent-population-year-data.ts +126 -0
  388. package/src/lib/testing/data/country-area-continent.ts +59 -0
  389. package/src/lib/testing/data/state-population-income-year-data.ts +123 -0
  390. package/src/lib/testing/stubs/bars.component.stub.ts +12 -0
  391. package/src/lib/testing/stubs/chart.component.stub.ts +6 -0
  392. package/src/lib/testing/stubs/click.directive.stub.ts +15 -0
  393. package/src/lib/testing/stubs/core/destroy-ref.stub.ts +9 -0
  394. package/src/lib/testing/stubs/core/overlay-ref.stub.ts +13 -0
  395. package/src/lib/testing/stubs/core/overlay.stub.ts +8 -0
  396. package/src/lib/testing/stubs/event.directive.stub.ts +10 -0
  397. package/src/lib/testing/stubs/hover-move.directive.stub.ts +17 -0
  398. package/src/lib/testing/stubs/hover.directive.stub.ts +14 -0
  399. package/src/lib/testing/stubs/input-event.directive.stub.ts +9 -0
  400. package/src/lib/testing/stubs/lines.component.stub.ts +13 -0
  401. package/src/lib/testing/stubs/map-aux-marks.stub.ts +10 -0
  402. package/src/lib/testing/stubs/map-chart.component.stub.ts +3 -0
  403. package/src/lib/testing/stubs/map-legend-content.stub.ts +16 -0
  404. package/src/lib/testing/stubs/map-legend.component.stub.ts +10 -0
  405. package/src/lib/testing/stubs/map-primary-marks.stub.ts +16 -0
  406. package/src/lib/testing/stubs/ordinal-axis.stub.ts +18 -0
  407. package/src/lib/testing/stubs/primary-marks.stub.ts +18 -0
  408. package/src/lib/testing/stubs/quantitative-axis.stub.ts +18 -0
  409. package/src/lib/testing/stubs/services/main.service.stub.ts +5 -0
  410. package/src/lib/testing/stubs/services/utilities.service.stub.ts +7 -0
  411. package/src/lib/testing/stubs/stacked-area.component.stub.ts +13 -0
  412. package/src/lib/testing/stubs/x-axis.stub.ts +10 -0
  413. package/src/lib/testing/stubs/xy-axis.class.stub.ts +20 -0
  414. package/src/lib/testing/stubs/xy-axis.stub.ts +44 -0
  415. package/src/lib/testing/stubs/xy-chart.component.stub.ts +5 -0
  416. package/src/lib/testing/stubs/xy-data-marks.stub.ts +15 -0
  417. package/src/lib/testing/stubs/y-axis.stub.ts +15 -0
  418. package/src/lib/tooltips/config/tooltip.ts +11 -0
  419. package/src/lib/tooltips/html-tooltip/config/html-tooltip-builder.ts +134 -0
  420. package/src/lib/tooltips/html-tooltip/config/html-tooltip-config.ts +21 -0
  421. package/{lib/tooltips/html-tooltip/config/html-tooltip-options.d.ts → src/lib/tooltips/html-tooltip/config/html-tooltip-options.ts} +12 -11
  422. package/src/lib/tooltips/html-tooltip/config/position/tooltip-position-builder.ts +191 -0
  423. package/src/lib/tooltips/html-tooltip/config/position/tooltip-position.ts +42 -0
  424. package/src/lib/tooltips/html-tooltip/config/size/tooltip-size-builder.ts +75 -0
  425. package/src/lib/tooltips/html-tooltip/config/size/tooltip-size-options.ts +8 -0
  426. package/src/lib/tooltips/html-tooltip/config/size/tooltip-size.ts +15 -0
  427. package/src/lib/tooltips/html-tooltip/html-tooltip.directive.spec.ts +537 -0
  428. package/src/lib/tooltips/html-tooltip/html-tooltip.directive.ts +210 -0
  429. package/src/lib/tooltips/html-tooltip/html-tooltip.module.ts +16 -0
  430. package/src/lib/tooltips/html-tooltip/tooltip-triangle/tooltip-triangle.component.html +41 -0
  431. package/src/lib/tooltips/html-tooltip/tooltip-triangle/tooltip-triangle.component.scss +63 -0
  432. package/src/lib/tooltips/html-tooltip/tooltip-triangle/tooltip-triangle.component.ts +19 -0
  433. package/{lib/tooltips/index.d.ts → src/lib/tooltips/index.ts} +11 -11
  434. package/src/lib/tooltips/svg-tooltip/config/svg-tooltip.ts +5 -0
  435. package/{lib/xy-background/index.d.ts → src/lib/xy-background/index.ts} +2 -2
  436. package/src/lib/xy-background/xy-background.component.html +10 -0
  437. package/src/lib/xy-background/xy-background.component.scss +0 -0
  438. package/src/lib/xy-background/xy-background.component.spec.ts +24 -0
  439. package/src/lib/xy-background/xy-background.component.ts +19 -0
  440. package/src/lib/xy-background/xy-background.module.ts +8 -0
  441. package/{public-api.d.ts → src/public-api.ts} +26 -23
  442. package/src/test.ts +15 -0
  443. package/tsconfig.doc.json +4 -0
  444. package/tsconfig.json +20 -0
  445. package/tsconfig.lib.json +23 -0
  446. package/tsconfig.lib.prod.json +10 -0
  447. package/tsconfig.spec.json +10 -0
  448. package/fesm2022/mathstack-viz.mjs +0 -11058
  449. package/fesm2022/mathstack-viz.mjs.map +0 -1
  450. package/index.d.ts +0 -5
  451. package/lib/axes/base/config/xy-axis-builder.d.ts +0 -38
  452. package/lib/axes/base/config/xy-axis-config.d.ts +0 -18
  453. package/lib/axes/base/xy-axis-base.d.ts +0 -49
  454. package/lib/axes/baseline/axis-baseline-builder.d.ts +0 -31
  455. package/lib/axes/baseline/axis-baseline-options.d.ts +0 -7
  456. package/lib/axes/baseline/axis-baseline.d.ts +0 -9
  457. package/lib/axes/grid/grid-builder.d.ts +0 -29
  458. package/lib/axes/grid/grid-config.d.ts +0 -8
  459. package/lib/axes/grid/grid-options.d.ts +0 -6
  460. package/lib/axes/index.d.ts +0 -13
  461. package/lib/axes/label/axis-label-builder.d.ts +0 -63
  462. package/lib/axes/label/axis-label-options.d.ts +0 -11
  463. package/lib/axes/label/axis-label.d.ts +0 -13
  464. package/lib/axes/ordinal/ordinal-axis-config.d.ts +0 -38
  465. package/lib/axes/ordinal/ordinal-axis.d.ts +0 -43
  466. package/lib/axes/quantitative/quantitative-axis-config.d.ts +0 -38
  467. package/lib/axes/quantitative/quantitative-axis.d.ts +0 -51
  468. package/lib/axes/ticks/tick-wrap/tick-wrap-builder.d.ts +0 -64
  469. package/lib/axes/ticks/tick-wrap/tick-wrap-options.d.ts +0 -8
  470. package/lib/axes/ticks/tick-wrap/tick-wrap.d.ts +0 -13
  471. package/lib/axes/ticks/ticks-builder.d.ts +0 -172
  472. package/lib/axes/ticks/ticks-options.d.ts +0 -22
  473. package/lib/axes/ticks/ticks.d.ts +0 -24
  474. package/lib/axes/x/x-axis-config.d.ts +0 -42
  475. package/lib/axes/x/x-axis.d.ts +0 -47
  476. package/lib/axes/x-ordinal/x-ordinal-axis-builder.d.ts +0 -29
  477. package/lib/axes/x-ordinal/x-ordinal-axis-config.d.ts +0 -25
  478. package/lib/axes/x-ordinal/x-ordinal-axis.component.d.ts +0 -88
  479. package/lib/axes/x-quantitative/x-quantitative-axis-builder.d.ts +0 -29
  480. package/lib/axes/x-quantitative/x-quantitative-axis-config.d.ts +0 -25
  481. package/lib/axes/x-quantitative/x-quantitative-axis.component.d.ts +0 -53
  482. package/lib/axes/xy-axis.module.d.ts +0 -10
  483. package/lib/axes/y/y-axis-config.d.ts +0 -42
  484. package/lib/axes/y/y-axis.d.ts +0 -53
  485. package/lib/axes/y-ordinal/y-ordinal-axis-builder.d.ts +0 -29
  486. package/lib/axes/y-ordinal/y-ordinal-axis-config.d.ts +0 -25
  487. package/lib/axes/y-ordinal/y-ordinal-axis.component.d.ts +0 -89
  488. package/lib/axes/y-quantitative-axis/y-quantitative-axis-builder.d.ts +0 -29
  489. package/lib/axes/y-quantitative-axis/y-quantitative-axis-config.d.ts +0 -25
  490. package/lib/axes/y-quantitative-axis/y-quantitative-axis.component.d.ts +0 -54
  491. package/lib/bars/bars.component.d.ts +0 -91
  492. package/lib/bars/bars.module.d.ts +0 -8
  493. package/lib/bars/config/backgrounds/bars-backgrounds-builder.d.ts +0 -27
  494. package/lib/bars/config/backgrounds/bars-backgrounds.d.ts +0 -6
  495. package/lib/bars/config/bars-builder.d.ts +0 -132
  496. package/lib/bars/config/bars-config.d.ts +0 -27
  497. package/lib/bars/config/bars-dimensions.d.ts +0 -11
  498. package/lib/bars/config/labels/bars-labels-builder.d.ts +0 -48
  499. package/lib/bars/config/labels/bars-labels-options.d.ts +0 -9
  500. package/lib/bars/config/labels/bars-labels.d.ts +0 -11
  501. package/lib/bars/events/actions/bars-click-actions.d.ts +0 -8
  502. package/lib/bars/events/actions/bars-hover-actions.d.ts +0 -12
  503. package/lib/bars/events/actions/bars-hover-move-actions.d.ts +0 -8
  504. package/lib/bars/events/bars-events.directive.d.ts +0 -38
  505. package/lib/bars/events/bars-interaction-output.d.ts +0 -16
  506. package/lib/bars/events/bars-tooltip-positioner.d.ts +0 -13
  507. package/lib/charts/chart/chart.component.d.ts +0 -73
  508. package/lib/charts/chart/chart.d.ts +0 -4
  509. package/lib/charts/chart/config/chart-builder.d.ts +0 -94
  510. package/lib/charts/chart/config/chart-config.d.ts +0 -16
  511. package/lib/charts/chart/config/chart-options.d.ts +0 -10
  512. package/lib/charts/chart.module.d.ts +0 -9
  513. package/lib/charts/map-chart/map-chart.component.d.ts +0 -40
  514. package/lib/charts/xy-chart/xy-chart.component.d.ts +0 -40
  515. package/lib/core/common-behaviors/constructor.d.ts +0 -2
  516. package/lib/core/index.d.ts +0 -5
  517. package/lib/core/types/layout.d.ts +0 -24
  518. package/lib/core/types/scale.d.ts +0 -5
  519. package/lib/core/utilities/colors.d.ts +0 -13
  520. package/lib/core/utilities/fill-utilities.d.ts +0 -7
  521. package/lib/core/utilities/type-guards.d.ts +0 -6
  522. package/lib/core/utilities/value-format.d.ts +0 -11
  523. package/lib/core/utilities/values.d.ts +0 -16
  524. package/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position-builder.d.ts +0 -39
  525. package/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position-options.d.ts +0 -18
  526. package/lib/data-dimensions/continuous-quantitative/date-chart-position/date-chart-position.d.ts +0 -38
  527. package/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/domain-padding.d.ts +0 -20
  528. package/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/percent-over/percent-over.d.ts +0 -9
  529. package/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/pixel/pixel.d.ts +0 -10
  530. package/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-interval/round-to-interval.d.ts +0 -8
  531. package/lib/data-dimensions/continuous-quantitative/number-chart-position/domain-padding/round-to-sig-fig/round-to-sig-fig.d.ts +0 -8
  532. package/lib/data-dimensions/continuous-quantitative/number-chart-position/number-chart-position-builder.d.ts +0 -71
  533. package/lib/data-dimensions/continuous-quantitative/number-dimension/number-dimension-options.d.ts +0 -8
  534. package/lib/data-dimensions/continuous-quantitative/number-dimension/number-dimension.d.ts +0 -28
  535. package/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value-builder.d.ts +0 -69
  536. package/lib/data-dimensions/continuous-quantitative/number-visual-value/number-visual-value-options.d.ts +0 -6
  537. package/lib/data-dimensions/dimension-builder.d.ts +0 -21
  538. package/lib/data-dimensions/dimension-options.d.ts +0 -11
  539. package/lib/data-dimensions/dimension.d.ts +0 -16
  540. package/lib/data-dimensions/index.d.ts +0 -9
  541. package/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position-builder.d.ts +0 -53
  542. package/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position-options.d.ts +0 -8
  543. package/lib/data-dimensions/ordinal/ordinal-chart-position/ordinal-chart-position.d.ts +0 -44
  544. package/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value-builder.d.ts +0 -45
  545. package/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value-options.d.ts +0 -7
  546. package/lib/data-dimensions/ordinal/ordinal-visual-value/ordinal-visual-value.d.ts +0 -38
  547. package/lib/data-export/data-export-config.d.ts +0 -50
  548. package/lib/data-export/data-export.d.ts +0 -7
  549. package/lib/dots/config/dots-builder.d.ts +0 -110
  550. package/lib/dots/config/dots-config.d.ts +0 -26
  551. package/lib/dots/dots.component.d.ts +0 -55
  552. package/lib/dots/dots.module.d.ts +0 -8
  553. package/lib/dots/events/actions/dots-hover-actions.d.ts +0 -6
  554. package/lib/dots/events/actions/dots-hover-move-actions.d.ts +0 -10
  555. package/lib/dots/events/dots-events.directive.d.ts +0 -37
  556. package/lib/dots/events/dots-interaction-output.d.ts +0 -14
  557. package/lib/dots/events/dots-tooltip-positioner.d.ts +0 -13
  558. package/lib/events/events.directive.d.ts +0 -43
  559. package/lib/events/events.types.d.ts +0 -34
  560. package/lib/events/interaction-output.d.ts +0 -33
  561. package/lib/events/tooltip-positioner.d.ts +0 -6
  562. package/lib/fill-definitions/fill-definitions.d.ts +0 -4
  563. package/lib/geographies/config/geographies-builder.d.ts +0 -80
  564. package/lib/geographies/config/geographies-config.d.ts +0 -19
  565. package/lib/geographies/config/geographies-options.d.ts +0 -13
  566. package/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer-builder.d.ts +0 -63
  567. package/lib/geographies/config/layers/attribute-data-layer/attribute-data-layer.d.ts +0 -30
  568. package/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data/attribute-data-dimension-builder.d.ts +0 -40
  569. package/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data/attribute-data-dimension-options.d.ts +0 -8
  570. package/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data/attribute-data-dimension.d.ts +0 -18
  571. package/lib/geographies/config/layers/attribute-data-layer/dimensions/attribute-data-bin-enums.d.ts +0 -10
  572. package/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins-builder.d.ts +0 -10
  573. package/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins-options.d.ts +0 -4
  574. package/lib/geographies/config/layers/attribute-data-layer/dimensions/calculated-bins/calculated-bins.d.ts +0 -8
  575. package/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins-builder.d.ts +0 -14
  576. package/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins-options.d.ts +0 -4
  577. package/lib/geographies/config/layers/attribute-data-layer/dimensions/categorical-bins/categorical-bins.d.ts +0 -20
  578. package/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins-builder.d.ts +0 -29
  579. package/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins-options.d.ts +0 -5
  580. package/lib/geographies/config/layers/attribute-data-layer/dimensions/custom-breaks/custom-breaks-bins.d.ts +0 -23
  581. package/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins-builder.d.ts +0 -16
  582. package/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins-options.d.ts +0 -4
  583. package/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-frequencies-bins/equal-frequencies-bins.d.ts +0 -18
  584. package/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins-builder.d.ts +0 -21
  585. package/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins-options.d.ts +0 -5
  586. package/lib/geographies/config/layers/attribute-data-layer/dimensions/equal-value-ranges-bins/equal-value-ranges-bins.d.ts +0 -24
  587. package/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins-builder.d.ts +0 -26
  588. package/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins-options.d.ts +0 -5
  589. package/lib/geographies/config/layers/attribute-data-layer/dimensions/no-bins/no-bins.d.ts +0 -12
  590. package/lib/geographies/config/layers/geographies-layer/geographies-layer-builder.d.ts +0 -52
  591. package/lib/geographies/config/layers/geographies-layer/geographies-layer.d.ts +0 -29
  592. package/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer-builder.d.ts +0 -25
  593. package/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer-options.d.ts +0 -11
  594. package/lib/geographies/config/layers/geojson-properties-layer/geojson-properties-layer.d.ts +0 -16
  595. package/lib/geographies/config/layers/labels/geographies-labels-builder.d.ts +0 -97
  596. package/lib/geographies/config/layers/labels/geographies-labels-options.d.ts +0 -33
  597. package/lib/geographies/config/layers/labels/geographies-labels.d.ts +0 -20
  598. package/lib/geographies/events/actions/geographies-click-actions.d.ts +0 -7
  599. package/lib/geographies/events/actions/geographies-hover-actions.d.ts +0 -7
  600. package/lib/geographies/events/actions/geographies-hover-move-actions.d.ts +0 -7
  601. package/lib/geographies/events/geographies-events.directive.d.ts +0 -38
  602. package/lib/geographies/events/geographies-interaction-output.d.ts +0 -16
  603. package/lib/geographies/events/geographies-tooltip-positioner.d.ts +0 -13
  604. package/lib/geographies/geographies-feature.d.ts +0 -5
  605. package/lib/geographies/geographies.component.d.ts +0 -36
  606. package/lib/geographies/geographies.module.d.ts +0 -8
  607. package/lib/grouped-bars/config/grouped-bars-builder.d.ts +0 -29
  608. package/lib/grouped-bars/config/grouped-bars-config.d.ts +0 -10
  609. package/lib/grouped-bars/config/grouped-bars-options.d.ts +0 -5
  610. package/lib/grouped-bars/events/grouped-bars-events.directive.d.ts +0 -35
  611. package/lib/grouped-bars/grouped-bars.component.d.ts +0 -19
  612. package/lib/grouped-bars/grouped-bars.module.d.ts +0 -8
  613. package/lib/image-download/image-download-config.d.ts +0 -31
  614. package/lib/image-download/image-download-enums.d.ts +0 -6
  615. package/lib/image-download/image-download-options.d.ts +0 -14
  616. package/lib/image-download/image-download.service.d.ts +0 -16
  617. package/lib/lines/config/area-fills/area-fills-builder.d.ts +0 -45
  618. package/lib/lines/config/area-fills/area-fills-options.d.ts +0 -7
  619. package/lib/lines/config/area-fills/area-fills.d.ts +0 -9
  620. package/lib/lines/config/lines-builder.d.ts +0 -101
  621. package/lib/lines/config/lines-config.d.ts +0 -37
  622. package/lib/lines/config/stroke/lines-stroke-builder.d.ts +0 -59
  623. package/lib/lines/config/stroke/lines-stroke.d.ts +0 -7
  624. package/lib/lines/events/actions/lines-click-actions.d.ts +0 -6
  625. package/lib/lines/events/actions/lines-hover-move-actions.d.ts +0 -41
  626. package/lib/lines/events/actions/lines-marker-click-actions.d.ts +0 -6
  627. package/lib/lines/events/lines-events.directive.d.ts +0 -49
  628. package/lib/lines/events/lines-interaction-output.d.ts +0 -16
  629. package/lib/lines/events/lines-tooltip-positioner.d.ts +0 -13
  630. package/lib/lines/lines.component.d.ts +0 -53
  631. package/lib/lines/lines.module.d.ts +0 -8
  632. package/lib/map-legend/continuous-legend/continuous-legend.component.d.ts +0 -18
  633. package/lib/map-legend/discontinuous-legend/discontinuous-legend.component.d.ts +0 -12
  634. package/lib/map-legend/map-legend-base.d.ts +0 -33
  635. package/lib/map-legend/map-legend.component.d.ts +0 -27
  636. package/lib/map-legend/map-legend.module.d.ts +0 -7
  637. package/lib/marks/aux-marks/aux-marks.d.ts +0 -10
  638. package/lib/marks/aux-marks/config/aux-marks-builder.d.ts +0 -11
  639. package/lib/marks/config/marks-config.d.ts +0 -9
  640. package/lib/marks/config/marks-options.d.ts +0 -8
  641. package/lib/marks/map-marks/map-aux-marks/map-aux-marks.d.ts +0 -17
  642. package/lib/marks/map-marks/map-primary-marks/map-primary-marks.d.ts +0 -20
  643. package/lib/marks/marks.d.ts +0 -31
  644. package/lib/marks/primary-marks/config/primary-marks-builder.d.ts +0 -32
  645. package/lib/marks/primary-marks/config/primary-marks-config.d.ts +0 -5
  646. package/lib/marks/primary-marks/primary-marks.d.ts +0 -23
  647. package/lib/marks/xy-marks/xy-aux-marks/xy-aux-marks.d.ts +0 -16
  648. package/lib/marks/xy-marks/xy-marks-config.d.ts +0 -4
  649. package/lib/marks/xy-marks/xy-marks.d.ts +0 -6
  650. package/lib/marks/xy-marks/xy-primary-marks/xy-primary-marks-config.d.ts +0 -4
  651. package/lib/marks/xy-marks/xy-primary-marks/xy-primary-marks.d.ts +0 -20
  652. package/lib/point-markers/point-markers-builder.d.ts +0 -47
  653. package/lib/point-markers/point-markers-options.d.ts +0 -6
  654. package/lib/point-markers/point-markers.d.ts +0 -8
  655. package/lib/quantitative-rules/config/labels/quantitative-rules-labels-builder.d.ts +0 -60
  656. package/lib/quantitative-rules/config/labels/quantitative-rules-labels-options.d.ts +0 -9
  657. package/lib/quantitative-rules/config/labels/quantitative-rules-labels.d.ts +0 -11
  658. package/lib/quantitative-rules/config/quantitative-rules-builder.d.ts +0 -52
  659. package/lib/quantitative-rules/config/quantitative-rules-config.d.ts +0 -12
  660. package/lib/quantitative-rules/config/quantitative-rules-dimensions.d.ts +0 -8
  661. package/lib/quantitative-rules/quantitative-rules.component.d.ts +0 -27
  662. package/lib/quantitative-rules/quantitative-rules.module.d.ts +0 -7
  663. package/lib/stacked-area/config/stacked-area-builder.d.ts +0 -85
  664. package/lib/stacked-area/config/stacked-area-config.d.ts +0 -36
  665. package/lib/stacked-area/config/stacked-area-options.d.ts +0 -21
  666. package/lib/stacked-area/events/actions/stacked-area-hover-move-actions.d.ts +0 -7
  667. package/lib/stacked-area/events/stacked-area-events.directive.d.ts +0 -38
  668. package/lib/stacked-area/events/stacked-area-interaction-output.d.ts +0 -28
  669. package/lib/stacked-area/events/stacked-area-tooltip-positioner.d.ts +0 -16
  670. package/lib/stacked-area/stacked-area.component.d.ts +0 -51
  671. package/lib/stacked-area/stacked-area.module.d.ts +0 -8
  672. package/lib/stacked-bars/config/stacked-bars-builder.d.ts +0 -26
  673. package/lib/stacked-bars/config/stacked-bars-config.d.ts +0 -16
  674. package/lib/stacked-bars/config/stacked-bars-options.d.ts +0 -7
  675. package/lib/stacked-bars/events/actions/stacked-bars-click-actions.d.ts +0 -8
  676. package/lib/stacked-bars/events/actions/stacked-bars-hover-actions.d.ts +0 -8
  677. package/lib/stacked-bars/events/actions/stacked-bars-hover-move-actions.d.ts +0 -8
  678. package/lib/stacked-bars/events/stacked-bars-events.directive.d.ts +0 -39
  679. package/lib/stacked-bars/stacked-bars.component.d.ts +0 -26
  680. package/lib/stacked-bars/stacked-bars.module.d.ts +0 -8
  681. package/lib/stroke/base/stroke-base-options.d.ts +0 -7
  682. package/lib/stroke/base/stroke-base.d.ts +0 -8
  683. package/lib/stroke/index.d.ts +0 -2
  684. package/lib/stroke/stroke-builder.d.ts +0 -56
  685. package/lib/stroke/stroke.d.ts +0 -6
  686. package/lib/svg-text-wrap/svg-text-wrap-builder.d.ts +0 -58
  687. package/lib/svg-text-wrap/svg-text-wrap-options.d.ts +0 -8
  688. package/lib/svg-text-wrap/svg-text-wrap.d.ts +0 -13
  689. package/lib/tooltips/config/tooltip.d.ts +0 -5
  690. package/lib/tooltips/html-tooltip/config/html-tooltip-builder.d.ts +0 -57
  691. package/lib/tooltips/html-tooltip/config/html-tooltip-config.d.ts +0 -15
  692. package/lib/tooltips/html-tooltip/config/position/tooltip-position-builder.d.ts +0 -34
  693. package/lib/tooltips/html-tooltip/config/position/tooltip-position.d.ts +0 -23
  694. package/lib/tooltips/html-tooltip/config/size/tooltip-size-builder.d.ts +0 -16
  695. package/lib/tooltips/html-tooltip/config/size/tooltip-size-options.d.ts +0 -8
  696. package/lib/tooltips/html-tooltip/config/size/tooltip-size.d.ts +0 -10
  697. package/lib/tooltips/html-tooltip/html-tooltip.directive.d.ts +0 -43
  698. package/lib/tooltips/html-tooltip/html-tooltip.module.d.ts +0 -10
  699. package/lib/tooltips/html-tooltip/tooltip-triangle/tooltip-triangle.component.d.ts +0 -7
  700. package/lib/xy-background/xy-background.component.d.ts +0 -9
  701. package/lib/xy-background/xy-background.module.d.ts +0 -7
@@ -0,0 +1,1470 @@
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
+ });