@gravity-ui/charts 0.6.0 → 0.6.1-beta.2

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 (178) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/components/Axis/AxisY.d.ts +1 -0
  3. package/dist/cjs/components/Axis/AxisY.js +55 -13
  4. package/dist/cjs/components/ChartInner/index.js +3 -2
  5. package/dist/cjs/components/ChartInner/useChartInnerHandlers.js +4 -0
  6. package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +2 -2
  7. package/dist/cjs/components/Legend/index.js +1 -2
  8. package/dist/cjs/components/PlotTitle/index.js +1 -1
  9. package/dist/cjs/components/PlotTitle/styles.css +1 -1
  10. package/dist/cjs/components/Tooltip/ChartTooltipContent.d.ts +2 -2
  11. package/dist/cjs/components/Tooltip/DefaultContent.js +19 -3
  12. package/dist/cjs/components/Tooltip/index.js +2 -2
  13. package/dist/cjs/components/Tooltip/styles.css +11 -9
  14. package/dist/cjs/components/index.d.ts +10 -9
  15. package/dist/cjs/constants/index.d.ts +1 -0
  16. package/dist/cjs/constants/index.js +1 -0
  17. package/dist/cjs/hooks/useChartOptions/types.d.ts +11 -1
  18. package/dist/cjs/hooks/useChartOptions/x-axis.js +1 -0
  19. package/dist/cjs/hooks/useChartOptions/y-axis.js +9 -1
  20. package/dist/cjs/hooks/useSeries/prepare-area.d.ts +1 -1
  21. package/dist/cjs/hooks/useSeries/prepare-bar-x.d.ts +2 -1
  22. package/dist/cjs/hooks/useSeries/prepare-bar-x.js +2 -1
  23. package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +2 -1
  24. package/dist/cjs/hooks/useSeries/prepare-bar-y.js +3 -1
  25. package/dist/cjs/hooks/useSeries/prepare-line.d.ts +1 -1
  26. package/dist/cjs/hooks/useSeries/prepare-pie.js +2 -2
  27. package/dist/cjs/hooks/useSeries/prepare-sankey.d.ts +11 -0
  28. package/dist/cjs/hooks/useSeries/prepare-sankey.js +38 -0
  29. package/dist/cjs/hooks/useSeries/prepareSeries.js +21 -2
  30. package/dist/cjs/hooks/useSeries/types.d.ts +12 -2
  31. package/dist/cjs/hooks/useSeries/utils.js +1 -1
  32. package/dist/cjs/hooks/useShapes/area/prepare-data.js +4 -0
  33. package/dist/cjs/hooks/useShapes/bar-x/index.js +16 -2
  34. package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +3 -1
  35. package/dist/cjs/hooks/useShapes/bar-x/types.d.ts +1 -0
  36. package/dist/cjs/hooks/useShapes/bar-y/index.js +16 -2
  37. package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +3 -1
  38. package/dist/cjs/hooks/useShapes/bar-y/types.d.ts +1 -0
  39. package/dist/cjs/hooks/useShapes/index.d.ts +2 -1
  40. package/dist/cjs/hooks/useShapes/index.js +19 -0
  41. package/dist/cjs/hooks/useShapes/line/index.js +2 -2
  42. package/dist/cjs/hooks/useShapes/line/prepare-data.js +1 -0
  43. package/dist/cjs/hooks/useShapes/pie/index.js +5 -4
  44. package/dist/cjs/hooks/useShapes/pie/prepare-data.js +168 -118
  45. package/dist/cjs/hooks/useShapes/pie/types.d.ts +2 -2
  46. package/dist/cjs/hooks/useShapes/sankey/index.d.ts +12 -0
  47. package/dist/cjs/hooks/useShapes/sankey/index.js +67 -0
  48. package/dist/cjs/hooks/useShapes/sankey/prepare-data.d.ts +7 -0
  49. package/dist/cjs/hooks/useShapes/sankey/prepare-data.js +72 -0
  50. package/dist/cjs/hooks/useShapes/sankey/types.d.ts +33 -0
  51. package/dist/cjs/hooks/useShapes/sankey/types.js +1 -0
  52. package/dist/cjs/hooks/useShapes/styles.css +2 -2
  53. package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +1 -0
  54. package/dist/cjs/hooks/useShapes/utils.d.ts +7 -2
  55. package/dist/cjs/hooks/useShapes/utils.js +22 -17
  56. package/dist/cjs/hooks/useShapes/waterfall/index.js +1 -2
  57. package/dist/cjs/index.d.ts +1 -1
  58. package/dist/cjs/index.js +1 -0
  59. package/dist/cjs/types/chart/area.d.ts +6 -6
  60. package/dist/cjs/types/chart/axis.d.ts +32 -7
  61. package/dist/cjs/types/chart/bar-x.d.ts +9 -4
  62. package/dist/cjs/types/chart/bar-y.d.ts +10 -6
  63. package/dist/cjs/types/chart/base.d.ts +6 -6
  64. package/dist/cjs/types/chart/chart.d.ts +4 -4
  65. package/dist/cjs/types/chart/halo.d.ts +2 -2
  66. package/dist/cjs/types/chart/legend.d.ts +10 -10
  67. package/dist/cjs/types/chart/line.d.ts +4 -4
  68. package/dist/cjs/types/chart/marker.d.ts +2 -2
  69. package/dist/cjs/types/chart/pie.d.ts +6 -4
  70. package/dist/cjs/types/chart/sankey.d.ts +22 -0
  71. package/dist/cjs/types/chart/sankey.js +1 -0
  72. package/dist/cjs/types/chart/scatter.d.ts +4 -4
  73. package/dist/cjs/types/chart/series.d.ts +21 -10
  74. package/dist/cjs/types/chart/split.d.ts +4 -4
  75. package/dist/cjs/types/chart/title.d.ts +2 -2
  76. package/dist/cjs/types/chart/tooltip.d.ts +27 -21
  77. package/dist/cjs/types/chart/treemap.d.ts +4 -4
  78. package/dist/cjs/types/chart/waterfall.d.ts +4 -4
  79. package/dist/cjs/types/chart-ui.d.ts +10 -6
  80. package/dist/cjs/types/formatter.d.ts +4 -4
  81. package/dist/cjs/types/index.d.ts +35 -4
  82. package/dist/cjs/types/index.js +1 -0
  83. package/dist/cjs/utils/chart/get-closest-data.d.ts +2 -0
  84. package/dist/cjs/utils/chart/get-closest-data.js +39 -3
  85. package/dist/cjs/utils/chart/index.js +1 -1
  86. package/dist/cjs/utils/chart/series/index.d.ts +1 -0
  87. package/dist/cjs/utils/chart/series/index.js +1 -0
  88. package/dist/cjs/utils/chart/series/line.d.ts +2 -0
  89. package/dist/cjs/utils/chart/series/line.js +17 -0
  90. package/dist/esm/components/Axis/AxisY.d.ts +1 -0
  91. package/dist/esm/components/Axis/AxisY.js +55 -13
  92. package/dist/esm/components/ChartInner/index.js +3 -2
  93. package/dist/esm/components/ChartInner/useChartInnerHandlers.js +4 -0
  94. package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +2 -2
  95. package/dist/esm/components/Legend/index.js +1 -2
  96. package/dist/esm/components/PlotTitle/index.js +1 -1
  97. package/dist/esm/components/PlotTitle/styles.css +1 -1
  98. package/dist/esm/components/Tooltip/ChartTooltipContent.d.ts +2 -2
  99. package/dist/esm/components/Tooltip/DefaultContent.js +19 -3
  100. package/dist/esm/components/Tooltip/index.js +2 -2
  101. package/dist/esm/components/Tooltip/styles.css +11 -9
  102. package/dist/esm/components/index.d.ts +10 -9
  103. package/dist/esm/constants/index.d.ts +1 -0
  104. package/dist/esm/constants/index.js +1 -0
  105. package/dist/esm/hooks/useChartOptions/types.d.ts +11 -1
  106. package/dist/esm/hooks/useChartOptions/x-axis.js +1 -0
  107. package/dist/esm/hooks/useChartOptions/y-axis.js +9 -1
  108. package/dist/esm/hooks/useSeries/prepare-area.d.ts +1 -1
  109. package/dist/esm/hooks/useSeries/prepare-bar-x.d.ts +2 -1
  110. package/dist/esm/hooks/useSeries/prepare-bar-x.js +2 -1
  111. package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +2 -1
  112. package/dist/esm/hooks/useSeries/prepare-bar-y.js +3 -1
  113. package/dist/esm/hooks/useSeries/prepare-line.d.ts +1 -1
  114. package/dist/esm/hooks/useSeries/prepare-pie.js +2 -2
  115. package/dist/esm/hooks/useSeries/prepare-sankey.d.ts +11 -0
  116. package/dist/esm/hooks/useSeries/prepare-sankey.js +38 -0
  117. package/dist/esm/hooks/useSeries/prepareSeries.js +21 -2
  118. package/dist/esm/hooks/useSeries/types.d.ts +12 -2
  119. package/dist/esm/hooks/useSeries/utils.js +1 -1
  120. package/dist/esm/hooks/useShapes/area/prepare-data.js +4 -0
  121. package/dist/esm/hooks/useShapes/bar-x/index.js +16 -2
  122. package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +3 -1
  123. package/dist/esm/hooks/useShapes/bar-x/types.d.ts +1 -0
  124. package/dist/esm/hooks/useShapes/bar-y/index.js +16 -2
  125. package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +3 -1
  126. package/dist/esm/hooks/useShapes/bar-y/types.d.ts +1 -0
  127. package/dist/esm/hooks/useShapes/index.d.ts +2 -1
  128. package/dist/esm/hooks/useShapes/index.js +19 -0
  129. package/dist/esm/hooks/useShapes/line/index.js +2 -2
  130. package/dist/esm/hooks/useShapes/line/prepare-data.js +1 -0
  131. package/dist/esm/hooks/useShapes/pie/index.js +5 -4
  132. package/dist/esm/hooks/useShapes/pie/prepare-data.js +168 -118
  133. package/dist/esm/hooks/useShapes/pie/types.d.ts +2 -2
  134. package/dist/esm/hooks/useShapes/sankey/index.d.ts +12 -0
  135. package/dist/esm/hooks/useShapes/sankey/index.js +67 -0
  136. package/dist/esm/hooks/useShapes/sankey/prepare-data.d.ts +7 -0
  137. package/dist/esm/hooks/useShapes/sankey/prepare-data.js +72 -0
  138. package/dist/esm/hooks/useShapes/sankey/types.d.ts +33 -0
  139. package/dist/esm/hooks/useShapes/sankey/types.js +1 -0
  140. package/dist/esm/hooks/useShapes/styles.css +2 -2
  141. package/dist/esm/hooks/useShapes/treemap/prepare-data.js +1 -0
  142. package/dist/esm/hooks/useShapes/utils.d.ts +7 -2
  143. package/dist/esm/hooks/useShapes/utils.js +22 -17
  144. package/dist/esm/hooks/useShapes/waterfall/index.js +1 -2
  145. package/dist/esm/index.d.ts +1 -1
  146. package/dist/esm/index.js +1 -0
  147. package/dist/esm/types/chart/area.d.ts +6 -6
  148. package/dist/esm/types/chart/axis.d.ts +32 -7
  149. package/dist/esm/types/chart/bar-x.d.ts +9 -4
  150. package/dist/esm/types/chart/bar-y.d.ts +10 -6
  151. package/dist/esm/types/chart/base.d.ts +6 -6
  152. package/dist/esm/types/chart/chart.d.ts +4 -4
  153. package/dist/esm/types/chart/halo.d.ts +2 -2
  154. package/dist/esm/types/chart/legend.d.ts +10 -10
  155. package/dist/esm/types/chart/line.d.ts +4 -4
  156. package/dist/esm/types/chart/marker.d.ts +2 -2
  157. package/dist/esm/types/chart/pie.d.ts +6 -4
  158. package/dist/esm/types/chart/sankey.d.ts +22 -0
  159. package/dist/esm/types/chart/sankey.js +1 -0
  160. package/dist/esm/types/chart/scatter.d.ts +4 -4
  161. package/dist/esm/types/chart/series.d.ts +21 -10
  162. package/dist/esm/types/chart/split.d.ts +4 -4
  163. package/dist/esm/types/chart/title.d.ts +2 -2
  164. package/dist/esm/types/chart/tooltip.d.ts +27 -21
  165. package/dist/esm/types/chart/treemap.d.ts +4 -4
  166. package/dist/esm/types/chart/waterfall.d.ts +4 -4
  167. package/dist/esm/types/chart-ui.d.ts +10 -6
  168. package/dist/esm/types/formatter.d.ts +4 -4
  169. package/dist/esm/types/index.d.ts +35 -4
  170. package/dist/esm/types/index.js +1 -0
  171. package/dist/esm/utils/chart/get-closest-data.d.ts +2 -0
  172. package/dist/esm/utils/chart/get-closest-data.js +39 -3
  173. package/dist/esm/utils/chart/index.js +1 -1
  174. package/dist/esm/utils/chart/series/index.d.ts +1 -0
  175. package/dist/esm/utils/chart/series/index.js +1 -0
  176. package/dist/esm/utils/chart/series/line.d.ts +2 -0
  177. package/dist/esm/utils/chart/series/line.js +17 -0
  178. package/package.json +7 -2
