@mui/x-charts 7.6.1 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/BarChart/BarChart.d.ts +1 -1
  2. package/BarChart/BarChart.js +2 -2
  3. package/BarChart/BarPlot.js +2 -2
  4. package/BarChart/formatter.js +2 -2
  5. package/BarChart/getColor.d.ts +1 -1
  6. package/BarChart/getColor.js +4 -4
  7. package/BarChart/plugin.d.ts +2 -0
  8. package/BarChart/plugin.js +17 -0
  9. package/CHANGELOG.md +147 -0
  10. package/ChartContainer/ChartContainer.d.ts +15 -3
  11. package/ChartContainer/ChartContainer.js +70 -22
  12. package/ChartContainer/defaultPlugins.d.ts +2 -0
  13. package/ChartContainer/defaultPlugins.js +11 -0
  14. package/ChartContainer/usePluginsMerge.d.ts +10 -0
  15. package/ChartContainer/usePluginsMerge.js +39 -0
  16. package/ChartsLegend/ChartsLegend.js +2 -2
  17. package/ChartsLegend/utils.js +4 -1
  18. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  19. package/ChartsOverlay/index.d.ts +1 -0
  20. package/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
  21. package/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
  22. package/ChartsText/ChartsText.js +1 -3
  23. package/ChartsTooltip/ChartsAxisTooltipContent.js +9 -15
  24. package/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
  25. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +5 -4
  26. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  27. package/ChartsTooltip/utils.d.ts +1 -7
  28. package/ChartsTooltip/utils.js +2 -10
  29. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  30. package/ChartsXAxis/ChartsXAxis.js +17 -19
  31. package/ChartsYAxis/ChartsYAxis.js +17 -19
  32. package/LineChart/AreaPlot.js +2 -2
  33. package/LineChart/LineChart.d.ts +2 -2
  34. package/LineChart/LineChart.js +3 -3
  35. package/LineChart/LineHighlightPlot.js +2 -2
  36. package/LineChart/LinePlot.js +2 -2
  37. package/LineChart/MarkPlot.js +2 -2
  38. package/LineChart/formatter.js +2 -2
  39. package/LineChart/getColor.d.ts +1 -1
  40. package/LineChart/getColor.js +2 -2
  41. package/LineChart/plugin.d.ts +2 -0
  42. package/LineChart/plugin.js +17 -0
  43. package/PieChart/PieChart.d.ts +2 -2
  44. package/PieChart/PieChart.js +3 -3
  45. package/PieChart/PiePlot.js +2 -2
  46. package/PieChart/plugin.d.ts +2 -0
  47. package/PieChart/plugin.js +14 -0
  48. package/ResponsiveChartContainer/ResizableContainer.d.ts +10 -0
  49. package/ResponsiveChartContainer/ResizableContainer.js +32 -0
  50. package/ResponsiveChartContainer/ResponsiveChartContainer.js +32 -24
  51. package/ScatterChart/ScatterChart.d.ts +2 -2
  52. package/ScatterChart/ScatterChart.js +3 -3
  53. package/ScatterChart/ScatterPlot.js +2 -2
  54. package/ScatterChart/formatter.js +2 -3
  55. package/ScatterChart/getColor.d.ts +1 -1
  56. package/ScatterChart/getColor.js +2 -2
  57. package/ScatterChart/plugin.d.ts +2 -0
  58. package/ScatterChart/plugin.js +17 -0
  59. package/SparkLineChart/SparkLineChart.d.ts +9 -4
  60. package/SparkLineChart/SparkLineChart.js +58 -2
  61. package/context/CartesianContextProvider.d.ts +21 -10
  62. package/context/CartesianContextProvider.js +7 -20
  63. package/context/ColorProvider.d.ts +12 -0
  64. package/context/ColorProvider.js +25 -0
  65. package/context/DrawingProvider.d.ts +3 -1
  66. package/context/DrawingProvider.js +9 -2
  67. package/context/HighlightedProvider/HighlightedContext.d.ts +2 -1
  68. package/context/HighlightedProvider/HighlightedContext.js +8 -5
  69. package/context/HighlightedProvider/HighlightedProvider.js +15 -12
  70. package/context/HighlightedProvider/useHighlighted.js +6 -3
  71. package/context/HighlightedProvider/useItemHighlighted.js +2 -8
  72. package/context/SeriesContextProvider.d.ts +16 -5
  73. package/context/SeriesContextProvider.js +14 -17
  74. package/context/context.types.d.ts +4 -0
  75. package/context/context.types.js +5 -0
  76. package/esm/BarChart/BarChart.js +2 -2
  77. package/esm/BarChart/BarPlot.js +2 -2
  78. package/esm/BarChart/formatter.js +1 -1
  79. package/esm/BarChart/getColor.js +4 -4
  80. package/esm/BarChart/plugin.js +10 -0
  81. package/esm/ChartContainer/ChartContainer.js +71 -23
  82. package/esm/ChartContainer/defaultPlugins.js +5 -0
  83. package/esm/ChartContainer/usePluginsMerge.js +31 -0
  84. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  85. package/esm/ChartsLegend/utils.js +4 -1
  86. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  87. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
  88. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
  89. package/esm/ChartsText/ChartsText.js +1 -3
  90. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +8 -14
  91. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
  92. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +5 -4
  93. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  94. package/esm/ChartsTooltip/utils.js +2 -8
  95. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  96. package/esm/ChartsXAxis/ChartsXAxis.js +17 -19
  97. package/esm/ChartsYAxis/ChartsYAxis.js +17 -19
  98. package/esm/LineChart/AreaPlot.js +2 -2
  99. package/esm/LineChart/LineChart.js +3 -3
  100. package/esm/LineChart/LineHighlightPlot.js +2 -2
  101. package/esm/LineChart/LinePlot.js +2 -2
  102. package/esm/LineChart/MarkPlot.js +2 -2
  103. package/esm/LineChart/formatter.js +1 -1
  104. package/esm/LineChart/getColor.js +2 -2
  105. package/esm/LineChart/plugin.js +10 -0
  106. package/esm/PieChart/PieChart.js +3 -3
  107. package/esm/PieChart/PiePlot.js +2 -2
  108. package/esm/PieChart/plugin.js +7 -0
  109. package/esm/ResponsiveChartContainer/ResizableContainer.js +26 -0
  110. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +31 -23
  111. package/esm/ScatterChart/ScatterChart.js +3 -3
  112. package/esm/ScatterChart/ScatterPlot.js +2 -2
  113. package/esm/ScatterChart/formatter.js +1 -1
  114. package/esm/ScatterChart/getColor.js +2 -2
  115. package/esm/ScatterChart/plugin.js +10 -0
  116. package/esm/SparkLineChart/SparkLineChart.js +58 -2
  117. package/esm/context/CartesianContextProvider.js +7 -20
  118. package/esm/context/ColorProvider.js +16 -0
  119. package/esm/context/DrawingProvider.js +9 -2
  120. package/esm/context/HighlightedProvider/HighlightedContext.js +8 -5
  121. package/esm/context/HighlightedProvider/HighlightedProvider.js +15 -12
  122. package/esm/context/HighlightedProvider/useHighlighted.js +6 -3
  123. package/esm/context/HighlightedProvider/useItemHighlighted.js +2 -6
  124. package/esm/context/SeriesContextProvider.js +14 -17
  125. package/esm/context/context.types.js +1 -0
  126. package/esm/hooks/index.js +1 -0
  127. package/esm/hooks/useColor.js +9 -0
  128. package/esm/hooks/useColorScale.js +27 -0
  129. package/esm/hooks/useInteractionItemProps.js +2 -2
  130. package/esm/hooks/useReducedMotion.js +7 -0
  131. package/esm/hooks/useSeries.js +6 -3
  132. package/esm/hooks/useSvgRef.js +6 -3
  133. package/esm/internals/configInit.js +20 -0
  134. package/esm/internals/defaultizeValueFormatter.js +2 -3
  135. package/esm/internals/index.js +27 -0
  136. package/esm/internals/isCartesian.js +7 -0
  137. package/esm/internals/warning.js +13 -0
  138. package/esm/models/index.js +1 -0
  139. package/esm/models/plugin.js +1 -0
  140. package/esm/models/seriesType/index.js +6 -0
  141. package/hooks/index.d.ts +1 -0
  142. package/hooks/index.js +12 -0
  143. package/hooks/useColor.d.ts +4 -0
  144. package/hooks/useColor.js +17 -0
  145. package/hooks/useColorScale.d.ts +4 -0
  146. package/hooks/useColorScale.js +37 -0
  147. package/hooks/useInteractionItemProps.js +1 -1
  148. package/hooks/useReducedMotion.js +7 -0
  149. package/hooks/useSeries.d.ts +6 -11
  150. package/hooks/useSeries.js +6 -3
  151. package/hooks/useSvgRef.js +6 -3
  152. package/hooks/useTicks.d.ts +4 -2
  153. package/index.js +1 -1
  154. package/internals/configInit.d.ts +9 -0
  155. package/internals/configInit.js +26 -0
  156. package/internals/defaultizeColor.d.ts +8 -8
  157. package/internals/defaultizeValueFormatter.d.ts +1 -2
  158. package/internals/defaultizeValueFormatter.js +2 -3
  159. package/internals/index.d.ts +17 -0
  160. package/internals/index.js +203 -0
  161. package/internals/isCartesian.d.ts +7 -0
  162. package/internals/isCartesian.js +14 -0
  163. package/internals/package.json +6 -0
  164. package/internals/warning.d.ts +1 -0
  165. package/internals/warning.js +19 -0
  166. package/models/axis.d.ts +4 -5
  167. package/models/index.d.ts +1 -0
  168. package/models/index.js +11 -0
  169. package/models/plugin.d.ts +16 -0
  170. package/models/plugin.js +5 -0
  171. package/models/seriesType/config.d.ts +30 -5
  172. package/models/seriesType/index.d.ts +8 -11
  173. package/models/seriesType/index.js +6 -0
  174. package/modern/BarChart/BarChart.js +2 -2
  175. package/modern/BarChart/BarPlot.js +2 -2
  176. package/modern/BarChart/formatter.js +1 -1
  177. package/modern/BarChart/getColor.js +4 -4
  178. package/modern/BarChart/plugin.js +10 -0
  179. package/modern/ChartContainer/ChartContainer.js +71 -23
  180. package/modern/ChartContainer/defaultPlugins.js +5 -0
  181. package/modern/ChartContainer/usePluginsMerge.js +31 -0
  182. package/modern/ChartsLegend/ChartsLegend.js +2 -2
  183. package/modern/ChartsLegend/utils.js +4 -1
  184. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
  185. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
  186. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
  187. package/modern/ChartsText/ChartsText.js +1 -3
  188. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +8 -14
  189. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
  190. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +5 -4
  191. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
  192. package/modern/ChartsTooltip/utils.js +2 -8
  193. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  194. package/modern/ChartsXAxis/ChartsXAxis.js +17 -19
  195. package/modern/ChartsYAxis/ChartsYAxis.js +17 -19
  196. package/modern/LineChart/AreaPlot.js +2 -2
  197. package/modern/LineChart/LineChart.js +3 -3
  198. package/modern/LineChart/LineHighlightPlot.js +2 -2
  199. package/modern/LineChart/LinePlot.js +2 -2
  200. package/modern/LineChart/MarkPlot.js +2 -2
  201. package/modern/LineChart/formatter.js +1 -1
  202. package/modern/LineChart/getColor.js +2 -2
  203. package/modern/LineChart/plugin.js +10 -0
  204. package/modern/PieChart/PieChart.js +3 -3
  205. package/modern/PieChart/PiePlot.js +2 -2
  206. package/modern/PieChart/plugin.js +7 -0
  207. package/modern/ResponsiveChartContainer/ResizableContainer.js +26 -0
  208. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +31 -23
  209. package/modern/ScatterChart/ScatterChart.js +3 -3
  210. package/modern/ScatterChart/ScatterPlot.js +2 -2
  211. package/modern/ScatterChart/formatter.js +1 -1
  212. package/modern/ScatterChart/getColor.js +2 -2
  213. package/modern/ScatterChart/plugin.js +10 -0
  214. package/modern/SparkLineChart/SparkLineChart.js +58 -2
  215. package/modern/context/CartesianContextProvider.js +7 -20
  216. package/modern/context/ColorProvider.js +16 -0
  217. package/modern/context/DrawingProvider.js +9 -2
  218. package/modern/context/HighlightedProvider/HighlightedContext.js +8 -5
  219. package/modern/context/HighlightedProvider/HighlightedProvider.js +15 -12
  220. package/modern/context/HighlightedProvider/useHighlighted.js +6 -3
  221. package/modern/context/HighlightedProvider/useItemHighlighted.js +2 -6
  222. package/modern/context/SeriesContextProvider.js +14 -17
  223. package/modern/context/context.types.js +1 -0
  224. package/modern/hooks/index.js +1 -0
  225. package/modern/hooks/useColor.js +9 -0
  226. package/modern/hooks/useColorScale.js +27 -0
  227. package/modern/hooks/useInteractionItemProps.js +2 -2
  228. package/modern/hooks/useReducedMotion.js +7 -0
  229. package/modern/hooks/useSeries.js +6 -3
  230. package/modern/hooks/useSvgRef.js +6 -3
  231. package/modern/index.js +1 -1
  232. package/modern/internals/configInit.js +20 -0
  233. package/modern/internals/defaultizeValueFormatter.js +2 -3
  234. package/modern/internals/index.js +27 -0
  235. package/modern/internals/isCartesian.js +7 -0
  236. package/modern/internals/warning.js +13 -0
  237. package/modern/models/index.js +1 -0
  238. package/modern/models/plugin.js +1 -0
  239. package/modern/models/seriesType/index.js +6 -0
  240. package/package.json +2 -2
  241. package/themeAugmentation/components.d.ts +12 -12
  242. package/esm/internals/colorGetter.js +0 -22
  243. package/internals/colorGetter.d.ts +0 -7
  244. package/internals/colorGetter.js +0 -29
  245. package/modern/internals/colorGetter.js +0 -22
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ useReducedMotion: true,
8
+ useSeries: true
9
+ };
10
+ Object.defineProperty(exports, "useReducedMotion", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _useReducedMotion.useReducedMotion;
14
+ }
15
+ });
16
+ Object.defineProperty(exports, "useSeries", {
17
+ enumerable: true,
18
+ get: function () {
19
+ return _useSeries.useSeries;
20
+ }
21
+ });
22
+ var _ChartsAxesGradients = require("./components/ChartsAxesGradients");
23
+ Object.keys(_ChartsAxesGradients).forEach(function (key) {
24
+ if (key === "default" || key === "__esModule") return;
25
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
26
+ if (key in exports && exports[key] === _ChartsAxesGradients[key]) return;
27
+ Object.defineProperty(exports, key, {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _ChartsAxesGradients[key];
31
+ }
32
+ });
33
+ });
34
+ var _useChartContainerDimensions = require("../ResponsiveChartContainer/useChartContainerDimensions");
35
+ Object.keys(_useChartContainerDimensions).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
38
+ if (key in exports && exports[key] === _useChartContainerDimensions[key]) return;
39
+ Object.defineProperty(exports, key, {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _useChartContainerDimensions[key];
43
+ }
44
+ });
45
+ });
46
+ var _ResizableContainer = require("../ResponsiveChartContainer/ResizableContainer");
47
+ Object.keys(_ResizableContainer).forEach(function (key) {
48
+ if (key === "default" || key === "__esModule") return;
49
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
50
+ if (key in exports && exports[key] === _ResizableContainer[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _ResizableContainer[key];
55
+ }
56
+ });
57
+ });
58
+ var _useReducedMotion = require("../hooks/useReducedMotion");
59
+ var _useSeries = require("../hooks/useSeries");
60
+ var _defaultizeValueFormatter = require("./defaultizeValueFormatter");
61
+ Object.keys(_defaultizeValueFormatter).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
64
+ if (key in exports && exports[key] === _defaultizeValueFormatter[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _defaultizeValueFormatter[key];
69
+ }
70
+ });
71
+ });
72
+ var _configInit = require("./configInit");
73
+ Object.keys(_configInit).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
76
+ if (key in exports && exports[key] === _configInit[key]) return;
77
+ Object.defineProperty(exports, key, {
78
+ enumerable: true,
79
+ get: function () {
80
+ return _configInit[key];
81
+ }
82
+ });
83
+ });
84
+ var _CartesianContextProvider = require("../context/CartesianContextProvider");
85
+ Object.keys(_CartesianContextProvider).forEach(function (key) {
86
+ if (key === "default" || key === "__esModule") return;
87
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
88
+ if (key in exports && exports[key] === _CartesianContextProvider[key]) return;
89
+ Object.defineProperty(exports, key, {
90
+ enumerable: true,
91
+ get: function () {
92
+ return _CartesianContextProvider[key];
93
+ }
94
+ });
95
+ });
96
+ var _DrawingProvider = require("../context/DrawingProvider");
97
+ Object.keys(_DrawingProvider).forEach(function (key) {
98
+ if (key === "default" || key === "__esModule") return;
99
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
100
+ if (key in exports && exports[key] === _DrawingProvider[key]) return;
101
+ Object.defineProperty(exports, key, {
102
+ enumerable: true,
103
+ get: function () {
104
+ return _DrawingProvider[key];
105
+ }
106
+ });
107
+ });
108
+ var _InteractionProvider = require("../context/InteractionProvider");
109
+ Object.keys(_InteractionProvider).forEach(function (key) {
110
+ if (key === "default" || key === "__esModule") return;
111
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
112
+ if (key in exports && exports[key] === _InteractionProvider[key]) return;
113
+ Object.defineProperty(exports, key, {
114
+ enumerable: true,
115
+ get: function () {
116
+ return _InteractionProvider[key];
117
+ }
118
+ });
119
+ });
120
+ var _SeriesContextProvider = require("../context/SeriesContextProvider");
121
+ Object.keys(_SeriesContextProvider).forEach(function (key) {
122
+ if (key === "default" || key === "__esModule") return;
123
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
124
+ if (key in exports && exports[key] === _SeriesContextProvider[key]) return;
125
+ Object.defineProperty(exports, key, {
126
+ enumerable: true,
127
+ get: function () {
128
+ return _SeriesContextProvider[key];
129
+ }
130
+ });
131
+ });
132
+ var _ZAxisContextProvider = require("../context/ZAxisContextProvider");
133
+ Object.keys(_ZAxisContextProvider).forEach(function (key) {
134
+ if (key === "default" || key === "__esModule") return;
135
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
136
+ if (key in exports && exports[key] === _ZAxisContextProvider[key]) return;
137
+ Object.defineProperty(exports, key, {
138
+ enumerable: true,
139
+ get: function () {
140
+ return _ZAxisContextProvider[key];
141
+ }
142
+ });
143
+ });
144
+ var _config = require("../models/seriesType/config");
145
+ Object.keys(_config).forEach(function (key) {
146
+ if (key === "default" || key === "__esModule") return;
147
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
148
+ if (key in exports && exports[key] === _config[key]) return;
149
+ Object.defineProperty(exports, key, {
150
+ enumerable: true,
151
+ get: function () {
152
+ return _config[key];
153
+ }
154
+ });
155
+ });
156
+ var _common = require("../models/seriesType/common");
157
+ Object.keys(_common).forEach(function (key) {
158
+ if (key === "default" || key === "__esModule") return;
159
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
160
+ if (key in exports && exports[key] === _common[key]) return;
161
+ Object.defineProperty(exports, key, {
162
+ enumerable: true,
163
+ get: function () {
164
+ return _common[key];
165
+ }
166
+ });
167
+ });
168
+ var _helpers = require("../models/helpers");
169
+ Object.keys(_helpers).forEach(function (key) {
170
+ if (key === "default" || key === "__esModule") return;
171
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
172
+ if (key in exports && exports[key] === _helpers[key]) return;
173
+ Object.defineProperty(exports, key, {
174
+ enumerable: true,
175
+ get: function () {
176
+ return _helpers[key];
177
+ }
178
+ });
179
+ });
180
+ var _zAxis = require("../models/z-axis");
181
+ Object.keys(_zAxis).forEach(function (key) {
182
+ if (key === "default" || key === "__esModule") return;
183
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
184
+ if (key in exports && exports[key] === _zAxis[key]) return;
185
+ Object.defineProperty(exports, key, {
186
+ enumerable: true,
187
+ get: function () {
188
+ return _zAxis[key];
189
+ }
190
+ });
191
+ });
192
+ var _axis = require("../models/axis");
193
+ Object.keys(_axis).forEach(function (key) {
194
+ if (key === "default" || key === "__esModule") return;
195
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
196
+ if (key in exports && exports[key] === _axis[key]) return;
197
+ Object.defineProperty(exports, key, {
198
+ enumerable: true,
199
+ get: function () {
200
+ return _axis[key];
201
+ }
202
+ });
203
+ });
@@ -0,0 +1,7 @@
1
+ import { ChartSeriesType, CartesianChartSeriesType, ChartSeriesDefaultized } from '../models/seriesType/config';
2
+ export declare function isCartesianSeriesType(seriesType: string): seriesType is CartesianChartSeriesType;
3
+ export declare function isCartesianSeries(series: ChartSeriesDefaultized<ChartSeriesType> & {
4
+ getColor: (dataIndex: number) => string;
5
+ }): series is ChartSeriesDefaultized<CartesianChartSeriesType> & {
6
+ getColor: (dataIndex: number) => string;
7
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isCartesianSeries = isCartesianSeries;
7
+ exports.isCartesianSeriesType = isCartesianSeriesType;
8
+ var _configInit = require("./configInit");
9
+ function isCartesianSeriesType(seriesType) {
10
+ return _configInit.cartesianSeriesTypes.getTypes().has(seriesType);
11
+ }
12
+ function isCartesianSeries(series) {
13
+ return isCartesianSeriesType(series.type);
14
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "../esm/internals/index.js",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1 @@
1
+ export declare function buildWarning(message: (...args: any) => string, gravity?: 'warning' | 'error'): (...args: any) => void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildWarning = buildWarning;
7
+ function buildWarning(message, gravity = 'warning') {
8
+ let alreadyWarned = false;
9
+ return (...args) => {
10
+ if (!alreadyWarned) {
11
+ alreadyWarned = true;
12
+ if (gravity === 'error') {
13
+ console.error(message(...args));
14
+ } else {
15
+ console.warn(message(...args));
16
+ }
17
+ }
18
+ };
19
+ }
package/models/axis.d.ts CHANGED
@@ -182,7 +182,7 @@ export interface AxisScaleConfig {
182
182
  colorMap?: ContinuousColorConfig | PiecewiseColorConfig;
183
183
  };
184
184
  }
185
- interface AxisScaleComputedConfig {
185
+ export interface AxisScaleComputedConfig {
186
186
  band: {
187
187
  colorScale?: ScaleOrdinal<string | number | Date, string, string | null> | ScaleOrdinal<number, string, string | null> | ScaleSequential<string, string | null> | ScaleThreshold<number | Date, string | null>;
188
188
  };
@@ -216,7 +216,7 @@ export type AxisValueFormatterContext = {
216
216
  */
217
217
  location: 'tick' | 'tooltip';
218
218
  };
219
- export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
219
+ export type AxisConfig<S extends ScaleName = ScaleName, V = any, AxisProps = ChartsXAxisProps | ChartsYAxisProps> = {
220
220
  /**
221
221
  * Id used to identify the axis.
222
222
  */
@@ -254,8 +254,8 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
254
254
  * If `true`, Reverse the axis scaleBand.
255
255
  */
256
256
  reverse?: boolean;
257
- } & Partial<ChartsXAxisProps | ChartsYAxisProps> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams;
258
- export type AxisDefaultized<S extends ScaleName = ScaleName, V = any> = Omit<AxisConfig<S, V>, 'scaleType'> & AxisScaleConfig[S] & AxisScaleComputedConfig[S] & {
257
+ } & Partial<AxisProps> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams;
258
+ export type AxisDefaultized<S extends ScaleName = ScaleName, V = any, AxisProps = ChartsXAxisProps | ChartsYAxisProps> = Omit<AxisConfig<S, V, AxisProps>, 'scaleType'> & AxisScaleConfig[S] & AxisScaleComputedConfig[S] & {
259
259
  /**
260
260
  * An indication of the expected number of ticks.
261
261
  */
@@ -267,4 +267,3 @@ export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): s
267
267
  export declare function isPointScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'point'> & {
268
268
  scaleType: 'point';
269
269
  };
270
- export {};
package/models/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './seriesType';
2
2
  export * from './layout';
3
3
  export * from './stacking';
4
+ export * from './plugin';
4
5
  export type { AxisConfig, ChartsYAxisProps, ChartsXAxisProps, ScaleName, ContinuousScaleName, } from './axis';
package/models/index.js CHANGED
@@ -35,4 +35,15 @@ Object.keys(_stacking).forEach(function (key) {
35
35
  return _stacking[key];
36
36
  }
37
37
  });
38
+ });
39
+ var _plugin = require("./plugin");
40
+ Object.keys(_plugin).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _plugin[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _plugin[key];
47
+ }
48
+ });
38
49
  });
