@semcore/d3-chart 3.18.1 → 3.18.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 (177) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +1 -1
  3. package/lib/cjs/Area.js +9 -9
  4. package/lib/cjs/Axis.js +14 -14
  5. package/lib/cjs/Bar.js +8 -8
  6. package/lib/cjs/Bubble.js +10 -10
  7. package/lib/cjs/Donut.js +7 -7
  8. package/lib/cjs/Dots.js +10 -10
  9. package/lib/cjs/HorizontalBar.js +8 -8
  10. package/lib/cjs/Hover.js +3 -3
  11. package/lib/cjs/Line.js +13 -11
  12. package/lib/cjs/Line.js.map +1 -1
  13. package/lib/cjs/Plot.js +3 -3
  14. package/lib/cjs/Radar.js +17 -17
  15. package/lib/cjs/RadialTree.js +10 -10
  16. package/lib/cjs/ReferenceLine.js +9 -9
  17. package/lib/cjs/ScatterPlot.js +8 -8
  18. package/lib/cjs/ScatterPlot.js.map +1 -1
  19. package/lib/cjs/Tooltip.js +8 -8
  20. package/lib/cjs/Venn.js +7 -7
  21. package/lib/cjs/a11y/PlotA11yModule.js +2 -2
  22. package/lib/cjs/a11y/PlotA11yView.js +2 -2
  23. package/lib/cjs/component/Chart/AbstractChart.js +420 -0
  24. package/lib/cjs/component/Chart/AbstractChart.js.map +1 -0
  25. package/lib/cjs/component/Chart/AbstractChart.type.js +2 -0
  26. package/lib/cjs/component/Chart/AbstractChart.type.js.map +1 -0
  27. package/lib/cjs/component/Chart/AreaChart.js +160 -0
  28. package/lib/cjs/component/Chart/AreaChart.js.map +1 -0
  29. package/lib/cjs/component/Chart/AreaChart.type.js +2 -0
  30. package/lib/cjs/component/Chart/AreaChart.type.js.map +1 -0
  31. package/lib/cjs/component/Chart/BarChart.js +253 -0
  32. package/lib/cjs/component/Chart/BarChart.js.map +1 -0
  33. package/lib/cjs/component/Chart/BarChart.type.js +2 -0
  34. package/lib/cjs/component/Chart/BarChart.type.js.map +1 -0
  35. package/lib/cjs/component/Chart/BubbleChart.js +145 -0
  36. package/lib/cjs/component/Chart/BubbleChart.js.map +1 -0
  37. package/lib/cjs/component/Chart/BubbleChart.type.js +2 -0
  38. package/lib/cjs/component/Chart/BubbleChart.type.js.map +1 -0
  39. package/lib/cjs/component/Chart/DonutChart.js +117 -0
  40. package/lib/cjs/component/Chart/DonutChart.js.map +1 -0
  41. package/lib/cjs/component/Chart/DonutChart.type.js +2 -0
  42. package/lib/cjs/component/Chart/DonutChart.type.js.map +1 -0
  43. package/lib/cjs/component/Chart/HistogramChart.js +189 -0
  44. package/lib/cjs/component/Chart/HistogramChart.js.map +1 -0
  45. package/lib/cjs/component/Chart/HistogramChart.type.js +2 -0
  46. package/lib/cjs/component/Chart/HistogramChart.type.js.map +1 -0
  47. package/lib/cjs/component/Chart/LineChart.js +147 -0
  48. package/lib/cjs/component/Chart/LineChart.js.map +1 -0
  49. package/lib/cjs/component/Chart/LineChart.type.js +2 -0
  50. package/lib/cjs/component/Chart/LineChart.type.js.map +1 -0
  51. package/lib/cjs/component/Chart/RadarChart.js +121 -0
  52. package/lib/cjs/component/Chart/RadarChart.js.map +1 -0
  53. package/lib/cjs/component/Chart/RadarChart.type.js +2 -0
  54. package/lib/cjs/component/Chart/RadarChart.type.js.map +1 -0
  55. package/lib/cjs/component/Chart/ScatterPlotChart.js +159 -0
  56. package/lib/cjs/component/Chart/ScatterPlotChart.js.map +1 -0
  57. package/lib/cjs/component/Chart/ScatterPlotChart.type.js +2 -0
  58. package/lib/cjs/component/Chart/ScatterPlotChart.type.js.map +1 -0
  59. package/lib/cjs/component/Chart/VennChart.js +144 -0
  60. package/lib/cjs/component/Chart/VennChart.js.map +1 -0
  61. package/lib/cjs/component/Chart/VennChart.type.js +2 -0
  62. package/lib/cjs/component/Chart/VennChart.type.js.map +1 -0
  63. package/lib/cjs/component/Chart/index.js +28 -0
  64. package/lib/cjs/component/Chart/index.js.map +1 -0
  65. package/lib/cjs/component/ChartLegend/BaseLegend.type.js.map +1 -1
  66. package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
  67. package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +20 -17
  68. package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
  69. package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +6 -7
  70. package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
  71. package/lib/cjs/component/ChartLegend/LegendTable/legend-table.shadow.css +5 -2
  72. package/lib/cjs/index.js +7 -0
  73. package/lib/cjs/index.js.map +1 -1
  74. package/lib/cjs/style/donut.shadow.css +3 -0
  75. package/lib/cjs/types/Line.d.js.map +1 -1
  76. package/lib/cjs/types/index.d.js +130 -1
  77. package/lib/cjs/types/index.d.js.map +1 -1
  78. package/lib/es6/Area.js +9 -9
  79. package/lib/es6/Axis.js +14 -14
  80. package/lib/es6/Bar.js +8 -8
  81. package/lib/es6/Bubble.js +10 -10
  82. package/lib/es6/Donut.js +7 -7
  83. package/lib/es6/Dots.js +10 -10
  84. package/lib/es6/HorizontalBar.js +8 -8
  85. package/lib/es6/Hover.js +3 -3
  86. package/lib/es6/Line.js +13 -11
  87. package/lib/es6/Line.js.map +1 -1
  88. package/lib/es6/Plot.js +3 -3
  89. package/lib/es6/Radar.js +17 -17
  90. package/lib/es6/RadialTree.js +10 -10
  91. package/lib/es6/ReferenceLine.js +9 -9
  92. package/lib/es6/ScatterPlot.js +8 -8
  93. package/lib/es6/ScatterPlot.js.map +1 -1
  94. package/lib/es6/Tooltip.js +8 -8
  95. package/lib/es6/Venn.js +7 -7
  96. package/lib/es6/a11y/PlotA11yModule.js +2 -2
  97. package/lib/es6/a11y/PlotA11yView.js +2 -2
  98. package/lib/es6/component/Chart/AbstractChart.js +412 -0
  99. package/lib/es6/component/Chart/AbstractChart.js.map +1 -0
  100. package/lib/es6/component/Chart/AbstractChart.type.js +2 -0
  101. package/lib/es6/component/Chart/AbstractChart.type.js.map +1 -0
  102. package/lib/es6/component/Chart/AreaChart.js +152 -0
  103. package/lib/es6/component/Chart/AreaChart.js.map +1 -0
  104. package/lib/es6/component/Chart/AreaChart.type.js +2 -0
  105. package/lib/es6/component/Chart/AreaChart.type.js.map +1 -0
  106. package/lib/es6/component/Chart/BarChart.js +245 -0
  107. package/lib/es6/component/Chart/BarChart.js.map +1 -0
  108. package/lib/es6/component/Chart/BarChart.type.js +2 -0
  109. package/lib/es6/component/Chart/BarChart.type.js.map +1 -0
  110. package/lib/es6/component/Chart/BubbleChart.js +137 -0
  111. package/lib/es6/component/Chart/BubbleChart.js.map +1 -0
  112. package/lib/es6/component/Chart/BubbleChart.type.js +2 -0
  113. package/lib/es6/component/Chart/BubbleChart.type.js.map +1 -0
  114. package/lib/es6/component/Chart/DonutChart.js +109 -0
  115. package/lib/es6/component/Chart/DonutChart.js.map +1 -0
  116. package/lib/es6/component/Chart/DonutChart.type.js +2 -0
  117. package/lib/es6/component/Chart/DonutChart.type.js.map +1 -0
  118. package/lib/es6/component/Chart/HistogramChart.js +181 -0
  119. package/lib/es6/component/Chart/HistogramChart.js.map +1 -0
  120. package/lib/es6/component/Chart/HistogramChart.type.js +2 -0
  121. package/lib/es6/component/Chart/HistogramChart.type.js.map +1 -0
  122. package/lib/es6/component/Chart/LineChart.js +139 -0
  123. package/lib/es6/component/Chart/LineChart.js.map +1 -0
  124. package/lib/es6/component/Chart/LineChart.type.js +2 -0
  125. package/lib/es6/component/Chart/LineChart.type.js.map +1 -0
  126. package/lib/es6/component/Chart/RadarChart.js +113 -0
  127. package/lib/es6/component/Chart/RadarChart.js.map +1 -0
  128. package/lib/es6/component/Chart/RadarChart.type.js +2 -0
  129. package/lib/es6/component/Chart/RadarChart.type.js.map +1 -0
  130. package/lib/es6/component/Chart/ScatterPlotChart.js +151 -0
  131. package/lib/es6/component/Chart/ScatterPlotChart.js.map +1 -0
  132. package/lib/es6/component/Chart/ScatterPlotChart.type.js +2 -0
  133. package/lib/es6/component/Chart/ScatterPlotChart.type.js.map +1 -0
  134. package/lib/es6/component/Chart/VennChart.js +136 -0
  135. package/lib/es6/component/Chart/VennChart.js.map +1 -0
  136. package/lib/es6/component/Chart/VennChart.type.js +2 -0
  137. package/lib/es6/component/Chart/VennChart.type.js.map +1 -0
  138. package/lib/es6/component/Chart/index.js +21 -0
  139. package/lib/es6/component/Chart/index.js.map +1 -0
  140. package/lib/es6/component/ChartLegend/BaseLegend.type.js.map +1 -1
  141. package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
  142. package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +20 -17
  143. package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
  144. package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +6 -7
  145. package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
  146. package/lib/es6/component/ChartLegend/LegendTable/legend-table.shadow.css +5 -2
  147. package/lib/es6/index.js +1 -0
  148. package/lib/es6/index.js.map +1 -1
  149. package/lib/es6/style/donut.shadow.css +3 -0
  150. package/lib/es6/types/Line.d.js.map +1 -1
  151. package/lib/es6/types/index.d.js +12 -0
  152. package/lib/es6/types/index.d.js.map +1 -1
  153. package/lib/types/Line.d.ts +7 -2
  154. package/lib/types/component/Chart/AbstractChart.d.ts +50 -0
  155. package/lib/types/component/Chart/AbstractChart.type.d.ts +161 -0
  156. package/lib/types/component/Chart/AreaChart.d.ts +2 -0
  157. package/lib/types/component/Chart/AreaChart.type.d.ts +16 -0
  158. package/lib/types/component/Chart/BarChart.d.ts +2 -0
  159. package/lib/types/component/Chart/BarChart.type.d.ts +19 -0
  160. package/lib/types/component/Chart/BubbleChart.d.ts +2 -0
  161. package/lib/types/component/Chart/BubbleChart.type.d.ts +17 -0
  162. package/lib/types/component/Chart/DonutChart.d.ts +2 -0
  163. package/lib/types/component/Chart/DonutChart.type.d.ts +15 -0
  164. package/lib/types/component/Chart/HistogramChart.d.ts +2 -0
  165. package/lib/types/component/Chart/HistogramChart.type.d.ts +11 -0
  166. package/lib/types/component/Chart/LineChart.d.ts +2 -0
  167. package/lib/types/component/Chart/LineChart.type.d.ts +24 -0
  168. package/lib/types/component/Chart/RadarChart.d.ts +2 -0
  169. package/lib/types/component/Chart/RadarChart.type.d.ts +14 -0
  170. package/lib/types/component/Chart/ScatterPlotChart.d.ts +2 -0
  171. package/lib/types/component/Chart/ScatterPlotChart.type.d.ts +13 -0
  172. package/lib/types/component/Chart/VennChart.d.ts +2 -0
  173. package/lib/types/component/Chart/VennChart.type.d.ts +11 -0
  174. package/lib/types/component/Chart/index.d.ts +12 -0
  175. package/lib/types/component/ChartLegend/BaseLegend.type.d.ts +2 -2
  176. package/lib/types/index.d.ts +13 -0
  177. package/package.json +2 -2