@@ -2,7 +2,7 @@ import type { LayoutAlgorithm, SeriesType } from '../../constants';
2
2
  import type { MeaningfulAny } from '../misc';
3
3
  import type { BaseSeries, BaseSeriesData } from './base';
4
4
  import type { ChartLegend, RectLegendSymbolOptions } from './legend';
5
- export type TreemapSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
5
+ export interface TreemapSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
6
6
  /** The name of the node (used in legend, tooltip etc). */
7
7
  name: string | string[];
8
8
  /** The value of the node. All nodes should have this property except nodes that have children. */
@@ -14,8 +14,8 @@ export type TreemapSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
14
14
  * If no nodes has a matching id, or this option is undefined, then the parent will be set to the root.
15
15
  */
16
16
  parentId?: string;
17
- };
18
- export type TreemapSeries<T = MeaningfulAny> = BaseSeries & {
17
+ }
18
+ export interface TreemapSeries<T = MeaningfulAny> extends BaseSeries {
19
19
  type: typeof SeriesType.Treemap;
20
20
  data: TreemapSeriesData<T>[];
21
21
  /** The name of the series (used in legend, tooltip etc). */
@@ -43,4 +43,4 @@ export type TreemapSeries<T = MeaningfulAny> = BaseSeries & {
43
43
  /** Horizontal alignment of the data label inside the tile. */
44
44
  align?: 'left' | 'center' | 'right';
45
45
  };
46
- };
46
+ }
@@ -2,7 +2,7 @@ import type { SeriesType } from '../../constants';
2
2
  import type { MeaningfulAny } from '../misc';