@@ -0,0 +1,16 @@
1
+ import { ChartSeriesType, ExtremumGetter, Formatter } from './seriesType/config';
2
+ import { AxisDefaultized } from './axis';
3
+ import { DefaultizedSeriesType } from './seriesType';
4
+ import { ZAxisDefaultized } from './z-axis';
5
+ type ColorProcessor<T extends ChartSeriesType> = (series: DefaultizedSeriesType<T>, xAxis?: AxisDefaultized, yAxis?: AxisDefaultized, zAxis?: ZAxisDefaultized) => (dataIndex: number) => string;
6
+ export type ColorProcessorsConfig<T extends ChartSeriesType> = {
7
+ [Key in T]?: ColorProcessor<Key>;
8
+ };
9
+ export type ChartsPluginType<T> = T extends ChartSeriesType ? {
10
+ seriesType: T;
11
+ seriesFormatter: Formatter<T>;
12
+ colorProcessor: ColorProcessor<T>;
13
+ xExtremumGetter?: ExtremumGetter<T>;
14
+ yExtremumGetter?: ExtremumGetter<T>;
15
+ } : never;
16
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -6,29 +6,44 @@ import { AxisConfig } from '../axis';
6
6
  import { DefaultizedProps, MakeOptional } from '../helpers';
7
7
  import { StackingGroupsType } from '../../internals/stackSeries';
