@amcharts/amcharts5 5.1.7 → 5.1.10

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 (316) hide show
  1. package/.internal/charts/flow/ChordLink.d.ts +12 -0
  2. package/.internal/charts/flow/ChordLink.d.ts.map +1 -1
  3. package/.internal/charts/flow/ChordLink.js.map +1 -1
  4. package/.internal/charts/flow/Flow.d.ts +2 -0
  5. package/.internal/charts/flow/Flow.d.ts.map +1 -1
  6. package/.internal/charts/flow/Flow.js +17 -0
  7. package/.internal/charts/flow/Flow.js.map +1 -1
  8. package/.internal/charts/flow/FlowNodes.d.ts +7 -0
  9. package/.internal/charts/flow/FlowNodes.d.ts.map +1 -1
  10. package/.internal/charts/flow/FlowNodes.js +7 -0
  11. package/.internal/charts/flow/FlowNodes.js.map +1 -1
  12. package/.internal/charts/flow/Sankey.d.ts.map +1 -1
  13. package/.internal/charts/flow/Sankey.js +59 -57
  14. package/.internal/charts/flow/Sankey.js.map +1 -1
  15. package/.internal/charts/funnel/FunnelSeries.d.ts +9 -0
  16. package/.internal/charts/funnel/FunnelSeries.d.ts.map +1 -1
  17. package/.internal/charts/funnel/FunnelSeries.js.map +1 -1
  18. package/.internal/charts/hierarchy/Hierarchy.d.ts +36 -0
  19. package/.internal/charts/hierarchy/Hierarchy.d.ts.map +1 -1
  20. package/.internal/charts/hierarchy/Hierarchy.js.map +1 -1
  21. package/.internal/charts/map/MapChart.d.ts +2 -0
  22. package/.internal/charts/map/MapChart.d.ts.map +1 -1
  23. package/.internal/charts/map/MapChart.js +30 -3
  24. package/.internal/charts/map/MapChart.js.map +1 -1
  25. package/.internal/charts/map/MapPointSeries.d.ts +6 -0
  26. package/.internal/charts/map/MapPointSeries.d.ts.map +1 -1
  27. package/.internal/charts/map/MapPointSeries.js.map +1 -1
  28. package/.internal/charts/percent/PercentSeries.d.ts +18 -0
  29. package/.internal/charts/percent/PercentSeries.d.ts.map +1 -1
  30. package/.internal/charts/percent/PercentSeries.js.map +1 -1
  31. package/.internal/charts/pie/PieSeries.d.ts +3 -0
  32. package/.internal/charts/pie/PieSeries.d.ts.map +1 -1
  33. package/.internal/charts/pie/PieSeries.js.map +1 -1
  34. package/.internal/charts/radar/AxisRendererCircular.d.ts +12 -0
  35. package/.internal/charts/radar/AxisRendererCircular.d.ts.map +1 -1
  36. package/.internal/charts/radar/AxisRendererCircular.js.map +1 -1
  37. package/.internal/charts/radar/AxisRendererRadial.d.ts +12 -0
  38. package/.internal/charts/radar/AxisRendererRadial.d.ts.map +1 -1
  39. package/.internal/charts/radar/AxisRendererRadial.js.map +1 -1
  40. package/.internal/charts/radar/RadarChart.d.ts +2 -0
  41. package/.internal/charts/radar/RadarChart.d.ts.map +1 -1
  42. package/.internal/charts/radar/RadarChart.js +14 -0
  43. package/.internal/charts/radar/RadarChart.js.map +1 -1
  44. package/.internal/charts/radar/RadarColumnSeries.d.ts +15 -0
  45. package/.internal/charts/radar/RadarColumnSeries.d.ts.map +1 -1
  46. package/.internal/charts/radar/RadarColumnSeries.js.map +1 -1
  47. package/.internal/charts/radar/RadarCursor.d.ts +12 -0
  48. package/.internal/charts/radar/RadarCursor.d.ts.map +1 -1
  49. package/.internal/charts/radar/RadarCursor.js.map +1 -1
  50. package/.internal/charts/wordcloud/WordCloud.d.ts +3 -0
  51. package/.internal/charts/wordcloud/WordCloud.d.ts.map +1 -1
  52. package/.internal/charts/wordcloud/WordCloud.js.map +1 -1
  53. package/.internal/charts/xy/XYChart.d.ts +45 -0
  54. package/.internal/charts/xy/XYChart.d.ts.map +1 -1
  55. package/.internal/charts/xy/XYChart.js +225 -17
  56. package/.internal/charts/xy/XYChart.js.map +1 -1
  57. package/.internal/charts/xy/XYChartDefaultTheme.js +3 -3
  58. package/.internal/charts/xy/XYChartDefaultTheme.js.map +1 -1
  59. package/.internal/charts/xy/XYCursor.d.ts.map +1 -1
  60. package/.internal/charts/xy/XYCursor.js +8 -1
  61. package/.internal/charts/xy/XYCursor.js.map +1 -1
  62. package/.internal/charts/xy/axes/Axis.js +1 -1
  63. package/.internal/charts/xy/axes/Axis.js.map +1 -1
  64. package/.internal/charts/xy/axes/AxisLabel.d.ts.map +1 -1
  65. package/.internal/charts/xy/axes/AxisLabel.js.map +1 -1
  66. package/.internal/charts/xy/axes/AxisRenderer.d.ts +3 -0
  67. package/.internal/charts/xy/axes/AxisRenderer.d.ts.map +1 -1
  68. package/.internal/charts/xy/axes/AxisRenderer.js.map +1 -1
  69. package/.internal/charts/xy/axes/AxisRendererX.d.ts.map +1 -1
  70. package/.internal/charts/xy/axes/AxisRendererX.js +7 -2
  71. package/.internal/charts/xy/axes/AxisRendererX.js.map +1 -1
  72. package/.internal/charts/xy/axes/AxisRendererY.js +2 -2
  73. package/.internal/charts/xy/axes/AxisRendererY.js.map +1 -1
  74. package/.internal/charts/xy/axes/DateAxis.d.ts.map +1 -1
  75. package/.internal/charts/xy/axes/DateAxis.js +4 -1
  76. package/.internal/charts/xy/axes/DateAxis.js.map +1 -1
  77. package/.internal/charts/xy/axes/DurationAxis.d.ts +5 -0
  78. package/.internal/charts/xy/axes/DurationAxis.d.ts.map +1 -1
  79. package/.internal/charts/xy/axes/DurationAxis.js.map +1 -1
  80. package/.internal/charts/xy/axes/GaplessDateAxis.d.ts +3 -0
  81. package/.internal/charts/xy/axes/GaplessDateAxis.d.ts.map +1 -1
  82. package/.internal/charts/xy/axes/GaplessDateAxis.js.map +1 -1
  83. package/.internal/charts/xy/axes/ValueAxis.d.ts +75 -0
  84. package/.internal/charts/xy/axes/ValueAxis.d.ts.map +1 -1
  85. package/.internal/charts/xy/axes/ValueAxis.js +110 -71
  86. package/.internal/charts/xy/axes/ValueAxis.js.map +1 -1
  87. package/.internal/charts/xy/series/BaseColumnSeries.d.ts.map +1 -1
  88. package/.internal/charts/xy/series/BaseColumnSeries.js +9 -0
  89. package/.internal/charts/xy/series/BaseColumnSeries.js.map +1 -1
  90. package/.internal/charts/xy/series/Candlestick.d.ts +27 -0
  91. package/.internal/charts/xy/series/Candlestick.d.ts.map +1 -1
  92. package/.internal/charts/xy/series/Candlestick.js.map +1 -1
  93. package/.internal/charts/xy/series/CandlestickSeries.d.ts +6 -1
  94. package/.internal/charts/xy/series/CandlestickSeries.d.ts.map +1 -1
  95. package/.internal/charts/xy/series/CandlestickSeries.js.map +1 -1
  96. package/.internal/charts/xy/series/ColumnSeries.d.ts +3 -0
  97. package/.internal/charts/xy/series/ColumnSeries.d.ts.map +1 -1
  98. package/.internal/charts/xy/series/ColumnSeries.js.map +1 -1
  99. package/.internal/charts/xy/series/LineSeries.d.ts.map +1 -1
  100. package/.internal/charts/xy/series/LineSeries.js +3 -0
  101. package/.internal/charts/xy/series/LineSeries.js.map +1 -1
  102. package/.internal/charts/xy/series/OHLCSeries.d.ts +3 -0
  103. package/.internal/charts/xy/series/OHLCSeries.d.ts.map +1 -1
  104. package/.internal/charts/xy/series/OHLCSeries.js.map +1 -1
  105. package/.internal/charts/xy/series/XYSeries.d.ts.map +1 -1
  106. package/.internal/charts/xy/series/XYSeries.js +6 -0
  107. package/.internal/charts/xy/series/XYSeries.js.map +1 -1
  108. package/.internal/core/Classes.d.ts +14 -8
  109. package/.internal/core/Classes.d.ts.map +1 -1
  110. package/.internal/core/Classes.js.map +1 -1
  111. package/.internal/core/Root.d.ts.map +1 -1
  112. package/.internal/core/Root.js +1 -0
  113. package/.internal/core/Root.js.map +1 -1
  114. package/.internal/core/render/Graphics.d.ts +2 -0
  115. package/.internal/core/render/Graphics.d.ts.map +1 -1
  116. package/.internal/core/render/Graphics.js +1 -1
  117. package/.internal/core/render/Graphics.js.map +1 -1
  118. package/.internal/core/render/Legend.d.ts.map +1 -1
  119. package/.internal/core/render/Legend.js +7 -0
  120. package/.internal/core/render/Legend.js.map +1 -1
  121. package/.internal/core/render/Series.d.ts.map +1 -1
  122. package/.internal/core/render/Series.js +11 -7
  123. package/.internal/core/render/Series.js.map +1 -1
  124. package/.internal/core/render/Sprite.d.ts.map +1 -1
  125. package/.internal/core/render/Sprite.js +15 -1
  126. package/.internal/core/render/Sprite.js.map +1 -1
  127. package/.internal/core/render/VerticalLayout.js +1 -1
  128. package/.internal/core/render/VerticalLayout.js.map +1 -1
  129. package/.internal/core/render/backend/CanvasRenderer.d.ts +4 -5
  130. package/.internal/core/render/backend/CanvasRenderer.d.ts.map +1 -1
  131. package/.internal/core/render/backend/CanvasRenderer.js +66 -35
  132. package/.internal/core/render/backend/CanvasRenderer.js.map +1 -1
  133. package/.internal/core/render/backend/Renderer.d.ts +1 -0
  134. package/.internal/core/render/backend/Renderer.d.ts.map +1 -1
  135. package/.internal/core/render/backend/Renderer.js.map +1 -1
  136. package/.internal/core/util/Benchmark.js +1 -1
  137. package/.internal/core/util/Benchmark.js.map +1 -1
  138. package/.internal/core/util/Entity.d.ts +1 -1
  139. package/.internal/core/util/Entity.d.ts.map +1 -1
  140. package/.internal/core/util/Entity.js +1 -1
  141. package/.internal/core/util/Entity.js.map +1 -1
  142. package/.internal/core/util/Language.js +3 -3
  143. package/.internal/core/util/Language.js.map +1 -1
  144. package/.internal/core/util/PopulateString.js +12 -2
  145. package/.internal/core/util/PopulateString.js.map +1 -1
  146. package/.internal/core/util/ResizeSensor.d.ts.map +1 -1
  147. package/.internal/core/util/ResizeSensor.js +2 -3
  148. package/.internal/core/util/ResizeSensor.js.map +1 -1
  149. package/.internal/core/util/Template.d.ts +1 -1
  150. package/.internal/core/util/Template.d.ts.map +1 -1
  151. package/.internal/core/util/Template.js.map +1 -1
  152. package/.internal/core/util/Time.d.ts +1 -0
  153. package/.internal/core/util/Time.d.ts.map +1 -1
  154. package/.internal/core/util/Time.js +12 -0
  155. package/.internal/core/util/Time.js.map +1 -1
  156. package/.internal/core/util/Utils.js +1 -1
  157. package/.internal/core/util/Utils.js.map +1 -1
  158. package/.internal/plugins/exporting/Exporting.d.ts +0 -4
  159. package/.internal/plugins/exporting/Exporting.d.ts.map +1 -1
  160. package/.internal/plugins/exporting/Exporting.js +4 -49
  161. package/.internal/plugins/exporting/Exporting.js.map +1 -1
  162. package/.internal/plugins/json/Classes-script.d.ts +271 -0
  163. package/.internal/plugins/json/Classes-script.d.ts.map +1 -0
  164. package/.internal/plugins/json/Classes-script.js +139 -0
  165. package/.internal/plugins/json/Classes-script.js.map +1 -0
  166. package/.internal/plugins/json/Classes.d.ts +271 -0
  167. package/.internal/plugins/json/Classes.d.ts.map +1 -0
  168. package/.internal/plugins/json/Classes.js +139 -0
  169. package/.internal/plugins/json/Classes.js.map +1 -0
  170. package/.internal/plugins/json/Json.d.ts +7 -0
  171. package/.internal/plugins/json/Json.d.ts.map +1 -0
  172. package/.internal/plugins/json/Json.js +266 -0
  173. package/.internal/plugins/json/Json.js.map +1 -0
  174. package/CHANGELOG.md +51 -0
  175. package/examples/javascript/flow-chord/package.json +1 -1
  176. package/examples/javascript/flow-chord-directed/package.json +1 -1
  177. package/examples/javascript/flow-chord-non-ribbon/package.json +1 -1
  178. package/examples/javascript/flow-sankey/package.json +1 -1
  179. package/examples/javascript/gauge/package.json +1 -1
  180. package/examples/javascript/gauge-bands/package.json +1 -1
  181. package/examples/javascript/hierarchy-force-directed/package.json +1 -1
  182. package/examples/javascript/hierarchy-pack/package.json +1 -1
  183. package/examples/javascript/hierarchy-partition/package.json +1 -1
  184. package/examples/javascript/hierarchy-sunburst/package.json +1 -1
  185. package/examples/javascript/hierarchy-tree/package.json +1 -1
  186. package/examples/javascript/hierarchy-treemap/package.json +1 -1
  187. package/examples/javascript/json/README.md +6 -0
  188. package/examples/javascript/json/index.css +11 -0
  189. package/examples/javascript/json/index.html +12 -0
  190. package/examples/javascript/json/index.js +94 -0
  191. package/examples/javascript/json/package.json +16 -0
  192. package/examples/javascript/json/webpack.config.js +38 -0
  193. package/examples/javascript/map-animating-along-lines/package.json +1 -1
  194. package/examples/javascript/map-day-and-night/package.json +1 -1
  195. package/examples/javascript/map-globe-rotate-to-country/package.json +1 -1
  196. package/examples/javascript/map-globe-with-projected-circles/package.json +1 -1
  197. package/examples/javascript/map-with-bubbles/package.json +1 -1
  198. package/examples/javascript/map-zoom-to-country/package.json +1 -1
  199. package/examples/javascript/misc-40-charts/package.json +1 -1
  200. package/examples/javascript/misc-microchart-grid/package.json +1 -1
  201. package/examples/javascript/pie-chart/package.json +1 -1
  202. package/examples/javascript/pie-donut-chart/package.json +1 -1
  203. package/examples/javascript/pie-variable-radius/package.json +1 -1
  204. package/examples/javascript/radar-column-iwatch-style/package.json +1 -1
  205. package/examples/javascript/radar-heat-map/package.json +1 -1
  206. package/examples/javascript/radar-line/package.json +1 -1
  207. package/examples/javascript/radar-time-line/package.json +1 -1
  208. package/examples/javascript/sliced-funnel/package.json +1 -1
  209. package/examples/javascript/sliced-pictorial-stacked/package.json +1 -1
  210. package/examples/javascript/sliced-pyramid/package.json +1 -1
  211. package/examples/javascript/venn-diagram/package.json +1 -1
  212. package/examples/javascript/wordcloud-with-data/package.json +1 -1
  213. package/examples/javascript/wordcloud-with-text/package.json +1 -1
  214. package/examples/javascript/xy-100-percent-stacked-column/package.json +1 -1
  215. package/examples/javascript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
  216. package/examples/javascript/xy-bubble/package.json +1 -1
  217. package/examples/javascript/xy-candlestick/package.json +1 -1
  218. package/examples/javascript/xy-clustered-column/package.json +1 -1
  219. package/examples/javascript/xy-column/package.json +1 -1
  220. package/examples/javascript/xy-comparing-series-google-analytics-style/package.json +1 -1
  221. package/examples/javascript/xy-data-grouping/package.json +1 -1
  222. package/examples/javascript/xy-draggable-range/package.json +1 -1
  223. package/examples/javascript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
  224. package/examples/javascript/xy-dumbbell plot/package.json +1 -1
  225. package/examples/javascript/xy-evenly-spaced-date-axis/package.json +1 -1
  226. package/examples/javascript/xy-line/package.json +1 -1
  227. package/examples/javascript/xy-line-highlight-on-legend-hover/package.json +1 -1
  228. package/examples/javascript/xy-live-data/package.json +1 -1
  229. package/examples/javascript/xy-multiple-synced-value-axes/package.json +1 -1
  230. package/examples/javascript/xy-ohlc/package.json +1 -1
  231. package/examples/javascript/xy-real-time-data-sorting/package.json +1 -1
  232. package/examples/javascript/xy-smoothed-line/package.json +1 -1
  233. package/examples/javascript/xy-stacked-and-clustered-column/package.json +1 -1
  234. package/examples/javascript/xy-stacked-column/package.json +1 -1
  235. package/examples/javascript/xy-stacked-step/package.json +1 -1
  236. package/examples/javascript/xy-stock/package.json +1 -1
  237. package/examples/javascript/xy-stock-comparing/package.json +1 -1
  238. package/examples/typescript/flow-chord/package.json +1 -1
  239. package/examples/typescript/flow-chord-directed/package.json +1 -1
  240. package/examples/typescript/flow-chord-non-ribbon/package.json +1 -1
  241. package/examples/typescript/flow-sankey/package.json +1 -1
  242. package/examples/typescript/gauge/package.json +1 -1
  243. package/examples/typescript/gauge-bands/package.json +1 -1
  244. package/examples/typescript/hierarchy-force-directed/package.json +1 -1
  245. package/examples/typescript/hierarchy-pack/package.json +1 -1
  246. package/examples/typescript/hierarchy-partition/package.json +1 -1
  247. package/examples/typescript/hierarchy-sunburst/package.json +1 -1
  248. package/examples/typescript/hierarchy-tree/package.json +1 -1
  249. package/examples/typescript/hierarchy-treemap/package.json +1 -1
  250. package/examples/typescript/json/README.md +6 -0
  251. package/examples/typescript/json/index.css +11 -0
  252. package/examples/typescript/json/index.html +12 -0
  253. package/examples/typescript/json/index.ts +94 -0
  254. package/examples/typescript/json/package.json +18 -0
  255. package/examples/typescript/json/tsconfig.json +12 -0
  256. package/examples/typescript/json/webpack.config.js +45 -0
  257. package/examples/typescript/map-animating-along-lines/package.json +1 -1
  258. package/examples/typescript/map-day-and-night/package.json +1 -1
  259. package/examples/typescript/map-globe-rotate-to-country/package.json +1 -1
  260. package/examples/typescript/map-globe-with-projected-circles/package.json +1 -1
  261. package/examples/typescript/map-with-bubbles/package.json +1 -1
  262. package/examples/typescript/map-zoom-to-country/package.json +1 -1
  263. package/examples/typescript/misc-40-charts/package.json +1 -1
  264. package/examples/typescript/misc-microchart-grid/package.json +1 -1
  265. package/examples/typescript/pie-chart/package.json +1 -1
  266. package/examples/typescript/pie-donut-chart/package.json +1 -1
  267. package/examples/typescript/pie-variable-radius/package.json +1 -1
  268. package/examples/typescript/radar-column-iwatch-style/package.json +1 -1
  269. package/examples/typescript/radar-heat-map/package.json +1 -1
  270. package/examples/typescript/radar-line/package.json +1 -1
  271. package/examples/typescript/radar-time-line/package.json +1 -1
  272. package/examples/typescript/sliced-funnel/package.json +1 -1
  273. package/examples/typescript/sliced-pictorial-stacked/package.json +1 -1
  274. package/examples/typescript/sliced-pyramid/package.json +1 -1
  275. package/examples/typescript/venn-diagram/package.json +1 -1
  276. package/examples/typescript/wordcloud-with-data/package.json +1 -1
  277. package/examples/typescript/wordcloud-with-text/package.json +1 -1
  278. package/examples/typescript/xy-100-percent-stacked-column/package.json +1 -1
  279. package/examples/typescript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
  280. package/examples/typescript/xy-bubble/package.json +1 -1
  281. package/examples/typescript/xy-candlestick/package.json +1 -1
  282. package/examples/typescript/xy-clustered-column/package.json +1 -1
  283. package/examples/typescript/xy-column/package.json +1 -1
  284. package/examples/typescript/xy-comparing-series-google-analytics-style/package.json +1 -1
  285. package/examples/typescript/xy-data-grouping/package.json +1 -1
  286. package/examples/typescript/xy-draggable-range/package.json +1 -1
  287. package/examples/typescript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
  288. package/examples/typescript/xy-dumbbell plot/package.json +1 -1
  289. package/examples/typescript/xy-evenly-spaced-date-axis/package.json +1 -1
  290. package/examples/typescript/xy-line/package.json +1 -1
  291. package/examples/typescript/xy-line-highlight-on-legend-hover/package.json +1 -1
  292. package/examples/typescript/xy-live-data/package.json +1 -1
  293. package/examples/typescript/xy-multiple-synced-value-axes/package.json +1 -1
  294. package/examples/typescript/xy-ohlc/package.json +1 -1
  295. package/examples/typescript/xy-real-time-data-sorting/package.json +1 -1
  296. package/examples/typescript/xy-smoothed-line/package.json +1 -1
  297. package/examples/typescript/xy-stacked-and-clustered-column/package.json +1 -1
  298. package/examples/typescript/xy-stacked-column/package.json +1 -1
  299. package/examples/typescript/xy-stacked-step/package.json +1 -1
  300. package/examples/typescript/xy-stock/package.json +1 -1
  301. package/examples/typescript/xy-stock-comparing/package.json +1 -1
  302. package/index.d.ts +4 -0
  303. package/index.d.ts.map +1 -1
  304. package/index.js +4 -0
  305. package/index.js.map +1 -1
  306. package/locales/lt_LT.js +25 -25
  307. package/locales/lt_LT.js.map +1 -1
  308. package/package.json +10 -9
  309. package/plugins/json.d.ts +2 -0
  310. package/plugins/json.d.ts.map +1 -0
  311. package/plugins/json.js +2 -0
  312. package/plugins/json.js.map +1 -0
  313. package/xy.d.ts +1 -0
  314. package/xy.d.ts.map +1 -1
  315. package/xy.js +1 -0
  316. package/xy.js.map +1 -1