3
3
  import type { BaseSeries, BaseSeriesData } from './base';
4
4
  import type { ChartLegend, RectLegendSymbolOptions } from './legend';
5
- export type WaterfallSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
5
+ export interface WaterfallSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
6
6
  /**
7
7
  * The `x` value. Depending on the context , it may represents:
8
8
  * - numeric value (for `linear` x axis)
@@ -21,8 +21,8 @@ export type WaterfallSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
21
21
  opacity?: number;
22
22
  /** When this property is true, the point display the total sum across the entire series. */
23
23
  total?: boolean;
24
- };
25
- export type WaterfallSeries<T = MeaningfulAny> = BaseSeries & {
24
+ }
25
+ export interface WaterfallSeries<T = MeaningfulAny> extends BaseSeries {
26
26
  type: typeof SeriesType.Waterfall;
27
27
  data: WaterfallSeriesData<T>[];
28
28
  /** The name of the series (used in legend, tooltip etc). */
@@ -37,4 +37,4 @@ export type WaterfallSeries<T = MeaningfulAny> = BaseSeries & {
37
37
  legend?: ChartLegend & {
38
38
  symbol?: RectLegendSymbolOptions;
39
39
  };
40
- };
40
+ }
@@ -1,5 +1,5 @@
1
1
  import type { BaseTextStyle } from './chart/base';
