You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

constants.js 2.9 KiB

7 vuotta sitten
7 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. export const ALL_CHART_TYPES = ['line', 'scatter', 'bar', 'percentage', 'heatmap', 'pie'];
  2. export const COMPATIBLE_CHARTS = {
  3. bar: ['line', 'scatter', 'percentage', 'pie'],
  4. line: ['scatter', 'bar', 'percentage', 'pie'],
  5. pie: ['line', 'scatter', 'percentage', 'bar'],
  6. percentage: ['bar', 'line', 'scatter', 'pie'],
  7. heatmap: []
  8. };
  9. export const DATA_COLOR_DIVISIONS = {
  10. bar: 'datasets',
  11. line: 'datasets',
  12. pie: 'labels',
  13. percentage: 'labels',
  14. heatmap: HEATMAP_DISTRIBUTION_SIZE
  15. };
  16. export const BASE_MEASURES = {
  17. margins: {
  18. top: 10,
  19. bottom: 10,
  20. left: 20,
  21. right: 20
  22. },
  23. paddings: {
  24. top: 20,
  25. bottom: 40,
  26. left: 30,
  27. right: 10
  28. },
  29. baseHeight: 240,
  30. titleHeight: 20,
  31. legendHeight: 30,
  32. titleFontSize: 12,
  33. };
  34. export function getTopOffset(m) {
  35. return m.titleHeight + m.margins.top + m.paddings.top;
  36. }
  37. export function getLeftOffset(m) {
  38. return m.margins.left + m.paddings.left;
  39. }
  40. export function getExtraHeight(m) {
  41. let totalExtraHeight = m.margins.top + m.margins.bottom
  42. + m.paddings.top + m.paddings.bottom
  43. + m.titleHeight + m.legendHeight;
  44. return totalExtraHeight;
  45. }
  46. export function getExtraWidth(m) {
  47. let totalExtraWidth = m.margins.left + m.margins.right
  48. + m.paddings.left + m.paddings.right;
  49. return totalExtraWidth;
  50. }
  51. export const INIT_CHART_UPDATE_TIMEOUT = 700;
  52. export const CHART_POST_ANIMATE_TIMEOUT = 400;
  53. export const AXIS_CHART_DEFAULT_TYPE = 'line';
  54. export const AXIS_CHART_MIXED_TYPE = 'axis-mixed';
  55. export const AXIS_CHART_TYPES = ['line', 'bar', 'axis-mixed'];
  56. export const AXIS_DATASET_CHART_TYPES = ['line', 'bar'];
  57. export const AXIS_CHART_OPTIONS = {
  58. barOptions: {
  59. spaceRatio: 1,
  60. }
  61. }
  62. export const AXIS_LEGEND_BAR_SIZE = 100;
  63. export const BAR_CHART_SPACE_RATIO = 1;
  64. export const MIN_BAR_PERCENT_HEIGHT = 0.01;
  65. export const LINE_CHART_DOT_SIZE = 4;
  66. export const DOT_OVERLAY_SIZE_INCR = 4;
  67. export const PERCENTAGE_BAR_DEFAULT_HEIGHT = 20;
  68. export const PERCENTAGE_BAR_DEFAULT_DEPTH = 2;
  69. // Fixed 5-color theme,
  70. // More colors are difficult to parse visually
  71. export const HEATMAP_DISTRIBUTION_SIZE = 5;
  72. export const HEATMAP_SQUARE_SIZE = 10;
  73. export const HEATMAP_GUTTER_SIZE = 2;
  74. export const DEFAULT_CHAR_WIDTH = 7;
  75. export const TOOLTIP_POINTER_TRIANGLE_HEIGHT = 5;
  76. const DEFAULT_CHART_COLORS = ['light-blue', 'blue', 'violet', 'red', 'orange',
  77. 'yellow', 'green', 'light-green', 'purple', 'magenta', 'light-grey', 'dark-grey'];
  78. const HEATMAP_COLORS_GREEN = ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127'];
  79. export const HEATMAP_COLORS_BLUE = ['#ebedf0', '#c0ddf9', '#73b3f3', '#3886e1', '#17459e'];
  80. export const HEATMAP_COLORS_YELLOW = ['#ebedf0', '#fdf436', '#ffc700', '#ff9100', '#06001c'];
  81. export const DEFAULT_COLORS = {
  82. bar: DEFAULT_CHART_COLORS,
  83. line: DEFAULT_CHART_COLORS,
  84. pie: DEFAULT_CHART_COLORS,
  85. percentage: DEFAULT_CHART_COLORS,
  86. heatmap: HEATMAP_COLORS_GREEN
  87. };
  88. // Universal constants
  89. export const ANGLE_RATIO = Math.PI / 180;
  90. export const FULL_ANGLE = 360;