migrations.test.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import { PanelModel, FieldConfigSource } from '@grafana/data';
  2. import { heatmapChangedHandler } from './migrations';
  3. describe('Heatmap Migrations', () => {
  4. let prevFieldConfig: FieldConfigSource;
  5. beforeEach(() => {
  6. prevFieldConfig = {
  7. defaults: {},
  8. overrides: [],
  9. };
  10. });
  11. it('simple heatmap', () => {
  12. const old: any = {
  13. angular: oldHeatmap,
  14. };
  15. const panel = {} as PanelModel;
  16. panel.options = heatmapChangedHandler(panel, 'heatmap', old, prevFieldConfig);
  17. expect(panel).toMatchInlineSnapshot(`
  18. Object {
  19. "fieldConfig": Object {
  20. "defaults": Object {},
  21. "overrides": Array [],
  22. },
  23. "options": Object {
  24. "calculate": true,
  25. "calculation": Object {
  26. "xBuckets": Object {
  27. "mode": "count",
  28. "value": "100",
  29. },
  30. "yBuckets": Object {
  31. "mode": "count",
  32. "scale": Object {
  33. "log": 2,
  34. "type": "log",
  35. },
  36. "value": "3",
  37. },
  38. },
  39. "cellGap": 2,
  40. "cellRadius": 10,
  41. "cellValues": Object {
  42. "decimals": undefined,
  43. },
  44. "color": Object {
  45. "exponent": 0.5,
  46. "fill": "dark-orange",
  47. "max": 100,
  48. "min": 5,
  49. "mode": "scheme",
  50. "scale": "exponential",
  51. "scheme": "BuGn",
  52. "steps": 128,
  53. },
  54. "exemplars": Object {
  55. "color": "rgba(255,0,255,0.7)",
  56. },
  57. "filterValues": Object {
  58. "le": 1e-9,
  59. },
  60. "legend": Object {
  61. "show": true,
  62. },
  63. "rowsFrame": Object {
  64. "layout": "auto",
  65. },
  66. "showValue": "never",
  67. "tooltip": Object {
  68. "show": true,
  69. "yHistogram": true,
  70. },
  71. "yAxis": Object {
  72. "axisPlacement": "left",
  73. "axisWidth": 400,
  74. "decimals": 6,
  75. "max": 22,
  76. "min": 7,
  77. "reverse": false,
  78. "unit": "short",
  79. },
  80. },
  81. }
  82. `);
  83. });
  84. });
  85. const oldHeatmap = {
  86. id: 4,
  87. gridPos: {
  88. x: 0,
  89. y: 0,
  90. w: 12,
  91. h: 8,
  92. },
  93. type: 'heatmap',
  94. title: 'Panel Title',
  95. datasource: {
  96. uid: '000000051',
  97. type: 'testdata',
  98. },
  99. targets: [
  100. {
  101. scenarioId: 'random_walk',
  102. refId: 'A',
  103. datasource: {
  104. uid: '000000051',
  105. type: 'testdata',
  106. },
  107. startValue: 0,
  108. seriesCount: 5,
  109. spread: 10,
  110. },
  111. ],
  112. heatmap: {},
  113. cards: {
  114. cardPadding: 2,
  115. cardRound: 10,
  116. },
  117. color: {
  118. mode: 'spectrum',
  119. cardColor: '#b4ff00',
  120. colorScale: 'sqrt',
  121. exponent: 0.5,
  122. colorScheme: 'interpolateBuGn',
  123. min: 5,
  124. max: 100,
  125. },
  126. legend: {
  127. show: true,
  128. },
  129. dataFormat: 'timeseries',
  130. yBucketBound: 'auto',
  131. reverseYBuckets: false,
  132. xAxis: {
  133. show: true,
  134. },
  135. yAxis: {
  136. show: true,
  137. format: 'short',
  138. decimals: 6,
  139. logBase: 2,
  140. splitFactor: 3,
  141. min: 7,
  142. max: 22,
  143. width: '400',
  144. },
  145. xBucketSize: null,
  146. xBucketNumber: 100,
  147. yBucketSize: null,
  148. yBucketNumber: 20,
  149. tooltip: {
  150. show: true,
  151. showHistogram: true,
  152. },
  153. highlightCards: true,
  154. hideZeroBuckets: true,
  155. };