2
- export type LabelData = {
2
+ export interface LabelData {
3
3
  text: string;
4
4
  x: number;
5
5
  y: number;
@@ -13,12 +13,16 @@ export type LabelData = {
13
13
  id: string;
14
14
  };
15
15
  active?: boolean;
16
- };
17
- export type HtmlItem = {
16
+ }
17
+ export interface HtmlItem {
18
18
  x: number;
19
19
  y: number;
20
20
  content: string;
21
- };
22
- export type ShapeDataWithHtmlItems = {
21
+ size: {
22
+ width: number;
23
+ height: number;
24
+ };
25
+ }
26
+ export interface ShapeDataWithHtmlItems {
23
27
  htmlElements: HtmlItem[];
24
- };
28
+ }
@@ -1,14 +1,14 @@
1
- export type FormatOptions = {
1
+ export interface FormatOptions {
2
2
  precision?: number | 'auto';
3
3
  unitRate?: number;
4
4
  showRankDelimiter?: boolean;
5
5
  lang?: string;
6
6
  labelMode?: string;
7
- };
8
- export type FormatNumberOptions = FormatOptions & {
7
+ }
8
+ export interface FormatNumberOptions extends FormatOptions {
9
9
  format?: 'number' | 'percent';
10
10
  multiplier?: number;
11
11
  prefix?: string;
12
12
  postfix?: string;
13
13
  unit?: 'auto' | 'k' | 'm' | 'b' | 't' | null;
14
- };
14
+ }
@@ -25,18 +25,49 @@ export * from './chart/tooltip';
25
25
  export * from './chart/halo';