@@ -0,0 +1,181 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _get from "@babel/runtime/helpers/get";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _inherits from "@babel/runtime/helpers/inherits";
8
+ import _createSuper from "@babel/runtime/helpers/createSuper";
9
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
+ import React from 'react';
11
+ import createComponent from '@semcore/core';
12
+ import { scaleBand, scaleLinear, scaleTime } from 'd3-scale';
13
+ // @ts-ignore
14
+ import { Bar, minMax, HoverRect, StackBar } from '../..';
15
+ import { AbstractChart } from './AbstractChart';
16
+ import { Box, Flex } from '@semcore/flex-box';
17
+ import { Text } from '@semcore/typography';
18
+ var HistogramChartComponent = /*#__PURE__*/function (_AbstractChart) {
19
+ _inherits(HistogramChartComponent, _AbstractChart);
20
+ var _super = _createSuper(HistogramChartComponent);
21
+ function HistogramChartComponent() {
22
+ _classCallCheck(this, HistogramChartComponent);
23
+ return _super.apply(this, arguments);
24
+ }
25
+ _createClass(HistogramChartComponent, [{
26
+ key: "xScale",
27
+ get: function get() {
28
+ var _this$asProps = this.asProps,
29
+ xScale = _this$asProps.xScale,
30
+ _this$asProps$marginY = _this$asProps.marginY,
31
+ marginY = _this$asProps$marginY === void 0 ? 30 : _this$asProps$marginY,
32
+ _this$asProps$marginX = _this$asProps.marginX,
33
+ marginX = _this$asProps$marginX === void 0 ? 30 : _this$asProps$marginX,
34
+ plotWidth = _this$asProps.plotWidth,
35
+ plotHeight = _this$asProps.plotHeight,
36
+ invertAxis = _this$asProps.invertAxis,
37
+ data = _this$asProps.data,
38
+ groupKey = _this$asProps.groupKey;
39
+ if (xScale) {
40
+ return xScale;
41
+ }
42
+ var testItem = data[0][groupKey];
43
+ var range = invertAxis ? [plotHeight - marginX, this.plotPadding] : [marginY, plotWidth - this.plotPadding];
44
+ if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {
45
+ var _domain = minMax(data, groupKey);
46
+ return scaleTime(_domain, range);
47
+ }
48
+ var domain = data.map(function (item) {
49
+ return item[groupKey];
50
+ });
51
+ return scaleBand(domain, range).paddingInner(0.05).paddingOuter(0.2);
52
+ }
53
+ }, {
54
+ key: "yScale",
55
+ get: function get() {
56
+ var _this$asProps2 = this.asProps,
57
+ yScale = _this$asProps2.yScale,
58
+ _this$asProps2$margin = _this$asProps2.marginY,
59
+ marginY = _this$asProps2$margin === void 0 ? 30 : _this$asProps2$margin,
60
+ _this$asProps2$margin2 = _this$asProps2.marginX,
61
+ marginX = _this$asProps2$margin2 === void 0 ? 30 : _this$asProps2$margin2,
62
+ plotHeight = _this$asProps2.plotHeight,
63
+ plotWidth = _this$asProps2.plotWidth,
64
+ invertAxis = _this$asProps2.invertAxis,
65
+ data = _this$asProps2.data;
66
+ var max;
67
+ if (this.isStack) {
68
+ max = data.reduce(function (max, item) {
69
+ var barSum = Object.values(item).reduce(function (sum, val) {
70
+ if (val instanceof Date && !Number.isNaN(val.getMilliseconds())) {
71
+ return sum + val.getMilliseconds();
72
+ }
73
+ return sum + val;
74
+ }, 0);
75
+ if (barSum > max) {
76
+ max = barSum;
77
+ }
78
+ return max;
79
+ }, 0);
80
+ } else {
81
+ var flatValues = _get(_getPrototypeOf(HistogramChartComponent.prototype), "flatValues", this);
82
+ max = Math.max.apply(Math, _toConsumableArray(flatValues));
83
+ }
84
+ return yScale !== null && yScale !== void 0 ? yScale : scaleLinear().range(invertAxis ? [marginY, plotWidth - this.plotPadding] : [plotHeight - marginX, this.plotPadding]).domain([0, max]);
85
+ }
86
+ }, {
87
+ key: "isStack",
88
+ get: function get() {
89
+ var dataDefinitions = this.state.dataDefinitions;
90
+ return dataDefinitions.length > 1;
91
+ }
92
+ }, {
93
+ key: "renderChart",
94
+ value: function renderChart() {
95
+ var _this$asProps3 = this.asProps,
96
+ groupKey = _this$asProps3.groupKey,
97
+ invertAxis = _this$asProps3.invertAxis;
98
+ var _this$state = this.state,
99
+ dataDefinitions = _this$state.dataDefinitions,
100
+ highlightedLine = _this$state.highlightedLine;
101
+ if (this.isStack) {
102
+ return /*#__PURE__*/React.createElement(StackBar, {
103
+ x: invertAxis ? undefined : groupKey,
104
+ y: invertAxis ? groupKey : undefined
105
+ }, dataDefinitions.map(function (item, index) {
106
+ var BarComponent = invertAxis ? StackBar.HorizontalBar : StackBar.Bar;
107
+ var commonBarComponentProps = {
108
+ color: item.color,
109
+ transparent: highlightedLine !== -1 && highlightedLine !== index
110
+ };
111
+ if (invertAxis) {
112
+ commonBarComponentProps.x = item.id;
113
+ } else {
114
+ commonBarComponentProps.y = item.id;
115
+ }
116
+ return item.checked && /*#__PURE__*/React.createElement(BarComponent, _extends({
117
+ key: item.id
118
+ }, commonBarComponentProps));
119
+ }));
120
+ }
121
+ var item = dataDefinitions[0];
122
+ return /*#__PURE__*/React.createElement(Bar, {
123
+ x: invertAxis ? item.id : groupKey,
124
+ y: invertAxis ? groupKey : item.id,
125
+ key: item.id,
126
+ color: item.color
127
+ });
128
+ }
129
+ }, {
130
+ key: "renderTooltip",
131
+ value: function renderTooltip() {
132
+ var _this = this;
133
+ var _this$asProps4 = this.asProps,
134
+ data = _this$asProps4.data,
135
+ groupKey = _this$asProps4.groupKey,
136
+ showTotalInTooltip = _this$asProps4.showTotalInTooltip,
137
+ showTooltip = _this$asProps4.showTooltip,
138
+ invertAxis = _this$asProps4.invertAxis;
139
+ var dataDefinitions = this.state.dataDefinitions;
140
+ if (!showTooltip) {
141
+ return null;
142
+ }
143
+ return /*#__PURE__*/React.createElement(HoverRect.Tooltip, {
144
+ x: invertAxis ? undefined : groupKey,
145
+ y: invertAxis ? groupKey : undefined,
146
+ wMin: 100
147
+ }, function (_ref) {
148
+ var _dataItem$groupKey;
149
+ var xIndex = _ref.xIndex,
150
+ yIndex = _ref.yIndex;
151
+ var index = invertAxis ? yIndex : xIndex;
152
+ var dataItem = data[index];
153
+ var total = _this.totalValue(dataItem);
154
+ return {
155
+ children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HoverRect.Tooltip.Title, null, (_dataItem$groupKey = dataItem[groupKey]) === null || _dataItem$groupKey === void 0 ? void 0 : _dataItem$groupKey.toString()), dataDefinitions.map(function (item) {
156
+ return item.checked && /*#__PURE__*/React.createElement(Flex, {
157
+ justifyContent: "space-between",
158
+ key: item.id
159
+ }, /*#__PURE__*/React.createElement(HoverRect.Tooltip.Dot, {
160
+ mr: 4,
161
+ color: item.color
162
+ }, item.label), /*#__PURE__*/React.createElement(Text, {
163
+ bold: true
164
+ }, _this.tooltipValueFormatter(dataItem[item.id])));
165
+ }), showTotalInTooltip === true && /*#__PURE__*/React.createElement(Flex, {
166
+ mt: 2,
167
+ justifyContent: "space-between"
168
+ }, /*#__PURE__*/React.createElement(Box, {
169
+ mr: 4
170
+ }, "Total"), /*#__PURE__*/React.createElement(Text, {
171
+ bold: true
172
+ }, total)))
173
+ };
174
+ });
175
+ }
176
+ }]);
177
+ return HistogramChartComponent;
178
+ }(AbstractChart);
179
+ _defineProperty(HistogramChartComponent, "displayName", 'Chart.Histogram');
180
+ export var HistogramChart = createComponent(HistogramChartComponent);
181
+ //# sourceMappingURL=HistogramChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistogramChart.js","names":["React","createComponent","scaleBand","scaleLinear","scaleTime","Bar","minMax","HoverRect","StackBar","AbstractChart","Box","Flex","Text","HistogramChartComponent","_AbstractChart","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","get","_this$asProps","asProps","xScale","_this$asProps$marginY","marginY","_this$asProps$marginX","marginX","plotWidth","plotHeight","invertAxis","data","groupKey","testItem","range","plotPadding","Date","Number","isNaN","getMilliseconds","domain","map","item","paddingInner","paddingOuter","_this$asProps2","yScale","_this$asProps2$margin","_this$asProps2$margin2","max","isStack","reduce","barSum","Object","values","sum","val","flatValues","_get","_getPrototypeOf","prototype","Math","_toConsumableArray","dataDefinitions","state","length","value","renderChart","_this$asProps3","_this$state","highlightedLine","createElement","x","undefined","y","index","BarComponent","HorizontalBar","commonBarComponentProps","color","transparent","id","checked","_extends","renderTooltip","_this","_this$asProps4","showTotalInTooltip","showTooltip","Tooltip","wMin","_ref","_dataItem$groupKey","xIndex","yIndex","dataItem","total","totalValue","children","Fragment","Title","toString","justifyContent","Dot","mr","label","bold","tooltipValueFormatter","mt","_defineProperty","HistogramChart"],"sources":["../../../../src/component/Chart/HistogramChart.tsx"],"sourcesContent":["import React from 'react';\nimport createComponent from '@semcore/core';\nimport { scaleBand, scaleLinear, ScaleLinear, scaleTime } from 'd3-scale';\n// @ts-ignore\nimport { Bar, minMax, HoverRect, StackBar, BarProps } from '../..';\nimport { AbstractChart } from './AbstractChart';\nimport { HistogramChartData, HistogramChartProps, HistogramChartType } from './HistogramChart.type';\nimport { Box, Flex } from '@semcore/flex-box';\nimport { Text } from '@semcore/typography';\n\nclass HistogramChartComponent extends AbstractChart<HistogramChartData, HistogramChartProps> {\n static displayName = 'Chart.Histogram';\n\n get xScale() {\n const {\n xScale,\n marginY = 30,\n marginX = 30,\n plotWidth,\n plotHeight,\n invertAxis,\n data,\n groupKey,\n } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n const testItem = data[0][groupKey];\n const range = invertAxis\n ? [plotHeight - marginX, this.plotPadding]\n : [marginY, plotWidth - this.plotPadding];\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n const domain = minMax(data, groupKey);\n\n return scaleTime(domain, range);\n }\n\n const domain = data.map((item) => item[groupKey]);\n\n return scaleBand(domain, range).paddingInner(0.05).paddingOuter(0.2);\n }\n\n get yScale(): ScaleLinear<any, any> {\n const {\n yScale,\n marginY = 30,\n marginX = 30,\n plotHeight,\n plotWidth,\n invertAxis,\n data,\n } = this.asProps;\n\n let max: number;\n\n if (this.isStack) {\n max = data.reduce((max, item) => {\n const barSum = Object.values(item).reduce<number>((sum, val) => {\n if (val instanceof Date && !Number.isNaN(val.getMilliseconds())) {\n return sum + val.getMilliseconds();\n }\n\n return sum + (val as number);\n }, 0);\n\n if (barSum > max) {\n max = barSum;\n }\n\n return max;\n }, 0);\n } else {\n const flatValues = super.flatValues;\n\n max = Math.max(...flatValues);\n }\n\n return (\n yScale ??\n scaleLinear()\n .range(\n invertAxis\n ? [marginY, plotWidth - this.plotPadding]\n : [plotHeight - marginX, this.plotPadding],\n )\n .domain([0, max])\n );\n }\n\n get isStack(): boolean {\n const { dataDefinitions } = this.state;\n\n return dataDefinitions.length > 1;\n }\n\n renderChart() {\n const { groupKey, invertAxis } = this.asProps;\n const { dataDefinitions, highlightedLine } = this.state;\n\n if (this.isStack) {\n return (\n <StackBar x={invertAxis ? undefined : groupKey} y={invertAxis ? groupKey : undefined}>\n {dataDefinitions.map((item, index) => {\n const BarComponent = invertAxis ? StackBar.HorizontalBar : StackBar.Bar;\n\n const commonBarComponentProps: BarProps = {\n color: item.color,\n transparent: highlightedLine !== -1 && highlightedLine !== index,\n };\n\n if (invertAxis) {\n commonBarComponentProps.x = item.id;\n } else {\n commonBarComponentProps.y = item.id;\n }\n\n return item.checked && <BarComponent key={item.id} {...commonBarComponentProps} />;\n })}\n </StackBar>\n );\n }\n\n const item = dataDefinitions[0];\n\n return (\n <Bar\n x={invertAxis ? item.id : groupKey}\n y={invertAxis ? groupKey : item.id}\n key={item.id}\n color={item.color}\n />\n );\n }\n\n renderTooltip(): React.ReactNode {\n const { data, groupKey, showTotalInTooltip, showTooltip, invertAxis } = this.asProps;\n const { dataDefinitions } = this.state;\n\n if (!showTooltip) {\n return null;\n }\n\n return (\n <HoverRect.Tooltip\n x={invertAxis ? undefined : groupKey}\n y={invertAxis ? groupKey : undefined}\n wMin={100}\n >\n {({ xIndex, yIndex }: any) => {\n const index = invertAxis ? yIndex : xIndex;\n const dataItem = data[index];\n const total = this.totalValue(dataItem);\n\n return {\n children: (\n <>\n <HoverRect.Tooltip.Title>{dataItem[groupKey]?.toString()}</HoverRect.Tooltip.Title>\n\n {dataDefinitions.map((item) => {\n return (\n item.checked && (\n <Flex justifyContent='space-between' key={item.id}>\n <HoverRect.Tooltip.Dot mr={4} color={item.color}>\n {item.label}\n </HoverRect.Tooltip.Dot>\n <Text bold>{this.tooltipValueFormatter(dataItem[item.id])}</Text>\n </Flex>\n )\n );\n })}\n\n {showTotalInTooltip === true && (\n <Flex mt={2} justifyContent='space-between'>\n <Box mr={4}>Total</Box>\n <Text bold>{total}</Text>\n </Flex>\n )}\n </>\n ),\n };\n }}\n </HoverRect.Tooltip>\n );\n }\n}\n\nexport const HistogramChart: HistogramChartType = createComponent(HistogramChartComponent);\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,MAAM,eAAe;AAC3C,SAASC,SAAS,EAAEC,WAAW,EAAeC,SAAS,QAAQ,UAAU;AACzE;AACA,SAASC,GAAG,EAAEC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAkB,OAAO;AAClE,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,GAAG,EAAEC,IAAI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,aAAA,CAAC/D,IAAI;cAAC8F,cAAc,EAAC,eAAe;cAACnF,GAAG,EAAEuB,IAAI,CAACuC;YAAG,gBAChDpF,KAAA,CAAA0E,aAAA,CAACnE,SAAS,CAACqF,OAAO,CAACc,GAAG;cAACC,EAAE,EAAE,CAAE;cAACzB,KAAK,EAAErC,IAAI,CAACqC;YAAM,GAC7CrC,IAAI,CAAC+D,KAAK,CACW,eACxB5G,KAAA,CAAA0E,aAAA,CAAC9D,IAAI;cAACiG,IAAI;YAAA,GAAErB,KAAI,CAACsB,qBAAqB,CAACZ,QAAQ,CAACrD,IAAI,CAACuC,EAAE,CAAC,CAAC,CAAQ,CAEpE;UAEL,CAAC,CAAC,EAEDM,kBAAkB,KAAK,IAAI,iBAC1B1F,KAAA,CAAA0E,aAAA,CAAC/D,IAAI;YAACoG,EAAE,EAAE,CAAE;YAACN,cAAc,EAAC;UAAe,gBACzCzG,KAAA,CAAA0E,aAAA,CAAChE,GAAG;YAACiG,EAAE,EAAE;UAAE,GAAC,OAAK,CAAM,eACvB3G,KAAA,CAAA0E,aAAA,CAAC9D,IAAI;YAACiG,IAAI;UAAA,GAAEV,KAAK,CAAQ,CAE5B;QAGP,CAAC;MACH,CAAC,CACiB;IAExB;EAAC;EAAA,OAAAtF,uBAAA;AAAA,EAhLmCJ,aAAa;AAAAuG,eAAA,CAA7CnG,uBAAuB,iBACN,iBAAiB;AAkLxC,OAAO,IAAMoG,cAAkC,GAAGhH,eAAe,CAACY,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=HistogramChart.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistogramChart.type.js","names":[],"sources":["../../../../src/component/Chart/HistogramChart.type.ts"],"sourcesContent":["import { Intergalactic } from '@semcore/core';\nimport { Flex } from '@semcore/flex-box';\nimport { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';\nimport { BaseChartProps } from './AbstractChart.type';\n\nexport type HistogramChartData = Array<Record<string, number | Date>>;\n\nexport type HistogramChartProps = BaseChartProps<HistogramChartData> & {\n groupKey: string;\n xScale?: ScaleBand<any> | ScaleTime<any, any>;\n yScale?: ScaleLinear<any, any>;\n};\n\nexport type HistogramChartType = Intergalactic.Component<typeof Flex, HistogramChartProps>;\n"],"mappings":""}
@@ -0,0 +1,139 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _get from "@babel/runtime/helpers/get";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+ import _inherits from "@babel/runtime/helpers/inherits";
7
+ import _createSuper from "@babel/runtime/helpers/createSuper";
8
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
+ import React from 'react';
10
+ import createComponent from '@semcore/core';
11
+ import { scaleLinear, scaleTime } from 'd3-scale';
12
+ // @ts-ignore
13
+ import { Line, minMax, HoverLine } from '../..';
14
+ import { AbstractChart } from './AbstractChart';
15
+ import { Box, Flex } from '@semcore/flex-box';
16
+ import { Text } from '@semcore/typography';
17
+ var LineChartComponent = /*#__PURE__*/function (_AbstractChart) {
18
+ _inherits(LineChartComponent, _AbstractChart);
19
+ var _super = _createSuper(LineChartComponent);
20
+ function LineChartComponent() {
21
+ _classCallCheck(this, LineChartComponent);
22
+ return _super.apply(this, arguments);
23
+ }
24
+ _createClass(LineChartComponent, [{
25
+ key: "xScale",
26
+ get: function get() {
27
+ var _this$asProps = this.asProps,
28
+ xScale = _this$asProps.xScale,
29
+ _this$asProps$marginY = _this$asProps.marginY,
30
+ marginY = _this$asProps$marginY === void 0 ? 30 : _this$asProps$marginY,
31
+ plotWidth = _this$asProps.plotWidth,
32
+ data = _this$asProps.data,
33
+ groupKey = _this$asProps.groupKey;
34
+ if (xScale) {
35
+ return xScale;
36
+ }
37
+ var testItem = data[0][groupKey];
38
+ var range = [marginY, plotWidth - this.plotPadding];
39
+ var domain = minMax(data, groupKey);
40
+ if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {
41
+ return scaleTime(domain, range);
42
+ }
43
+ return scaleLinear(domain, range);
44
+ }
45
+ }, {
46
+ key: "yScale",
47
+ get: function get() {
48
+ var _this$asProps2 = this.asProps,
49
+ yScale = _this$asProps2.yScale,
50
+ _this$asProps2$margin = _this$asProps2.marginX,
51
+ marginX = _this$asProps2$margin === void 0 ? 30 : _this$asProps2$margin,
52
+ plotHeight = _this$asProps2.plotHeight;
53
+ if (yScale) {
54
+ return yScale;
55
+ }
56
+ var flatValues = _get(_getPrototypeOf(LineChartComponent.prototype), "flatValues", this);
57
+ var max = Math.max.apply(Math, _toConsumableArray(flatValues));
58
+ var min = Math.min.apply(Math, _toConsumableArray(flatValues));
59
+ return scaleLinear().range([plotHeight - marginX, this.plotPadding]).domain([min, max]);
60
+ }
61
+ }, {
62
+ key: "renderChart",
63
+ value: function renderChart() {
64
+ var _this$asProps3 = this.asProps,
65
+ groupKey = _this$asProps3.groupKey,
66
+ curve = _this$asProps3.curve,
67
+ showDots = _this$asProps3.showDots,
68
+ area = _this$asProps3.area,
69
+ areaCurve = _this$asProps3.areaCurve;
70
+ var _this$state = this.state,
71
+ dataDefinitions = _this$state.dataDefinitions,
72
+ highlightedLine = _this$state.highlightedLine;
73
+ return dataDefinitions.map(function (item, index) {
74
+ return item.checked && /*#__PURE__*/React.createElement(Line, {
75
+ x: groupKey.toString(),
76
+ y: item.id,
77
+ key: item.id,
78
+ color: item.color,
79
+ transparent: highlightedLine !== -1 && highlightedLine !== index,
80
+ curve: curve
81
+ }, showDots && /*#__PURE__*/React.createElement(Line.Dots, {
82
+ display: true
83
+ }), (area === null || area === void 0 ? void 0 : area[item.id]) && /*#__PURE__*/React.createElement(Line.Area, {
84
+ area: area[item.id],
85
+ y0: 'y0',
86
+ y1: 'y1',
87
+ curve: areaCurve
88
+ }));
89
+ });
90
+ }
91
+ }, {
92
+ key: "renderTooltip",
93
+ value: function renderTooltip() {
94
+ var _this = this;
95
+ var _this$asProps4 = this.asProps,
96
+ data = _this$asProps4.data,
97
+ groupKey = _this$asProps4.groupKey,
98
+ showTotalInTooltip = _this$asProps4.showTotalInTooltip,
99
+ showTooltip = _this$asProps4.showTooltip;
100
+ var dataDefinitions = this.state.dataDefinitions;
101
+ if (!showTooltip) {
102
+ return null;
103
+ }
104
+ return /*#__PURE__*/React.createElement(HoverLine.Tooltip, {
105
+ x: groupKey,
106
+ wMin: 100
107
+ }, function (_ref) {
108
+ var _dataItem$groupKey;
109
+ var xIndex = _ref.xIndex;
110
+ var dataItem = data[xIndex];
111
+ var total = _this.totalValue(dataItem);
112
+ return {
113
+ children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HoverLine.Tooltip.Title, null, (_dataItem$groupKey = dataItem[groupKey]) === null || _dataItem$groupKey === void 0 ? void 0 : _dataItem$groupKey.toString()), dataDefinitions.map(function (item) {
114
+ return item.checked && /*#__PURE__*/React.createElement(Flex, {
115
+ justifyContent: "space-between",
116
+ key: item.id
117
+ }, /*#__PURE__*/React.createElement(HoverLine.Tooltip.Dot, {
118
+ mr: 4,
119
+ color: item.color
120
+ }, item.label), /*#__PURE__*/React.createElement(Text, {
121
+ bold: true
122
+ }, _this.tooltipValueFormatter(dataItem[item.id])));
123
+ }), showTotalInTooltip === true && /*#__PURE__*/React.createElement(Flex, {
124
+ mt: 2,
125
+ justifyContent: "space-between"
126
+ }, /*#__PURE__*/React.createElement(Box, {
127
+ mr: 4
128
+ }, "Total"), /*#__PURE__*/React.createElement(Text, {
129
+ bold: true
130
+ }, total)))
131
+ };
132
+ });
133
+ }
134
+ }]);
135
+ return LineChartComponent;
136
+ }(AbstractChart);
137
+ _defineProperty(LineChartComponent, "displayName", 'Chart.Line');
138
+ export var LineChart = createComponent(LineChartComponent);
139
+ //# sourceMappingURL=LineChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineChart.js","names":["React","createComponent","scaleLinear","scaleTime","Line","minMax","HoverLine","AbstractChart","Box","Flex","Text","LineChartComponent","_AbstractChart","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","get","_this$asProps","asProps","xScale","_this$asProps$marginY","marginY","plotWidth","data","groupKey","testItem","range","plotPadding","domain","Date","Number","isNaN","getMilliseconds","_this$asProps2","yScale","_this$asProps2$margin","marginX","plotHeight","flatValues","_get","_getPrototypeOf","prototype","max","Math","_toConsumableArray","min","value","renderChart","_this$asProps3","curve","showDots","area","areaCurve","_this$state","state","dataDefinitions","highlightedLine","map","item","index","checked","createElement","x","toString","y","id","color","transparent","Dots","display","Area","y0","y1","renderTooltip","_this","_this$asProps4","showTotalInTooltip","showTooltip","Tooltip","wMin","_ref","_dataItem$groupKey","xIndex","dataItem","total","totalValue","children","Fragment","Title","justifyContent","Dot","mr","label","bold","tooltipValueFormatter","mt","_defineProperty","LineChart"],"sources":["../../../../src/component/Chart/LineChart.tsx"],"sourcesContent":["import React from 'react';\nimport createComponent from '@semcore/core';\nimport { LineChartData, LineChartProps, LineChartType } from './LineChart.type';\nimport { ScaleLinear, scaleLinear, scaleTime } from 'd3-scale';\n// @ts-ignore\nimport { Line, minMax, HoverLine } from '../..';\nimport { AbstractChart } from './AbstractChart';\nimport { Box, Flex } from '@semcore/flex-box';\nimport { Text } from '@semcore/typography';\n\nclass LineChartComponent extends AbstractChart<LineChartData, LineChartProps> {\n static displayName = 'Chart.Line';\n\n protected get xScale() {\n const { xScale, marginY = 30, plotWidth, data, groupKey } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n const testItem = data[0][groupKey];\n const range = [marginY, plotWidth - this.plotPadding];\n const domain = minMax(data, groupKey);\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n return scaleTime(domain, range);\n }\n\n return scaleLinear(domain, range);\n }\n\n protected get yScale(): ScaleLinear<any, any> {\n const { yScale, marginX = 30, plotHeight } = this.asProps;\n\n if (yScale) {\n return yScale;\n }\n\n const flatValues = super.flatValues;\n\n const max = Math.max(...flatValues);\n const min = Math.min(...flatValues);\n\n return scaleLinear()\n .range([plotHeight - marginX, this.plotPadding])\n .domain([min, max]);\n }\n\n protected renderChart() {\n const { groupKey, curve, showDots, area, areaCurve } = this.asProps;\n const { dataDefinitions, highlightedLine } = this.state;\n\n return dataDefinitions.map((item, index) => {\n return (\n item.checked && (\n <Line\n x={groupKey.toString()}\n y={item.id}\n key={item.id}\n color={item.color}\n transparent={highlightedLine !== -1 && highlightedLine !== index}\n curve={curve}\n >\n {showDots && <Line.Dots display />}\n {area?.[item.id] && (\n <Line.Area area={area[item.id]} y0={'y0'} y1={'y1'} curve={areaCurve} />\n )}\n </Line>\n )\n );\n });\n }\n\n protected renderTooltip() {\n const { data, groupKey, showTotalInTooltip, showTooltip } = this.asProps;\n const { dataDefinitions } = this.state;\n\n if (!showTooltip) {\n return null;\n }\n\n return (\n <HoverLine.Tooltip x={groupKey} wMin={100}>\n {({ xIndex }: any) => {\n const dataItem = data[xIndex];\n const total = this.totalValue(dataItem);\n\n return {\n children: (\n <>\n <HoverLine.Tooltip.Title>{dataItem[groupKey]?.toString()}</HoverLine.Tooltip.Title>\n\n {dataDefinitions.map((item) => {\n return (\n item.checked && (\n <Flex justifyContent='space-between' key={item.id}>\n <HoverLine.Tooltip.Dot mr={4} color={item.color}>\n {item.label}\n </HoverLine.Tooltip.Dot>\n <Text bold>{this.tooltipValueFormatter(dataItem[item.id])}</Text>\n </Flex>\n )\n );\n })}\n\n {showTotalInTooltip === true && (\n <Flex mt={2} justifyContent='space-between'>\n <Box mr={4}>Total</Box>\n <Text bold>{total}</Text>\n </Flex>\n )}\n </>\n ),\n };\n }}\n </HoverLine.Tooltip>\n );\n }\n}\n\nexport const LineChart: LineChartType = createComponent(LineChartComponent);\n"],"mappings":";;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,MAAM,eAAe;AAE3C,SAAsBC,WAAW,EAAEC,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AkE,aAAA,CAACzD,IAAI;YAAC2F,EAAE,EAAE,CAAE;YAACN,cAAc,EAAC;UAAe,gBACzC9F,KAAA,CAAAkE,aAAA,CAAC1D,GAAG;YAACwF,EAAE,EAAE;UAAE,GAAC,OAAK,CAAM,eACvBhG,KAAA,CAAAkE,aAAA,CAACxD,IAAI;YAACwF,IAAI;UAAA,GAAET,KAAK,CAAQ,CAE5B;QAGP,CAAC;MACH,CAAC,CACiB;IAExB;EAAC;EAAA,OAAA9E,kBAAA;AAAA,EA3G8BJ,aAAa;AAAA8F,eAAA,CAAxC1F,kBAAkB,iBACD,YAAY;AA6GnC,OAAO,IAAM2F,SAAwB,GAAGrG,eAAe,CAACU,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LineChart.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineChart.type.js","names":[],"sources":["../../../../src/component/Chart/LineChart.type.ts"],"sourcesContent":["import { Intergalactic } from '@semcore/core';\nimport { Flex } from '@semcore/flex-box';\nimport { interpolateValue } from '../../utils';\nimport { ScaleLinear, ScaleTime } from 'd3-scale';\nimport { CurveFactory } from 'd3-shape';\nimport { BaseChartProps } from './AbstractChart.type';\nimport { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\n\ntype AreaItem = {\n x: number;\n y0: number;\n y1: number;\n};\n\nexport type LineChartData = Array<Record<string, string | number | typeof interpolateValue | Date>>;\n\nexport type LineChartProps = BaseChartProps<LineChartData> & {\n groupKey: string;\n area?: Record<LegendItemKey, AreaItem[]>;\n xScale?: ScaleLinear<any, any> | ScaleTime<any, any>;\n yScale?: ScaleLinear<any, any>;\n showDots?: boolean;\n curve?: CurveFactory;\n areaCurve?: CurveFactory;\n};\n\nexport type LineChartType = Intergalactic.Component<typeof Flex, LineChartProps>;\n"],"mappings":""}
@@ -0,0 +1,113 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _get from "@babel/runtime/helpers/get";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+ import _inherits from "@babel/runtime/helpers/inherits";
7
+ import _createSuper from "@babel/runtime/helpers/createSuper";
8
+ import React from 'react';
9
+ import createComponent from '@semcore/core';
10
+ import { scaleLinear } from 'd3-scale';
11
+ import { AbstractChart } from './AbstractChart';
12
+ // @ts-ignore
13
+ import { Radar } from '../..';
14
+ var RadarChartComponent = /*#__PURE__*/function (_AbstractChart) {
15
+ _inherits(RadarChartComponent, _AbstractChart);
16
+ var _super = _createSuper(RadarChartComponent);
17
+ function RadarChartComponent() {
18
+ _classCallCheck(this, RadarChartComponent);
19
+ return _super.apply(this, arguments);
20
+ }
21
+ _createClass(RadarChartComponent, [{
22
+ key: "renderChart",
23
+ value: function renderChart() {
24
+ var _this$asProps = this.asProps,
25
+ groupKey = _this$asProps.groupKey,
26
+ showDots = _this$asProps.showDots,
27
+ circle = _this$asProps.circle;
28
+ var _this$state = this.state,
29
+ dataDefinitions = _this$state.dataDefinitions,
30
+ highlightedLine = _this$state.highlightedLine;
31
+ return /*#__PURE__*/React.createElement(Radar, {
32
+ scale: this.xScale,
33
+ type: circle ? 'circle' : undefined
34
+ }, /*#__PURE__*/React.createElement(Radar.Axis, {
35
+ dataKey: groupKey
36
+ }, /*#__PURE__*/React.createElement(Radar.Axis.Ticks, null), /*#__PURE__*/React.createElement(Radar.Axis.Labels, null)), dataDefinitions.map(function (item) {
37
+ return item.checked && /*#__PURE__*/React.createElement(Radar.Polygon, {
38
+ dataKey: item.id,
39
+ key: item.id,
40
+ color: item.color
41
+ }, /*#__PURE__*/React.createElement(Radar.Polygon.Line, null), showDots && /*#__PURE__*/React.createElement(Radar.Polygon.Dots, null));
42
+ }), this.renderRadarTooltip());
43
+ }
44
+ }, {
45
+ key: "renderRadarTooltip",
46
+ value: function renderRadarTooltip() {
47
+ var _this = this;
48
+ var _this$asProps2 = this.asProps,
49
+ data = _this$asProps2.data,
50
+ groupKey = _this$asProps2.groupKey,
51
+ showTooltip = _this$asProps2.showTooltip;
52
+ var dataDefinitions = this.state.dataDefinitions;
53
+ if (!showTooltip) {
54
+ return null;
55
+ }
56
+ return /*#__PURE__*/React.createElement(Radar.Tooltip, {
57
+ wMin: 100
58
+ }, function (_ref) {
59
+ var _data$groupKey;
60
+ var index = _ref.index;
61
+ return {
62
+ children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Radar.Tooltip.Title, null, (_data$groupKey = data[groupKey]) === null || _data$groupKey === void 0 ? void 0 : _data$groupKey[index]), dataDefinitions.map(function (item) {
63
+ var _data$item$id;
64
+ var value = (_data$item$id = data[item.id]) === null || _data$item$id === void 0 ? void 0 : _data$item$id[index];
65
+ return item.checked && /*#__PURE__*/React.createElement(Radar.Tooltip.Dot, {
66
+ color: item.color,
67
+ key: item.id
68
+ }, _this.tooltipValueFormatter(value));
69
+ }))
70
+ };
71
+ });
72
+ }
73
+
74
+ // By default, tooltip will render in Plot component.
75
+ // In RadarChart, we need to render it in Radar component, so we use renderRadarTooltip method
76
+ }, {
77
+ key: "renderTooltip",
78
+ value: function renderTooltip() {
79
+ return null;
80
+ }
81
+ }, {
82
+ key: "dataKeys",
83
+ get: function get() {
84
+ var _this$props = this.props,
85
+ data = _this$props.data,
86
+ groupKey = _this$props.groupKey;
87
+ var legendKeys = Object.keys(data).filter(function (key) {
88
+ return key !== groupKey;
89
+ });
90
+ return legendKeys;
91
+ }
92
+ }, {
93
+ key: "xScale",
94
+ get: function get() {
95
+ var _this$asProps$scale;
96
+ return (_this$asProps$scale = this.asProps.scale) !== null && _this$asProps$scale !== void 0 ? _this$asProps$scale : scaleLinear().domain(this.domain);
97
+ }
98
+ }, {
99
+ key: "yScale",
100
+ get: function get() {
101
+ var _this$asProps$scale2;
102
+ return (_this$asProps$scale2 = this.asProps.scale) !== null && _this$asProps$scale2 !== void 0 ? _this$asProps$scale2 : scaleLinear().domain(this.domain);
103
+ }
104
+ }, {
105
+ key: "domain",
106
+ get: function get() {
107
+ return [Math.min.apply(Math, _toConsumableArray(_get(_getPrototypeOf(RadarChartComponent.prototype), "flatValues", this))), Math.max.apply(Math, _toConsumableArray(_get(_getPrototypeOf(RadarChartComponent.prototype), "flatValues", this)))];
108
+ }
109
+ }]);
110
+ return RadarChartComponent;
111
+ }(AbstractChart);
112
+ export var RadarChart = createComponent(RadarChartComponent);
113
+ //# sourceMappingURL=RadarChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadarChart.js","names":["React","createComponent","scaleLinear","AbstractChart","Radar","RadarChartComponent","_AbstractChart","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","renderChart","_this$asProps","asProps","groupKey","showDots","circle","_this$state","state","dataDefinitions","highlightedLine","createElement","scale","xScale","type","undefined","Axis","dataKey","Ticks","Labels","map","item","checked","Polygon","id","color","Line","Dots","renderRadarTooltip","_this","_this$asProps2","data","showTooltip","Tooltip","wMin","_ref","_data$groupKey","index","children","Fragment","Title","_data$item$id","Dot","tooltipValueFormatter","renderTooltip","get","_this$props","props","legendKeys","Object","keys","filter","_this$asProps$scale","domain","_this$asProps$scale2","Math","min","_toConsumableArray","_get","_getPrototypeOf","prototype","max","RadarChart"],"sources":["../../../../src/component/Chart/RadarChart.tsx"],"sourcesContent":["import React from 'react';\nimport createComponent from '@semcore/core';\nimport { scaleLinear, ScaleLinear } from 'd3-scale';\nimport { AbstractChart } from './AbstractChart';\nimport { RadarChartData, RadarChartProps, RadarChartType } from './RadarChart.type';\n// @ts-ignore\nimport { Radar } from '../..';\n\nclass RadarChartComponent extends AbstractChart<RadarChartData, RadarChartProps> {\n protected renderChart(): React.ReactNode {\n const { groupKey, showDots, circle } = this.asProps;\n const { dataDefinitions, highlightedLine } = this.state;\n\n return (\n <Radar scale={this.xScale} type={circle ? 'circle' : undefined}>\n <Radar.Axis dataKey={groupKey}>\n <Radar.Axis.Ticks />\n <Radar.Axis.Labels />\n </Radar.Axis>\n\n {dataDefinitions.map((item) => {\n return (\n item.checked && (\n <Radar.Polygon dataKey={item.id} key={item.id} color={item.color}>\n <Radar.Polygon.Line />\n {showDots && <Radar.Polygon.Dots />}\n </Radar.Polygon>\n )\n );\n })}\n {this.renderRadarTooltip()}\n </Radar>\n );\n }\n\n protected renderRadarTooltip(): React.ReactNode {\n const { data, groupKey, showTooltip } = this.asProps;\n const { dataDefinitions } = this.state;\n\n if (!showTooltip) {\n return null;\n }\n\n return (\n <Radar.Tooltip wMin={100}>\n {({ index }: any) => {\n return {\n children: (\n <>\n <Radar.Tooltip.Title>{data[groupKey]?.[index]}</Radar.Tooltip.Title>\n\n {dataDefinitions.map((item) => {\n const value = data[item.id]?.[index];\n\n return (\n item.checked && (\n <Radar.Tooltip.Dot color={item.color} key={item.id}>\n {this.tooltipValueFormatter(value)}\n </Radar.Tooltip.Dot>\n )\n );\n })}\n </>\n ),\n };\n }}\n </Radar.Tooltip>\n );\n }\n\n // By default, tooltip will render in Plot component.\n // In RadarChart, we need to render it in Radar component, so we use renderRadarTooltip method\n protected renderTooltip(): React.ReactNode {\n return null;\n }\n\n protected get dataKeys(): string[] {\n const { data, groupKey } = this.props;\n\n const legendKeys: string[] = Object.keys(data).filter((key) => key !== groupKey);\n\n return legendKeys;\n }\n\n protected get xScale(): ScaleLinear<any, any> {\n return this.asProps.scale ?? scaleLinear().domain(this.domain);\n }\n\n protected get yScale(): ScaleLinear<any, any> {\n return this.asProps.scale ?? scaleLinear().domain(this.domain);\n }\n\n private get domain(): [number, number] {\n return [Math.min(...super.flatValues), Math.max(...super.flatValues)];\n }\n}\n\nexport const RadarChart: RadarChartType = createComponent(RadarChartComponent);\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,MAAM,eAAe;AAC3C,SAASC,WAAW,QAAqB,UAAU;AACnD,SAASC,aAAa,QAAQ,iBAAi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M,CAAC,IAAI,CAACA,MAAM,CAAC;IAChE;EAAC;IAAAtD,GAAA;IAAA8C,GAAA,EAED,SAAAA,IAAA,EAAuC;MACrC,OAAO,CAACU,IAAI,CAACC,GAAG,CAAA5D,KAAA,CAAR2D,IAAI,EAAAE,kBAAA,CAAAC,IAAA,CAAAC,eAAA,CAAArE,mBAAA,CAAAsE,SAAA,wBAAyB,EAAEL,IAAI,CAACM,GAAG,CAAAjE,KAAA,CAAR2D,IAAI,EAAAE,kBAAA,CAAAC,IAAA,CAAAC,eAAA,CAAArE,mBAAA,CAAAsE,SAAA,wBAAyB,CAAC;IACvE;EAAC;EAAA,OAAAtE,mBAAA;AAAA,EAtF+BF,aAAa;AAyF/C,OAAO,IAAM0E,UAA0B,GAAG5E,eAAe,CAACI,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=RadarChart.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadarChart.type.js","names":[],"sources":["../../../../src/component/Chart/RadarChart.type.ts"],"sourcesContent":["import { Intergalactic } from '@semcore/core';\nimport { Flex } from '@semcore/flex-box';\nimport { ScaleLinear } from 'd3-scale';\nimport { BaseChartProps } from './AbstractChart.type';\n\nexport type RadarChartData = Record<string, string[] | number[]>;\n\nexport type RadarChartProps = BaseChartProps<RadarChartData> & {\n groupKey: string;\n scale?: ScaleLinear<any, any>;\n xScale?: never;\n yScale?: never;\n showDots?: boolean;\n circle?: boolean;\n};\n\nexport type RadarChartType = Intergalactic.Component<typeof Flex, RadarChartProps>;\n"],"mappings":""}