@oanda/labs-crowd-view-widget 1.0.52 → 1.0.54

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 (312) hide show
  1. package/CHANGELOG.md +436 -0
  2. package/dist/main/CrowdViewWidget/Main.js +4 -6
  3. package/dist/main/CrowdViewWidget/Main.js.map +1 -1
  4. package/dist/main/CrowdViewWidget/components/Chart/Chart.js +18 -31
  5. package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
  6. package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +7 -5
  7. package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
  8. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +18 -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 +5 -52
  13. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
  14. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +54 -0
  15. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
  16. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +65 -0
  17. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
  18. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +60 -0
  19. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
  20. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +53 -0
  21. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
  22. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +31 -0
  23. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
  24. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +42 -0
  25. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
  26. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +75 -0
  27. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
  28. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js +116 -0
  29. package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
  30. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +18 -0
  31. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
  32. package/dist/main/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
  33. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
  34. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +14 -0
  35. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
  36. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +42 -0
  37. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
  38. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +14 -0
  39. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
  40. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +108 -0
  41. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
  42. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js +83 -0
  43. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
  44. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +15 -0
  45. package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
  46. package/dist/main/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
  47. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
  48. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +18 -0
  49. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
  50. package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.js +8 -41
  51. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
  52. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js +65 -0
  53. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
  54. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +65 -0
  55. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
  56. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js +43 -0
  57. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
  58. package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +8 -2
  59. package/dist/main/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
  60. package/dist/main/CrowdViewWidget/components/Chart/getOption.js +103 -0
  61. package/dist/main/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
  62. package/dist/main/CrowdViewWidget/components/Chart/index.js +11 -11
  63. package/dist/main/CrowdViewWidget/components/Chart/index.js.map +1 -1
  64. package/dist/main/CrowdViewWidget/components/Chart/types.js.map +1 -1
  65. package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +53 -30
  66. package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
  67. package/dist/main/CrowdViewWidget/components/Legend/Legend.js +15 -13
  68. package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
  69. package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +5 -16
  70. package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
  71. package/dist/main/CrowdViewWidget/constants.js +12 -18
  72. package/dist/main/CrowdViewWidget/constants.js.map +1 -1
  73. package/dist/main/gql/getOrderPositionBooks.js +1 -1
  74. package/dist/main/gql/getOrderPositionBooks.js.map +1 -1
  75. package/dist/main/gql/getPriceCandles.js +1 -1
  76. package/dist/main/gql/getPriceCandles.js.map +1 -1
  77. package/dist/main/gql/types/gql.js +2 -2
  78. package/dist/main/gql/types/gql.js.map +1 -1
  79. package/dist/main/gql/types/graphql.js +111 -18
  80. package/dist/main/gql/types/graphql.js.map +1 -1
  81. package/dist/main/translations/sources/en.json +2 -1
  82. package/dist/module/CrowdViewWidget/Main.js +3 -5
  83. package/dist/module/CrowdViewWidget/Main.js.map +1 -1
  84. package/dist/module/CrowdViewWidget/components/Chart/Chart.js +20 -33
  85. package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
  86. package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +7 -5
  87. package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
  88. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +11 -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 +5 -52
  93. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
  94. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +46 -0
  95. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
  96. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +58 -0
  97. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
  98. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +53 -0
  99. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
  100. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +46 -0
  101. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
  102. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +24 -0
  103. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
  104. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +35 -0
  105. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
  106. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +68 -0
  107. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
  108. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js +11 -0
  109. package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
  110. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +11 -0
  111. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
  112. package/dist/module/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
  113. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
  114. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +6 -0
  115. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
  116. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +35 -0
  117. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
  118. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +7 -0
  119. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
  120. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +101 -0
  121. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
  122. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js +8 -0
  123. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
  124. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +8 -0
  125. package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
  126. package/dist/module/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
  127. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
  128. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +11 -0
  129. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
  130. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js +7 -0
  131. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
  132. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js +58 -0
  133. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
  134. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +58 -0
  135. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
  136. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js +36 -0
  137. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
  138. package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +8 -2
  139. package/dist/module/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
  140. package/dist/module/CrowdViewWidget/components/Chart/getOption.js +96 -0
  141. package/dist/module/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
  142. package/dist/module/CrowdViewWidget/components/Chart/index.js +1 -1
  143. package/dist/module/CrowdViewWidget/components/Chart/index.js.map +1 -1
  144. package/dist/module/CrowdViewWidget/components/Chart/types.js.map +1 -1
  145. package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js +50 -27
  146. package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
  147. package/dist/module/CrowdViewWidget/components/Legend/Legend.js +15 -13
  148. package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
  149. package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +5 -16
  150. package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
  151. package/dist/module/CrowdViewWidget/constants.js +10 -17
  152. package/dist/module/CrowdViewWidget/constants.js.map +1 -1
  153. package/dist/module/gql/getOrderPositionBooks.js +1 -1
  154. package/dist/module/gql/getOrderPositionBooks.js.map +1 -1
  155. package/dist/module/gql/getPriceCandles.js +1 -1
  156. package/dist/module/gql/getPriceCandles.js.map +1 -1
  157. package/dist/module/gql/types/gql.js +2 -2
  158. package/dist/module/gql/types/gql.js.map +1 -1
  159. package/dist/module/gql/types/graphql.js +111 -18
  160. package/dist/module/gql/types/graphql.js.map +1 -1
  161. package/dist/module/translations/sources/en.json +2 -1
  162. package/dist/types/CrowdViewWidget/components/Chart/Chart.d.ts +1 -1
  163. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.d.ts +2 -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 +6 -0
  166. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.d.ts +9 -0
  167. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.d.ts +11 -0
  168. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.d.ts +7 -0
  169. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +16 -0
  170. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.d.ts +7 -0
  171. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.d.ts +7 -0
  172. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.d.ts +9 -0
  173. package/dist/types/CrowdViewWidget/components/Chart/chartOptions/index.d.ts +10 -0
  174. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.d.ts +1 -0
  175. package/dist/types/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.d.ts +2 -2
  176. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.d.ts +1 -0
  177. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getLabelData.d.ts +17 -0
  178. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getRectColor.d.ts +1 -0
  179. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +10 -0
  180. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/index.d.ts +7 -0
  181. package/dist/types/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.d.ts +1 -0
  182. package/dist/types/CrowdViewWidget/{utils/instrumentUtils.d.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.d.ts} +2 -2
  183. package/dist/types/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.d.ts +2 -0
  184. package/dist/types/CrowdViewWidget/components/Chart/dataUtils/index.d.ts +6 -0
  185. package/dist/types/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.d.ts +11 -0
  186. package/dist/types/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.d.ts +12 -0
  187. package/dist/types/CrowdViewWidget/components/Chart/dataUtils/processSentiments.d.ts +6 -0
  188. package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.d.ts +1 -1
  189. package/dist/types/CrowdViewWidget/components/Chart/index.d.ts +1 -1
  190. package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +28 -11
  191. package/dist/types/CrowdViewWidget/components/Legend/Legend.d.ts +1 -4
  192. package/dist/types/CrowdViewWidget/components/Legend/LegendBar.d.ts +1 -3
  193. package/dist/types/CrowdViewWidget/constants.d.ts +4 -12
  194. package/dist/types/gql/types/gql.d.ts +6 -4
  195. package/dist/types/gql/types/graphql.d.ts +30 -11
  196. package/package.json +3 -3
  197. package/src/CrowdViewWidget/Main.tsx +3 -4
  198. package/src/CrowdViewWidget/components/Chart/Chart.tsx +25 -40
  199. package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +8 -4
  200. package/src/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.ts +13 -0
  201. package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +29 -0
  202. package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +84 -0
  203. package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.ts +52 -0
  204. package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.ts +82 -0
  205. package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.ts +63 -0
  206. package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +63 -0
  207. package/src/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.ts +32 -0
  208. package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +43 -0
  209. package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +77 -0
  210. package/src/CrowdViewWidget/components/Chart/chartOptions/index.ts +10 -0
  211. package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts +16 -0
  212. package/src/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.ts +9 -6
  213. package/src/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.ts +16 -0
  214. package/src/CrowdViewWidget/components/Chart/chartUtils/getLabelData.ts +42 -0
  215. package/src/CrowdViewWidget/components/Chart/chartUtils/getRectColor.ts +27 -0
  216. package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +183 -0
  217. package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +7 -0
  218. package/src/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.ts +13 -0
  219. package/src/CrowdViewWidget/{utils/instrumentUtils.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.ts} +2 -2
  220. package/src/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.ts +14 -0
  221. package/src/CrowdViewWidget/components/Chart/dataUtils/index.ts +6 -0
  222. package/src/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.ts +92 -0
  223. package/src/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.ts +67 -0
  224. package/src/CrowdViewWidget/components/Chart/dataUtils/processSentiments.ts +55 -0
  225. package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.ts +10 -2
  226. package/src/CrowdViewWidget/components/Chart/getOption.ts +114 -0
  227. package/src/CrowdViewWidget/components/Chart/index.ts +1 -1
  228. package/src/CrowdViewWidget/components/Chart/types.ts +30 -19
  229. package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +84 -67
  230. package/src/CrowdViewWidget/components/Legend/Legend.tsx +24 -23
  231. package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +13 -26
  232. package/src/CrowdViewWidget/constants.ts +21 -23
  233. package/src/gql/getOrderPositionBooks.ts +13 -5
  234. package/src/gql/getPriceCandles.ts +1 -0
  235. package/src/gql/types/gql.ts +6 -6
  236. package/src/gql/types/graphql.ts +98 -16
  237. package/src/translations/sources/en.json +2 -1
  238. package/test/components/Chart/utils/chartUtils.test.ts +39 -21
  239. package/test/components/Chart/utils/getChartStyles.test.ts +10 -10
  240. package/test/components/Chart/utils/processSentiments.test.ts +138 -30
  241. package/test/components/Legend.test.tsx +13 -21
  242. package/test/components/LegendBar.test.tsx +31 -51
  243. package/test/utils/instrumentUtils.test.ts +1 -1
  244. package/test/utils/processOrderPositionBooks.test.ts +201 -84
  245. package/test/utils/processPriceCandles.test.ts +93 -67
  246. package/test/utils/validateData.test.ts +136 -38
  247. package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js +0 -359
  248. package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js.map +0 -1
  249. package/dist/main/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js +0 -37
  250. package/dist/main/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js.map +0 -1
  251. package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js +0 -127
  252. package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +0 -1
  253. package/dist/main/CrowdViewWidget/components/Chart/utils/getChartStyles.js.map +0 -1
  254. package/dist/main/CrowdViewWidget/components/Chart/utils/getGridLines.js.map +0 -1
  255. package/dist/main/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js +0 -14
  256. package/dist/main/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js.map +0 -1
  257. package/dist/main/CrowdViewWidget/components/Chart/utils/index.js.map +0 -1
  258. package/dist/main/CrowdViewWidget/components/Chart/utils/processBuckets.js +0 -29
  259. package/dist/main/CrowdViewWidget/components/Chart/utils/processBuckets.js.map +0 -1
  260. package/dist/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js +0 -23
  261. package/dist/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
  262. package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js +0 -43
  263. package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
  264. package/dist/main/CrowdViewWidget/components/Chart/utils/processSentiments.js +0 -28
  265. package/dist/main/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +0 -1
  266. package/dist/main/CrowdViewWidget/components/Chart/utils/validateData.js.map +0 -1
  267. package/dist/main/CrowdViewWidget/utils/instrumentUtils.js.map +0 -1
  268. package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js +0 -351
  269. package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js.map +0 -1
  270. package/dist/module/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js +0 -29
  271. package/dist/module/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js.map +0 -1
  272. package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js +0 -114
  273. package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +0 -1
  274. package/dist/module/CrowdViewWidget/components/Chart/utils/getChartStyles.js.map +0 -1
  275. package/dist/module/CrowdViewWidget/components/Chart/utils/getGridLines.js.map +0 -1
  276. package/dist/module/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js +0 -7
  277. package/dist/module/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js.map +0 -1
  278. package/dist/module/CrowdViewWidget/components/Chart/utils/index.js +0 -10
  279. package/dist/module/CrowdViewWidget/components/Chart/utils/index.js.map +0 -1
  280. package/dist/module/CrowdViewWidget/components/Chart/utils/processBuckets.js +0 -22
  281. package/dist/module/CrowdViewWidget/components/Chart/utils/processBuckets.js.map +0 -1
  282. package/dist/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js +0 -16
  283. package/dist/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
  284. package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js +0 -36
  285. package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
  286. package/dist/module/CrowdViewWidget/components/Chart/utils/processSentiments.js +0 -21
  287. package/dist/module/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +0 -1
  288. package/dist/module/CrowdViewWidget/components/Chart/utils/validateData.js.map +0 -1
  289. package/dist/module/CrowdViewWidget/utils/instrumentUtils.js.map +0 -1
  290. package/dist/types/CrowdViewWidget/components/Chart/utils/aggregateBuckets.d.ts +0 -2
  291. package/dist/types/CrowdViewWidget/components/Chart/utils/chartUtils.d.ts +0 -31
  292. package/dist/types/CrowdViewWidget/components/Chart/utils/getGridLines.d.ts +0 -97
  293. package/dist/types/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.d.ts +0 -3
  294. package/dist/types/CrowdViewWidget/components/Chart/utils/index.d.ts +0 -9
  295. package/dist/types/CrowdViewWidget/components/Chart/utils/processBuckets.d.ts +0 -3
  296. package/dist/types/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.d.ts +0 -8
  297. package/dist/types/CrowdViewWidget/components/Chart/utils/processPriceCandles.d.ts +0 -27
  298. package/dist/types/CrowdViewWidget/components/Chart/utils/processSentiments.d.ts +0 -3
  299. package/src/CrowdViewWidget/components/Chart/chartOptions.ts +0 -401
  300. package/src/CrowdViewWidget/components/Chart/utils/aggregateBuckets.ts +0 -44
  301. package/src/CrowdViewWidget/components/Chart/utils/chartUtils.ts +0 -216
  302. package/src/CrowdViewWidget/components/Chart/utils/getGridLines.ts +0 -148
  303. package/src/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.ts +0 -13
  304. package/src/CrowdViewWidget/components/Chart/utils/index.ts +0 -9
  305. package/src/CrowdViewWidget/components/Chart/utils/processBuckets.ts +0 -43
  306. package/src/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.ts +0 -30
  307. package/src/CrowdViewWidget/components/Chart/utils/processPriceCandles.ts +0 -53
  308. package/src/CrowdViewWidget/components/Chart/utils/processSentiments.ts +0 -42
  309. package/test/utils/aggregateBuckets.test.ts +0 -82
  310. package/test/utils/getTargetBucketWidth.test.ts +0 -37
  311. package/test/utils/processBuckets.test.ts +0 -153
  312. /package/dist/types/CrowdViewWidget/components/Chart/{chartOptions.d.ts → getOption.d.ts} +0 -0