26
26
  export * from './chart/treemap';
27
27
  export * from './chart/waterfall';
28
- export type ChartData<T = MeaningfulAny> = {
28
+ export * from './chart/sankey';
29
+ export interface ChartData<T = MeaningfulAny> {
30
+ /**
31
+ * General options for the chart.
32
+ */
29
33
  chart?: ChartOptions;
34
+ /**
35
+ * The legend displays a labeled box for each data element in the chart.
36
+ * It shows a distinctive symbol paired with a name for every series.
37
+ */
30
38
  legend?: ChartLegend;
39
+ /**
40
+ * Represents the series data and series options.
41
+ */
31
42
  series: {
43
+ /**
44
+ * Contains data points to be plotted.
45
+ */
32
46
  data: ChartSeries<T>[];
47
+ /**
48
+ * Allows for customizing the appearance and behavior of the series.
49
+ */
33
50
  options?: ChartSeriesOptions;
34
51
  };
52
+ /**
53
+ * The main title of the chart.
54
+ */
35
55
  title?: ChartTitle;
56
+ /**
57
+ * Options for the tooltip that appears when the user hovers over a series or point.
58
+ */
36
59
  tooltip?: ChartTooltip<T>;
60
+ /**
61
+ * Options for the the X axis.
62
+ */
37
63
  xAxis?: ChartXAxis;
64
+ /**
65
+ * Options for the the Y axis or multiple Y axes.
66
+ */
38
67
  yAxis?: ChartYAxis[];
39
- /** Setting for displaying charts on different plots.
40
- * It can be used to visualize related information on multiple charts. */
68
+ /**
69
+ * Setting for displaying charts on different plots.
70
+ * It can be used to visualize related information on multiple charts.
71
+ */
41
72
  split?: ChartSplit;
42
- };
73
+ }
@@ -17,3 +17,4 @@ export * from './chart/tooltip';
17
17
  export * from './chart/halo';
18
18
  export * from './chart/treemap';
19
19
  export * from './chart/waterfall';
20
+ export * from './chart/sankey';
@@ -3,6 +3,8 @@ import type { ChartSeries, ChartSeriesData, TooltipDataChunk } from '../../types
3
3
  type GetClosestPointsArgs = {
4
4
  position: [number, number];
5
5
  shapesData: ShapeData[];
6
+ boundsHeight: number;
7
+ boundsWidth: number;
6
8
  };