@@ -0,0 +1,266 @@
1
+ import { __awaiter, __generator, __read } from "tslib";
2
+ import { Entity } from "../../core/util/Entity";
3
+ import { Container } from "../../core/render/Container";
4
+ import { Color } from "../../core/util/Color";
5
+ import * as $type from "../../core/util/Type";
6
+ import * as $array from "../../core/util/Array";
7
+ import * as $object from "../../core/util/Object";
8
+ import classes from "./Classes";
9
+ function hasType(value) {
10
+ return $type.isString(value.type);
11
+ }
12
+ function getClass(object) {
13
+ return __awaiter(this, void 0, void 0, function () {
14
+ var promise;
15
+ return __generator(this, function (_a) {
16
+ switch (_a.label) {
17
+ case 0:
18
+ promise = classes[object.type];
19
+ return [4 /*yield*/, promise()];
20
+ case 1: return [2 /*return*/, _a.sent()];
21
+ }
22
+ });
23
+ });
24
+ }
25
+ function parseArray(root, value, refs) {
26
+ return Promise.all($array.map(value, function (value) { return parseType(root, value, refs); }));
27
+ }
28
+ function lookupRef(refs, name) {
29
+ var i = refs.length;
30
+ while (i--) {
31
+ var sub = refs[i];
32
+ if (name in sub) {
33
+ return sub[name];
34
+ }
35
+ }
36
+ throw new Error("Could not find ref #" + name);
37
+ }
38
+ function parseSettings(root, object, refs) {
39
+ return __awaiter(this, void 0, void 0, function () {
40
+ var settings;
41
+ var _this = this;
42
+ return __generator(this, function (_a) {
43
+ switch (_a.label) {
44
+ case 0:
45
+ settings = {};
46
+ return [4 /*yield*/, Promise.all($array.map($object.keys(object), function (key) { return __awaiter(_this, void 0, void 0, function () {
47
+ var _a, _b;
48
+ return __generator(this, function (_c) {
49
+ switch (_c.label) {
50
+ case 0:
51
+ _a = settings;
52
+ _b = key;
53
+ return [4 /*yield*/, parseType(root, object[key], refs)];
54
+ case 1:
55
+ _a[_b] = _c.sent();
56
+ return [2 /*return*/];
57
+ }
58
+ });
59
+ }); }))];
60
+ case 1:
61
+ _a.sent();
62
+ return [2 /*return*/, settings];
63
+ }
64
+ });
65
+ });
66
+ }
67
+ function parseProperties(root, object, refs) {
68
+ return __awaiter(this, void 0, void 0, function () {
69
+ var _this = this;
70
+ return __generator(this, function (_a) {
71
+ switch (_a.label) {
72
+ case 0: return [4 /*yield*/, Promise.all($array.map($object.keys(object), function (key) { return __awaiter(_this, void 0, void 0, function () {
73
+ var parsed;
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0: return [4 /*yield*/, parseValue(root, object[key], refs)];
77
+ case 1:
78
+ parsed = _a.sent();
79
+ return [2 /*return*/, function (entity) {
80
+ var old = entity[key];
81
+ if (old && old instanceof Entity) {
82
+ // TODO merge it if the value is an Entity
83
+ if (parsed.isValue) {
84
+ throw new Error("Cannot merge value into Entity");
85
+ }
86
+ if (parsed.settings) {
87
+ old.setAll(parsed.settings);
88
+ }
89
+ mergeEntity(old, parsed);
90
+ }
91
+ else if (parsed.isValue) {
92
+ // TODO merge it if the value is an Entity
93
+ entity[key] = parsed.value;
94
+ }
95
+ else {
96
+ entity[key] = constructEntity(root, parsed);
97
+ }
98
+ }];
99
+ }
100
+ });
101
+ }); }))];
102
+ case 1: return [2 /*return*/, _a.sent()];
103
+ }
104
+ });
105
+ });
106
+ }
107
+ function parseValue(root, value, refs) {
108
+ return __awaiter(this, void 0, void 0, function () {
109
+ var _a, construct, settings, properties, children, ref;
110
+ var _b;
111
+ return __generator(this, function (_c) {
112
+ switch (_c.label) {
113
+ case 0:
114
+ if (!$type.isArray(value)) return [3 /*break*/, 2];
115
+ _b = {
116
+ isValue: true
117
+ };
118
+ return [4 /*yield*/, parseArray(root, value, refs)];
119
+ case 1: return [2 /*return*/, (_b.value = _c.sent(),
120
+ _b)];
121
+ case 2:
122
+ if (!$type.isObject(value)) return [3 /*break*/, 8];
123
+ if (!hasType(value)) return [3 /*break*/, 6];
124
+ if (!(value.type === "Color")) return [3 /*break*/, 3];
125
+ return [2 /*return*/, {
126
+ isValue: true,
127
+ value: Color.fromAny(value.value),
128
+ }];
129
+ case 3:
130
+ if (value.refs) {
131
+ refs = refs.concat([value.refs]);
132
+ }
133
+ return [4 /*yield*/, Promise.all([
134
+ (value.type ? getClass(value) : Promise.resolve(undefined)),
135
+ (value.settings ? parseSettings(root, value.settings, refs) : Promise.resolve(undefined)),
136
+ (value.properties ? parseProperties(root, value.properties, refs) : Promise.resolve(undefined)),
137
+ (value.children ? parseArray(root, value.children, refs) : Promise.resolve(undefined)),
138
+ ])];
139
+ case 4:
140
+ _a = __read.apply(void 0, [_c.sent(), 4]), construct = _a[0], settings = _a[1], properties = _a[2], children = _a[3];
141
+ return [2 /*return*/, {
142
+ isValue: false,
143
+ type: value.type,
144
+ construct: construct,
145
+ settings: settings,
146
+ adapters: value.adapters,
147
+ children: children,
148
+ properties: properties,
149
+ }];
150
+ case 5: return [3 /*break*/, 7];
151
+ case 6: throw new Error("Objects must have a `type` property");
152
+ case 7: return [3 /*break*/, 9];
153
+ case 8:
154
+ if ($type.isString(value)) {
155
+ if (value[0] === "#") {
156
+ ref = value.slice(1);
157
+ if (value[1] === "#") {
158
+ return [2 /*return*/, {
159
+ isValue: true,
160
+ value: ref,
161
+ }];
162
+ }
163
+ else {
164
+ return [2 /*return*/, {
165
+ isValue: true,
166
+ value: lookupRef(refs, ref),
167
+ }];
168
+ }
169
+ }
170
+ else {
171
+ return [2 /*return*/, {
172
+ isValue: true,
173
+ value: value,
174
+ }];
175
+ }
176
+ }
177
+ else {
178
+ return [2 /*return*/, {
179
+ isValue: true,
180
+ value: value,
181
+ }];
182
+ }
183
+ _c.label = 9;
184
+ case 9: return [2 /*return*/];
185
+ }
186
+ });
187
+ });
188
+ }
189
+ function mergeEntity(entity, parsed) {
190
+ if (parsed.adapters) {
191
+ $array.each(parsed.adapters, function (adapter) {
192
+ entity.adapters.add(adapter.key, adapter.callback);
193
+ });
194
+ }
195
+ if (parsed.properties) {
196
+ $array.each(parsed.properties, function (fn) {
197
+ fn(entity);
198
+ });
199
+ }
200
+ if (entity instanceof Container) {
201
+ if (parsed.children) {
202
+ entity.children.setAll(parsed.children);
203
+ }
204
+ }
205
+ }
206
+ function constructEntity(root, parsed) {
207
+ if (!parsed.construct) {
208
+ throw new Error("Could not find class `" + parsed.type + "`");
209
+ }
210
+ var entity = parsed.construct.new(root, parsed.settings || {});
211
+ mergeEntity(entity, parsed);
212
+ return entity;
213
+ }
214
+ function parseType(root, value, refs) {
215
+ return __awaiter(this, void 0, void 0, function () {
216
+ var parsed;
217
+ return __generator(this, function (_a) {
218
+ switch (_a.label) {
219
+ case 0: return [4 /*yield*/, parseValue(root, value, refs)];
220
+ case 1:
221
+ parsed = _a.sent();
222
+ if (parsed.isValue) {
223
+ return [2 /*return*/, parsed.value];
224
+ }
225
+ else {
226
+ return [2 /*return*/, constructEntity(root, parsed)];
227
+ }
228
+ return [2 /*return*/];
229
+ }
230
+ });
231
+ });
232
+ }
233
+ var JsonParser = /** @class */ (function () {
234
+ function JsonParser() {
235
+ }
236
+ Object.defineProperty(JsonParser.prototype, "parse", {
237
+ enumerable: false,
238
+ configurable: true,
239
+ writable: true,
240
+ value: function (root, object) {
241
+ return __awaiter(this, void 0, void 0, function () {
242
+ return __generator(this, function (_a) {
243
+ return [2 /*return*/, parseType(root, object, [])];
244
+ });
245
+ });
246
+ }
247
+ });
248
+ Object.defineProperty(JsonParser.prototype, "parseString", {
249
+ enumerable: false,
250
+ configurable: true,
251
+ writable: true,
252
+ value: function (root, string) {
253
+ return __awaiter(this, void 0, void 0, function () {
254
+ return __generator(this, function (_a) {
255
+ switch (_a.label) {
256
+ case 0: return [4 /*yield*/, this.parse(root, JSON.parse(string))];
257
+ case 1: return [2 /*return*/, _a.sent()];
258
+ }
259
+ });
260
+ });
261
+ }
262
+ });
263
+ return JsonParser;
264
+ }());
265
+ export { JsonParser };
266
+ //# sourceMappingURL=Json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Json.js","sourceRoot":"","sources":["../../../../../src/.internal/plugins/json/Json.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAGlD,OAAO,OAAO,MAAM,WAAW,CAAC;AAahC,SAAS,OAAO,CAAC,KAAa;IAC1B,OAAO,KAAK,CAAC,QAAQ,CAAE,KAAa,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAGD,SAAe,QAAQ,CAAC,MAAwB;;;;;;oBACtC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAsB,CAAC,CAAC;oBAChD,qBAAM,OAAO,EAAE,EAAA;wBAAtB,sBAAO,SAAgC,EAAC;;;;CAC3C;AAGD,SAAS,UAAU,CAAC,IAAU,EAAE,KAAqB,EAAE,IAAiB;IACpE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,UAAC,KAAK,IAAK,OAAA,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,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AAC,MAAM,CAAC,SAAS,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;KACjE;IAED,IAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAM,CAAC;IAEtE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE5B,OAAO,MAAM,CAAC;AAClB,CAAC;AAGD,SAAe,SAAS,CAAC,IAAU,EAAE,KAAc,EAAE,IAAiB;;;;;wBACnD,qBAAM,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAA;;oBAA5C,MAAM,GAAG,SAAmC;oBAElD,IAAI,MAAM,CAAC,OAAO,EAAE;wBAChB,sBAAO,MAAM,CAAC,KAAK,EAAC;qBAEvB;yBAAM;wBACH,sBAAO,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,EAAC;qBACxC;;;;;CACJ;AAGD;IAAA;IAQA,CAAC;;;;;eAPG,UAA8B,IAAU,EAAE,MAAe;;;oBACrD,sBAAO,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAC;;;SACtC;;;;;;eAED,UAAoC,IAAU,EAAE,MAAc;;;;gCACnD,qBAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAA;gCAAjD,sBAAO,SAA0C,EAAC;;;;SACrD;;IACL,iBAAC;AAAD,CAAC,AARD,IAQC","sourcesContent":["import type { Root } from \"../../core/Root\";\nimport type { Sprite } from \"../../core/render/Sprite\";\nimport { Entity } from \"../../core/util/Entity\";\nimport { Container } from \"../../core/render/Container\";\nimport { Color } from \"../../core/util/Color\";\n\nimport * as $type from \"../../core/util/Type\";\nimport * as $array from \"../../core/util/Array\";\nimport * as $object from \"../../core/util/Object\";\n\nimport type { IClasses } from \"./Classes\";\nimport classes from \"./Classes\";\n\n\ninterface IType {\n type: string;\n [key: string]: any;\n}\n\ninterface IRef {\n [key: string]: any;\n}\n\n\nfunction hasType(value: object): value is IType {\n return $type.isString((value as any).type);\n}\n\n\nasync function getClass(object: { type: string }): Promise<typeof Entity> {\n const promise = classes[object.type as keyof IClasses];\n return await promise() as typeof Entity;\n}\n\n\nfunction parseArray(root: Root, value: Array<unknown>, refs: Array<IRef>): Promise<any> {\n return Promise.all($array.map(value, (value) => parseType(root, value, refs)));\n}\n\n\nfunction lookupRef(refs: Array<IRef>, name: string): any {\n let i = refs.length;\n\n while (i--) {\n const sub = refs[i];\n\n if (name in sub) {\n return sub[name];\n }\n }\n\n throw new Error(\"Could not find ref #\" + name);\n}\n\n\ninterface IAdapter<E extends Entity> {\n key: keyof E[\"_settings\"],\n callback: (value: E[\"_settings\"][this[\"key\"]], target: E, key: this[\"key\"]) => E[\"_settings\"][this[\"key\"]],\n}\n\ntype IParsedProperties = Array<(entity: Entity) => void>;\n\ninterface IParsedEntity<E extends Entity> {\n isValue: false,\n type: string | undefined,\n construct: typeof Entity | undefined,\n settings: object | undefined,\n adapters: Array<IAdapter<E>> | undefined,\n children: Array<Sprite> | undefined,\n properties: IParsedProperties | undefined,\n}\n\ntype IParsed<E extends Entity>\n = IParsedEntity<E>\n | { isValue: true, value: any };\n\n\nasync function parseSettings<E extends Entity>(root: Root, object: object, refs: Array<IRef>): Promise<E[\"_settings\"]> {\n const settings: { [key: string]: any } = {};\n\n await Promise.all($array.map($object.keys(object), async (key) => {\n settings[key] = await parseType(root, object[key], refs);\n }));\n\n return settings;\n}\n\n\nasync function parseProperties(root: Root, object: object, refs: Array<IRef>): Promise<IParsedProperties> {\n return await Promise.all($array.map($object.keys(object), async (key) => {\n const parsed = await parseValue(root, object[key], refs);\n\n return (entity: Entity) => {\n const old = entity[key] as unknown;\n\n if (old && old instanceof Entity) {\n // TODO merge it if the value is an Entity\n if (parsed.isValue) {\n throw new Error(\"Cannot merge value into Entity\");\n }\n\n if (parsed.settings) {\n old.setAll(parsed.settings);\n }\n\n mergeEntity(old, parsed);\n\n } else if (parsed.isValue) {\n // TODO merge it if the value is an Entity\n (entity as any)[key] = parsed.value;\n\n } else {\n (entity as any)[key] = constructEntity(root, parsed);\n }\n };\n }));\n}\n\n\nasync function parseValue<E extends Entity>(root: Root, value: any, refs: Array<IRef>): Promise<IParsed<E>> {\n if ($type.isArray(value)) {\n return {\n isValue: true,\n value: await parseArray(root, value, refs),\n };\n\n } else if ($type.isObject(value)) {\n if (hasType(value)) {\n if (value.type === \"Color\") {\n return {\n isValue: true,\n value: Color.fromAny(value.value),\n };\n\n } else {\n if (value.refs) {\n refs = refs.concat([value.refs]);\n }\n\n const [construct, settings, properties, children] = await Promise.all([\n (value.type ? getClass(value) : Promise.resolve(undefined)),\n (value.settings ? parseSettings(root, value.settings, refs) : Promise.resolve(undefined)),\n (value.properties ? parseProperties(root, value.properties, refs) : Promise.resolve(undefined)),\n (value.children ? parseArray(root, value.children, refs) : Promise.resolve(undefined)),\n ]);\n\n return {\n isValue: false,\n type: value.type,\n construct,\n settings,\n adapters: value.adapters,\n children,\n properties,\n };\n }\n\n } else {\n throw new Error(\"Objects must have a `type` property\");\n }\n\n } else if ($type.isString(value)) {\n if (value[0] === \"#\") {\n const ref = value.slice(1);\n\n if (value[1] === \"#\") {\n return {\n isValue: true,\n value: ref,\n };\n\n } else {\n return {\n isValue: true,\n value: lookupRef(refs, ref),\n };\n }\n\n } else {\n return {\n isValue: true,\n value,\n };\n }\n\n } else {\n return {\n isValue: true,\n value,\n };\n }\n}\n\n\nfunction mergeEntity<E extends Entity>(entity: E, parsed: IParsedEntity<E>): void {\n if (parsed.adapters) {\n $array.each(parsed.adapters, (adapter) => {\n entity.adapters.add(adapter.key, adapter.callback);\n });\n }\n\n if (parsed.properties) {\n $array.each(parsed.properties, (fn) => {\n fn(entity);\n });\n }\n\n if (entity instanceof Container) {\n if (parsed.children) {\n entity.children.setAll(parsed.children);\n }\n }\n}\n\n\nfunction constructEntity<E extends Entity>(root: Root, parsed: IParsedEntity<E>): E {\n if (!parsed.construct) {\n throw new Error(\"Could not find class `\" + parsed.type + \"`\");\n }\n\n const entity = parsed.construct.new(root, parsed.settings || {}) as E;\n\n mergeEntity(entity, parsed);\n\n return entity;\n}\n\n\nasync function parseType(root: Root, value: unknown, refs: Array<IRef>): Promise<any> {\n const parsed = await parseValue(root, value, refs);\n\n if (parsed.isValue) {\n return parsed.value;\n\n } else {\n return constructEntity(root, parsed);\n }\n}\n\n\nexport class JsonParser {\n async parse<E extends Entity>(root: Root, object: unknown): Promise<E> {\n return parseType(root, object, []);\n }\n\n async parseString<E extends Entity>(root: Root, string: string): Promise<E> {\n return await this.parse(root, JSON.parse(string));\n }\n}\n"]}
package/CHANGELOG.md CHANGED
@@ -5,6 +5,57 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
5
5
  Please note, that this project, while following numbering syntax, it DOES NOT
