@unovis/ts 1.7.0-pre.0 → 1.7.0-pre.1

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 (54) hide show
  1. package/components/annotations/config.d.ts +2 -0
  2. package/components/annotations/config.js +1 -1
  3. package/components/annotations/config.js.map +1 -1
  4. package/components/annotations/index.d.ts +1 -0
  5. package/components/annotations/index.js +25 -10
  6. package/components/annotations/index.js.map +1 -1
  7. package/components/annotations/style.d.ts +2 -0
  8. package/components/annotations/style.js +8 -1
  9. package/components/annotations/style.js.map +1 -1
  10. package/components/area/config.d.ts +9 -1
  11. package/components/area/config.js +1 -1
  12. package/components/area/config.js.map +1 -1
  13. package/components/area/index.d.ts +6 -0
  14. package/components/area/index.js +74 -4
  15. package/components/area/index.js.map +1 -1
  16. package/components/area/style.d.ts +1 -0
  17. package/components/area/style.js +7 -1
  18. package/components/area/style.js.map +1 -1
  19. package/components/axis/index.d.ts +2 -0
  20. package/components/axis/index.js +45 -7
  21. package/components/axis/index.js.map +1 -1
  22. package/components/bullet-legend/index.d.ts +2 -0
  23. package/components/bullet-legend/index.js +9 -5
  24. package/components/bullet-legend/index.js.map +1 -1
  25. package/components/bullet-legend/modules/shape.js +3 -2
  26. package/components/bullet-legend/modules/shape.js.map +1 -1
  27. package/components/crosshair/index.js +3 -2
  28. package/components/crosshair/index.js.map +1 -1
  29. package/components/flow-legend/config.d.ts +10 -0
  30. package/components/flow-legend/config.js +4 -0
  31. package/components/flow-legend/config.js.map +1 -1
  32. package/components/flow-legend/index.d.ts +6 -2
  33. package/components/flow-legend/index.js +34 -16
  34. package/components/flow-legend/index.js.map +1 -1
  35. package/components/flow-legend/style.d.ts +3 -3
  36. package/components/flow-legend/style.js +30 -26
  37. package/components/flow-legend/style.js.map +1 -1
  38. package/components/graph/modules/link/index.js +1 -1
  39. package/components/graph/modules/link/index.js.map +1 -1
  40. package/components/graph/modules/node/index.js +2 -1
  41. package/components/graph/modules/node/index.js.map +1 -1
  42. package/components/leaflet-map/leaflet.css.js +2 -2
  43. package/components/treemap/index.d.ts +5 -2
  44. package/components/treemap/index.js +51 -45
  45. package/components/treemap/index.js.map +1 -1
  46. package/package.json +9 -43
  47. package/utils/misc.js +13 -2
  48. package/utils/misc.js.map +1 -1
  49. package/utils/text.d.ts +1 -1
  50. package/utils/text.js +13 -15
  51. package/utils/text.js.map +1 -1
  52. package/utils/to-px.d.ts +1 -0
  53. package/utils/to-px.js +110 -0
  54. package/utils/to-px.js.map +1 -0
@@ -15,5 +15,7 @@ export interface AnnotationsConfigInterface extends ComponentConfigInterface {
15
15
  * To learn more, see our docs https://unovis.dev/docs/auxiliary/Annotations/
16
16
  * Default: `[]` */
17
17
  items: AnnotationItem[] | undefined;
18
+ /** Debug option to render bounding boxes around text elements. Default: `false` */
19
+ renderTextBoundingBoxes?: boolean;
18
20
  }
19
21
  export declare const AnnotationsDefaultConfig: AnnotationsConfigInterface;
@@ -1,6 +1,6 @@
1
1
  import { ComponentDefaultConfig } from '../../core/component/config.js';
2
2
 
3
- const AnnotationsDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { items: [] });
3
+ const AnnotationsDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { items: [], renderTextBoundingBoxes: false });
4
4
 
5
5
  export { AnnotationsDefaultConfig };
