-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1451 from merico-dev/1450-apply-visualmap-to-cale…
…ndar-heatmap-merico-heatmap 1450 apply visualmap to calendar heatmap merico heatmap
- Loading branch information
Showing
31 changed files
with
301 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
dashboard/src/components/plugins/viz-components/calendar-heatmap/migrators/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { getDefaultVisualMap } from '~/components/plugins/common-echarts-fields/visual-map'; | ||
import { ICalendarHeatmapConf } from '../type'; | ||
import { IMigrationEnv } from '~/components/plugins/plugin-data-migrator'; | ||
|
||
export function v2(legacyConf: any, { panelModel }: IMigrationEnv): ICalendarHeatmapConf { | ||
try { | ||
const queryID = panelModel.queryIDs[0]; | ||
if (!queryID) { | ||
throw new Error('cannot migrate when queryID is empty'); | ||
} | ||
const changeKey = (key: string) => (key ? `${queryID}.${key}` : key); | ||
const { calendar, heat_block, tooltip, ...rest } = legacyConf; | ||
return { | ||
...rest, | ||
calendar: { | ||
...calendar, | ||
data_key: changeKey(calendar.data_key), | ||
}, | ||
heat_block: { | ||
...heat_block, | ||
data_key: changeKey(heat_block.data_key), | ||
}, | ||
tooltip: { | ||
...tooltip, | ||
metrics: tooltip.metrics.map((m: any) => ({ | ||
...m, | ||
data_key: changeKey(m.data_key), | ||
})), | ||
}, | ||
}; | ||
} catch (error) { | ||
console.error('[Migration failed]', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export function v3(legacyConf: any): ICalendarHeatmapConf { | ||
const { heat_block } = legacyConf; | ||
let { min, max } = heat_block; | ||
if (typeof min !== 'number') { | ||
min = 0; | ||
} | ||
if (typeof max !== 'number') { | ||
max = 100; | ||
} | ||
|
||
return { | ||
...legacyConf, | ||
heat_block: { | ||
...heat_block, | ||
min: { | ||
type: 'static', | ||
value: min, | ||
}, | ||
max: { | ||
type: 'static', | ||
value: max, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
export function v4(legacyConf: any): ICalendarHeatmapConf { | ||
const { | ||
visualMap = getDefaultVisualMap(), | ||
heat_block: { min, max, ...restHeatBlock }, | ||
...rest | ||
} = legacyConf; | ||
return { | ||
...rest, | ||
heat_block: restHeatBlock, | ||
visualMap: { | ||
...getDefaultVisualMap(), | ||
min, | ||
max, | ||
}, | ||
}; | ||
} |
Oops, something went wrong.