12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import _ from 'lodash'
- export function settingToTheme (config, type) {
-
-
- if (['dark', 'light'].includes(type)) {
- const theme = { dark: { ...config?.theme?.dark }, light: { ...config?.theme?.light } }
-
-
- if (['customComponent', 'remoteComponent'].includes(config.type)) {
- config.setting.forEach((setItem) => {
- if (['gradual', 'colorPicker', 'colorSelect'].includes(setItem.type)) {
- theme[type][setItem.field] = setItem.value
- }
- })
- } else {
-
- if (config.customize && Object.keys(config.customize).length) {
- for (const item in config.customize) {
- if (item.includes('color') || item.includes('Color') || item.includes('BGC')) {
- theme[type][item] = config.customize[item]
- }
- }
- }
- }
- return theme
- } else {
- return {}
- }
- }
- export function themeToSetting (chartList, type) {
-
- if (['dark', 'light'].includes(type)) {
- chartList.forEach(chart => {
- chart.option.theme = type
- if (chart.theme && chart.theme[type]) {
-
- if (['customComponent', 'remoteComponent'].includes(chart.type)) {
- for (const item of chart.setting) {
-
- if (Object.prototype.hasOwnProperty.call(chart.theme[type], item.field)) {
-
- item.value = chart.theme[type][item.field]
- }
- }
- } else {
-
- if (chart.customize && Object.keys(chart.customize).length) {
- for (const item in chart.customize) {
-
- if (Object.prototype.hasOwnProperty.call(chart.theme[type], item)) {
-
- chart.customize[item] = chart.theme[type][item]
- }
- }
- }
- }
- }
- })
- }
- return chartList
- }
|