Charts.constants.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Just extracting the color configuration to a single file so that it's easier to observe
  2. // Needs better naming to be honest, but just to get things going
  3. // For ChartHandler
  4. export const CHART_COLORS = {
  5. TICK: 'hsl(var(--background-overlay-hover))',
  6. AXIS: 'hsl(var(--background-overlay-hover))',
  7. GREEN_1: 'hsl(var(--brand-default))', // #3ECF8E
  8. GREEN_2: 'hsl(var(--brand-500))',
  9. RED_1: 'hsl(var(--destructive-default))',
  10. RED_2: 'hsl(var(--destructive-500))',
  11. REFERENCE_LINE: 'hsl(var(--foreground-muted))',
  12. REFERENCE_LINE_TEXT: 'hsl(var(--foreground-muted))',
  13. }
  14. const LIGHT_STACKED_CHART_COLORS = [
  15. '#3ECF8E',
  16. '#DA760B',
  17. '#097c4f',
  18. '#EDC35E',
  19. '#65BCD9',
  20. '#0063E8',
  21. '#DB8DF9',
  22. '#B616A6',
  23. ]
  24. const LIGHT_STACKED_CHART_FILLS = [
  25. '#9FE8C7',
  26. '#FFB885',
  27. '#4BA67A',
  28. '#F6D99F',
  29. '#B2DCEC',
  30. '#80B1F4',
  31. '#EDC9FC',
  32. '#DB8BD3',
  33. ]
  34. const DARK_STACKED_CHART_COLORS = [
  35. '#3ECF8E',
  36. '#A3FFC2',
  37. '#DA760B',
  38. '#EDD35E',
  39. '#65BCD9',
  40. '#0063E8',
  41. '#DB8DF9',
  42. '#B616A6',
  43. ]
  44. const DARK_STACKED_CHART_FILLS = [
  45. '#2A5C3F',
  46. '#1F3D2A',
  47. '#5C3D0A',
  48. '#5C5230',
  49. '#2A3D45',
  50. '#001F3D',
  51. '#4A3D5C',
  52. '#3D1F3A',
  53. ]
  54. // Default to light mode colors, will be updated based on theme
  55. export let STACKED_CHART_COLORS = LIGHT_STACKED_CHART_COLORS
  56. export let STACKED_CHART_FILLS = LIGHT_STACKED_CHART_FILLS
  57. // Function to update colors based on theme
  58. export const updateStackedChartColors = (isDarkMode: boolean) => {
  59. STACKED_CHART_COLORS = isDarkMode ? DARK_STACKED_CHART_COLORS : LIGHT_STACKED_CHART_COLORS
  60. STACKED_CHART_FILLS = isDarkMode ? DARK_STACKED_CHART_FILLS : LIGHT_STACKED_CHART_FILLS
  61. }
  62. export type ValidStackColor =
  63. | 'brand'
  64. | 'blue'
  65. | 'red'
  66. | 'yellow'
  67. | 'green'
  68. | 'slate'
  69. | 'indigo'
  70. | 'tomato'
  71. | 'orange'
  72. | 'amber'
  73. export const genStackColorScales = (colors: ValidStackColor[]) =>
  74. colors.map((color) => {
  75. let scale = 9
  76. if (color === 'slate') {
  77. scale = 11
  78. }
  79. return {
  80. lighter: `var(--color-${color}-${scale - 1}00)`,
  81. base: `var(--color-${color}-${scale * 100})`,
  82. darker: `var(--color-${color}-${scale + 1}00)`,
  83. }
  84. })
  85. export const DEFAULT_STACK_COLORS: ValidStackColor[] = [
  86. 'brand',
  87. 'slate',
  88. 'blue',
  89. 'yellow',
  90. 'indigo',
  91. ]
  92. export enum DateTimeFormats {
  93. FULL = 'MMM D, YYYY, hh:mma',
  94. FULL_SECONDS = 'MMM D, hh:mm:ssa',
  95. DATE_ONLY = 'MMM D, YYYY',
  96. }