@oanda/labs-crowd-view-widget 1.0.53 → 1.0.55

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 (289) hide show
  1. package/CHANGELOG.md +444 -0
  2. package/dist/main/CrowdViewWidget/Main.js +4 -2
  3. package/dist/main/CrowdViewWidget/Main.js.map +1 -1
  4. package/dist/main/CrowdViewWidget/components/Chart/Chart.js +41 -83
  5. package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
  6. package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +23 -17
  7. package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
  8. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +24 -0
  9. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -0
  10. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +30 -0
  11. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -0
  12. package/dist/main/CrowdViewWidget/components/Chart/{utils → chartOptions}/getGridLines.js +30 -49
  13. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
  14. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +159 -0
  15. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -0
  16. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +47 -0
  17. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
  18. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +83 -0
  19. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
  20. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +68 -0
  21. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
  22. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +60 -0
  23. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
  24. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +31 -0
  25. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
  26. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +57 -0
  27. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
  28. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +66 -0
  29. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
  30. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js +127 -0
  31. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
  32. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +18 -0
  33. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -0
  34. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +18 -0
  35. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
  36. package/dist/main/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
  37. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
  38. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +14 -0
  39. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
  40. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +23 -0
  41. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
  42. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +14 -0
  43. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
  44. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +120 -0
  45. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
  46. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +59 -0
  47. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -0
  48. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js +34 -0
  49. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js.map +1 -0
  50. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js +116 -0
  51. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
  52. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +15 -0
  53. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
  54. package/dist/main/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
  55. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
  56. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js +19 -0
  57. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js.map +1 -0
  58. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +18 -0
  59. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
  60. package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.js +19 -8
  61. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
  62. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
  63. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
  64. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
  65. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
  66. package/dist/main/CrowdViewWidget/components/Chart/getOption.js +115 -0
  67. package/dist/main/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
  68. package/dist/main/CrowdViewWidget/components/Chart/index.js +11 -11
  69. package/dist/main/CrowdViewWidget/components/Chart/index.js.map +1 -1
  70. package/dist/main/CrowdViewWidget/components/Chart/types.js.map +1 -1
  71. package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +15 -12
  72. package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
  73. package/dist/main/CrowdViewWidget/components/Legend/Legend.js +15 -12
  74. package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
  75. package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +15 -16
  76. package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
  77. package/dist/main/CrowdViewWidget/constants.js +20 -14
  78. package/dist/main/CrowdViewWidget/constants.js.map +1 -1
  79. package/dist/main/CrowdViewWidget/selectConfig.js +0 -6
  80. package/dist/main/CrowdViewWidget/selectConfig.js.map +1 -1
  81. package/dist/main/translations/sources/en.json +3 -1
  82. package/dist/module/CrowdViewWidget/Main.js +4 -2
  83. package/dist/module/CrowdViewWidget/Main.js.map +1 -1
  84. package/dist/module/CrowdViewWidget/components/Chart/Chart.js +43 -84
  85. package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
  86. package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +22 -16
  87. package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
  88. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +17 -0
  89. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -0
  90. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +23 -0
  91. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -0
  92. package/dist/module/CrowdViewWidget/components/Chart/{utils → chartOptions}/getGridLines.js +30 -49
  93. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
  94. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +151 -0
  95. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -0
  96. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +39 -0
  97. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
  98. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +76 -0
  99. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
  100. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +61 -0
  101. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
  102. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +53 -0
  103. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
  104. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +24 -0
  105. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
  106. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +50 -0
  107. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
  108. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +59 -0
  109. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
  110. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js +12 -0
  111. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
  112. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +11 -0
  113. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -0
  114. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +11 -0
  115. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
  116. package/dist/module/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
  117. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
  118. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +6 -0
  119. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
  120. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +16 -0
  121. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
  122. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +7 -0
  123. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
  124. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +113 -0
  125. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
  126. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +52 -0
  127. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -0
  128. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js +27 -0
  129. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js.map +1 -0
  130. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js +11 -0
  131. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
  132. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +8 -0
  133. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
  134. package/dist/module/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
  135. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
  136. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js +12 -0
  137. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js.map +1 -0
  138. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +11 -0
  139. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
  140. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js +8 -0
  141. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
  142. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
  143. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
  144. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
  145. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
  146. package/dist/module/CrowdViewWidget/components/Chart/getOption.js +108 -0
  147. package/dist/module/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
  148. package/dist/module/CrowdViewWidget/components/Chart/index.js +1 -1
  149. package/dist/module/CrowdViewWidget/components/Chart/index.js.map +1 -1
  150. package/dist/module/CrowdViewWidget/components/Chart/types.js.map +1 -1
  151. package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js +8 -5
  152. package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
  153. package/dist/module/CrowdViewWidget/components/Legend/Legend.js +15 -12
  154. package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
  155. package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +15 -16
  156. package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
  157. package/dist/module/CrowdViewWidget/constants.js +18 -13
  158. package/dist/module/CrowdViewWidget/constants.js.map +1 -1
  159. package/dist/module/CrowdViewWidget/selectConfig.js +0 -6
  160. package/dist/module/CrowdViewWidget/selectConfig.js.map +1 -1
  161. package/dist/module/translations/sources/en.json +3 -1
  162. package/dist/types/CrowdViewWidget/components/Chart/Chart.d.ts +1 -1
  163. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.d.ts +6 -0
  164. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.d.ts +6 -0
  165. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridLines.d.ts +7 -0
  166. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.d.ts +8 -0
  167. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.d.ts +8 -0
  168. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.d.ts +12 -0
  169. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.d.ts +8 -0
  170. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +18 -0
  171. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.d.ts +7 -0
  172. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.d.ts +7 -0
  173. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.d.ts +7 -0
  174. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/index.d.ts +11 -0
  175. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.d.ts +1 -0
  176. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.d.ts +1 -0
  177. package/dist/types/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.d.ts +2 -2
  178. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.d.ts +1 -0
  179. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getLabelData.d.ts +2 -0
  180. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getRectColor.d.ts +1 -0
  181. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +12 -0
  182. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.d.ts +4 -0
  183. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.d.ts +3 -0
  184. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/index.d.ts +10 -0
  185. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.d.ts +1 -0
  186. package/dist/types/CrowdViewWidget/{utils/instrumentUtils.d.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.d.ts} +2 -2
  187. package/dist/types/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.d.ts +2 -0
  188. package/dist/types/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.d.ts +2 -0
  189. package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.d.ts +3 -2
  190. package/dist/types/CrowdViewWidget/components/Chart/index.d.ts +1 -1
  191. package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +5 -0
  192. package/dist/types/CrowdViewWidget/components/Legend/Legend.d.ts +1 -4
  193. package/dist/types/CrowdViewWidget/components/Legend/LegendBar.d.ts +1 -3
  194. package/dist/types/CrowdViewWidget/constants.d.ts +13 -9
  195. package/package.json +3 -3
  196. package/src/CrowdViewWidget/Main.tsx +3 -2
  197. package/src/CrowdViewWidget/components/Chart/Chart.tsx +76 -109
  198. package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +33 -28
  199. package/src/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.ts +22 -0
  200. package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +29 -0
  201. package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +126 -0
  202. package/src/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.ts +191 -0
  203. package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.ts +44 -0
  204. package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.ts +103 -0
  205. package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.ts +72 -0
  206. package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +74 -0
  207. package/src/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.ts +32 -0
  208. package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +68 -0
  209. package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +60 -0
  210. package/src/CrowdViewWidget/components/Chart/chartOptions/index.ts +11 -0
  211. package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.ts +13 -0
  212. package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts +16 -0
  213. package/src/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.ts +9 -6
  214. package/src/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.ts +16 -0
  215. package/src/CrowdViewWidget/components/Chart/chartUtils/getLabelData.ts +18 -0
  216. package/src/CrowdViewWidget/components/Chart/chartUtils/getRectColor.ts +27 -0
  217. package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +212 -0
  218. package/src/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.ts +75 -0
  219. package/src/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.ts +37 -0
  220. package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +10 -0
  221. package/src/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.ts +13 -0
  222. package/src/CrowdViewWidget/{utils/instrumentUtils.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.ts} +2 -2
  223. package/src/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.ts +13 -0
  224. package/src/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.ts +14 -0
  225. package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.ts +3 -2
  226. package/src/CrowdViewWidget/components/Chart/getOption.ts +138 -0
  227. package/src/CrowdViewWidget/components/Chart/index.ts +1 -1
  228. package/src/CrowdViewWidget/components/Chart/types.ts +5 -0
  229. package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +14 -7
  230. package/src/CrowdViewWidget/components/Legend/Legend.tsx +24 -22
  231. package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +29 -26
  232. package/src/CrowdViewWidget/constants.ts +30 -19
  233. package/src/CrowdViewWidget/selectConfig.ts +0 -8
  234. package/src/translations/sources/en.json +3 -1
  235. package/test/components/Chart/utils/chartUtils.test.ts +20 -9
  236. package/test/components/Chart/utils/getChartStyles.test.ts +10 -10
  237. package/test/components/Chart/utils/handleLabelUpdate.test.ts +419 -0
  238. package/test/components/Chart/utils/handleTooltipUpdate.test.ts +140 -0
  239. package/test/components/Chart/utils/processSentiments.test.ts +1 -1
  240. package/test/components/Legend.test.tsx +15 -23
  241. package/test/components/LegendBar.test.tsx +45 -63
  242. package/test/utils/instrumentUtils.test.ts +1 -1
  243. package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js +0 -399
  244. package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js.map +0 -1
  245. package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js +0 -126
  246. package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +0 -1
  247. package/dist/main/CrowdViewWidget/components/Chart/utils/getChartStyles.js.map +0 -1
  248. package/dist/main/CrowdViewWidget/components/Chart/utils/getGridLines.js.map +0 -1
  249. package/dist/main/CrowdViewWidget/components/Chart/utils/index.js.map +0 -1
  250. package/dist/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
  251. package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
  252. package/dist/main/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +0 -1
  253. package/dist/main/CrowdViewWidget/components/Chart/utils/validateData.js.map +0 -1
  254. package/dist/main/CrowdViewWidget/utils/instrumentUtils.js.map +0 -1
  255. package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js +0 -391
  256. package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js.map +0 -1
  257. package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js +0 -113
  258. package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +0 -1
  259. package/dist/module/CrowdViewWidget/components/Chart/utils/getChartStyles.js.map +0 -1
  260. package/dist/module/CrowdViewWidget/components/Chart/utils/getGridLines.js.map +0 -1
  261. package/dist/module/CrowdViewWidget/components/Chart/utils/index.js +0 -7
  262. package/dist/module/CrowdViewWidget/components/Chart/utils/index.js.map +0 -1
  263. package/dist/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
  264. package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
  265. package/dist/module/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +0 -1
  266. package/dist/module/CrowdViewWidget/components/Chart/utils/validateData.js.map +0 -1
  267. package/dist/module/CrowdViewWidget/utils/instrumentUtils.js.map +0 -1
  268. package/dist/types/CrowdViewWidget/components/Chart/utils/chartUtils.d.ts +0 -30
  269. package/dist/types/CrowdViewWidget/components/Chart/utils/getGridLines.d.ts +0 -97
  270. package/src/CrowdViewWidget/components/Chart/chartOptions.ts +0 -449
  271. package/src/CrowdViewWidget/components/Chart/utils/chartUtils.ts +0 -228
  272. package/src/CrowdViewWidget/components/Chart/utils/getGridLines.ts +0 -148
  273. /package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/processOrderPositionBooks.js +0 -0
  274. /package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/processPriceCandles.js +0 -0
  275. /package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/processSentiments.js +0 -0
  276. /package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +0 -0
  277. /package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/processOrderPositionBooks.js +0 -0
  278. /package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/processPriceCandles.js +0 -0
  279. /package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/processSentiments.js +0 -0
  280. /package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +0 -0
  281. /package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/processOrderPositionBooks.d.ts +0 -0
  282. /package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/processPriceCandles.d.ts +0 -0
  283. /package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/processSentiments.d.ts +0 -0
  284. /package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.d.ts +0 -0
  285. /package/dist/types/CrowdViewWidget/components/Chart/{chartOptions.d.ts → getOption.d.ts} +0 -0
  286. /package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/processOrderPositionBooks.ts +0 -0
  287. /package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/processPriceCandles.ts +0 -0
  288. /package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/processSentiments.ts +0 -0
  289. /package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.ts +0 -0