7
9
  export type ShapePoint = {
8
10
  x: number;
@@ -35,7 +35,7 @@ function getSeriesType(shapeData) {
35
35
  return get(shapeData, 'series.type') || get(shapeData, 'point.series.type');
36
36
  }
37
37
  export function getClosestPoints(args) {
38
- const { position, shapesData } = args;
38
+ const { position, shapesData, boundsHeight, boundsWidth } = args;
39
39
  const [pointerX, pointerY] = position;
40
40
  const result = [];
41
41
  const groups = groupBy(shapesData, getSeriesType);
@@ -135,13 +135,13 @@ export function getClosestPoints(args) {
135
135
  case 'pie': {
136
136
  const points = list.map((d) => d.segments).flat();
137
137
  const closestPoint = points.find((p) => {
138
- const { center, radius } = p.data.pie;
138
+ const { center } = p.data.pie;
139
139
  const x = pointerX - center[0];
140
140
  const y = pointerY - center[1];
141
141
  let angle = Math.atan2(y, x) + 0.5 * Math.PI;
142
142
  angle = angle < 0 ? Math.PI * 2 + angle : angle;
143
143
  const polarRadius = Math.sqrt(x * x + y * y);
144
- return angle >= p.startAngle && angle <= p.endAngle && polarRadius < radius;
144
+ return (angle >= p.startAngle && angle <= p.endAngle && polarRadius < p.data.radius);
145
145
  });
146
146
  if (closestPoint) {
147
147
  result.push({
@@ -166,7 +166,43 @@ export function getClosestPoints(args) {
166
166
  }
167
167
  break;
168
168
  }
169
+ case 'sankey': {
170
+ const [data] = list;
171
+ const closestLink = data.links.find((d) => {
172
+ var _a;
173
+ return isInsidePath({
174
+ path: (_a = d.path) !== null && _a !== void 0 ? _a : '',
175
+ strokeWidth: d.strokeWidth,
176
+ point: [pointerX, pointerY],
177
+ width: boundsWidth,
178
+ height: boundsHeight,
179
+ });
180
+ });
181
+ if (closestLink) {
182
+ result.push({
183
+ data: closestLink.source,
184
+ target: closestLink.target,
185
+ series: data.series,
186
+ closest: true,
187
+ });
188
+ }
189
+ break;
190
+ }
169
191
  }
170
192
  });
171
193
  return result;
172
194
  }
195
+ function isInsidePath(args) {
196
+ const { path, point, width, height, strokeWidth } = args;
197
+ const canvas = document.createElement('canvas');
198
+ canvas.width = width;
199
+ canvas.height = height;
200
+ const ctx = canvas.getContext('2d');
201
+ if (ctx) {
202
+ ctx.lineWidth = strokeWidth;
203
+ const path2D = new Path2D(path);
204
+ ctx.stroke(path2D);
205
+ return ctx.isPointInPath(path2D, ...point) || ctx.isPointInStroke(path2D, ...point);
206
+ }
207
+ return null;
208
+ }
@@ -15,7 +15,7 @@ export * from './legend';
15
15
  export * from './symbol';
16
16
  export * from './series';
17
17
  export * from './color';
18
- const CHARTS_WITHOUT_AXIS = ['pie', 'treemap'];
18
+ const CHARTS_WITHOUT_AXIS = ['pie', 'treemap', 'sankey'];
19
19
  export const CHART_SERIES_WITH_VOLUME_ON_Y_AXIS = [
20
20
  'bar-x',
21
21
  'area',
@@ -1 +1,2 @@
1
+ export * from './line';
1
2
  export * from './waterfall';
@@ -1 +1,2 @@
1
+ export * from './line';
1
2
  export * from './waterfall';
@@ -0,0 +1,2 @@
1
+ import type { DashStyle } from 'src/constants';
2
+ export declare function getLineDashArray(dashStyle: DashStyle, strokeWidth?: number): string;
@@ -0,0 +1,17 @@
1
+ export function getLineDashArray(dashStyle, strokeWidth = 2) {
2
+ const value = dashStyle.toLowerCase();
3
+ const arrayValue = value
4
+ .replace('shortdashdotdot', '3,1,1,1,1,1,')
5
+ .replace('shortdashdot', '3,1,1,1')
6
+ .replace('shortdot', '1,1,')
7
+ .replace('shortdash', '3,1,')
8
+ .replace('longdash', '8,3,')
9
+ .replace(/dot/g, '1,3,')
10
+ .replace('dash', '4,3,')
11
+ .replace(/,$/, '')
12
+ .split(',')
13
+ .map((part) => {
14
+ return `${parseInt(part, 10) * strokeWidth}`;
15
+ });
16
+ return arrayValue.join(',').replace(/NaN/g, 'none');
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/charts",
3
- "version": "0.6.0",
3
+ "version": "0.6.1-beta.2",
4
4
  "description": "React component used to render charts",
5
5
  "license": "MIT",
6
6
  "main": "dist/cjs/index.js",
@@ -50,13 +50,17 @@
50
50
  "build": "gulp",
51
51
  "start": "storybook dev -p 7007",
52
52
  "build-storybook": "storybook build -c .storybook -o storybook-static",
53
- "prepublishOnly": "npm run build"
53
+ "prepublishOnly": "npm run build",
54
+ "docs:deps": "cd ./docs && npm ci",
55
+ "docs:dev": "cd ./docs && npm run docs:dev",
56
+ "docs:build": "cd ./docs && npm run docs:build"
54
57
  },
55
58
  "dependencies": {
56
59
  "@bem-react/classname": "^1.6.0",
57
60
  "@gravity-ui/date-utils": "^2.5.4",
58
61
  "@gravity-ui/i18n": "^1.6.0",
59
62
  "d3": "^7.9.0",
63
+ "d3-sankey": "^0.12.3",
60
64
  "lodash": "^4.17.21",
61
65
  "tslib": "^2.6.2"
62
66
  },
@@ -90,6 +94,7 @@
90
94
  "@testing-library/react": "^16.0.0",
91
95
  "@testing-library/user-event": "^14.5.2",
92
96
  "@types/d3": "^7.4.3",
97
+ "@types/d3-sankey": "^0.12.4",
93
98
  "@types/d3-selection": "^3.0.11",
94
99
  "@types/jest": "^29.5.12",
95
100
  "@types/lodash": "^4.17.12",