@@ -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: `${CHART_CONFIG.Y_SENTIMENT_LABEL_SIZE}px`,
16
+ right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
17
+ top: '0px',
18
+ bottom: `${CHART_CONFIG.X_LABEL_SIZE}px`,
19
+ height: `${CHART_CONFIG.MAIN_HEIGHT}px`,
20
+ },
21
+ {
22
+ id: 'sentiment-grid',
23
+ name: 'sentiment-grid',
24
+ left: `${CHART_CONFIG.Y_SENTIMENT_LABEL_SIZE}px`,
25
+ right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
26
+ top: `0px`,
27
+ height: `${CHART_CONFIG.MAIN_HEIGHT}px`,
28
+ },
29
+ ];
@@ -0,0 +1,84 @@
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
+ }
9
+
10
+ export const getGridLines = ({
11
+ isDark,
12
+ }: GetGridLinesParams): GraphicComponentOption[] => {
13
+ const { WIDTH, MAIN_HEIGHT, X_LABEL_SIZE, Y_SENTIMENT_LABEL_SIZE } =
14
+ CHART_CONFIG;
15
+ return [
16
+ // Top
17
+ {
18
+ ...getLineCommons(isDark),
19
+ top: -2,
20
+ shape: {
21
+ x1: 0,
22
+ y1: 0,
23
+ x2: WIDTH,
24
+ y2: 0,
25
+ },
26
+ },
27
+ // Right
28
+ {
29
+ ...getLineCommons(isDark),
30
+ right: -2,
31
+ shape: {
32
+ x1: 0,
33
+ y1: 0,
34
+ x2: 0,
35
+ y2: MAIN_HEIGHT + X_LABEL_SIZE + 2,
36
+ },
37
+ },
38
+ // Bottom
39
+ {
40
+ ...getLineCommons(isDark),
41
+ bottom: -2,
42
+ shape: {
43
+ x1: 0,
44
+ y1: 0,
45
+ x2: WIDTH,
46
+ y2: 0,
47
+ },
48
+ },
49
+ // Left
50
+ {
51
+ ...getLineCommons(isDark),
52
+ left: -2,
53
+ shape: {
54
+ x1: 0,
55
+ y1: 0,
56
+ x2: 0,
57
+ y2: MAIN_HEIGHT + X_LABEL_SIZE + 2,
58
+ },
59
+ },
60
+ // Y Sentiment Label
61
+ {
62
+ ...getLineCommons(isDark),
63
+ left: Y_SENTIMENT_LABEL_SIZE - 2,
64
+ top: -2,
65
+ shape: {
66
+ x1: 0,
67
+ y1: 0,
68
+ x2: 0,
69
+ y2: MAIN_HEIGHT,
70
+ },
71
+ },
72
+ // X Label
73
+ {
74
+ ...getLineCommons(isDark),
75
+ top: MAIN_HEIGHT - 2,
76
+ shape: {
77
+ x1: 0,
78
+ y1: 0,
79
+ x2: WIDTH,
80
+ y2: 0,
81
+ },
82
+ },
83
+ ];
84
+ };
@@ -0,0 +1,52 @@
1
+ import chroma from 'chroma-js';
2
+ import type { CandlestickSeriesOption } from 'echarts';
3
+
4
+ import { getLabelData } from '../chartUtils';
5
+ import type { ChartStyles } from '../chartUtils/getChartStyles';
6
+
7
+ interface GetSeriesCandlestickConfigParams {
8
+ dates: string[];
9
+ isGreaterThanTwoWeeks: boolean;
10
+ styles: ChartStyles;
11
+ }
12
+
13
+ export const getSeriesCandlestickConfig = ({
14
+ dates,
15
+ isGreaterThanTwoWeeks,
16
+ styles,
17
+ }: GetSeriesCandlestickConfigParams): CandlestickSeriesOption => {
18
+ const { candleLongColor, candleShortColor } = styles;
19
+ const labelsData = getLabelData({
20
+ dates,
21
+ isGreaterThanTwoWeeks,
22
+ });
23
+
24
+ return {
25
+ type: 'candlestick',
26
+ id: 'candlestick',
27
+ xAxisIndex: 0,
28
+ yAxisIndex: 0,
29
+ encode: {
30
+ x: 'dates',
31
+ y: ['open', 'close', 'low', 'high'],
32
+ },
33
+ itemStyle: {
34
+ color: chroma(candleLongColor).desaturate().css(),
35
+ color0: chroma(candleShortColor).desaturate().css(),
36
+ borderColor: candleLongColor,
37
+ borderColor0: candleShortColor,
38
+ },
39
+ emphasis: {
40
+ itemStyle: {
41
+ color: candleLongColor,
42
+ color0: candleShortColor,
43
+ },
44
+ },
45
+ markPoint: {
46
+ data: labelsData,
47
+ symbol: 'circle',
48
+ symbolSize: 0,
49
+ },
50
+ z: 2,
51
+ };
52
+ };
@@ -0,0 +1,82 @@
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
+ }
17
+
18
+ export const getSeriesHeatmapConfig = ({
19
+ bucketWidth,
20
+ buckets,
21
+ isDark,
22
+ sentimentThresholdMax,
23
+ sentimentThresholdMin,
24
+ }: GetSeriesHeatmapConfigParams): CustomSeriesOption => {
25
+ return {
26
+ type: 'custom',
27
+ id: 'heatmap',
28
+ name: 'heatmap',
29
+ xAxisIndex: 0,
30
+ yAxisIndex: 0,
31
+ encode: {
32
+ x: 'dates',
33
+ y: 'bookPrices',
34
+ },
35
+ dimensions: ['dates', 'bookPrices', 'bookIndexes'],
36
+ clip: true,
37
+ renderItem: (
38
+ _params: CustomSeriesRenderItemParams,
39
+ api: CustomSeriesRenderItemAPI
40
+ ) => {
41
+ const xVal = api.value(0);
42
+ const bucketIndex = api.value(2) as number;
43
+
44
+ if (bucketIndex == null) {
45
+ return null;
46
+ }
47
+
48
+ const metaValues = buckets[bucketIndex];
49
+
50
+ const [rectWidth, rectHeight] = api.size!([0, bucketWidth]) as number[];
51
+
52
+ const items = metaValues.map(({ price, sentiment }: Bucket) => {
53
+ const start = api.coord([xVal, price]);
54
+
55
+ return {
56
+ shape: {
57
+ height: rectHeight,
58
+ width: rectWidth + 1,
59
+ x: start[0] - rectWidth / 2,
60
+ y: start[1] - rectHeight,
61
+ },
62
+ style: {
63
+ fill: getRectColor(
64
+ sentiment,
65
+ isDark,
66
+ sentimentThresholdMin,
67
+ sentimentThresholdMax
68
+ ),
69
+ },
70
+ type: 'rect' as const,
71
+ };
72
+ });
73
+
74
+ return {
75
+ children: items,
76
+ emphasisDisabled: true,
77
+ type: 'group' as const,
78
+ };
79
+ },
80
+ z: 1,
81
+ };
82
+ };
@@ -0,0 +1,63 @@
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
+ }
9
+
10
+ export const getSeriesSentimentConfig = ({
11
+ styles,
12
+ }: GetSeriesSentimentConfigParams): LineSeriesOption => {
13
+ return {
14
+ type: 'line',
15
+ id: 'sentiment',
16
+ name: 'sentiment',
17
+ xAxisIndex: 1,
18
+ yAxisIndex: 1,
19
+ encode: {
20
+ x: 'dates',
21
+ y: 'sentimentShorts',
22
+ },
23
+ dimensions: ['dates', 'sentimentShorts', 'sentimentLongs'],
24
+ lineStyle: {
25
+ width: styles.sentimentOutlineWidth,
26
+ opacity: 1,
27
+ shadowColor: styles.sentimentOutlineColor,
28
+ shadowBlur: 3,
29
+ },
30
+ emphasis: {
31
+ disabled: true,
32
+ },
33
+ markLine: {
34
+ silent: true,
35
+ symbol: ['none', 'none'],
36
+ label: {
37
+ show: false,
38
+ },
39
+ lineStyle: {
40
+ color: colorPalette.grayLight,
41
+ width: 1,
42
+ },
43
+ data: [
44
+ {
45
+ yAxis: 20,
46
+ },
47
+ {
48
+ yAxis: 50,
49
+ lineStyle: {
50
+ width: 1,
51
+ },
52
+ },
53
+ {
54
+ yAxis: 80,
55
+ },
56
+ ],
57
+ },
58
+ stack: 'sentiment',
59
+ showSymbol: false,
60
+ symbol: 'none',
61
+ z: 3,
62
+ };
63
+ };
@@ -0,0 +1,63 @@
1
+ import type { TooltipComponentOption } from 'echarts';
2
+
3
+ import type { BookType } from '../../../../gql/types/graphql';
4
+ import { getTooltipFormatter } from '../chartUtils';
5
+ import type { Bucket, TooltipParam } from '../types';
6
+
7
+ interface GetTooltipConfigParams {
8
+ bookType: BookType;
9
+ bucketWidth: number;
10
+ buckets: Bucket[][];
11
+ displayPrecision: number;
12
+ labelCallback: (key: string, params?: Record<string, unknown>) => string;
13
+ selectedPriceRef: { current: number };
14
+ tooltipLinesColor: string;
15
+ }
16
+
17
+ export const getTooltipConfig = ({
18
+ bookType,
19
+ bucketWidth,
20
+ buckets,
21
+ displayPrecision,
22
+ labelCallback,
23
+ selectedPriceRef,
24
+ tooltipLinesColor,
25
+ }: GetTooltipConfigParams): TooltipComponentOption => ({
26
+ trigger: 'axis' as const,
27
+ formatter: (params) =>
28
+ getTooltipFormatter({
29
+ bookType,
30
+ bucketWidth,
31
+ buckets,
32
+ labelCallback,
33
+ params: params as unknown as TooltipParam[],
34
+ selectedPrice: selectedPriceRef.current,
35
+ }),
36
+
37
+ axisPointer: {
38
+ type: 'cross' as const,
39
+ axis: 'x' as const,
40
+ lineStyle: {
41
+ color: tooltipLinesColor,
42
+ },
43
+ crossStyle: {
44
+ color: tooltipLinesColor,
45
+ },
46
+ label: {
47
+ padding: 0,
48
+ lineHeight: 24,
49
+ formatter: (params: {
50
+ axisDimension?: string;
51
+ axisIndex?: number;
52
+ value: unknown;
53
+ }) => {
54
+ if (params.axisDimension === 'y' && params.axisIndex === 0) {
55
+ selectedPriceRef.current = Number(params.value);
56
+ return ` ${Number(params.value).toFixed(displayPrecision)} `;
57
+ }
58
+ return '';
59
+ },
60
+ },
61
+ },
62
+ confine: true,
63
+ });
@@ -0,0 +1,32 @@
1
+ import type { VisualMapComponentOption } from 'echarts';
2
+
3
+ import { CHART_CONFIG } from '../../../constants';
4
+
5
+ interface GetVisualMapConfigParams {
6
+ sentimentLongColor: string;
7
+ sentimentShortColor: string;
8
+ }
9
+
10
+ export const getVisualMapConfig = ({
11
+ sentimentLongColor,
12
+ sentimentShortColor,
13
+ }: GetVisualMapConfigParams): VisualMapComponentOption => ({
14
+ show: false,
15
+ dimension: 1,
16
+ seriesId: 'sentiment',
17
+ pieces: [
18
+ {
19
+ lt: CHART_CONFIG.SENTIMENT_MAX / 2,
20
+ color: sentimentShortColor,
21
+ },
22
+ {
23
+ gte: CHART_CONFIG.SENTIMENT_MAX / 2,
24
+ lte: CHART_CONFIG.SENTIMENT_MAX,
25
+ color: sentimentLongColor,
26
+ },
27
+ {
28
+ gt: CHART_CONFIG.SENTIMENT_MAX,
29
+ color: sentimentLongColor,
30
+ },
31
+ ],
32
+ });
@@ -0,0 +1,43 @@
1
+ import type { XAXisComponentOption } from 'echarts';
2
+
3
+ import { formatXAxisLabel } from '../chartUtils';
4
+
5
+ interface GetXAxisConfigParams {
6
+ dates: string[];
7
+ isGreaterThanTwoWeeks: boolean;
8
+ }
9
+
10
+ export const getXAxisConfig = ({
11
+ dates,
12
+ isGreaterThanTwoWeeks,
13
+ }: GetXAxisConfigParams): XAXisComponentOption[] => [
14
+ {
15
+ type: 'category',
16
+ id: 'main-xAxis',
17
+ name: 'xAxis-less-than-two-weeks',
18
+ nameTextStyle: {
19
+ fontSize: 0,
20
+ },
21
+ axisTick: {
22
+ show: false,
23
+ },
24
+ axisLabel: {
25
+ padding: [8, 16, 8, 16],
26
+ margin: 0,
27
+ formatter: (value: unknown) =>
28
+ formatXAxisLabel(value, isGreaterThanTwoWeeks),
29
+ },
30
+ },
31
+ {
32
+ type: 'category',
33
+ gridIndex: 1,
34
+ show: false,
35
+ axisTick: {
36
+ show: false,
37
+ },
38
+ axisLabel: {
39
+ show: false,
40
+ },
41
+ data: dates,
42
+ },
43
+ ];
@@ -0,0 +1,77 @@
1
+ import type { YAXisComponentOption } from 'echarts';
2
+
3
+ import { BUCKET_CONFIG, CHART_CONFIG } from '../../../constants';
4
+
5
+ interface GetYAxisConfigParams {
6
+ bucketWidth: number;
7
+ displayPrecision: number;
8
+ isDesktop: boolean;
9
+ labelCallback: (key: string, params?: Record<string, unknown>) => string;
10
+ }
11
+
12
+ export const getYAxisConfig = ({
13
+ bucketWidth,
14
+ displayPrecision,
15
+ isDesktop,
16
+ labelCallback,
17
+ }: GetYAxisConfigParams): YAXisComponentOption[] => [
18
+ {
19
+ type: 'value',
20
+ gridIndex: 0,
21
+ position: 'right',
22
+ min: (val: { min: number }) =>
23
+ val.min - bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,
24
+ max: (val: { max: number }) =>
25
+ val.max + bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,
26
+ axisLine: { show: false },
27
+ axisTick: { show: false },
28
+ axisLabel: {
29
+ showMinLabel: false,
30
+ showMaxLabel: false,
31
+ formatter: (value: number) => value.toFixed(displayPrecision - 1),
32
+ },
33
+ },
34
+ {
35
+ type: 'value',
36
+ gridIndex: 1,
37
+ position: 'left',
38
+ min: CHART_CONFIG.SENTIMENT_MIN,
39
+ max: CHART_CONFIG.SENTIMENT_MAX,
40
+ axisLine: { show: false },
41
+ axisTick: { show: false },
42
+ axisPointer: {
43
+ show: false,
44
+ },
45
+ axisLabel: {
46
+ margin: isDesktop ? 4 : 2,
47
+ lineHeight: 20,
48
+ verticalAlignMinLabel: 'bottom',
49
+ verticalAlignMaxLabel: 'top',
50
+ customValues: [
51
+ CHART_CONFIG.SENTIMENT_MIN,
52
+ CHART_CONFIG.SENTIMENT_MAX / 5,
53
+ CHART_CONFIG.SENTIMENT_MAX / 2,
54
+ (CHART_CONFIG.SENTIMENT_MAX * 4) / 5,
55
+ CHART_CONFIG.SENTIMENT_MAX,
56
+ ],
57
+ formatter: (value: number) => {
58
+ if (value === CHART_CONFIG.SENTIMENT_MIN) {
59
+ return `${labelCallback('short')}`;
60
+ }
61
+ if (value === CHART_CONFIG.SENTIMENT_MAX) {
62
+ return `${labelCallback('long')}`;
63
+ }
64
+ if (value === CHART_CONFIG.SENTIMENT_MAX / 2) {
65
+ return '50%';
66
+ }
67
+ if (value === CHART_CONFIG.SENTIMENT_MAX / 5) {
68
+ return '80%';
69
+ }
70
+ if (value === (CHART_CONFIG.SENTIMENT_MAX * 4) / 5) {
71
+ return '20%';
72
+ }
73
+ return '';
74
+ },
75
+ },
76
+ },
77
+ ];
@@ -0,0 +1,10 @@
1
+ export * from './getDataZoomConfig';
2
+ export * from './getGridConfig';
3
+ export * from './getGridLines';
4
+ export * from './getSeriesCandlestickConfig';
5
+ export * from './getSeriesHeatmapConfig';
6
+ export * from './getSeriesSentimentConfig';
7
+ export * from './getTooltipConfig';
8
+ export * from './getVisualMapConfig';
9
+ export * from './getXAxisConfig';
10
+ export * from './getYAxisConfig';
@@ -0,0 +1,16 @@
1
+ import { CHART_CONFIG } from '../../../constants';
2
+
3
+ export const formatXAxisLabel = (
4
+ value: unknown,
5
+ isGreaterThanTwoWeeks: boolean
6
+ ) => {
7
+ const date = new Date(value as string);
8
+ return isGreaterThanTwoWeeks
9
+ ? `${date.toLocaleTimeString(undefined, {
10
+ hour: '2-digit',
11
+ minute: '2-digit',
12
+ })}`
13
+ : `${CHART_CONFIG.X_AXIS_DATE_PADDING}${date.toLocaleDateString(undefined, {
14
+ day: 'numeric',
15
+ })}${CHART_CONFIG.X_AXIS_DATE_PADDING}`;
16
+ };
@@ -3,11 +3,11 @@ import { colorPalette } from '@oanda/labs-widget-common';
3
3
  export interface ChartStyles {
4
4
  sentimentLongColor: string;
5
5
  sentimentShortColor: string;
6
+ sentimentOutlineColor: string;
6
7
  candleLongColor: string;
7
8
  candleShortColor: string;
8
- sentimentAreaOpacity: number;
9
9
  tooltipLinesColor: string;
10
- sentimentLabelColor: string;
10
+ sentimentOutlineWidth: number;
11
11
  }