@@ -5,9 +5,9 @@ import {
5
5
  SpinnerSize,
6
6
  useLayoutProvider,
7
7
  } from '@oanda/labs-widget-common';
8
- import React from 'react';
8
+ import React, { useEffect, useState } from 'react';
9
+ import { useDebounceCallback } from 'usehooks-ts';
9
10
 
10
- import { Legend } from '../Legend';
11
11
  import { Chart } from './Chart';
12
12
  import type { ChartWithDataProps } from './types';
13
13
  import { useCrowdViewData } from './useCrowdViewData';
@@ -18,51 +18,56 @@ const ChartWithData = ({
18
18
  division,
19
19
  granularity,
20
20
  }: ChartWithDataProps) => {
21
- const { size, isDark } = useLayoutProvider();
21
+ const { size } = useLayoutProvider();
22
+ const [debouncedLoading, setDebouncedLoading] = useState(true);
22
23
  const isDesktop = size === Size.DESKTOP;
23
24
 
24
- const { mainData, additionalData, loading, error } = useCrowdViewData({
25
- instrument,
26
- bookType,
27
- division,
28
- granularity,
29
- });
25
+ const { mainData, additionalData, loading, priceCandlesLoading, error } =
26
+ useCrowdViewData({
27
+ instrument,
28
+ bookType,
29
+ division,
30
+ granularity,
31
+ });
32
+
33
+ const hideLoading = useDebounceCallback(
34
+ () => setDebouncedLoading(false),
35
+ 500
36
+ );
37
+
38
+ useEffect(() => {
39
+ if (loading === false) {
40
+ hideLoading();
41
+ }
42
+ if (loading === true) {
43
+ setDebouncedLoading(true);
44
+ }
45
+ }, [loading, hideLoading]);
30
46
 
31
47
  return (
32
48
  <>
33
- <div className="lw-relative lw-h-[610px] lw-w-full">
49
+ <div className="lw-relative lw-h-[440px] lw-w-full lw-overflow-hidden">
34
50
  {error && (
35
51
  <div className="lw-absolute lw-left-0 lw-top-0 lw-flex lw-h-full lw-w-full lw-items-center lw-justify-center lw-border lw-border-solid lw-border-border-primary">
36
52
  <ChartError />
37
53
  </div>
38
54
  )}
39
- {loading && (
40
- <div className="lw-absolute lw-left-0 lw-top-0 lw-flex lw-h-full lw-w-full lw-items-center lw-justify-center lw-border lw-border-solid lw-border-border-primary">
41
- <Spinner size={SpinnerSize.lg} />
42
- </div>
43
- )}
44
- {!loading && !error && !!mainData && !!additionalData && (
55
+ {!priceCandlesLoading && !error && !!mainData && !!additionalData && (
45
56
  <div className="lw-absolute lw-left-0 lw-top-0 lw-flex lw-h-full lw-w-full">
46
57
  <Chart
47
58
  additionalData={additionalData}
48
59
  isDesktop={isDesktop}
60
+ isLoading={debouncedLoading}
49
61
  mainData={mainData}
50
62
  />
51
63
  </div>
52
64
  )}
65
+ {loading && (
66
+ <div className="lw-absolute lw-left-0 lw-top-0 lw-flex lw-h-full lw-w-full lw-items-center lw-justify-center lw-border lw-border-solid lw-border-border-primary lw-bg-bg-transparent-50">
67
+ <Spinner size={SpinnerSize.lg} />
68
+ </div>
69
+ )}
53
70
  </div>
54
- <Legend
55
- bookType={bookType}
56
- isDark={isDark}
57
- longValues={[
58
- additionalData?.sentimentThresholdMin,
59
- additionalData?.sentimentThresholdMax,
60
- ]}
61
- shortValues={[
62
- additionalData?.sentimentThresholdMin,
63
- additionalData?.sentimentThresholdMax,
64
- ]}
65
- />
66
71
  </>
67
72
  );
68
73
  };
@@ -0,0 +1,22 @@
1
+ import type { DataZoomComponentOption } from 'echarts';
2
+
3
+ import { CHART_CONFIG } from '../../../constants';
4
+
5
+ interface GetDataZoomConfigParams {
6
+ isDesktop: boolean;
7
+ }
8
+
9
+ export const getDataZoomConfig = ({
10
+ isDesktop,
11
+ }: GetDataZoomConfigParams): DataZoomComponentOption => ({
12
+ type: 'inside',
13
+ id: 'main',
14
+ xAxisIndex: [0, 1],
15
+ start: isDesktop
16
+ ? CHART_CONFIG.INITIAL_START_ZOOM_DESKTOP
17
+ : CHART_CONFIG.INITIAL_START_ZOOM_MOBILE,
18
+ end: CHART_CONFIG.INITIAL_END_ZOOM,
19
+ filterMode: 'filter',
20
+ minSpan: 10,
21
+ preventDefaultMouseMove: true,
22
+ });
@@ -0,0 +1,29 @@
1
+ import type { GridComponentOption } from 'echarts';
2
+
3
+ import { CHART_CONFIG } from '../../../constants';
4
+
5
+ interface GetGridConfigParams {
6
+ isDesktop: boolean;
7
+ }
8
+
9
+ export const getGridConfig = ({
10
+ isDesktop,
11
+ }: GetGridConfigParams): GridComponentOption[] => [
12
+ {
13
+ id: 'main-grid',
14
+ name: 'main-grid',
15
+ left: `${isDesktop ? CHART_CONFIG.Y_SENTIMENT_LABEL_DESKTOP_SIZE : CHART_CONFIG.Y_SENTIMENT_LABEL_MOBILE_SIZE}px`,
16
+ right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
17
+ top: `${isDesktop ? CHART_CONFIG.TOP_MARGIN_DESKTOP : CHART_CONFIG.TOP_MARGIN_MOBILE}px`,
18
+ bottom: `${CHART_CONFIG.X_LABEL_SIZE}px`,
19
+ height: `${isDesktop ? CHART_CONFIG.MAIN_HEIGHT - CHART_CONFIG.TOP_MARGIN_DESKTOP : CHART_CONFIG.MAIN_HEIGHT - CHART_CONFIG.TOP_MARGIN_MOBILE}px`,
20
+ },
21
+ {
22
+ id: 'sentiment-grid',
23
+ name: 'sentiment-grid',
24
+ left: `${isDesktop ? CHART_CONFIG.Y_SENTIMENT_LABEL_DESKTOP_SIZE : CHART_CONFIG.Y_SENTIMENT_LABEL_MOBILE_SIZE}px`,
25
+ right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
26
+ top: `${isDesktop ? CHART_CONFIG.TOP_MARGIN_DESKTOP : CHART_CONFIG.TOP_MARGIN_MOBILE}px`,
27
+ height: `${isDesktop ? CHART_CONFIG.MAIN_HEIGHT - CHART_CONFIG.TOP_MARGIN_DESKTOP : CHART_CONFIG.MAIN_HEIGHT - CHART_CONFIG.TOP_MARGIN_MOBILE}px`,
28
+ },
29
+ ];
@@ -0,0 +1,126 @@
1
+ import { getLineCommons } from '@oanda/labs-widget-common';
2
+ import type { GraphicComponentOption } from 'echarts';
3
+
4
+ import { CHART_CONFIG } from '../../../constants';
5
+
6
+ interface GetGridLinesParams {
7
+ isDark: boolean;
8
+ isDesktop: boolean;
9
+ }
10
+
11
+ export const getGridLines = ({
12
+ isDark,
13
+ isDesktop,
14
+ }: GetGridLinesParams): GraphicComponentOption[] => {
15
+ const { WIDTH, MAIN_HEIGHT, X_LABEL_SIZE } = CHART_CONFIG;
16
+ const ySentimentLabelSize = isDesktop
17
+ ? CHART_CONFIG.Y_SENTIMENT_LABEL_DESKTOP_SIZE
18
+ : CHART_CONFIG.Y_SENTIMENT_LABEL_MOBILE_SIZE;
19
+
20
+ const yLabelSize = isDesktop
21
+ ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP
22
+ : CHART_CONFIG.Y_LABEL_SIZE_MOBILE;
23
+
24
+ const topMargin = isDesktop ? 0 : CHART_CONFIG.TOP_MARGIN_MOBILE;
25
+
26
+ return [
27
+ // Top
28
+ {
29
+ ...getLineCommons(isDark),
30
+ top: -2,
31
+ shape: {
32
+ x1: 0,
33
+ y1: 0,
34
+ x2: WIDTH,
35
+ y2: 0,
36
+ },
37
+ z: 30,
38
+ },
39
+ // Right
40
+ {
41
+ ...getLineCommons(isDark),
42
+ right: -2,
43
+ shape: {
44
+ x1: 0,
45
+ y1: 0,
46
+ x2: 0,
47
+ y2: MAIN_HEIGHT + X_LABEL_SIZE + 2,
48
+ },
49
+ z: 30,
50
+ },
51
+ // Bottom
52
+ {
53
+ ...getLineCommons(isDark),
54
+ bottom: -2,
55
+ shape: {
56
+ x1: 0,
57
+ y1: 0,
58
+ x2: WIDTH,
59
+ y2: 0,
60
+ },
61
+ z: 30,
62
+ },
63
+ // Left
64
+ {
65
+ ...getLineCommons(isDark),
66
+ left: -2,
67
+ shape: {
68
+ x1: 0,
69
+ y1: 0,
70
+ x2: 0,
71
+ y2: MAIN_HEIGHT + X_LABEL_SIZE + 2,
72
+ },
73
+ z: 30,
74
+ },
75
+ // Y Label
76
+ {
77
+ ...getLineCommons(isDark),
78
+ right: yLabelSize - 3,
79
+ top: topMargin - 2,
80
+ shape: {
81
+ x1: 0,
82
+ y1: 0,
83
+ x2: 0,
84
+ y2: MAIN_HEIGHT - topMargin,
85
+ },
86
+ z: 30,
87
+ },
88
+ // Y Sentiment Label
89
+ {
90
+ ...getLineCommons(isDark),
91
+ left: ySentimentLabelSize - 2,
92
+ top: topMargin - 2,
93
+ shape: {
94
+ x1: 0,
95
+ y1: 0,
96
+ x2: 0,
97
+ y2: MAIN_HEIGHT - topMargin,
98
+ },
99
+ z: 30,
100
+ },
101
+ // X Label
102
+ {
103
+ ...getLineCommons(isDark),
104
+ bottom: X_LABEL_SIZE - 3,
105
+ shape: {
106
+ x1: 0,
107
+ y1: 0,
108
+ x2: WIDTH,
109
+ y2: 0,
110
+ },
111
+ z: 30,
112
+ },
113
+ // X Mobile Label
114
+ {
115
+ ...getLineCommons(isDark),
116
+ top: topMargin - 3,
117
+ shape: {
118
+ x1: 0,
119
+ y1: 0,
120
+ x2: WIDTH,
121
+ y2: 0,
122
+ },
123
+ z: 30,
124
+ },
125
+ ];
126
+ };
@@ -0,0 +1,191 @@
1
+ import { colorPalette } from '@oanda/labs-widget-common';
2
+ import chroma from 'chroma-js';
3
+ import type { GraphicComponentOption } from 'echarts';
4
+
5
+ import { CHART_CONFIG } from '../../../constants';
6
+
7
+ interface getLabelsConfigParams {
8
+ isDark: boolean;
9
+ isDesktop: boolean;
10
+ labelCallback: (key: string, params?: Record<string, unknown>) => string;
11
+ }
12
+
13
+ export const getLabelsConfig = ({
14
+ isDark,
15
+ isDesktop,
16
+ labelCallback,
17
+ }: getLabelsConfigParams): GraphicComponentOption[] => {
18
+ const ySentimentLabelSize = isDesktop
19
+ ? CHART_CONFIG.Y_SENTIMENT_LABEL_DESKTOP_SIZE
20
+ : CHART_CONFIG.Y_SENTIMENT_LABEL_MOBILE_SIZE;
21
+
22
+ const yMainLabelSize = isDesktop
23
+ ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP
24
+ : CHART_CONFIG.Y_LABEL_SIZE_MOBILE;
25
+
26
+ const textColor = isDark ? colorPalette.white : colorPalette.black;
27
+ const labelBackgroundColor = isDark
28
+ ? colorPalette.darkGray
29
+ : colorPalette.white;
30
+ const backgroundColor = isDark ? colorPalette.black : colorPalette.white;
31
+ const shadowColor = chroma(colorPalette.black).alpha(0.1).hex();
32
+
33
+ // Estimate text width for centering rotated text
34
+ // Approximate: fontSize * characterCount * 0.65 (typical character width ratio)
35
+ const sentimentText = labelCallback('sentiment').toUpperCase();
36
+ const priceText = labelCallback('price').toUpperCase();
37
+ const sentimentEstimatedWidth = 10 * sentimentText.length * 0.65;
38
+ const priceEstimatedWidth = 10 * priceText.length * 0.65;
39
+ const sentimentVerticalOffset = sentimentEstimatedWidth / 2;
40
+ const priceVerticalOffset = priceEstimatedWidth / 2;
41
+
42
+ const topMargin = isDesktop
43
+ ? CHART_CONFIG.TOP_MARGIN_DESKTOP
44
+ : CHART_CONFIG.TOP_MARGIN_MOBILE;
45
+
46
+ return [
47
+ {
48
+ type: 'group',
49
+ left: `${ySentimentLabelSize + 5}px'`,
50
+ top: `${topMargin + 5}px`,
51
+ silent: true,
52
+ children: [
53
+ {
54
+ type: 'rect',
55
+ z: 100,
56
+ right: 'center',
57
+ top: 'middle',
58
+ shape: {
59
+ width: 50,
60
+ height: 24,
61
+ },
62
+ style: {
63
+ fill: labelBackgroundColor,
64
+ shadowBlur: 8,
65
+ shadowOffsetX: 0,
66
+ shadowOffsetY: 1,
67
+ shadowColor: shadowColor,
68
+ },
69
+ },
70
+ {
71
+ type: 'text',
72
+ z: 100,
73
+ right: 'center',
74
+ top: 'middle',
75
+ style: {
76
+ fontSize: 11,
77
+ fontFamily: 'Sofia W03',
78
+ fontWeight: 500,
79
+ fill: textColor,
80
+ width: 70,
81
+ height: 30,
82
+ text: labelCallback('short'),
83
+ },
84
+ },
85
+ ],
86
+ },
87
+ {
88
+ type: 'group',
89
+ left: `${ySentimentLabelSize + 5}px'`,
90
+ top: `${CHART_CONFIG.MAIN_HEIGHT - 24 - 5}px`,
91
+ silent: true,
92
+ children: [
93
+ {
94
+ type: 'rect',
95
+ z: 100,
96
+ right: 'center',
97
+ top: 'middle',
98
+ shape: {
99
+ width: 50,
100
+ height: 24,
101
+ },
102
+ style: {
103
+ fill: labelBackgroundColor,
104
+ shadowBlur: 8,
105
+ shadowOffsetX: 0,
106
+ shadowOffsetY: 1,
107
+ shadowColor: shadowColor,
108
+ },
109
+ },
110
+ {
111
+ type: 'text',
112
+ z: 100,
113
+ right: 'center',
114
+ top: 'middle',
115
+ style: {
116
+ fontSize: 11,
117
+ fontFamily: 'Sofia W03',
118
+ fontWeight: 500,
119
+ fill: textColor,
120
+ width: 70,
121
+ height: 30,
122
+ text: labelCallback('long'),
123
+ },
124
+ },
125
+ ],
126
+ },
127
+
128
+ {
129
+ type: 'text',
130
+ z: 30,
131
+ rotation: isDesktop ? Math.PI / 2 : 0,
132
+ left: `5px`,
133
+ top: isDesktop
134
+ ? `${topMargin + CHART_CONFIG.MAIN_HEIGHT / 2 - sentimentVerticalOffset}px`
135
+ : `${topMargin - 18}px`,
136
+ silent: true,
137
+ style: {
138
+ fontSize: 10,
139
+ fontFamily: 'Sofia W03',
140
+ fontWeight: 300,
141
+ fill: textColor,
142
+ text: sentimentText,
143
+ },
144
+ },
145
+ {
146
+ type: 'text',
147
+ z: 30,
148
+ rotation: isDesktop ? -Math.PI / 2 : 0,
149
+ right: `5px`,
150
+ top: isDesktop
151
+ ? `${topMargin + CHART_CONFIG.MAIN_HEIGHT / 2 - priceVerticalOffset}px`
152
+ : `${topMargin - 18}px`,
153
+ silent: true,
154
+ style: {
155
+ fontSize: 10,
156
+ fontFamily: 'Sofia W03',
157
+ fontWeight: 300,
158
+ fill: textColor,
159
+ text: priceText,
160
+ },
161
+ },
162
+ {
163
+ type: 'rect',
164
+ z: 20,
165
+ right: '0px',
166
+ top: '0px',
167
+ shape: {
168
+ width: yMainLabelSize,
169
+ height: CHART_CONFIG.MAIN_HEIGHT,
170
+ },
171
+ silent: true,
172
+ style: {
173
+ fill: backgroundColor,
174
+ },
175
+ },
176
+ {
177
+ type: 'rect',
178
+ z: 20,
179
+ left: '0px',
180
+ top: '0px',
181
+ shape: {
182
+ width: ySentimentLabelSize,
183
+ height: CHART_CONFIG.MAIN_HEIGHT,
184
+ },
185
+ silent: true,
186
+ style: {
187
+ fill: backgroundColor,
188
+ },
189
+ },
190
+ ];
191
+ };
@@ -0,0 +1,44 @@
1
+ import chroma from 'chroma-js';
2
+ import type { CandlestickSeriesOption } from 'echarts';
3
+
4
+ import type { ChartStyles } from '../chartUtils/getChartStyles';
5
+
6
+ interface GetSeriesCandlestickConfigParams {
7
+ styles: ChartStyles;
8
+ isLoading: boolean;
9
+ }
10
+
11
+ export const getSeriesCandlestickConfig = ({
12
+ styles,
13
+ isLoading,
14
+ }: GetSeriesCandlestickConfigParams): CandlestickSeriesOption => {
15
+ const { candleLongColor, candleShortColor } = styles;
16
+
17
+ return {
18
+ animation: isLoading,
19
+ type: 'candlestick',
20
+ id: 'candlestick',
21
+ xAxisIndex: 0,
22
+ yAxisIndex: 0,
23
+ silent: true,
24
+ clip: true,
25
+ large: true,
26
+ encode: {
27
+ x: 'dates',
28
+ y: ['open', 'close', 'low', 'high'],
29
+ },
30
+ itemStyle: {
31
+ color: chroma(candleLongColor).desaturate().css(),
32
+ color0: chroma(candleShortColor).desaturate().css(),
33
+ borderColor: candleLongColor,
34
+ borderColor0: candleShortColor,
35
+ },
36
+ emphasis: {
37
+ itemStyle: {
38
+ color: candleLongColor,
39
+ color0: candleShortColor,
40
+ },
41
+ },
42
+ z: 3,
43
+ };
44
+ };
@@ -0,0 +1,103 @@
1
+ import type {
2
+ CustomSeriesOption,
3
+ CustomSeriesRenderItemAPI,
4
+ CustomSeriesRenderItemParams,
5
+ } from 'echarts';
6
+
7
+ import { getRectColor } from '../chartUtils';
8
+ import type { Bucket } from '../types';
9
+
10
+ interface GetSeriesHeatmapConfigParams {
11
+ bucketWidth: number;
12
+ buckets: Bucket[][];
13
+ isDark: boolean;
14
+ sentimentThresholdMax: number;
15
+ sentimentThresholdMin: number;
16
+ isLoading: boolean;
17
+ }
18
+
19
+ export const getSeriesHeatmapConfig = ({
20
+ bucketWidth,
21
+ buckets,
22
+ isDark,
23
+ sentimentThresholdMax,
24
+ sentimentThresholdMin,
25
+ isLoading,
26
+ }: GetSeriesHeatmapConfigParams): CustomSeriesOption => {
27
+ return {
28
+ animation: isLoading,
29
+ type: 'custom',
30
+ id: 'heatmap',
31
+ name: 'heatmap',
32
+ xAxisIndex: 0,
33
+ yAxisIndex: 0,
34
+ encode: {
35
+ x: 'dates',
36
+ y: 'bookPrices',
37
+ },
38
+ dimensions: ['dates', 'bookPrices', 'bookIndexes'],
39
+ clip: true,
40
+ renderItem: (
41
+ params: CustomSeriesRenderItemParams,
42
+ api: CustomSeriesRenderItemAPI
43
+ ) => {
44
+ const animationDelay =
45
+ (350 * params.dataIndexInside) / params.dataInsideLength;
46
+ const xVal = api.value(0);
47
+ const bucketIndex = api.value(2) as number;
48
+
49
+ if (bucketIndex == null) {
50
+ return null;
51
+ }
52
+
53
+ const metaValues = buckets[bucketIndex];
54
+
55
+ if (!metaValues) {
56
+ return null;
57
+ }
58
+
59
+ const [rectWidth, rectHeight] = api.size!([0, bucketWidth]) as number[];
60
+
61
+ const items = metaValues.map(({ price, sentiment }: Bucket) => {
62
+ const start = api.coord([xVal, price]);
63
+
64
+ return {
65
+ silent: true,
66
+ shape: {
67
+ height: rectHeight,
68
+ width: rectWidth + 1,
69
+ x: start[0] - rectWidth / 2,
70
+ y: start[1] - rectHeight,
71
+ },
72
+ style: {
73
+ fill: getRectColor(
74
+ sentiment,
75
+ isDark,
76
+ sentimentThresholdMin,
77
+ sentimentThresholdMax
78
+ ),
79
+ },
80
+ enterFrom: {
81
+ shape: {},
82
+ style: {
83
+ opacity: 0,
84
+ },
85
+ },
86
+ enterAnimation: {
87
+ duration: 150,
88
+ delay: animationDelay,
89
+ },
90
+ type: 'rect' as const,
91
+ };
92
+ });
93
+
94
+ return {
95
+ children: items,
96
+ emphasisDisabled: true,
97
+ silent: true,
98
+ type: 'group' as const,
99
+ };
100
+ },
101
+ z: 1,
102
+ };
103
+ };
@@ -0,0 +1,72 @@
1
+ import { colorPalette } from '@oanda/labs-widget-common';
2
+ import type { LineSeriesOption } from 'echarts';
3
+
4
+ import type { ChartStyles } from '../chartUtils';
5
+
6
+ interface GetSeriesSentimentConfigParams {
7
+ styles: ChartStyles;
8
+ isLoading: boolean;
9
+ }
10
+
11
+ export const getSeriesSentimentConfig = ({
12
+ styles,
13
+ isLoading,
14
+ }: GetSeriesSentimentConfigParams): LineSeriesOption => {
15
+ return {
16
+ animation: isLoading,
17
+ animationDelay: 350,
18
+ type: 'line',
19
+ id: 'sentiment',
20
+ name: 'sentiment',
21
+ xAxisIndex: 1,
22
+ yAxisIndex: 1,
23
+ encode: {
24
+ x: 'dates',
25
+ y: 'sentimentLongs',
26
+ },
27
+ dimensions: ['dates', 'sentimentLongs', 'sentimentShorts'],
28
+ lineStyle: {
29
+ width: styles.sentimentOutlineWidth,
30
+ opacity: 1,
31
+ shadowColor: styles.sentimentOutlineColor,
32
+ shadowBlur: 3,
33
+ },
34
+ emphasis: {
35
+ disabled: true,
36
+ },
37
+ tooltip: {
38
+ show: false,
39
+ },
40
+ markLine: {
41
+ animation: isLoading,
42
+ silent: true,
43
+ symbol: ['none', 'none'],
44
+ label: {
45
+ show: false,
46
+ },
47
+ lineStyle: {
48
+ color: colorPalette.grayLight,
49
+ width: 1,
50
+ },
51
+ data: [
52
+ {
53
+ yAxis: 20,
54
+ },
55
+ {
56
+ yAxis: 50,
57
+ lineStyle: {
58
+ width: 1,
59
+ },
60
+ },
61
+ {
62
+ yAxis: 80,
63
+ },
64
+ ],
65
+ },
66
+ showSymbol: false,
67
+ symbol: 'none',
68
+ z: 2,
69
+ connectNulls: true,
70
+ silent: true,
71
+ };
72
+ };