@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
@@ -1,401 +0,0 @@
1
- import chroma from 'chroma-js';
2
-
3
- import { CHART_CONFIG, CHART_CONFIG_CALCULATED } from '../../constants';
4
- import type { Bucket, GetOptionType, TooltipParam } from './types';
5
- import {
6
- formatXAxisLabel,
7
- getLabelData,
8
- getRectColor,
9
- getTooltipFormatter,
10
- isDifferenceGreaterThanTwoWeeks,
11
- } from './utils/chartUtils';
12
- import { getChartStyles } from './utils/getChartStyles';
13
- import { getGridLines } from './utils/getGridLines';
14
-
15
- // @ts-expect-error
16
- export const getOption: GetOptionType = (
17
- {
18
- xAxisData,
19
- candlesSeriesData,
20
- orderPositionBooks,
21
- bucketWidth,
22
- buckets,
23
- precision,
24
- bookType,
25
- sentiments,
26
- },
27
- isDark,
28
- isDesktop,
29
- labelCallback
30
- ) => {
31
- let selectedPrice: number;
32
- const {
33
- sentimentLongColor,
34
- sentimentShortColor,
35
- candleLongColor,
36
- candleShortColor,
37
- sentimentAreaOpacity,
38
- tooltipLinesColor,
39
- sentimentLabelColor,
40
- } = getChartStyles(isDark);
41
-
42
- const visibleXAxisData = xAxisData.slice(
43
- (xAxisData.length * CHART_CONFIG.INITIAL_START_ZOOM) / 100,
44
- (xAxisData.length * CHART_CONFIG.INITIAL_END_ZOOM) / 100
45
- );
46
-
47
- const isGreaterThanTwoWeeks = isDifferenceGreaterThanTwoWeeks(
48
- visibleXAxisData[0],
49
- visibleXAxisData[visibleXAxisData.length - 1]
50
- );
51
-
52
- const labelsData = getLabelData({
53
- xAxisData,
54
- isGreaterThanTwoWeeks,
55
- });
56
-
57
- const gridMainLines = getGridLines({
58
- isDark,
59
- isDesktop,
60
- });
61
-
62
- return {
63
- animation: false,
64
- dataZoom: [
65
- {
66
- id: 'main',
67
- type: 'inside',
68
- xAxisIndex: 0,
69
- start: CHART_CONFIG.INITIAL_START_ZOOM,
70
- end: CHART_CONFIG.INITIAL_END_ZOOM,
71
- filterMode: 'filter',
72
- },
73
- {
74
- id: 'sentiment',
75
- type: 'inside',
76
- xAxisIndex: 1,
77
- start: CHART_CONFIG.INITIAL_START_ZOOM,
78
- end: CHART_CONFIG.INITIAL_END_ZOOM,
79
- filterMode: 'none',
80
- },
81
- ],
82
- tooltip: {
83
- trigger: 'axis',
84
- axisPointer: {
85
- type: 'cross',
86
- axis: 'x',
87
- lineStyle: {
88
- color: tooltipLinesColor,
89
- },
90
- crossStyle: {
91
- color: tooltipLinesColor,
92
- },
93
- label: {
94
- padding: 0,
95
- lineHeight: 24,
96
- formatter: (params) => {
97
- if (params.axisDimension === 'y' && params.axisIndex === 0) {
98
- selectedPrice = Number(params.value);
99
- return ` ${Number(params.value).toFixed(precision)} `;
100
- }
101
-
102
- return null;
103
- },
104
- },
105
- },
106
- confine: true,
107
- formatter: (params: TooltipParam[]) =>
108
- getTooltipFormatter({
109
- params,
110
- buckets,
111
- bucketWidth,
112
- selectedPrice,
113
- labelCallback,
114
- precision,
115
- bookType,
116
- }),
117
- },
118
- xAxis: [
119
- {
120
- type: 'category',
121
- name: 'xAxis-less-than-two-weeks',
122
- nameTextStyle: {
123
- fontSize: 0,
124
- },
125
- id: 'main-xAxis',
126
- data: xAxisData,
127
- splitNumber: 1,
128
- axisTick: {
129
- show: false,
130
- },
131
- axisLabel: {
132
- padding: [8, 16, 8, 16],
133
- margin: 0,
134
- formatter: (value) => formatXAxisLabel(value, isGreaterThanTwoWeeks),
135
- },
136
- },
137
- {
138
- type: 'category',
139
- gridIndex: 1,
140
- show: false,
141
- data: xAxisData,
142
- splitNumber: 1,
143
- axisTick: {
144
- show: false,
145
- },
146
- axisLabel: {
147
- show: false,
148
- },
149
- },
150
- ],
151
- yAxis: [
152
- {
153
- type: 'value',
154
- gridIndex: 0,
155
- position: 'right',
156
- min: (val) => val.min - bucketWidth * 2,
157
- max: (val) => val.max + bucketWidth * 2,
158
- axisLine: { show: false },
159
- axisTick: { show: false },
160
- axisLabel: {
161
- showMaxLabel: false,
162
- showMinLabel: false,
163
- margin: isDesktop ? 4 : 2,
164
- formatter: (value: number) => value.toFixed(precision - 1),
165
- },
166
- },
167
- {
168
- type: 'value',
169
- gridIndex: 1,
170
- position: 'right',
171
- min: CHART_CONFIG.SENTIMENT_MIN,
172
- max: CHART_CONFIG.SENTIMENT_MAX,
173
- interval: CHART_CONFIG.SENTIMENT_INTERVAL,
174
- axisLine: { show: false },
175
- axisTick: { show: false },
176
- axisLabel: {
177
- verticalAlignMaxLabel: 'top',
178
- verticalAlignMinLabel: 'bottom',
179
- lineHeight: 20,
180
- margin: isDesktop ? 4 : 2,
181
- rich: {
182
- shortRect: {
183
- backgroundColor: chroma(sentimentShortColor).alpha(0.3).css(),
184
- borderColor: sentimentShortColor,
185
- borderWidth: 1,
186
- width: 8,
187
- height: 8,
188
- },
189
- longRect: {
190
- backgroundColor: chroma(sentimentLongColor).alpha(0.3).css(),
191
- borderColor: sentimentLongColor,
192
- borderWidth: 1,
193
- width: 8,
194
- height: 8,
195
- },
196
- },
197
- formatter: (value: number) => {
198
- if (value === CHART_CONFIG.SENTIMENT_MIN) {
199
- return `{shortRect| } ${labelCallback('short')}`;
200
- }
201
-
202
- if (value === CHART_CONFIG.SENTIMENT_MAX) {
203
- return `{longRect| } ${labelCallback('long')}`;
204
- }
205
-
206
- if (value === CHART_CONFIG.SENTIMENT_MAX / 2) {
207
- return '50%';
208
- }
209
-
210
- return undefined;
211
- },
212
- },
213
- },
214
- ],
215
- axisPointer: {
216
- link: [
217
- {
218
- xAxisIndex: 'all',
219
- },
220
- ],
221
- },
222
- visualMap: {
223
- show: false,
224
- seriesId: 'sentiment',
225
- dimension: 1,
226
- pieces: [
227
- {
228
- lt: CHART_CONFIG.SENTIMENT_MAX / 2,
229
- color: sentimentShortColor,
230
- },
231
- {
232
- gte: CHART_CONFIG.SENTIMENT_MAX / 2,
233
- lte: CHART_CONFIG.SENTIMENT_MAX,
234
- color: sentimentLongColor,
235
- },
236
- {
237
- gt: CHART_CONFIG.SENTIMENT_MAX,
238
- color: sentimentLongColor,
239
- },
240
- ],
241
- },
242
- series: [
243
- {
244
- type: 'candlestick',
245
- id: 'candlestick',
246
- gridIndex: 0,
247
- xAxisIndex: 0,
248
- yAxisIndex: 0,
249
- data: candlesSeriesData,
250
- itemStyle: {
251
- color: chroma(candleShortColor).desaturate().css(),
252
- color0: chroma(candleLongColor).desaturate().css(),
253
- borderColor: candleShortColor,
254
- borderColor0: candleLongColor,
255
- },
256
- emphasis: {
257
- itemStyle: {
258
- color: candleShortColor,
259
- color0: candleLongColor,
260
- },
261
- },
262
- markPoint: {
263
- symbol: 'circle',
264
- symbolSize: 0,
265
- data: labelsData,
266
- },
267
- },
268
- {
269
- type: 'custom',
270
- gridIndex: 0,
271
- name: 'heatmap',
272
- id: 'heatmap',
273
- xAxisIndex: 0,
274
- yAxisIndex: 0,
275
- silent: true,
276
- clip: true,
277
- renderItem: (_params, api) => {
278
- const xVal = api.value(0);
279
- const bucketIndex = api.value(2) as number;
280
- const metaValues = buckets[bucketIndex];
281
-
282
- const [rectWidth, rectHeight] = api.size!([
283
- 0,
284
- bucketWidth,
285
- ]) as number[];
286
-
287
- const items = metaValues.map(({ price, sentiment }: Bucket) => {
288
- const start = api.coord([xVal, price]);
289
-
290
- return {
291
- type: 'rect',
292
- shape: {
293
- x: start[0] - rectWidth / 2,
294
- y: start[1] - rectHeight,
295
- width: rectWidth + 1,
296
- height: rectHeight,
297
- },
298
- style: {
299
- fill: getRectColor(sentiment, isDark),
300
- },
301
- silent: true,
302
- emphasisDisabled: true,
303
- };
304
- });
305
-
306
- return {
307
- type: 'group',
308
- children: items,
309
- silent: true,
310
- emphasisDisabled: true,
311
- };
312
- },
313
- data: orderPositionBooks,
314
- },
315
- {
316
- type: 'line',
317
- name: 'sentiment-short',
318
- id: 'sentiment',
319
- xAxisIndex: 1,
320
- yAxisIndex: 1,
321
- data: sentiments,
322
- showSymbol: false,
323
- symbol: 'none',
324
- lineStyle: {
325
- width: 3,
326
- opacity: 1,
327
- },
328
- areaStyle: {
329
- color: sentimentShortColor,
330
- opacity: sentimentAreaOpacity,
331
- },
332
- emphasis: {
333
- areaStyle: {
334
- opacity: 0,
335
- },
336
- },
337
- stack: 'sentiment',
338
- },
339
- {
340
- type: 'line',
341
- name: 'sentiment-long',
342
- id: 'sentiment-long',
343
- xAxisIndex: 1,
344
- yAxisIndex: 1,
345
- data: sentiments.map((sentiment) => [sentiment[0], sentiment[2]]),
346
- symbol: 'none',
347
- lineStyle: {
348
- color: 'transparent',
349
- width: 0,
350
- },
351
- areaStyle: {
352
- color: sentimentLongColor,
353
- opacity: sentimentAreaOpacity,
354
- },
355
- stack: 'sentiment',
356
- emphasis: {
357
- disabled: true,
358
- },
359
- tooltip: {
360
- show: false,
361
- },
362
- },
363
- ],
364
- grid: [
365
- {
366
- name: 'main-grid',
367
- id: 'main-grid',
368
- height: `${CHART_CONFIG.MAIN_HEIGHT}px`,
369
- top: '0px',
370
- left: '0px',
371
- right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
372
- bottom: `${CHART_CONFIG.X_LABEL_SIZE}px`,
373
- },
374
- {
375
- name: 'sentiment-grid',
376
- id: 'sentiment-grid',
377
- height: `${CHART_CONFIG.SENTIMENT_HEIGHT}px`,
378
- bottom: `0px`,
379
- left: '0px',
380
- right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
381
- },
382
- ],
383
- graphic: [
384
- ...gridMainLines,
385
- {
386
- type: 'text',
387
- silent: true,
388
- z: 1,
389
- left: 4,
390
- bottom: CHART_CONFIG_CALCULATED.SENTIMENT_TEXT_POSITION,
391
- style: {
392
- text: `${labelCallback('sentiment')}:`,
393
- fontFamily: 'Sofia W03',
394
- fontSize: 14,
395
- fontWeight: 'bold',
396
- fill: sentimentLabelColor,
397
- },
398
- },
399
- ],
400
- };
401
- };
@@ -1,44 +0,0 @@
1
- import Decimal from 'decimal.js';
2
-
3
- import type { Bucket } from '../types';
4
-
5
- export const aggregateBuckets = (
6
- buckets: Bucket[],
7
- newBucketWidth: number
8
- ): Bucket[] => {
9
- if (!buckets.length) {
10
- return [];
11
- }
12
-
13
- const bucketWidthDecimal = new Decimal(newBucketWidth);
14
-
15
- const aggregatedMap = new Map<string, Decimal>();
16
-
17
- for (const bucket of buckets) {
18
- const priceDecimal = new Decimal(bucket.price);
19
- const sentimentDecimal = new Decimal(bucket.sentiment);
20
-
21
- const bucketIndex = priceDecimal.div(bucketWidthDecimal).floor();
22
- const groupingKey = bucketIndex.mul(bucketWidthDecimal);
23
-
24
- const groupingKeyStr = groupingKey.toString();
25
-
26
- const currentSentiment =
27
- aggregatedMap.get(groupingKeyStr) ?? new Decimal(0);
28
- aggregatedMap.set(groupingKeyStr, currentSentiment.add(sentimentDecimal));
29
- }
30
-
31
- const aggregatedBuckets = Array.from(aggregatedMap.entries()).map(
32
- ([priceStr, sentimentDecimal]) => {
33
- const price = new Decimal(priceStr).toNumber();
34
- const sentiment = sentimentDecimal.toNumber();
35
-
36
- return {
37
- price,
38
- sentiment,
39
- };
40
- }
41
- );
42
-
43
- return aggregatedBuckets;
44
- };
@@ -1,216 +0,0 @@
1
- import chroma from 'chroma-js';
2
-
3
- import { BookType, Granularity, TimeSpan } from '../../../../gql/types/graphql';
4
- import {
5
- BOOKS_THRESHOLDS,
6
- CHART_CONFIG,
7
- COLOR_MAP,
8
- TIME_THRESHOLDS,
9
- } from '../../../constants';
10
- import type { Bucket, GetLabelsDataProps, TooltipParam } from '../types';
11
-
12
- export const getLabelData = ({
13
- xAxisData,
14
- isGreaterThanTwoWeeks,
15
- }: GetLabelsDataProps) =>
16
- xAxisData
17
- .filter((record, index, arr) => {
18
- if (index === 0) {
19
- return false;
20
- }
21
- const previousTimestamp = arr[index - 1];
22
- const currentDate = new Date(record);
23
- const previousDate = new Date(previousTimestamp);
24
-
25
- return isGreaterThanTwoWeeks
26
- ? currentDate.getDate() !== previousDate.getDate()
27
- : currentDate.getMonth() !== previousDate.getMonth();
28
- })
29
- .map((item) => ({
30
- name: new Date(item).toLocaleDateString(undefined, {
31
- month: isGreaterThanTwoWeeks ? 'short' : 'long',
32
- day: isGreaterThanTwoWeeks ? 'numeric' : undefined,
33
- }),
34
- xAxis: item,
35
- y: CHART_CONFIG.MAIN_HEIGHT + CHART_CONFIG.X_LABEL_SIZE - 22,
36
- silent: true,
37
- emphasis: {
38
- disabled: true,
39
- },
40
- label: {
41
- fontFamily: 'Sofia W03',
42
- fontSize: 10,
43
- position: 'bottom',
44
- align: 'center',
45
- formatter: '{b}',
46
- },
47
- }));
48
-
49
- export const isDifferenceGreaterThanTwoWeeks = (
50
- startDate: string,
51
- endDate: string
52
- ) => {
53
- const date1 = new Date(startDate);
54
- const date2 = new Date(endDate);
55
-
56
- const differenceInMs = Math.abs(date2.getTime() - date1.getTime());
57
-
58
- return differenceInMs < TIME_THRESHOLDS.TWO_WEEKS_MS;
59
- };
60
-
61
- export const getTimeSpanForGranularity = (
62
- granularity: Granularity
63
- ): TimeSpan => {
64
- const granularityTimeSpanMap: Record<Granularity, TimeSpan> = {
65
- [Granularity.M5]: TimeSpan.TwoDays,
66
- [Granularity.M15]: TimeSpan.FiveDays,
67
- [Granularity.H1]: TimeSpan.TwentyDays,
68
- [Granularity.H4]: TimeSpan.NinetyDays,
69
- };
70
-
71
- return granularityTimeSpanMap[granularity] || TimeSpan.TwoDays;
72
- };
73
-
74
- const getGradientColor = (
75
- value: number,
76
- startColor: string,
77
- targetColor: string
78
- ): string => {
79
- const startThreshold = BOOKS_THRESHOLDS.MIN;
80
- const endThreshold = BOOKS_THRESHOLDS.MAX;
81
-
82
- const colorScale = chroma
83
- .scale([startColor, targetColor])
84
- .domain([startThreshold, endThreshold])
85
- .mode('rgb');
86
-
87
- return colorScale(value).hex();
88
- };
89
-
90
- export const getRectColor = (sentiment: number, isDark: boolean) => {
91
- const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
92
-
93
- return sentiment < 0
94
- ? getGradientColor(
95
- sentiment * -1,
96
- colorPalette.short[0],
97
- colorPalette.short[1]
98
- )
99
- : getGradientColor(sentiment, colorPalette.long[0], colorPalette.long[1]);
100
- };
101
-
102
- export const getTooltipFormatter = ({
103
- params,
104
- buckets,
105
- bucketWidth,
106
- selectedPrice,
107
- precision,
108
- bookType,
109
- labelCallback,
110
- }: {
111
- params: TooltipParam[];
112
- buckets: Bucket[][];
113
- bucketWidth: number;
114
- selectedPrice: number;
115
- precision: number;
116
- bookType: BookType;
117
- labelCallback: (key: string) => string;
118
- }) => {
119
- if (!params || !Array.isArray(params) || params.length === 0) {
120
- return undefined;
121
- }
122
- const candleParam = params.find(
123
- (series): series is Extract<TooltipParam, { seriesId: 'candlestick' }> =>
124
- series.seriesId === 'candlestick'
125
- );
126
- const booksParam = params.find(
127
- (series): series is Extract<TooltipParam, { seriesId: 'heatmap' }> =>
128
- series.seriesId === 'heatmap'
129
- );
130
- const sentimentParam = params.find(
131
- (series): series is Extract<TooltipParam, { seriesId: 'sentiment' }> =>
132
- series.seriesId === 'sentiment'
133
- );
134
-
135
- if (!candleParam) {
136
- return undefined;
137
- }
138
- const time = new Date(candleParam.axisValue as string);
139
-
140
- const candleData = candleParam.value;
141
- const bucketsIndex = booksParam?.value[2];
142
- const selectedBuckets =
143
- bucketsIndex !== undefined ? buckets[bucketsIndex] : undefined;
144
-
145
- const matchedBucket = selectedBuckets?.find(
146
- ({ price }) => selectedPrice >= price && selectedPrice < price + bucketWidth
147
- );
148
- const showCandles =
149
- !!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[4];
150
-
151
- if (!showCandles && !matchedBucket) {
152
- return undefined;
153
- }
154
-
155
- const showSentiment =
156
- !!sentimentParam?.value[1] && !!sentimentParam?.value[2];
157
-
158
- return `<p>${time.toLocaleString(undefined, {
159
- hour: '2-digit',
160
- minute: '2-digit',
161
- year: 'numeric',
162
- day: 'numeric',
163
- month: 'numeric',
164
- timeZoneName: 'short',
165
- })}</p><br />
166
- ${
167
- showCandles
168
- ? `<p><b>${labelCallback('candle')}:</b></p>
169
- <p>${labelCallback('open_price')}: ${candleData[1]} </p>
170
- <p>${labelCallback('close_price')}: ${candleData[2]} </p>
171
- <p>${labelCallback('low')}: ${candleData[3]} </p>
172
- <p>${labelCallback('high')}: ${candleData[4]} </p>
173
- `
174
- : ''
175
- }
176
- ${
177
- matchedBucket
178
- ? `<br /><p><b>${labelCallback(bookType === BookType.Order ? 'orders' : 'positions')}:</b></p>
179
- <p>${labelCallback('price_range')}: ${matchedBucket.price.toFixed(precision - 1)} - ${Number(matchedBucket.price + bucketWidth).toFixed(precision - 1)} </p>
180
- <p>${
181
- matchedBucket.sentiment < 0
182
- ? labelCallback(
183
- bookType === BookType.Order
184
- ? 'sell_overbalance'
185
- : 'short_overbalance'
186
- )
187
- : labelCallback(
188
- bookType === BookType.Order
189
- ? 'buy_overbalance'
190
- : 'long_overbalance'
191
- )
192
- }: ${Math.abs(matchedBucket.sentiment)}% </p>`
193
- : ''
194
- }${
195
- showSentiment && sentimentParam
196
- ? `<br /><p><b>${labelCallback('sentiment')}:</b></p>
197
- <p>${labelCallback('long')}: ${sentimentParam.value[2].toFixed(2)}% </p>
198
- <p>${labelCallback('short')}: ${sentimentParam.value[1].toFixed(2)}% </p>`
199
- : ''
200
- }`;
201
- };
202
-
203
- export const formatXAxisLabel = (
204
- value: unknown,
205
- isGreaterThanTwoWeeks: boolean
206
- ) => {
207
- const date = new Date(value as string);
208
- return isGreaterThanTwoWeeks
209
- ? `${date.toLocaleTimeString(undefined, {
210
- hour: '2-digit',
211
- minute: '2-digit',
212
- })}`
213
- : `${CHART_CONFIG.X_AXIS_DATE_PADDING}${date.toLocaleDateString(undefined, {
214
- day: 'numeric',
215
- })}${CHART_CONFIG.X_AXIS_DATE_PADDING}`;
216
- };