8
8
  import { SeriesId } from './common';
9
- interface ChartsSeriesConfig {
9
+ export interface ChartsSeriesConfig {
10
10
  bar: {
11
+ /**
12
+ * Series type when passed to the formatter (some ids are given default values to simplify the DX)
13
+ */
11
14
  seriesInput: DefaultizedProps<BarSeriesType, 'id'> & {
12
15
  color: string;
13
16
  };
17
+ /**
18
+ * Series type when stored in the context (with all the preprocessing added))
19
+ */
14
20
  series: DefaultizedBarSeriesType;
15
- canBeStacked: true;
21
+ /**
22
+ * Series typing such that the one user need to provide
23
+ */
24
+ seriesProp: BarSeriesType;
16
25
  itemIdentifier: BarItemIdentifier;
26
+ canBeStacked: true;
27
+ cartesian: true;
17
28
  };
18
29
  line: {
19
30
  seriesInput: DefaultizedProps<LineSeriesType, 'id'> & {
20
31
  color: string;
21
32
  };
22
33
  series: DefaultizedLineSeriesType;
23
- canBeStacked: true;
34
+ seriesProp: LineSeriesType;
24
35
  itemIdentifier: LineItemIdentifier;
36
+ canBeStacked: true;
37
+ cartesian: true;
25
38
  };
26
39
  scatter: {
27
40
  seriesInput: DefaultizedProps<ScatterSeriesType, 'id'> & {
28
41
  color: string;
29
42
  };
30
43
  series: DefaultizedScatterSeriesType;
44
+ seriesProp: ScatterSeriesType;
31
45
  itemIdentifier: ScatterItemIdentifier;
46
+ cartesian: true;
32
47
  };
33
48
  pie: {
34
49
  seriesInput: Omit<DefaultizedProps<PieSeriesType, 'id'>, 'data'> & {
@@ -37,11 +52,21 @@ interface ChartsSeriesConfig {
37
52
  })[];
38
53
  };
39
54
  series: DefaultizedPieSeriesType;
55
+ seriesProp: PieSeriesType<MakeOptional<PieValueType, 'id'>>;
40
56
  itemIdentifier: PieItemIdentifier;
41
57
  };
42
58
  }
