|
|
@ -1,5 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Description: 主题设置格式化
|
|
|
|
* @Description: 主题设置格式化
|
|
|
|
* @author liu.shiyi
|
|
|
|
* @author liu.shiyi
|
|
|
@ -25,13 +24,13 @@ export function settingToTheme (config, type) {
|
|
|
|
if (config.customize && Object.keys(config.customize).length) {
|
|
|
|
if (config.customize && Object.keys(config.customize).length) {
|
|
|
|
// customize属性存在层级
|
|
|
|
// customize属性存在层级
|
|
|
|
for (const item in config.customize) {
|
|
|
|
for (const item in config.customize) {
|
|
|
|
const value = config.customize[item];
|
|
|
|
const value = config.customize[item]
|
|
|
|
// 如果包含二级属性
|
|
|
|
// 如果包含二级属性
|
|
|
|
if (value && typeof value === 'object' && Object.keys(value).length) {
|
|
|
|
if (value && typeof value === 'object' && Object.keys(value).length) {
|
|
|
|
// 对于二级属性
|
|
|
|
// 对于二级属性
|
|
|
|
for (const subKey in value) {
|
|
|
|
for (const subKey in value) {
|
|
|
|
if (subKey.includes('color') || subKey.includes('Color') || subKey.includes('BGC')) {
|
|
|
|
if (subKey.includes('color') || subKey.includes('Color') || subKey.includes('BGC')) {
|
|
|
|
theme[type][`${item}_${subKey}`] = value[subKey];
|
|
|
|
theme[type][`${item}_${subKey}`] = value[subKey]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -53,7 +52,7 @@ export function themeToSetting (chartList, type) {
|
|
|
|
// 排除掉主题非暗黑非明亮的情况
|
|
|
|
// 排除掉主题非暗黑非明亮的情况
|
|
|
|
if (['dark', 'light'].includes(type)) {
|
|
|
|
if (['dark', 'light'].includes(type)) {
|
|
|
|
chartList.forEach(chart => {
|
|
|
|
chartList.forEach(chart => {
|
|
|
|
chart.option.theme = type
|
|
|
|
chart.option.theme = type === 'dark' ? 'transparent' : 'light'
|
|
|
|
if (chart.theme && chart.theme[type]) {
|
|
|
|
if (chart.theme && chart.theme[type]) {
|
|
|
|
// 如果是g2组件或者远程组件
|
|
|
|
// 如果是g2组件或者远程组件
|
|
|
|
if (['customComponent', 'remoteComponent'].includes(chart.type)) {
|
|
|
|
if (['customComponent', 'remoteComponent'].includes(chart.type)) {
|
|
|
@ -67,15 +66,15 @@ export function themeToSetting (chartList, type) {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 如果是普通组件
|
|
|
|
// 如果是普通组件
|
|
|
|
if (chart.customize && Object.keys(chart.customize).length) {
|
|
|
|
if (chart.customize && Object.keys(chart.customize).length) {
|
|
|
|
for(let key in chart.theme[type]){
|
|
|
|
for (const key in chart.theme[type]) {
|
|
|
|
const value = chart.theme[type][key];
|
|
|
|
const value = chart.theme[type][key]
|
|
|
|
// 如果对应的是二级属性
|
|
|
|
// 如果对应的是二级属性
|
|
|
|
if (key.includes('_')) {
|
|
|
|
if (key.includes('_')) {
|
|
|
|
const [propertyName, subPropertyName] = key.split('_');
|
|
|
|
const [propertyName, subPropertyName] = key.split('_')
|
|
|
|
if (!chart.customize[propertyName]) {
|
|
|
|
if (!chart.customize[propertyName]) {
|
|
|
|
chart.customize[propertyName] = {}
|
|
|
|
chart.customize[propertyName] = {}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
chart.customize[propertyName][subPropertyName] = value;
|
|
|
|
chart.customize[propertyName][subPropertyName] = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 对应的一级属性
|
|
|
|
// 对应的一级属性
|
|
|
@ -84,7 +83,6 @@ export function themeToSetting (chartList, type) {
|
|
|
|
chart.customize[key] = chart.theme[type][key]
|
|
|
|
chart.customize[key] = chart.theme[type][key]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const item in chart.customize) {
|
|
|
|
for (const item in chart.customize) {
|
|
|
|
// 检查 obj 中是否存在与 customize 相对应的属性
|
|
|
|
// 检查 obj 中是否存在与 customize 相对应的属性
|
|
|
|