6
6
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/annotations/config.ts"],"sourcesContent":["import { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { AnnotationItem } from './types'\n\nexport interface AnnotationsConfigInterface extends ComponentConfigInterface {\n /** Legend items. Array of `AnnotationItem`:\n * ```\n * {\n * content: string | UnovisText | UnovisText[];\n * subject?: AnnotationSubject;\n * x?: LengthUnit;\n * y?: LengthUnit;\n * width?: LengthUnit;\n * height?: LengthUnit;\n * }\n * ```\n * To learn more, see our docs https://unovis.dev/docs/auxiliary/Annotations/\n * Default: `[]` */\n items: AnnotationItem[] | undefined;\n}\n\nexport const AnnotationsDefaultConfig: AnnotationsConfigInterface = {\n ...ComponentDefaultConfig,\n items: [],\n}\n"],"names":[],"mappings":";;AAsBa,MAAA,wBAAwB,GAChC,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,sBAAsB,KACzB,KAAK,EAAE,EAAE,EAAA;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/annotations/config.ts"],"sourcesContent":["import { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { AnnotationItem } from './types'\n\nexport interface AnnotationsConfigInterface extends ComponentConfigInterface {\n /** Legend items. Array of `AnnotationItem`:\n * ```\n * {\n * content: string | UnovisText | UnovisText[];\n * subject?: AnnotationSubject;\n * x?: LengthUnit;\n * y?: LengthUnit;\n * width?: LengthUnit;\n * height?: LengthUnit;\n * }\n * ```\n * To learn more, see our docs https://unovis.dev/docs/auxiliary/Annotations/\n * Default: `[]` */\n items: AnnotationItem[] | undefined;\n /** Debug option to render bounding boxes around text elements. Default: `false` */\n renderTextBoundingBoxes?: boolean;\n}\n\nexport const AnnotationsDefaultConfig: AnnotationsConfigInterface = {\n ...ComponentDefaultConfig,\n items: [],\n renderTextBoundingBoxes: false,\n}\n"],"names":[],"mappings":";;AAwBO,MAAM,wBAAwB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAChC,sBAAsB,CACzB,EAAA,EAAA,KAAK,EAAE,EAAE,EACT,uBAAuB,EAAE,KAAK;;;;"}
@@ -12,6 +12,7 @@ export declare class Annotations extends ComponentCore<unknown[], AnnotationsCon
12
12
  annotationsSubjectStrokeColor: "--vis-annotations-subject-stroke-color";
13
13
  annotationsSubjectFillColor: "--vis-annotations-subject-fill-color";
14
14
  annotationsSubjectStrokeDasharray: "--vis-annotations-subject-stroke-dasharray";
15
+ annotationsDebugBoundingBoxStrokeColor: "--vis-annotations-debug-bounding-box-stroke-color";
15
16
  darkAnnotationsTextColor: "--vis-dark-annotations-text-color";
16
17
  darkAnnotationsConnectorStrokeColor: "--vis-dark-annotations-connector-stroke-color";
17
18
  darkAnnotationsSubjectStrokeColor: "--vis-dark-annotations-subject-stroke-color";
@@ -7,7 +7,7 @@ import { parseUnit } from '../../utils/misc.js';
7
7
  import { UNOVIS_TEXT_DEFAULT } from '../../styles/index.js';
8
8
  import { AnnotationsDefaultConfig } from './config.js';
9
9
  import * as style from './style.js';
10
- import { annotation, annotationContent, annotationSubject, variables } from './style.js';
10
+ import { annotation, annotationContent, debugBoundingBox, annotationSubject, variables } from './style.js';
11
11
 
12
12
  class Annotations extends ComponentCore {
13
13
  constructor(config) {
@@ -29,11 +29,6 @@ class Annotations extends ComponentCore {
29
29
  .style('opacity', 0);
30
30
  // Content
31
31
  annotationsEnter.append('g').attr('class', annotationContent);
32
- // Subject
33
- const subject = annotationsEnter.append('g')
34
- .attr('class', annotationSubject);
35
- subject.append('circle');
36
- subject.append('line');
37
32
  const annotationsMerged = annotationsEnter.merge(annotations)
38
33
  .attr('cursor', d => d === null || d === void 0 ? void 0 : d.cursor)
39
34
  .each((annotation, i, elements) => {
@@ -46,10 +41,25 @@ class Annotations extends ComponentCore {
46
41
  const options = Object.assign(Object.assign({}, annotation), { x, y, width, height });
47
42
  const contentGroupElement = select(elements[i]).select(`.${annotationContent}`);
48
43
  renderTextIntoFrame(contentGroupElement.node(), content, options);
44
+ // Render debug bounding boxes showing the frame (x, y, width, height)
45
+ contentGroupElement.selectAll(`.${debugBoundingBox}`).remove();
46
+ if (config.renderTextBoundingBoxes) {
47
+ const debugWidth = width !== null && width !== void 0 ? width : 100;
48
+ const debugHeight = height || 0.1;
49
+ contentGroupElement.append('rect')
50
+ .attr('class', debugBoundingBox)
51
+ .attr('x', x)
52
+ .attr('y', y)
53
+ .attr('width', debugWidth)
54
+ .attr('height', debugHeight);
55
+ }
49
56
  }
50
57
  if (annotation.subject) {
51
58
  requestAnimationFrame(() => this._renderSubject(elements[i], annotation.subject));
52
59
  }
60
+ else {
61
+ select(elements[i]).select(`.${annotationSubject}`).remove();
62
+ }
53
63
  });
54
64
  smartTransition(annotationsMerged, duration)
55
65
  .style('opacity', 1);
@@ -59,8 +69,15 @@ class Annotations extends ComponentCore {
59
69
  }
60
70
  _renderSubject(annotationGroupElement, subject) {
61
71
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
62
- const contentGroup = select(annotationGroupElement).select(`.${annotationContent}`);
63
- const subjectGroup = select(annotationGroupElement).select(`.${annotationSubject}`);
72
+ const annotationGroup = select(annotationGroupElement);
73
+ const contentGroup = annotationGroup.select(`.${annotationContent}`);
74
+ // Create subject group if it doesn't exist
75
+ let subjectGroup = annotationGroup.select(`.${annotationSubject}`);
76
+ if (subjectGroup.empty()) {
77
+ subjectGroup = annotationGroup.append('g').attr('class', annotationSubject);
78
+ subjectGroup.append('circle');
79
+ subjectGroup.append('line');
80
+ }
64
81
  const subjectX = (_a = parseUnit(typeof (subject === null || subject === void 0 ? void 0 : subject.x) === 'function' ? subject.x() : subject === null || subject === void 0 ? void 0 : subject.x, this._width)) !== null && _a !== void 0 ? _a : null;
65
82
  const subjectY = (_b = parseUnit(typeof (subject === null || subject === void 0 ? void 0 : subject.y) === 'function' ? subject.y() : subject === null || subject === void 0 ? void 0 : subject.y, this._height)) !== null && _b !== void 0 ? _b : null;
66
83
  const subjectStrokeColor = (_c = subject === null || subject === void 0 ? void 0 : subject.strokeColor) !== null && _c !== void 0 ? _c : null;
@@ -84,7 +101,6 @@ class Annotations extends ComponentCore {
84
101
  const x1 = subjectX + Math.cos(angle * Math.PI / 180) * (subjectRadius + padding);
85
102
  const y1 = subjectY + Math.sin(angle * Math.PI / 180) * (subjectRadius + padding);
86
103
  subjectGroup.select('circle')
87
- .attr('visibility', subject ? null : 'hidden')
88
104
  .attr('cx', subjectX)
89
105
  .attr('cy', subjectY)
90
106
  .attr('r', subjectRadius)
@@ -92,7 +108,6 @@ class Annotations extends ComponentCore {
92
108
  .style('fill', subjectFillColor)
93
109
  .style('stroke-dasharray', subjectStrokeDasharray);
94
110
  subjectGroup.select('line')
95
- .attr('visibility', subject ? null : 'hidden')
96
111
  .attr('x1', x1)
97
112
  .attr('y1', y1)
98
113
  .attr('x2', x1)
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/annotations/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\n\n// Utils\nimport { isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { renderTextIntoFrame } from 'utils/text'\nimport { parseUnit } from 'utils/misc'\nimport { UNOVIS_TEXT_DEFAULT } from 'styles'\n\n// Local Types\nimport { AnnotationItem, AnnotationSubject } from './types'\n\n// Config\nimport { AnnotationsDefaultConfig, AnnotationsConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Annotations extends ComponentCore<unknown[], AnnotationsConfigInterface> {\n static selectors = s\n static cssVariables = s.variables\n protected _defaultConfig = AnnotationsDefaultConfig as AnnotationsConfigInterface\n public config: AnnotationsConfigInterface = this._defaultConfig\n\n g: Selection<SVGGElement, unknown, null, undefined>\n\n events = {}\n\n constructor (config?: AnnotationsConfigInterface) {\n super()\n if (config) this.setConfig(config)\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config } = this\n\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const annotations = this.g.selectAll<SVGGElement, AnnotationItem[]>(`.${s.annotation}`)\n .data(config.items, d => JSON.stringify(d))\n\n const annotationsEnter = annotations.enter().append('g')\n .attr('class', s.annotation)\n .style('opacity', 0)\n\n // Content\n annotationsEnter.append('g').attr('class', s.annotationContent)\n\n // Subject\n const subject = annotationsEnter.append('g')\n .attr('class', s.annotationSubject)\n\n subject.append('circle')\n subject.append('line')\n\n const annotationsMerged = annotationsEnter.merge(annotations)\n .attr('cursor', d => d?.cursor)\n .each((annotation, i, elements) => {\n if (annotation.content) {\n const content = typeof annotation.content === 'string' ? { ...UNOVIS_TEXT_DEFAULT, text: annotation.content } : annotation.content\n const x = parseUnit(annotation.x, this._width)\n const y = parseUnit(annotation.y, this._height)\n const width = parseUnit(annotation.width, this._width)\n const height = parseUnit(annotation.height, this._height)\n const options = { ...annotation, x, y, width, height }\n\n const contentGroupElement = select(elements[i]).select<SVGGElement>(`.${s.annotationContent}`)\n renderTextIntoFrame(contentGroupElement.node(), content, options)\n }\n\n if (annotation.subject) {\n requestAnimationFrame(() => this._renderSubject(elements[i], annotation.subject))\n }\n })\n\n smartTransition(annotationsMerged, duration)\n .style('opacity', 1)\n\n smartTransition(annotations.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n\n private _renderSubject (\n annotationGroupElement: SVGElement,\n subject: AnnotationSubject | undefined\n ): void {\n const contentGroup = select(annotationGroupElement).select<SVGGElement>(`.${s.annotationContent}`)\n const subjectGroup = select(annotationGroupElement).select<SVGGElement>(`.${s.annotationSubject}`)\n\n const subjectX: number | null = parseUnit(typeof subject?.x === 'function' ? subject.x() : subject?.x, this._width) ?? null\n const subjectY: number | null = parseUnit(typeof subject?.y === 'function' ? subject.y() : subject?.y, this._height) ?? null\n\n const subjectStrokeColor: string | null = subject?.strokeColor ?? null\n const subjectFillColor: string | null = subject?.fillColor ?? null\n const subjectStrokeDasharray: string | null = subject?.strokeDasharray ?? null\n const connectorLineColor: string | null = subject?.connectorLineColor ?? null\n const connectorLineStrokeDasharray: string | null = subject?.connectorLineStrokeDasharray ?? null\n const subjectRadius: number | null = subject?.radius ?? 0\n const padding = subject?.padding ?? 5\n\n const contentBbox = contentGroup.node().getBBox()\n const dy = Math.abs(subjectY - (contentBbox.y + contentBbox.height / 2))\n const dx = Math.abs(subjectX - (contentBbox.x + contentBbox.width / 2))\n const annotationPadding = 5\n const x2 = (dx < dy) && ((subjectY < contentBbox.y) || (subjectY > (contentBbox.y + contentBbox.height)))\n ? contentBbox.x + contentBbox.width / 2\n : (subjectX < contentBbox.x) ? contentBbox.x - annotationPadding : contentBbox.x + contentBbox.width + annotationPadding\n\n const y2 = (dx >= dy) || ((subjectY >= contentBbox.y) && (subjectY <= (contentBbox.y + contentBbox.height)))\n ? contentBbox.y + contentBbox.height / 2\n : (subjectY < contentBbox.y) ? contentBbox.y - annotationPadding : contentBbox.y + contentBbox.height + annotationPadding\n\n const angle = Math.atan2(y2 - subjectY, x2 - subjectX) * 180 / Math.PI\n const x1 = subjectX + Math.cos(angle * Math.PI / 180) * (subjectRadius + padding)\n const y1 = subjectY + Math.sin(angle * Math.PI / 180) * (subjectRadius + padding)\n\n subjectGroup.select('circle')\n .attr('visibility', subject ? null : 'hidden')\n .attr('cx', subjectX)\n .attr('cy', subjectY)\n .attr('r', subjectRadius)\n .style('stroke', subjectStrokeColor)\n .style('fill', subjectFillColor)\n .style('stroke-dasharray', subjectStrokeDasharray)\n\n subjectGroup.select('line')\n .attr('visibility', subject ? null : 'hidden')\n .attr('x1', x1)\n .attr('y1', y1)\n .attr('x2', x1)\n .attr('y2', y1)\n .attr('x2', x2)\n .attr('y2', y2)\n .style('stroke', connectorLineColor)\n .style('stroke-dasharray', connectorLineStrokeDasharray)\n }\n}\n"],"names":["s.annotation","s.annotationContent","s.annotationSubject","s","s.variables"],"mappings":";;;;;;;;;;;AAqBM,MAAO,WAAY,SAAQ,aAAoD,CAAA;AAUnF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QARC,IAAc,CAAA,cAAA,GAAG,wBAAsD,CAAA;AAC1E,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;QAI/D,IAAM,CAAA,MAAA,GAAG,EAAE,CAAA;AAIT,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KACnC;AAED,IAAA,OAAO,CAAE,cAAuB,EAAA;AAC9B,QAAA,KAAK,CAAC,OAAO,CA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AI,CAAC,YAAY,EAAE,OAAO,GAAG,IAAI,GAAG,QAAQ,CAAC;AAC7C,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,KAAK,CAAC,QAAQ,EAAE,kBAAkB,CAAC;AACnC,aAAA,KAAK,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,CAAA;KAC3D;;AAvHM,WAAS,CAAA,SAAA,GAAGC,KAAC,CAAA;AACb,WAAA,CAAA,YAAY,GAAGC,SAAW;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/annotations/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\n\n// Utils\nimport { isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { renderTextIntoFrame } from 'utils/text'\nimport { parseUnit } from 'utils/misc'\nimport { UNOVIS_TEXT_DEFAULT } from 'styles'\n\n// Local Types\nimport { AnnotationItem, AnnotationSubject } from './types'\n\n// Config\nimport { AnnotationsDefaultConfig, AnnotationsConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Annotations extends ComponentCore<unknown[], AnnotationsConfigInterface> {\n static selectors = s\n static cssVariables = s.variables\n protected _defaultConfig = AnnotationsDefaultConfig as AnnotationsConfigInterface\n public config: AnnotationsConfigInterface = this._defaultConfig\n\n g: Selection<SVGGElement, unknown, null, undefined>\n\n events = {}\n\n constructor (config?: AnnotationsConfigInterface) {\n super()\n if (config) this.setConfig(config)\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config } = this\n\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const annotations = this.g.selectAll<SVGGElement, AnnotationItem[]>(`.${s.annotation}`)\n .data(config.items, d => JSON.stringify(d))\n\n const annotationsEnter = annotations.enter().append('g')\n .attr('class', s.annotation)\n .style('opacity', 0)\n\n // Content\n annotationsEnter.append('g').attr('class', s.annotationContent)\n\n const annotationsMerged = annotationsEnter.merge(annotations)\n .attr('cursor', d => d?.cursor)\n .each((annotation, i, elements) => {\n if (annotation.content) {\n const content = typeof annotation.content === 'string' ? { ...UNOVIS_TEXT_DEFAULT, text: annotation.content } : annotation.content\n const x = parseUnit(annotation.x, this._width)\n const y = parseUnit(annotation.y, this._height)\n const width = parseUnit(annotation.width, this._width)\n const height = parseUnit(annotation.height, this._height)\n const options = { ...annotation, x, y, width, height }\n\n const contentGroupElement = select(elements[i]).select<SVGGElement>(`.${s.annotationContent}`)\n renderTextIntoFrame(contentGroupElement.node(), content, options)\n\n // Render debug bounding boxes showing the frame (x, y, width, height)\n contentGroupElement.selectAll(`.${s.debugBoundingBox}`).remove()\n if (config.renderTextBoundingBoxes) {\n const debugWidth = width ?? 100\n const debugHeight = height || 0.1\n contentGroupElement.append('rect')\n .attr('class', s.debugBoundingBox)\n .attr('x', x)\n .attr('y', y)\n .attr('width', debugWidth)\n .attr('height', debugHeight)\n }\n }\n\n if (annotation.subject) {\n requestAnimationFrame(() => this._renderSubject(elements[i], annotation.subject))\n } else {\n select(elements[i]).select(`.${s.annotationSubject}`).remove()\n }\n })\n\n smartTransition(annotationsMerged, duration)\n .style('opacity', 1)\n\n smartTransition(annotations.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n\n private _renderSubject (\n annotationGroupElement: SVGElement,\n subject: AnnotationSubject | undefined\n ): void {\n const annotationGroup = select(annotationGroupElement)\n const contentGroup = annotationGroup.select<SVGGElement>(`.${s.annotationContent}`)\n\n // Create subject group if it doesn't exist\n let subjectGroup = annotationGroup.select<SVGGElement>(`.${s.annotationSubject}`)\n if (subjectGroup.empty()) {\n subjectGroup = annotationGroup.append('g').attr('class', s.annotationSubject)\n subjectGroup.append('circle')\n subjectGroup.append('line')\n }\n\n const subjectX: number | null = parseUnit(typeof subject?.x === 'function' ? subject.x() : subject?.x, this._width) ?? null\n const subjectY: number | null = parseUnit(typeof subject?.y === 'function' ? subject.y() : subject?.y, this._height) ?? null\n\n const subjectStrokeColor: string | null = subject?.strokeColor ?? null\n const subjectFillColor: string | null = subject?.fillColor ?? null\n const subjectStrokeDasharray: string | null = subject?.strokeDasharray ?? null\n const connectorLineColor: string | null = subject?.connectorLineColor ?? null\n const connectorLineStrokeDasharray: string | null = subject?.connectorLineStrokeDasharray ?? null\n const subjectRadius: number | null = subject?.radius ?? 0\n const padding = subject?.padding ?? 5\n\n const contentBbox = contentGroup.node().getBBox()\n const dy = Math.abs(subjectY - (contentBbox.y + contentBbox.height / 2))\n const dx = Math.abs(subjectX - (contentBbox.x + contentBbox.width / 2))\n const annotationPadding = 5\n const x2 = (dx < dy) && ((subjectY < contentBbox.y) || (subjectY > (contentBbox.y + contentBbox.height)))\n ? contentBbox.x + contentBbox.width / 2\n : (subjectX < contentBbox.x) ? contentBbox.x - annotationPadding : contentBbox.x + contentBbox.width + annotationPadding\n\n const y2 = (dx >= dy) || ((subjectY >= contentBbox.y) && (subjectY <= (contentBbox.y + contentBbox.height)))\n ? contentBbox.y + contentBbox.height / 2\n : (subjectY < contentBbox.y) ? contentBbox.y - annotationPadding : contentBbox.y + contentBbox.height + annotationPadding\n\n const angle = Math.atan2(y2 - subjectY, x2 - subjectX) * 180 / Math.PI\n const x1 = subjectX + Math.cos(angle * Math.PI / 180) * (subjectRadius + padding)\n const y1 = subjectY + Math.sin(angle * Math.PI / 180) * (subjectRadius + padding)\n\n subjectGroup.select('circle')\n .attr('cx', subjectX)\n .attr('cy', subjectY)\n .attr('r', subjectRadius)\n .style('stroke', subjectStrokeColor)\n .style('fill', subjectFillColor)\n .style('stroke-dasharray', subjectStrokeDasharray)\n\n subjectGroup.select('line')\n .attr('x1', x1)\n .attr('y1', y1)\n .attr('x2', x1)\n .attr('y2', y1)\n .attr('x2', x2)\n .attr('y2', y2)\n .style('stroke', connectorLineColor)\n .style('stroke-dasharray', connectorLineStrokeDasharray)\n }\n}\n"],"names":["s.annotation","s.annotationContent","s.debugBoundingBox","s.annotationSubject","s","s.variables"],"mappings":";;;;;;;;;;;AAqBM,MAAO,WAAY,SAAQ,aAAoD,CAAA;AAUnF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QARC,IAAc,CAAA,cAAA,GAAG,wBAAsD,CAAA;AAC1E,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;QAI/D,IAAM,CAAA,MAAA,GAAG,EAAE,CAAA;AAIT,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KACnC;AAED,IAAA,OAAO,CAAE,cAAuB,EAAA;AAC9B,QAAA,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;AAC7B,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAA;AAE5E,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAgC,CAAI,CAAA,EAAAA,UAAY,EAAE,CAAC;AACpF,aAAA,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;QAE7C,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;AACrD,aAAA,IAAI,CAAC,OAAO,EAAEA,UAAY,CAAC;AAC3B,aAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;;AAGtB,QAAA,gBA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;AACxB,aAAA,KAAK,CAAC,QAAQ,EAAE,kBAAkB,CAAC;AACnC,aAAA,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC;AAC/B,aAAA,KAAK,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAA;AAEpD,QAAA,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC;AACxB,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AACd,aAAA,KAAK,CAAC,QAAQ,EAAE,kBAAkB,CAAC;AACnC,aAAA,KAAK,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,CAAA;KAC3D;;AArIM,WAAS,CAAA,SAAA,GAAGC,KAAC,CAAA;AACb,WAAA,CAAA,YAAY,GAAGC,SAAW;;;;"}
@@ -7,6 +7,7 @@ export declare const variables: {
7
7
  annotationsSubjectStrokeColor: "--vis-annotations-subject-stroke-color";
8
8
  annotationsSubjectFillColor: "--vis-annotations-subject-fill-color";
9
9
  annotationsSubjectStrokeDasharray: "--vis-annotations-subject-stroke-dasharray";
10
+ annotationsDebugBoundingBoxStrokeColor: "--vis-annotations-debug-bounding-box-stroke-color";
10
11
  darkAnnotationsTextColor: "--vis-dark-annotations-text-color";
11
12
  darkAnnotationsConnectorStrokeColor: "--vis-dark-annotations-connector-stroke-color";
12
13
  darkAnnotationsSubjectStrokeColor: "--vis-dark-annotations-subject-stroke-color";
@@ -14,3 +15,4 @@ export declare const variables: {
14
15
  export declare const annotation: string;
15
16
  export declare const annotationSubject: string;
16
17
  export declare const annotationContent: string;
18
+ export declare const debugBoundingBox: string;
@@ -9,6 +9,7 @@ const cssVarDefaults = {
9
9
  '--vis-annotations-subject-stroke-color': '#444',
10
10
  '--vis-annotations-subject-fill-color': 'none',
11
11
  '--vis-annotations-subject-stroke-dasharray': 'none',
12
+ '--vis-annotations-debug-bounding-box-stroke-color': '#f00',
12
13
  '--vis-dark-annotations-text-color': '#e8e9ef',
13
14
  '--vis-dark-annotations-connector-stroke-color': '#fff',
14
15
  '--vis-dark-annotations-subject-stroke-color': '#fff',
@@ -41,7 +42,13 @@ const annotationContent = css `
41
42
  > text {
42
43
  fill: var(--vis-annotations-text-color);
43
44
  }
45
+ `;
46
+ const debugBoundingBox = css `
47
+ label: debugBoundingBox;
48
+ fill: none;
49
+ stroke: var(--vis-annotations-debug-bounding-box-stroke-color);
50
+ stroke-width: 1;
44
51
  `;
45
52
 
46
- export { annotation, annotationContent, annotationSubject, root, variables };
53
+ export { annotation, annotationContent, annotationSubject, debugBoundingBox, root, variables };
47
54
  //# sourceMappingURL=style.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sources":["../../../src/components/annotations/style.ts"],"sourcesContent":["import { css } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\nconst cssVarDefaults = {\n '--vis-annotations-text-color': '#282C34',\n\n '--vis-annotations-connector-stroke-color': '#444',\n '--vis-annotations-connector-stroke-width': '1px',\n '--vis-annotations-connector-stroke-dasharray': 'none',\n\n '--vis-annotations-subject-stroke-color': '#444',\n '--vis-annotations-subject-fill-color': 'none',\n '--vis-annotations-subject-stroke-dasharray': 'none',\n\n '--vis-dark-annotations-text-color': '#e8e9ef',\n '--vis-dark-annotations-connector-stroke-color': '#fff',\n '--vis-dark-annotations-subject-stroke-color': '#fff',\n}\n\nexport const root = css`\n label: annotations-component;\n`\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const annotation = css`\n label: annotation;\n`\n\nexport const annotationSubject = css`\n label: annotationSubject;\n\n line {\n stroke: var(${variables.annotationsConnectorStrokeColor});\n stroke-width: var(${variables.annotationsConnectorStrokeWidth});\n stroke-dasharray: var(${variables.annotationsConnectorStrokeDasharray});\n }\n\n circle {\n stroke: var(${variables.annotationsSubjectStrokeColor});\n fill: var(${variables.annotationsSubjectFillColor});\n stroke-dasharray: var(${variables.annotationsSubjectStrokeDasharray});\n }\n`\n\nexport const annotationContent = css`\n label: annotationContent;\n > text {\n fill: var(--vis-annotations-text-color);\n }\n`\n"],"names":[],"mappings":";;;AAKA,MAAM,cAAc,GAAG;AACrB,IAAA,8BAA8B,EAAE,SAAS;AAEzC,IAAA,0CAA0C,EAAE,MAAM;AAClD,IAAA,0CAA0C,EAAE,KAAK;AACjD,IAAA,8CAA8C,EAAE,MAAM;AAEtD,IAAA,wCAAwC,EAAE,MAAM;AAChD,IAAA,sCAAsC,EAAE,MAAM;AAC9C,IAAA,4CAA4C,EAAE,MAAM;AAEpD,IAAA,mCAAmC,EAAE,SAAS;AAC9C,IAAA,+CAA+C,EAAE,MAAM;AACvD,IAAA,6CAA6C,EAAE,MAAM;CACtD,CAAA;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;MACY,SAAS,GAAG,cAAc,CAAC,cAAc,EAAC;AACvD,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;AAEvC,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;EAE5B;AAEM,MAAM,iBAAiB,GAAG,GAAG,CAAA,CAAA;;;;AAIlB,gBAAA,EAAA,SAAS,CAAC,+BAA+B,CAAA;AACnC,sBAAA,EAAA,SAAS,CAAC,+BAA+B,CAAA;AACrC,0BAAA,EAAA,SAAS,CAAC,mCAAmC,CAAA;;;;AAIvD,gBAAA,EAAA,SAAS,CAAC,6BAA6B,CAAA;AACzC,cAAA,EAAA,SAAS,CAAC,2BAA2B,CAAA;AACzB,0BAAA,EAAA,SAAS,CAAC,iCAAiC,CAAA;;EAEtE;AAEM,MAAM,iBAAiB,GAAG,GAAG,CAAA,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"style.js","sources":["../../../src/components/annotations/style.ts"],"sourcesContent":["import { css } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\nconst cssVarDefaults = {\n '--vis-annotations-text-color': '#282C34',\n\n '--vis-annotations-connector-stroke-color': '#444',\n '--vis-annotations-connector-stroke-width': '1px',\n '--vis-annotations-connector-stroke-dasharray': 'none',\n\n '--vis-annotations-subject-stroke-color': '#444',\n '--vis-annotations-subject-fill-color': 'none',\n '--vis-annotations-subject-stroke-dasharray': 'none',\n\n '--vis-annotations-debug-bounding-box-stroke-color': '#f00',\n\n '--vis-dark-annotations-text-color': '#e8e9ef',\n '--vis-dark-annotations-connector-stroke-color': '#fff',\n '--vis-dark-annotations-subject-stroke-color': '#fff',\n}\n\nexport const root = css`\n label: annotations-component;\n`\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const annotation = css`\n label: annotation;\n`\n\nexport const annotationSubject = css`\n label: annotationSubject;\n\n line {\n stroke: var(${variables.annotationsConnectorStrokeColor});\n stroke-width: var(${variables.annotationsConnectorStrokeWidth});\n stroke-dasharray: var(${variables.annotationsConnectorStrokeDasharray});\n }\n\n circle {\n stroke: var(${variables.annotationsSubjectStrokeColor});\n fill: var(${variables.annotationsSubjectFillColor});\n stroke-dasharray: var(${variables.annotationsSubjectStrokeDasharray});\n }\n`\n\nexport const annotationContent = css`\n label: annotationContent;\n > text {\n fill: var(--vis-annotations-text-color);\n }\n`\n\nexport const debugBoundingBox = css`\n label: debugBoundingBox;\n fill: none;\n stroke: var(--vis-annotations-debug-bounding-box-stroke-color);\n stroke-width: 1;\n`\n"],"names":[],"mappings":";;;AAKA,MAAM,cAAc,GAAG;AACrB,IAAA,8BAA8B,EAAE,SAAS;AAEzC,IAAA,0CAA0C,EAAE,MAAM;AAClD,IAAA,0CAA0C,EAAE,KAAK;AACjD,IAAA,8CAA8C,EAAE,MAAM;AAEtD,IAAA,wCAAwC,EAAE,MAAM;AAChD,IAAA,sCAAsC,EAAE,MAAM;AAC9C,IAAA,4CAA4C,EAAE,MAAM;AAEpD,IAAA,mDAAmD,EAAE,MAAM;AAE3D,IAAA,mCAAmC,EAAE,SAAS;AAC9C,IAAA,+CAA+C,EAAE,MAAM;AACvD,IAAA,6CAA6C,EAAE,MAAM;CACtD,CAAA;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;MACY,SAAS,GAAG,cAAc,CAAC,cAAc,EAAC;AACvD,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;AAEvC,MAAM,UAAU,GAAG,GAAG,CAAA,CAAA;;EAE5B;AAEM,MAAM,iBAAiB,GAAG,GAAG,CAAA,CAAA;;;;AAIlB,gBAAA,EAAA,SAAS,CAAC,+BAA+B,CAAA;AACnC,sBAAA,EAAA,SAAS,CAAC,+BAA+B,CAAA;AACrC,0BAAA,EAAA,SAAS,CAAC,mCAAmC,CAAA;;;;AAIvD,gBAAA,EAAA,SAAS,CAAC,6BAA6B,CAAA;AACzC,cAAA,EAAA,SAAS,CAAC,2BAA2B,CAAA;AACzB,0BAAA,EAAA,SAAS,CAAC,iCAAiC,CAAA;;EAEtE;AAEM,MAAM,iBAAiB,GAAG,GAAG,CAAA,CAAA;;;;;EAKnC;AAEM,MAAM,gBAAgB,GAAG,GAAG,CAAA,CAAA;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { XYComponentConfigInterface } from "../../core/xy-component/config";
2
2
  import { CurveType } from "../../types/curve";
3
- import { ColorAccessor, NumericAccessor, StringAccessor } from "../../types/accessor";
3
+ import { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from "../../types/accessor";
4
4
  export interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {
5
5
  /** Area color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */
6
6
  color?: ColorAccessor<Datum[]>;
@@ -12,6 +12,14 @@ export interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<D
12
12
  opacity?: NumericAccessor<Datum[]>;
13
13
  /** Optional area cursor. String or accessor function. Default: `null` */
14
14
  cursor?: StringAccessor<Datum[]>;
15
+ /** Display a line on the top of the area. Default: `false` */
16
+ line?: boolean;
17
+ /** Line color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */
18
+ lineColor?: ColorAccessor<Datum[]>;
19
+ /** Line width in pixels. Default: `2` */
20
+ lineWidth?: number;
21
+ /** Line dash array, see SVG's stroke-dasharray. Default: `undefined` */
22
+ lineDashArray?: GenericAccessor<number[], Datum[]>;
15
23
  /** If an area is smaller than 1px, extend it to have 1px height. Default: `false`
16
24
  * @deprecated Use minHeight instead
17
25
  */
@@ -1,7 +1,7 @@
1
1
  import { XYComponentDefaultConfig } from '../../core/xy-component/config.js';
2
2
  import { CurveType } from '../../types/curve.js';
3
3
 
4
- const AreaDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { color: undefined, curveType: CurveType.MonotoneX, baseline: () => 0, opacity: 1, cursor: null, minHeight1Px: false, minHeight: undefined, stackMinHeight: false });
4
+ const AreaDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { color: undefined, curveType: CurveType.MonotoneX, baseline: () => 0, opacity: 1, cursor: null, line: false, lineColor: undefined, lineWidth: 2, lineDashArray: undefined, minHeight1Px: false, minHeight: undefined, stackMinHeight: false });
5
5
 
6
6
  export { AreaDefaultConfig };
7
7
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/area/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { CurveType } from 'types/curve'\nimport { ColorAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\n\nexport interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /** Area color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */\n color?: ColorAccessor<Datum[]>;\n /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */\n curveType?: CurveType | string;\n /** Baseline value or accessor function. Default: `undefined` */\n baseline?: NumericAccessor<Datum>;\n /** Opacity value or accessor function. Default: `1` */\n opacity?: NumericAccessor<Datum[]>;\n /** Optional area cursor. String or accessor function. Default: `null` */\n cursor?: StringAccessor<Datum[]>;\n /** If an area is smaller than 1px, extend it to have 1px height. Default: `false`\n * @deprecated Use minHeight instead\n */\n minHeight1Px?: boolean;\n /** Minimum height of the area, use carefully.\n * This setting is useful when some of the area values are zeros or very small so visually they become\n * practically invisible, but you want to show that the data behind them exists and they're not just empty segments.\n * Default: `undefined` */\n minHeight?: number;\n /** Whether to stack min height areas or not. Default: `undefined` */\n stackMinHeight?: boolean;\n}\n\nexport const AreaDefaultConfig: AreaConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n color: undefined,\n curveType: CurveType.MonotoneX,\n baseline: (): number => 0,\n opacity: 1,\n cursor: null,\n minHeight1Px: false,\n minHeight: undefined,\n stackMinHeight: false,\n}\n"],"names":[],"mappings":";;;AA8Ba,MAAA,iBAAiB,mCACzB,wBAAwB,CAAA,EAAA,EAC3B,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,QAAQ,EAAE,MAAc,CAAC,EACzB,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,IAAI,EACZ,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,KAAK;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/area/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { CurveType } from 'types/curve'\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\n\nexport interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /** Area color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */\n color?: ColorAccessor<Datum[]>;\n /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */\n curveType?: CurveType | string;\n /** Baseline value or accessor function. Default: `undefined` */\n baseline?: NumericAccessor<Datum>;\n /** Opacity value or accessor function. Default: `1` */\n opacity?: NumericAccessor<Datum[]>;\n /** Optional area cursor. String or accessor function. Default: `null` */\n cursor?: StringAccessor<Datum[]>;\n /** Display a line on the top of the area. Default: `false` */\n line?: boolean;\n /** Line color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */\n lineColor?: ColorAccessor<Datum[]>;\n /** Line width in pixels. Default: `2` */\n lineWidth?: number;\n /** Line dash array, see SVG's stroke-dasharray. Default: `undefined` */\n lineDashArray?: GenericAccessor<number[], Datum[]>;\n /** If an area is smaller than 1px, extend it to have 1px height. Default: `false`\n * @deprecated Use minHeight instead\n */\n minHeight1Px?: boolean;\n /** Minimum height of the area, use carefully.\n * This setting is useful when some of the area values are zeros or very small so visually they become\n * practically invisible, but you want to show that the data behind them exists and they're not just empty segments.\n * Default: `undefined` */\n minHeight?: number;\n /** Whether to stack min height areas or not. Default: `undefined` */\n stackMinHeight?: boolean;\n}\n\nexport const AreaDefaultConfig: AreaConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n color: undefined,\n curveType: CurveType.MonotoneX,\n baseline: (): number => 0,\n opacity: 1,\n cursor: null,\n line: false,\n lineColor: undefined,\n lineWidth: 2,\n lineDashArray: undefined,\n minHeight1Px: false,\n minHeight: undefined,\n stackMinHeight: false,\n}\n"],"names":[],"mappings":";;;AAsCa,MAAA,iBAAiB,GACzB,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,wBAAwB,CAC3B,EAAA,EAAA,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,QAAQ,EAAE,MAAc,CAAC,EACzB,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,IAAI,EACZ,IAAI,EAAE,KAAK,EACX,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,CAAC,EACZ,aAAa,EAAE,SAAS,EACxB,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,KAAK,EAAA;;;;"}
@@ -1,4 +1,6 @@
1
1
  import { XYComponentCore } from "../../core/xy-component";
2
+ import { Spacing } from "../../types/spacing";
3
+ import { AreaDatum } from './types';
2
4
  import { AreaConfigInterface } from './config';
3
5
  import * as s from './style';
4
6
  export declare class Area<Datum> extends XYComponentCore<Datum, AreaConfigInterface<Datum>> {
@@ -7,12 +9,16 @@ export declare class Area<Datum> extends XYComponentCore<Datum, AreaConfigInterf
7
9
  config: AreaConfigInterface<Datum>;
8
10
  stacked: boolean;
9
11
  private _areaGen;
12
+ private _lineGen;
10
13
  private _prevNegative;
11
14
  events: {
12
15
  [x: string]: {};
13
16
  };
14
17
  constructor(config?: AreaConfigInterface<Datum>);
18
+ get bleed(): Spacing;
15
19
  _render(customDuration?: number): void;
20
+ _renderLines(duration: number, stackedData: AreaDatum[][]): void;
16
21
  getYDataExtent(scaleByVisibleData: boolean): number[];
17
22
  _emptyPath(): string;
23
+ _emptyLinePath(): string;
18
24
  }
@@ -1,14 +1,15 @@
1
1
  import { select } from 'd3-selection';
2
- import { area } from 'd3-shape';
2
+ import { area, line } from 'd3-shape';
3
3
  import { interpolatePath } from 'd3-interpolate-path';
4
4
  import { XYComponentCore } from '../../core/xy-component/index.js';
5
- import { isNumber, isArray, getNumber, getStackedData, getString, filterDataByRange, getStackedExtent } from '../../utils/data.js';
5
+ import { isNumber, isArray, getNumber, getStackedData, getString, getValue, filterDataByRange, getStackedExtent } from '../../utils/data.js';
6
6
  import { smartTransition } from '../../utils/d3.js';
7
7
  import { getColor } from '../../utils/color.js';
8
8
  import { Curve } from '../../types/curve.js';
9
+ import { Direction } from '../../types/direction.js';
9
10
  import { AreaDefaultConfig } from './config.js';
10
11
  import * as style from './style.js';
11
- import { area as area$1 } from './style.js';
12
+ import { area as area$1, areaLinePath } from './style.js';
12
13
 
13
14
  class Area extends XYComponentCore {
14
15
  constructor(config) {
@@ -24,6 +25,24 @@ class Area extends XYComponentCore {
24
25
  // Determine if the provided chart should be stacked
25
26
  this.stacked = Array.isArray(this.config.y);
26
27
  }
28
+ get bleed() {
29
+ const { config: { line, lineWidth } } = this;
30
+ if (!line)
31
+ return { top: 0, bottom: 0, left: 0, right: 0 };
32
+ const yDomain = this.yScale.domain();
33
+ const yDirection = this.yScale.range()[0] > this.yScale.range()[1]
34
+ ? Direction.North
35
+ : Direction.South;
36
+ const isYDirectionSouth = yDirection === Direction.South;
37
+ const isLineThick = lineWidth > 3;
38
+ const isLineVeryThick = lineWidth >= 10;
39
+ return {
40
+ top: !isLineVeryThick && ((!isYDirectionSouth && (yDomain[1] === 0)) || (isYDirectionSouth && (yDomain[0] === 0))) ? 0 : lineWidth / 2,
41
+ bottom: !isLineVeryThick && ((!isYDirectionSouth && (yDomain[0] === 0)) || (isYDirectionSouth && (yDomain[1] === 0))) ? 0 : lineWidth / 2,
42
+ left: isLineThick ? lineWidth / 2 : 0,
43
+ right: isLineThick ? lineWidth / 2 : 0,
44
+ };
45
+ }
27
46
  _render(customDuration) {
28
47
  super._render(customDuration);
29
48
  const { config, datamodel: { data } } = this;
@@ -70,7 +89,7 @@ class Area extends XYComponentCore {
70
89
  // We reverse the data in order to have the first areas to be displayed on top
71
90
  // for better visibility when they're close to zero
72
91
  const areaMaxIdx = stackedData.length - 1;
73
- const stackedDataReversed = stackedData.reverse();
92
+ const stackedDataReversed = [...stackedData].reverse();
74
93
  const areas = this.g
75
94
  .selectAll(`.${area$1}`)
76
95
  .data(stackedDataReversed);
@@ -100,6 +119,52 @@ class Area extends XYComponentCore {
100
119
  smartTransition(areas.exit(), duration)
101
120
  .style('opacity', 0)
102
121
  .remove();
122
+ if (config.line) {
123
+ this._renderLines(duration, stackedData);
124
+ }
125
+ }
126
+ _renderLines(duration, stackedData) {
127
+ var _a;
128
+ const { config, datamodel: { data } } = this;
129
+ const areaMaxIdx = stackedData.length - 1;
130
+ const stackedDataReversed = [...stackedData].reverse();
131
+ const colorAccessor = (_a = config.lineColor) !== null && _a !== void 0 ? _a : config.color;
132
+ const lines = this.g
133
+ .selectAll(`.${areaLinePath}`)
134
+ .data(stackedDataReversed);
135
+ const areas = this.g.selectAll(`.${area$1}`).nodes();
136
+ const linesEnter = lines.enter().insert('path', (d, i) => areas[i + 1])
137
+ .attr('class', areaLinePath)
138
+ .attr('stroke', (d, i) => getColor(data, colorAccessor, areaMaxIdx - i))
139
+ .attr('stroke-width', config.lineWidth)
140
+ .attr('stroke-opacity', 0);
141
+ const linesMerged = smartTransition(linesEnter.merge(lines), duration)
142
+ .attr('stroke', (d, i) => getColor(data, colorAccessor, areaMaxIdx - i))
143
+ .attr('stroke-width', config.lineWidth)
144
+ .attr('stroke-opacity', 1)
145
+ .attr('cursor', (d, i) => getString(data, config.cursor, areaMaxIdx - i))
146
+ .style('stroke-dasharray', (d, i) => { var _a, _b; return (_b = (_a = getValue(data, config.lineDashArray, i)) === null || _a === void 0 ? void 0 : _a.join(' ')) !== null && _b !== void 0 ? _b : null; });
147
+ const curveGen = Curve[config.curveType];
148
+ this._lineGen = line()
149
+ .x(d => d.x)
150
+ .y(d => d.y1)
151
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
152
+ // @ts-ignore
153
+ .curve(curveGen);
154
+ if (duration) {
155
+ const lineTransition = linesMerged;
156
+ lineTransition.attrTween('d', (d, i, el) => {
157
+ const previous = select(el[i]).attr('d') || this._emptyLinePath();
158
+ const next = this._lineGen(d) || this._emptyLinePath();
159
+ return interpolatePath(previous, next);
160
+ });
161
+ }
162
+ else {
163
+ linesMerged.attr('d', d => this._lineGen(d) || this._emptyLinePath());
164
+ }
165
+ smartTransition(lines.exit(), duration)
166
+ .style('opacity', 0)
167
+ .remove();
103
168
  }
104
169
  getYDataExtent(scaleByVisibleData) {
105
170
  const { config, datamodel } = this;
@@ -118,6 +183,11 @@ class Area extends XYComponentCore {
118
183
  { y0, y1, x: xRange[1] },
119
184
  ]);
120
185
  }
186
+ _emptyLinePath() {
187
+ const xRange = this.xScale.range();
188
+ const yRange = this.yScale.range();
189
+ return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`;
190
+ }
121
191
  }
122
192
  Area.selectors = style;
123
193
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/area/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { area, Area as AreaInterface } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, isArray, isNumber, getStackedExtent, getStackedData, filterDataByRange } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Curve, CurveType } from 'types/curve'\nimport { NumericAccessor } from 'types/accessor'\n\n// Local Types\nimport { AreaDatum } from './types'\n\n// Config\nimport { AreaDefaultConfig, AreaConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Area<Datum> extends XYComponentCore<Datum, AreaConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = AreaDefaultConfig as AreaConfigInterface<Datum>\n public config: AreaConfigInterface<Datum> = this._defaultConfig\n public stacked = true\n private _areaGen: AreaInterface<AreaDatum>\n private _prevNegative: boolean[] | undefined // To help guessing the stack direction when an accessor was set to null or 0\n\n events = {\n [Area.selectors.area]: {},\n }\n\n constructor (config?: AreaConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n // Determine if the provided chart should be stacked\n this.stacked = Array.isArray(this.config.y)\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const curveGen = Curve[config.curveType as CurveType]\n this._areaGen = area<AreaDatum>()\n .x(d => d.x)\n .y0(d => d.y0)\n .y1(d => d.y1)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n .curve(curveGen)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const areaDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n\n const stacked = getStackedData(data, config.baseline, yAccessors, this._prevNegative)\n this._prevNegative = stacked.map(s => !!s.isMostlyNegative)\n const minHeightCumulativeArray: number[] = []\n const stackedData: AreaDatum[][] = stacked.map(\n arr => arr.map(\n (d, j) => {\n const x = areaDataX[j]\n const y0 = this.yScale(d[0])\n const y1 = this.yScale(d[1])\n const isNegativeArea = y1 > y0\n\n // Only apply cumulative adjustment if `config.stackMinHeight` is true\n const cumulative = config.stackMinHeight ? (minHeightCumulativeArray[j] || 0) : 0\n const adjustedY0 = isNegativeArea ? y0 + cumulative : y0 - cumulative\n const adjustedY1 = isNegativeArea ? y1 + cumulative : y1 - cumulative\n\n // Calculate height adjustment if needed\n let heightAdjustment = 0\n if ((config.minHeight || config.minHeight1Px) &&\n Math.abs(adjustedY1 - adjustedY0) < (config.minHeight ?? 1)) {\n heightAdjustment = (config.minHeight ?? 1) - Math.abs(adjustedY1 - adjustedY0)\n\n // Only update cumulative array if we're stacking min heights\n if (config.stackMinHeight) {\n minHeightCumulativeArray[j] = cumulative + heightAdjustment\n }\n }\n\n return {\n x,\n y0: adjustedY0,\n y1: isNegativeArea ? adjustedY1 + heightAdjustment : adjustedY1 - heightAdjustment,\n }\n }\n )\n )\n\n // We reverse the data in order to have the first areas to be displayed on top\n // for better visibility when they're close to zero\n const areaMaxIdx = stackedData.length - 1\n const stackedDataReversed = stackedData.reverse()\n const areas = this.g\n .selectAll<SVGPathElement, AreaDatum>(`.${s.area}`)\n .data(stackedDataReversed)\n\n const areasEnter = areas.enter().append('path')\n .attr('class', s.area)\n .attr('d', d => this._areaGen(d) || this._emptyPath())\n .style('opacity', 0)\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n\n const areasMerged = smartTransition(areasEnter.merge(areas), duration)\n .style('opacity', (d, i) => {\n const isDefined = d.some(p => (p.y0 - p.y1) !== 0)\n return isDefined ? getNumber(data, config.opacity, areaMaxIdx - i) : 0\n })\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n .style('cursor', (d, i) => getString(data, config.cursor, areaMaxIdx - i))\n\n if (duration) {\n const transition = areasMerged as Transition<SVGPathElement, AreaDatum[], SVGGElement, AreaDatum[]>\n transition.attrTween('d', (d, i, el) => {\n const previous = select(el[i]).attr('d')\n const next = this._areaGen(d) || this._emptyPath()\n return interpolatePath(previous, next)\n })\n } else {\n areasMerged.attr('d', d => this._areaGen(d) || this._emptyPath())\n }\n\n smartTransition(areas.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n getYDataExtent (scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n\n const xDomain = this.xScale.domain() as [number, number]\n const data = scaleByVisibleData ? filterDataByRange(datamodel.data, xDomain, config.x, true) : datamodel.data\n return getStackedExtent(data, config.baseline, ...yAccessors)\n }\n\n _emptyPath (): string {\n const xRange = this.xScale.range()\n const yDomain = this.yScale.domain() as number[]\n\n const y0 = this.yScale((yDomain[0] + yDomain[1]) / 2)\n const y1 = y0\n\n return this._areaGen([\n { y0, y1, x: xRange[0] },\n { y0, y1, x: xRange[1] },\n ])\n }\n}\n"],"names":["s.area","s"],"mappings":";;;;;;;;;;;;AA0BM,MAAO,IAAY,SAAQ,eAAkD,CAAA;AAYjF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QAXC,IAAc,CAAA,cAAA,GAAG,iBAA+C,CAAA;AACnE,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;QACxD,IAAO,CAAA,OAAA,GAAG,IAAI,CAAA;AAIrB,QAAA,I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,MAAM,CAAC,CAAC,CAAC,EAAE;AACzB,SAAA,CAAC,CAAA;KACH;;AAnIM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/area/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { area, Area as AreaInterface, line, Line as LineInterface } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, isArray, isNumber, getStackedExtent, getStackedData, filterDataByRange, getValue } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Curve, CurveType } from 'types/curve'\nimport { NumericAccessor } from 'types/accessor'\nimport { Spacing } from 'types/spacing'\nimport { Direction } from 'types/direction'\n\n// Local Types\nimport { AreaDatum } from './types'\n\n// Config\nimport { AreaDefaultConfig, AreaConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Area<Datum> extends XYComponentCore<Datum, AreaConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = AreaDefaultConfig as AreaConfigInterface<Datum>\n public config: AreaConfigInterface<Datum> = this._defaultConfig\n public stacked = true\n private _areaGen: AreaInterface<AreaDatum>\n private _lineGen: LineInterface<AreaDatum>\n private _prevNegative: boolean[] | undefined // To help guessing the stack direction when an accessor was set to null or 0\n\n events = {\n [Area.selectors.area]: {},\n }\n\n constructor (config?: AreaConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n // Determine if the provided chart should be stacked\n this.stacked = Array.isArray(this.config.y)\n }\n\n get bleed (): Spacing {\n const { config: { line, lineWidth } } = this\n if (!line) return { top: 0, bottom: 0, left: 0, right: 0 }\n\n const yDomain = this.yScale.domain() as [number, number]\n const yDirection = this.yScale.range()[0] > this.yScale.range()[1]\n ? Direction.North\n : Direction.South\n const isYDirectionSouth = yDirection === Direction.South\n\n const isLineThick = lineWidth > 3\n const isLineVeryThick = lineWidth >= 10\n return {\n top: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[1] === 0)) || (isYDirectionSouth && (yDomain[0] === 0))\n ) ? 0 : lineWidth / 2,\n bottom: !isLineVeryThick && (\n (!isYDirectionSouth && (yDomain[0] === 0)) || (isYDirectionSouth && (yDomain[1] === 0))\n ) ? 0 : lineWidth / 2,\n left: isLineThick ? lineWidth / 2 : 0,\n right: isLineThick ? lineWidth / 2 : 0,\n }\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const curveGen = Curve[config.curveType as CurveType]\n this._areaGen = area<AreaDatum>()\n .x(d => d.x)\n .y0(d => d.y0)\n .y1(d => d.y1)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n .curve(curveGen)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const areaDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n\n const stacked = getStackedData(data, config.baseline, yAccessors, this._prevNegative)\n this._prevNegative = stacked.map(s => !!s.isMostlyNegative)\n const minHeightCumulativeArray: number[] = []\n const stackedData: AreaDatum[][] = stacked.map(\n arr => arr.map(\n (d, j) => {\n const x = areaDataX[j]\n const y0 = this.yScale(d[0])\n const y1 = this.yScale(d[1])\n const isNegativeArea = y1 > y0\n\n // Only apply cumulative adjustment if `config.stackMinHeight` is true\n const cumulative = config.stackMinHeight ? (minHeightCumulativeArray[j] || 0) : 0\n const adjustedY0 = isNegativeArea ? y0 + cumulative : y0 - cumulative\n const adjustedY1 = isNegativeArea ? y1 + cumulative : y1 - cumulative\n\n // Calculate height adjustment if needed\n let heightAdjustment = 0\n if ((config.minHeight || config.minHeight1Px) &&\n Math.abs(adjustedY1 - adjustedY0) < (config.minHeight ?? 1)) {\n heightAdjustment = (config.minHeight ?? 1) - Math.abs(adjustedY1 - adjustedY0)\n\n // Only update cumulative array if we're stacking min heights\n if (config.stackMinHeight) {\n minHeightCumulativeArray[j] = cumulative + heightAdjustment\n }\n }\n\n return {\n x,\n y0: adjustedY0,\n y1: isNegativeArea ? adjustedY1 + heightAdjustment : adjustedY1 - heightAdjustment,\n }\n }\n )\n )\n\n // We reverse the data in order to have the first areas to be displayed on top\n // for better visibility when they're close to zero\n const areaMaxIdx = stackedData.length - 1\n const stackedDataReversed = [...stackedData].reverse()\n const areas = this.g\n .selectAll<SVGPathElement, AreaDatum>(`.${s.area}`)\n .data(stackedDataReversed)\n\n const areasEnter = areas.enter().append('path')\n .attr('class', s.area)\n .attr('d', d => this._areaGen(d) || this._emptyPath())\n .style('opacity', 0)\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n\n const areasMerged = smartTransition(areasEnter.merge(areas), duration)\n .style('opacity', (d, i) => {\n const isDefined = d.some(p => (p.y0 - p.y1) !== 0)\n return isDefined ? getNumber(data, config.opacity, areaMaxIdx - i) : 0\n })\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n .style('cursor', (d, i) => getString(data, config.cursor, areaMaxIdx - i))\n\n if (duration) {\n const transition = areasMerged as Transition<SVGPathElement, AreaDatum[], SVGGElement, AreaDatum[]>\n transition.attrTween('d', (d, i, el) => {\n const previous = select(el[i]).attr('d')\n const next = this._areaGen(d) || this._emptyPath()\n return interpolatePath(previous, next)\n })\n } else {\n areasMerged.attr('d', d => this._areaGen(d) || this._emptyPath())\n }\n\n smartTransition(areas.exit(), duration)\n .style('opacity', 0)\n .remove()\n\n if (config.line) {\n this._renderLines(duration, stackedData)\n }\n }\n\n _renderLines (duration: number, stackedData: AreaDatum[][]): void {\n const { config, datamodel: { data } } = this\n const areaMaxIdx = stackedData.length - 1\n const stackedDataReversed = [...stackedData].reverse()\n const colorAccessor = config.lineColor ?? config.color\n const lines = this.g\n .selectAll<SVGPathElement, AreaDatum[]>(`.${s.areaLinePath}`)\n .data(stackedDataReversed)\n\n const areas = this.g.selectAll(`.${s.area}`).nodes()\n const linesEnter = lines.enter().insert('path', (d, i) => areas[i + 1])\n .attr('class', s.areaLinePath)\n .attr('stroke', (d, i) => getColor(data, colorAccessor, areaMaxIdx - i))\n .attr('stroke-width', config.lineWidth)\n .attr('stroke-opacity', 0)\n\n const linesMerged = smartTransition(linesEnter.merge(lines), duration)\n .attr('stroke', (d, i) => getColor(data, colorAccessor, areaMaxIdx - i))\n .attr('stroke-width', config.lineWidth)\n .attr('stroke-opacity', 1)\n .attr('cursor', (d, i) => getString(data, config.cursor, areaMaxIdx - i))\n .style('stroke-dasharray', (d, i) => getValue<Datum[], number[]>(data, config.lineDashArray, i)?.join(' ') ?? null)\n\n const curveGen = Curve[config.curveType as CurveType]\n this._lineGen = line<AreaDatum>()\n .x(d => d.x)\n .y(d => d.y1)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n .curve(curveGen)\n\n if (duration) {\n const lineTransition = linesMerged as Transition<SVGPathElement, AreaDatum[], SVGGElement, AreaDatum[]>\n lineTransition.attrTween('d', (d, i, el) => {\n const previous = select(el[i]).attr('d') || this._emptyLinePath()\n const next = this._lineGen(d) || this._emptyLinePath()\n return interpolatePath(previous, next)\n })\n } else {\n linesMerged.attr('d', d => this._lineGen(d) || this._emptyLinePath())\n }\n\n smartTransition(lines.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n getYDataExtent (scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n\n const xDomain = this.xScale.domain() as [number, number]\n const data = scaleByVisibleData ? filterDataByRange(datamodel.data, xDomain, config.x, true) : datamodel.data\n return getStackedExtent(data, config.baseline, ...yAccessors)\n }\n\n _emptyPath (): string {\n const xRange = this.xScale.range()\n const yDomain = this.yScale.domain() as number[]\n\n const y0 = this.yScale((yDomain[0] + yDomain[1]) / 2)\n const y1 = y0\n\n return this._areaGen([\n { y0, y1, x: xRange[0] },\n { y0, y1, x: xRange[1] },\n ])\n }\n\n _emptyLinePath (): string {\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n return `M${xRange[0]},${yRange[0]} L${xRange[1]},${yRange[0]}`\n }\n}\n"],"names":["s.area","s.areaLinePath","s"],"mappings":";;;;;;;;;;;;;AA4BM,MAAO,IAAY,SAAQ,eAAkD,CAAA;AAajF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QAZC,IAAc,CAAA,cAAA,GAAG,iBAA+C,CAAA;AACnE,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;QACxD,IAAO,CAAA,OAAA,GAAG,IAAI,CAAA;AAKrB,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE;SAC1B,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;;AAGlC,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;KAC5C;AAED,IAAA,IAAI,KAAK,GAAA;QACP,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,CAAA;AAC5C,QAAA,IAAI,CAAC,IAAI;AAAE,YAAA,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;QAE1D,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAsB,CAAA;QACxD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAA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CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE;YACxB,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE;AACzB,SAAA,CAAC,CAAA;KACH;IAED,cAAc,GAAA;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAClC,OAAO,CAAA,CAAA,EAAI,MAAM,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAA,CAAA,EAAI,MAAM,CAAC,CAAC,CAAC,CAAA,CAAE,CAAA;KAC/D;;AArNM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
@@ -1,3 +1,4 @@
1
1
  export declare const root: string;
2
2
  export declare const globalStyles: void;
3
3
  export declare const area: string;
4
+ export declare const areaLinePath: string;
@@ -36,7 +36,13 @@ const area = css `
36
36
  fill-opacity: var(--vis-area-hover-fill-opacity);
37
37
  stroke-width: var(--vis-area-hover-stroke-width);
38
38
  }
39
+ `;
40
+ const areaLinePath = css `
41
+ label: areaLinePath;
42
+ fill: none;
43
+ stroke-dasharray: var(--vis-line-stroke-dasharray);
44
+ stroke-dashoffset: var(--vis-line-stroke-dashoffset);
39
45
  `;
40
46
 
41
- export { area, globalStyles, root };
47
+ export { area, areaLinePath, globalStyles, root };
42
48
  //# sourceMappingURL=style.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sources":["../../../src/components/area/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\n\nexport const root = css`\n label: area-component;\n`\n\nexport const globalStyles = injectGlobal`\n :root {\n --vis-area-cursor: default;\n --vis-area-fill-opacity: 1;\n --vis-area-stroke-color: none;\n --vis-area-stroke-width: 0px;\n --vis-area-stroke-dasharray: none;\n --vis-area-stroke-opacity: 1;\n --vis-area-hover-fill-opacity: none;\n --vis-area-hover-stroke-width: none;\n\n /* Dark Theme */\n --vis-dark-area-stroke-color: none;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-area-stroke-color: var(--vis-dark-area-stroke-color);\n }\n\n`\nexport const area = css`\n label: area;\n cursor: var(--vis-area-cursor);\n fill-opacity: var(--vis-area-fill-opacity);\n stroke-width: var(--vis-area-stroke-width);\n stroke-dasharray: var(--vis-area-stroke-dasharray);\n stroke: var(--vis-area-stroke-color);\n stroke-opacity: var(--vis-area-stroke-opacity);\n\n &:hover {\n fill-opacity: var(--vis-area-hover-fill-opacity);\n stroke-width: var(--vis-area-hover-stroke-width);\n }\n`\n"],"names":[],"mappings":";;AAGO,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,YAAY,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;;;AAepB,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;;EAI7B;AACM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"style.js","sources":["../../../src/components/area/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\n\nexport const root = css`\n label: area-component;\n`\n\nexport const globalStyles = injectGlobal`\n :root {\n --vis-area-cursor: default;\n --vis-area-fill-opacity: 1;\n --vis-area-stroke-color: none;\n --vis-area-stroke-width: 0px;\n --vis-area-stroke-dasharray: none;\n --vis-area-stroke-opacity: 1;\n --vis-area-hover-fill-opacity: none;\n --vis-area-hover-stroke-width: none;\n\n /* Dark Theme */\n --vis-dark-area-stroke-color: none;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-area-stroke-color: var(--vis-dark-area-stroke-color);\n }\n\n`\nexport const area = css`\n label: area;\n cursor: var(--vis-area-cursor);\n fill-opacity: var(--vis-area-fill-opacity);\n stroke-width: var(--vis-area-stroke-width);\n stroke-dasharray: var(--vis-area-stroke-dasharray);\n stroke: var(--vis-area-stroke-color);\n stroke-opacity: var(--vis-area-stroke-opacity);\n\n &:hover {\n fill-opacity: var(--vis-area-hover-fill-opacity);\n stroke-width: var(--vis-area-hover-stroke-width);\n }\n`\n\nexport const areaLinePath = css`\n label: areaLinePath;\n fill: none;\n stroke-dasharray: var(--vis-line-stroke-dasharray);\n stroke-dashoffset: var(--vis-line-stroke-dashoffset);\n`\n"],"names":[],"mappings":";;AAGO,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,YAAY,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;;;AAepB,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;;EAI7B;AACM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;EAatB;AAEM,MAAM,YAAY,GAAG,GAAG,CAAA,CAAA;;;;;;;;;"}
@@ -15,6 +15,7 @@ export declare class Axis<Datum> extends XYComponentCore<Datum, AxisConfigInterf
15
15
  private _requiredMargin;
16
16
  private _defaultNumTicks;
17
17
  private _collideTickLabelsAnimFrameId;
18
+ private _tickTextStyleCached;
18
19
  protected events: {};
19
20
  constructor(config?: AxisConfigInterface<Datum>);
20
21
  /** Renders axis to an invisible grouped to calculate automatic chart margins */
@@ -40,6 +41,7 @@ export declare class Axis<Datum> extends XYComponentCore<Datum, AxisConfigInterf
40
41
  private _getFullDomainPath;
41
42
  private _renderAxisLabel;
42
43
  private _getLabelDY;
44
+ private _getTickTextOffset;
43
45
  private _alignTickLabels;
44
46
  private _getYTickTextTranslate;
45
47
  }