43
- export type CartesianChartSeriesType = 'bar' | 'line' | 'scatter';
44
- export type ChartSeriesType = 'bar' | 'line' | 'scatter' | 'pie';
59
+ export type ChartSeriesType = keyof ChartsSeriesConfig;
60
+ export type CartesianChartSeriesType = keyof Pick<ChartsSeriesConfig, {
61
+ [Key in ChartSeriesType]: ChartsSeriesConfig[Key] extends {
62
+ cartesian: true;
63
+ } ? Key : never;
64
+ }[ChartSeriesType]>;
65
+ export type StackableChartSeriesType = keyof Pick<ChartsSeriesConfig, {
66
+ [Key in ChartSeriesType]: ChartsSeriesConfig[Key] extends {
67
+ canBeStacked: true;
68
+ } ? Key : never;
69
+ }[ChartSeriesType]>;
45
70
  export type ChartSeries<T extends ChartSeriesType> = ChartsSeriesConfig[T] extends {
46
71
  canBeStacked: true;
47
72
  } ? ChartsSeriesConfig[T]['seriesInput'] & {
@@ -1,14 +1,11 @@
1
- import { BarItemIdentifier, BarSeriesType, DefaultizedBarSeriesType } from './bar';
2
- import { DefaultizedLineSeriesType, LineItemIdentifier, LineSeriesType } from './line';
3
- import { DefaultizedScatterSeriesType, ScatterItemIdentifier, ScatterSeriesType } from './scatter';
4
- import { DefaultizedPieSeriesType, PieSeriesType, PieItemIdentifier, PieValueType } from './pie';
5
- import { MakeOptional } from '../helpers';
6
- type AllSeriesType = BarSeriesType | LineSeriesType | ScatterSeriesType | PieSeriesType<MakeOptional<PieValueType, 'id'>>;
7
- type CartesianSeriesType = BarSeriesType | LineSeriesType | ScatterSeriesType;
8
- type DefaultizedCartesianSeriesType = DefaultizedBarSeriesType | DefaultizedLineSeriesType | DefaultizedScatterSeriesType;
9
- type DefaultizedSeriesType = DefaultizedCartesianSeriesType | DefaultizedPieSeriesType;
10
- type StackableSeriesType = DefaultizedBarSeriesType | DefaultizedLineSeriesType;
11
- export type SeriesItemIdentifier = BarItemIdentifier | LineItemIdentifier | ScatterItemIdentifier | PieItemIdentifier;
1
+ import { BarSeriesType, DefaultizedBarSeriesType } from './bar';
2
+ import { CartesianChartSeriesType, ChartSeriesType, ChartsSeriesConfig, StackableChartSeriesType } from './config';
3
+ type AllSeriesType<T extends ChartSeriesType = ChartSeriesType> = ChartsSeriesConfig[T]['seriesProp'];
4
+ type CartesianSeriesType = AllSeriesType<CartesianChartSeriesType>;
5
+ type DefaultizedSeriesType<T extends ChartSeriesType = ChartSeriesType> = ChartsSeriesConfig[T]['series'];
6
+ type DefaultizedCartesianSeriesType = DefaultizedSeriesType<CartesianChartSeriesType>;
7
+ type StackableSeriesType = DefaultizedSeriesType<StackableChartSeriesType>;
8
+ export type SeriesItemIdentifier<T extends ChartSeriesType = ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
12
9
  export * from './line';
13
10
  export * from './bar';
14
11
  export * from './scatter';
@@ -57,6 +57,12 @@ Object.keys(_pie).forEach(function (key) {
57
57
  }
58
58
  });