12
12
 
13
13
  export const getChartStyles = (isDark: boolean): ChartStyles => {
@@ -18,25 +18,28 @@ export const getChartStyles = (isDark: boolean): ChartStyles => {
18
18
  ? colorPalette.darkYellow90
19
19
  : colorPalette.lightYellow90;
20
20
 
21
+ const sentimentOutlineColor = isDark
22
+ ? colorPalette.black
23
+ : colorPalette.white;
24
+ const sentimentOutlineWidth = isDark ? 3 : 2;
25
+
21
26
  const candleLongColor = isDark
22
27
  ? colorPalette.bottleGreenDark
23
28
  : colorPalette.bottleGreenLight;
24
29
  const candleShortColor = isDark
25
30
  ? colorPalette.orange
26
31
  : colorPalette.raspberryLight;
27
- const sentimentAreaOpacity = isDark ? 0.5 : 0.2;
28
32
  const tooltipLinesColor = isDark
29
33
  ? colorPalette.orange
30
34
  : colorPalette.bottleGreenLight;
31
- const sentimentLabelColor = isDark ? colorPalette.white : colorPalette.black;
32
35
 
33
36
  return {
34
37
  sentimentLongColor,
35
38
  sentimentShortColor,
39
+ sentimentOutlineColor,
36
40
  candleLongColor,
37
41
  candleShortColor,
38
- sentimentAreaOpacity,
39
42
  tooltipLinesColor,
40
- sentimentLabelColor,
43
+ sentimentOutlineWidth,
41
44
  };
42
45
  };
@@ -0,0 +1,16 @@
1
+ import chroma from 'chroma-js';
2
+
3
+ export const getGradientColor = (
4
+ value: number,
5
+ startColor: string,
6
+ targetColor: string,
7
+ minThreshold: number,
8
+ maxThreshold: number
9
+ ): string => {
10
+ const colorScale = chroma
11
+ .scale([startColor, targetColor])
12
+ .domain([minThreshold, maxThreshold])
13
+ .mode('rgb');
14
+
15
+ return colorScale(value).hex();
16
+ };
@@ -0,0 +1,42 @@
1
+ import { CHART_CONFIG } from '../../../constants';
2
+ import type { GetLabelsDataProps } from '../types';
3
+
4
+ export const getLabelData = ({
5
+ dates,
6
+ isGreaterThanTwoWeeks,
7
+ }: GetLabelsDataProps) =>
8
+ dates
9
+ .filter((record, index, arr) => {
10
+ if (index === 0) {
11
+ return false;
12
+ }
13
+ const previousTimestamp = arr[index - 1];
14
+ const currentDate = new Date(record);
15
+ const previousDate = new Date(previousTimestamp);
16
+
17
+ return isGreaterThanTwoWeeks
18
+ ? currentDate.getDate() !== previousDate.getDate()
19
+ : currentDate.getMonth() !== previousDate.getMonth();
20
+ })
21
+ .map(
22
+ (item) =>
23
+ ({
24
+ name: new Date(item).toLocaleDateString(undefined, {
25
+ month: isGreaterThanTwoWeeks ? 'short' : 'long',
26
+ day: isGreaterThanTwoWeeks ? 'numeric' : undefined,
27
+ }),
28
+ xAxis: item,
29
+ y: CHART_CONFIG.MAIN_HEIGHT + CHART_CONFIG.X_LABEL_SIZE - 22,
30
+ silent: true,
31
+ emphasis: {
32
+ disabled: true,
33
+ },
34
+ label: {
35
+ fontFamily: 'Sofia W03',
36
+ fontSize: 10,
37
+ position: 'bottom' as const,
38
+ align: 'center' as const,
39
+ formatter: '{b}',
40
+ },
41
+ }) as const
42
+ );
@@ -0,0 +1,27 @@
1
+ import { COLOR_MAP } from '../../../constants';
2
+ import { getGradientColor } from './getGradientColor';
3
+
4
+ export const getRectColor = (
5
+ sentiment: number,
6
+ isDark: boolean,
7
+ minThreshold: number,
8
+ maxThreshold: number
9
+ ) => {
10
+ const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
11
+
12
+ return sentiment < 0
13
+ ? getGradientColor(
14
+ sentiment * -1,
15
+ colorPalette.short[0],
16
+ colorPalette.short[1],
17
+ minThreshold,
18
+ maxThreshold
19
+ )
20
+ : getGradientColor(
21
+ sentiment,
22
+ colorPalette.long[0],
23
+ colorPalette.long[1],
24
+ minThreshold,
25
+ maxThreshold
26
+ );
27
+ };