123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- import { PanelModel, FieldConfigSource } from '@grafana/data';
- import { heatmapChangedHandler } from './migrations';
- describe('Heatmap Migrations', () => {
- let prevFieldConfig: FieldConfigSource;
- beforeEach(() => {
- prevFieldConfig = {
- defaults: {},
- overrides: [],
- };
- });
- it('simple heatmap', () => {
- const old: any = {
- angular: oldHeatmap,
- };
- const panel = {} as PanelModel;
- panel.options = heatmapChangedHandler(panel, 'heatmap', old, prevFieldConfig);
- expect(panel).toMatchInlineSnapshot(`
- Object {
- "fieldConfig": Object {
- "defaults": Object {},
- "overrides": Array [],
- },
- "options": Object {
- "calculate": true,
- "calculation": Object {
- "xBuckets": Object {
- "mode": "count",
- "value": "100",
- },
- "yBuckets": Object {
- "mode": "count",
- "scale": Object {
- "log": 2,
- "type": "log",
- },
- "value": "3",
- },
- },
- "cellGap": 2,
- "cellRadius": 10,
- "cellValues": Object {
- "decimals": undefined,
- },
- "color": Object {
- "exponent": 0.5,
- "fill": "dark-orange",
- "max": 100,
- "min": 5,
- "mode": "scheme",
- "scale": "exponential",
- "scheme": "BuGn",
- "steps": 128,
- },
- "exemplars": Object {
- "color": "rgba(255,0,255,0.7)",
- },
- "filterValues": Object {
- "le": 1e-9,
- },
- "legend": Object {
- "show": true,
- },
- "rowsFrame": Object {
- "layout": "auto",
- },
- "showValue": "never",
- "tooltip": Object {
- "show": true,
- "yHistogram": true,
- },
- "yAxis": Object {
- "axisPlacement": "left",
- "axisWidth": 400,
- "decimals": 6,
- "max": 22,
- "min": 7,
- "reverse": false,
- "unit": "short",
- },
- },
- }
- `);
- });
- });
- const oldHeatmap = {
- id: 4,
- gridPos: {
- x: 0,
- y: 0,
- w: 12,
- h: 8,
- },
- type: 'heatmap',
- title: 'Panel Title',
- datasource: {
- uid: '000000051',
- type: 'testdata',
- },
- targets: [
- {
- scenarioId: 'random_walk',
- refId: 'A',
- datasource: {
- uid: '000000051',
- type: 'testdata',
- },
- startValue: 0,
- seriesCount: 5,
- spread: 10,
- },
- ],
- heatmap: {},
- cards: {
- cardPadding: 2,
- cardRound: 10,
- },
- color: {
- mode: 'spectrum',
- cardColor: '#b4ff00',
- colorScale: 'sqrt',
- exponent: 0.5,
- colorScheme: 'interpolateBuGn',
- min: 5,
- max: 100,
- },
- legend: {
- show: true,
- },
- dataFormat: 'timeseries',
- yBucketBound: 'auto',
- reverseYBuckets: false,
- xAxis: {
- show: true,
- },
- yAxis: {
- show: true,
- format: 'short',
- decimals: 6,
- logBase: 2,
- splitFactor: 3,
- min: 7,
- max: 22,
- width: '400',
- },
- xBucketSize: null,
- xBucketNumber: 100,
- yBucketSize: null,
- yBucketNumber: 20,
- tooltip: {
- show: true,
- showHistogram: true,
- },
- highlightCards: true,
- hideZeroBuckets: true,
- };
|