59
59
  });
60
+ // Series definition
61
+
62
+ // item identifier
63
+
64
+ // Helpers
65
+
60
66
  function isDefaultizedBarSeries(series) {
61
67
  return series.type === 'bar';
62
68
  }
@@ -351,7 +351,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
351
351
  labelStyle: PropTypes.object,
352
352
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
353
353
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
354
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
354
+ position: PropTypes.oneOf(['bottom', 'top']),
355
355
  reverse: PropTypes.bool,
356
356
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
357
357
  slotProps: PropTypes.object,
@@ -404,7 +404,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
404
404
  labelStyle: PropTypes.object,
405
405
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
406
406
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
407
- position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
407
+ position: PropTypes.oneOf(['left', 'right']),
408
408
  reverse: PropTypes.bool,
409
409
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
410
410
  slotProps: PropTypes.object,
@@ -4,7 +4,6 @@ const _excluded = ["skipAnimation", "onItemClick", "borderRadius", "barLabel"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useTransition } from '@react-spring/web';
7
- import { SeriesContext } from '../context/SeriesContextProvider';
8
7
  import { CartesianContext } from '../context/CartesianContextProvider';
9
8
  import { BarElement } from './BarElement';
10
9
  import getColor from './getColor';
@@ -12,6 +11,7 @@ import { useChartId } from '../hooks';
12
11
  import { BarClipPath } from './BarClipPath';