6
6
  adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) rules.
7
7
 
8
+ ## [5.1.10] - 2022-03-30
9
+
10
+ ### Added
11
+ - New in-line text formatting property `verticalAlign` added. Currently supports only `"super"` and `"sub"` values. E.g. `Copyright[fontSize: 8px; verticalAlign: super;]TM[\]`.
12
+
13
+ ### Changed
14
+ - Logarithmic scale on `ValueAxis` was revamped with a different approach. No changes from the configration, but might influence appearance/scale.
15
+ - When calculating derivative values for series, `low`, `high`, and `open` used previous `low`, `high`, and `open` values. Now they all use `value` instead.
16
+
17
+ ### Fixed
18
+ - In some cases, using a text placehodler, an empty string was shown insteaf of a zero.
19
+ - Some grid container masking issues fixed.
20
+ - Sometimes `valueAxis` was zoomed-in a bit on the first render of an `XYChart`.
21
+ - Axis ranges with `dRadius > 0` were not visible on `RadarChart`.
22
+ - Dynamic change of `value*Show` fields of an `XYSeries` was not working.
23
+ - Removing data from a legend could lead to JS errors in some particular cases.
24
+ - Ghost label was creating a gap in an `XYChartScrollbar` between scrollbar bottom an scrollbar series.
25
+
26
+
27
+ ## [5.1.9] - 2022-03-17
28
+
29
+ ### Fixed
30
+ - Fixed the issue with resizing a chart inside of a flexbox. ([Issue 311](https://github.com/amcharts/amcharts5/issues/311))
31
+ - Fixed jumpy axis when panning an `XYChart` with mouse wheel.
32
+ - Panning XYChart with mouse wheel had incorrect direction if axis was inversed.
33
+ - If axis range had a gradient fill, gradient used to spread only through visible area, making it look icorrect.
34
+ - After pinch zooming and `XYChart` or zooming the chart with no animated theme used, CPU usage used to increase.
35
+ - `DateAxis` with `baseIntervals` `timeUnit` set to `"month"` could show incorrect month in the axis tooltip.
36
+ - If a `Graphics` had a gradient `fill`/`stroke` and initially was invisible, setting it to visible did not make the gradient to appear.
37
+ - While zooming `LineSeries`, a part of the line to the left of the first visible data point could disappear.
38
+
39
+
40
+ ## [5.1.8] - 2022-03-10
41
+
42
+ ### Added
43
+ - Settings `pinchZoomX` and `pinchZoomY` (defaults: `false`) added to `XYChart`. If set to `true` will allow pinch-zooming of a chart on touch devices. NOTE: these settings are not supported on `RadarChart`.
44
+ - `topPlotContainer` added to `XYChart`. It's a `Container` that can be used to place element over plot area.
45
+
46
+ ### Changed
47
+ - The types for adapters has been changed to be more intuitive and useful. ([Issue 312](https://github.com/amcharts/amcharts5/issues/312))
48
+ - Tapping an element on a touch device will now generate `pointerover` event in addition to `click`. When tapped somewhere else, `pointerout` event will be triggered.
49
+
50
+ ### Fixed
51
+ - Fixing ES6 module detection by BundlePhobia again ([Issue 294](https://github.com/amcharts/amcharts5/issues/294)).
52
+ - Pinch-zooming of a `MapChart` was not working well in some cases.
53
+ - `maxHeight` setting in `Sprite` was not working.
54
+ - Change of `minWidth` was not being applied at once, only if some other changes triggered chart to be redrawn.
55
+ - Changing or not setting data on an existing `FlowChart` was resulting in a JS error.
56
+ - `maxPanOut` setting in `MapChart` was not working.
57
+
58
+
8
59
  ## [5.1.7] - 2022-02-28
9
60
 
10
61
  ### Fixed
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-flow-chord",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-flow-chord-directed",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-flow-chord-non-ribbon",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-flow-sankey",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-gauge",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-gauge-bands",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-hierarchy-force-directed",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-hierarchy-pack",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-hierarchy-partition",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-hierarchy-sunburst",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-hierarchy-tree",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -3,7 +3,7 @@
3
3
  "name": "amcharts5-example-hierarchy-treemap",
4
4
  "version": "0.1.0",
5
5
  "devDependencies": {
6
- "@amcharts/amcharts5": "^5.1.7",
6
+ "@amcharts/amcharts5": "^5.1.10",
7
7
  "source-map-loader": "^3.0.0",
8
8
  "webpack": "^5.1.3",
9
9
  "webpack-cli": "^4.1.0",
@@ -0,0 +1,6 @@
1
+ Steps to use
2
+ ============
3
+
4
+ 1. Run `yarn`
5
+
6
+ 2. Run `yarn start` for development, or `yarn build` for production
@@ -0,0 +1,11 @@
1
+ body {
2
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
3
+ padding: 0;
4
+ margin: 0;
5
+ background-color: #ffffff;
6
+ }
7
+
8
+ #chartdiv {
9
+ width: 100%;
10
+ height: 80vh;
11
+ }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>amCharts 5 Example - json</title>
6
+ <link rel="stylesheet" href="index.css" />
7
+ </head>
8
+ <body>
9
+ <div id="chartdiv"></div>
10
+ <script src="dist/index.js"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,94 @@
1
+ import * as am5 from "@amcharts/amcharts5";
2
+ import * as am5xy from "@amcharts/amcharts5/xy";
3
+ import * as am5plugins_json from "@amcharts/amcharts5/plugins/json";
4
+
5
+ const root = am5.Root.new("chartdiv");
6
+
7
+ new am5plugins_json.JsonParser().parse(root, {
8
+ name: "XYChart",
9
+ settings: {
10
+ panX: false,
11
+ panY: false,
12
+ wheelX: "panX",
13
+ wheelY: "zoomX",
14
+ },
15
+ children: [
16
+ ],
17
+ }).then((chart) => {
18
+ root.container.children.push(chart);
19
+
20
+ // Add cursor
21
+ // https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/
22
+ const cursor = chart.set("cursor", am5xy.XYCursor.new(root, {
23
+ behavior: "zoomX"
24
+ }));
25
+ cursor.lineY.set("visible", false);
26
+
27
+ let date = new Date();
28
+ date.setHours(0, 0, 0, 0);
29
+ let value = 100;
30
+
31
+ function generateData() {
32
+ value = Math.round((Math.random() * 10 - 5) + value);
33
+ am5.time.add(date, "day", 1);
34
+ return {
35
+ date: date.getTime(),
36
+ value: value
37
+ };
38
+ }
39
+
40
+ function generateDatas(count) {
41
+ const data = [];
42
+ for (let i = 0; i < count; ++i) {
43
+ data.push(generateData());
44
+ }
45
+ return data;
46
+ }
47
+
48
+
49
+ // Create axes
50
+ // https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
51
+ const xAxis = chart.xAxes.push(am5xy.DateAxis.new(root, {
52
+ maxDeviation: 0,
53
+ baseInterval: {
54
+ timeUnit: "day",
55
+ count: 1
56
+ },
57
+ renderer: am5xy.AxisRendererX.new(root, {}),
58
+ tooltip: am5.Tooltip.new(root, {})
59
+ }));
60
+
61
+ const yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
62
+ renderer: am5xy.AxisRendererY.new(root, {})
63
+ }));
64
+
65
+
66
+ // Add series
67
+ // https://www.amcharts.com/docs/v5/charts/xy-chart/series/
68
+ const series = chart.series.push(am5xy.ColumnSeries.new(root, {
69
+ name: "Series",
70
+ xAxis: xAxis,
71
+ yAxis: yAxis,
72
+ valueYField: "value",
73
+ valueXField: "date",
74
+ tooltip: am5.Tooltip.new(root, {
75
+ labelText: "{valueY}"
76
+ })
77
+ }));
78
+
79
+
80
+ // Add scrollbar
81
+ // https://www.amcharts.com/docs/v5/charts/xy-chart/scrollbars/
82
+ chart.set("scrollbarX", am5.Scrollbar.new(root, {
83
+ orientation: "horizontal"
84
+ }));
85
+
86
+ let data = generateDatas(50);
87
+ series.data.setAll(data);
88
+
89
+
90
+ // Make stuff animate on load
91
+ // https://www.amcharts.com/docs/v5/concepts/animations/#Forcing_appearance_animation
92
+ series.appear(1000);
93
+ chart.appear(1000, 100);
94
+ });
@@ -0,0 +1,16 @@
1
+ {
2
+ "private": true,
3
+ "name": "amcharts5-example-json",
4
+ "version": "0.1.0",
5
+ "devDependencies": {
6
+ "@amcharts/amcharts5": "^5.1.10",
7
+ "source-map-loader": "^3.0.0",
8
+ "webpack": "^5.1.3",
9
+ "webpack-cli": "^4.1.0",
10
+ "webpack-dev-server": "^3.11.0"
11
+ },
12
+ "scripts": {
13
+ "build": "webpack",
14
+ "start": "webpack serve --mode development"
15
+ }
16
+ }
@@ -0,0 +1,38 @@
1
+ var $path = require("path");
2
+
3
+ module.exports = {
4
+ mode: "production",
5
+
6
+ devtool: "source-map",
7
+
8
+ stats: "errors-warnings",
9
+
10
+ target: ["web", "es5"],
11
+
12
+ entry: {
13
+ index: "./index.js",
14
+ },
15
+
16
+ devServer: {
17
+ publicPath: "/dist/",
18
+ liveReload: true,
19
+ overlay: true,
20
+ noInfo: true,
21
+ open: true
22
+ },
23
+
24
+ output: {
25
+ path: $path.join(__dirname, "dist"),
26
+ publicPath: "dist/",
27
+ filename: "[name].js",
28
+ chunkFilename: "[name].js"
29
+ },
30
+
31
+ module: {
32
+ rules: [{
33
+ test: /.js$/,
34
+ use: ["source-map-loader"],
35
+ enforce: "pre"
36
+ }]
37
+ }
38
+ };