13
12
  import { BarLabelPlot } from './BarLabel/BarLabelPlot';
14
13
  import { checkScaleErrors } from './checkScaleErrors';
14
+ import { useBarSeries } from '../hooks/useSeries';
15
15
 
16
16
  /**
17
17
  * Solution of the equations
@@ -42,7 +42,7 @@ function getBandSize({
42
42
  };
43
43
  }
44
44
  const useAggregatedData = () => {
45
- const seriesData = React.useContext(SeriesContext).bar ?? {
45
+ const seriesData = useBarSeries() ?? {
46
46
  series: {},
47
47
  stackingGroups: [],
48
48
  seriesOrder: []
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { stack as d3Stack } from 'd3-shape';
3
3
  import { getStackingGroups } from '../internals/stackSeries';
4
- import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
4
+ import { defaultizeValueFormatter } from '../internals/defaultizeValueFormatter';
5
5
  let warnOnce = false;
6
6
  const formatter = (params, dataset) => {
7
7
  const {
@@ -1,8 +1,8 @@
1
1
  export default function getColor(series, xAxis, yAxis) {
2
2
  const verticalLayout = series.layout === 'vertical';
3
- const bandColorScale = verticalLayout ? xAxis.colorScale : yAxis.colorScale;
4
- const valueColorScale = verticalLayout ? yAxis.colorScale : xAxis.colorScale;
5
- const bandValues = verticalLayout ? xAxis.data : yAxis.data;
3
+ const bandColorScale = verticalLayout ? xAxis?.colorScale : yAxis?.colorScale;
4
+ const valueColorScale = verticalLayout ? yAxis?.colorScale : xAxis?.colorScale;
5
+ const bandValues = verticalLayout ? xAxis?.data : yAxis?.data;
6
6
  if (valueColorScale) {
7
7
  return dataIndex => {
8
8
  const value = series.data[dataIndex];
@@ -13,7 +13,7 @@ export default function getColor(series, xAxis, yAxis) {
13
13
  return color;
14
14
  };
15
15
  }
16
- if (bandColorScale) {
16
+ if (bandColorScale && bandValues) {
17
17
  return dataIndex => {
18
18
  const value = bandValues[dataIndex];
19
19
  const color = value === null ? series.color : bandColorScale(value);
@@ -0,0 +1,10 @@
1
+ import { getExtremumX, getExtremumY } from './extremums';
2
+ import formatter from './formatter';
3
+ import getColor from './getColor';
4
+ export const plugin = {
5
+ seriesType: 'bar',
6
+ seriesFormatter: formatter,
7
+ colorProcessor: getColor,
8
+ xExtremumGetter: getExtremumX,
9
+ yExtremumGetter: getExtremumY
10
+ };