fix:3d组件可预览可保存

main
liu.shiyi 2 years ago
parent bdc5f0ea5a
commit 4e5f7be43a

@ -106,7 +106,7 @@ export default {
getDataList (config) { getDataList (config) {
this.loading = true this.loading = true
// G2option // G2option
if (['customComponent', 'remoteComponent'].includes(config.type) && (!config.dataSource.businessKey)) { if (['customComponent', 'remoteComponent', 'echartsComponent'].includes(config.type) && (!config.dataSource.businessKey)) {
this.getDataByOption(config) this.getDataByOption(config)
this.fieldsFormat() this.fieldsFormat()
this.loading = false this.loading = false

@ -458,7 +458,7 @@ export default {
const newChartList = chartList?.map((chart) => { const newChartList = chartList?.map((chart) => {
// optionjson // optionjson
if (['customComponent', 'remoteComponent'].includes(chart.type)) { if (['customComponent', 'remoteComponent', 'echartsComponent'].includes(chart.type)) {
// chart.option.data = [] // chart.option.data = []
chart.option = stringifyObjectFunctions(chart.option) chart.option = stringifyObjectFunctions(chart.option)
} }

@ -41,7 +41,7 @@
</div> </div>
</div> </div>
<div <div
v-if="['customComponent','marquee'].includes(config.type)" v-if="['customComponent','marquee', 'echartsComponent'].includes(config.type)"
class="data-setting-data-box" class="data-setting-data-box"
> >
<div class="lc-field-head"> <div class="lc-field-head">

@ -46,6 +46,60 @@ const setting = [
multiple: false, multiple: false,
value: '', value: '',
tabName: 'data' tabName: 'data'
},
{
label: '柱子顶部颜色',
type: 'colorPicker', // 设置组件类型
field: 'seriesCustom_barTopColor', // 字段
optionField: 'seriesCustom.barTopColor', // 对应options中的字段
value: '#2DB1EF',
tabName: 'custom',
groupName: 'graph'
},
{
label: '柱子颜色1',
type: 'colorPicker', // 设置组件类型
field: 'seriesCustom_barColor1', // 字段
optionField: 'seriesCustom.barColor1', // 对应options中的字段
value: '#115ba6',
tabName: 'custom',
groupName: 'graph'
},
{
label: '柱子颜色2',
type: 'colorPicker', // 设置组件类型
field: 'seriesCustom_barColor2', // 字段
optionField: 'seriesCustom.barColor2', // 对应options中的字段
value: '#1db0dd',
tabName: 'custom',
groupName: 'graph'
},
{
label: '柱子底部颜色',
type: 'colorPicker', // 设置组件类型
field: 'seriesCustom_barBottomColor', // 字段
optionField: 'seriesCustom.barBottomColor', // 对应options中的字段
value: '#187dcb',
tabName: 'custom',
groupName: 'graph'
},
{
label: '柱子背景顶部颜色',
type: 'colorPicker', // 设置组件类型
field: 'seriesCustom_shadowColor', // 字段
optionField: 'seriesCustom.shadowColor', // 对应options中的字段
value: '#041133',
tabName: 'custom',
groupName: 'graph'
},
{
label: '柱子背景颜色',
type: 'colorPicker', // 设置组件类型
field: 'seriesCustom_shadowTopColor', // 字段
optionField: 'seriesCustom.shadowTopColor', // 对应options中的字段
value: '#142f5a',
tabName: 'custom',
groupName: 'graph'
} }
] ]
@ -170,7 +224,16 @@ const option = {
} }
} }
], ],
seriesCustom: {
barTopColor: '#2DB1EF',
barBottomColor: '#187dcb',
barColor1: '#115ba6',
barColor2: '#1db0dd',
shadowColor: '#041133',
shadowTopColor: '#142f5a'
},
series: [ series: [
// 顶部
{ {
type: 'pictorialBar', // 象形柱图 type: 'pictorialBar', // 象形柱图
symbol: 'diamond', symbol: 'diamond',
@ -191,6 +254,7 @@ const option = {
color: '#2DB1EF', color: '#2DB1EF',
data: yData data: yData
}, },
// 底部
{ {
type: 'pictorialBar', type: 'pictorialBar',
symbol: 'diamond', symbol: 'diamond',
@ -201,6 +265,7 @@ const option = {
color: '#187dcb', color: '#187dcb',
data: yData data: yData
}, },
// 柱子
{ {
type: 'bar', type: 'bar',
barWidth: 30, barWidth: 30,
@ -224,13 +289,13 @@ const option = {
}, },
data: yData data: yData
}, },
// 阴影柱子
{ {
type: 'bar', type: 'bar',
barWidth: 30, barWidth: 30,
barGap: '-100%', barGap: '-100%',
itemStyle: { itemStyle: {
normal: { normal: {
color: '#041133',
opacity: 0.8, opacity: 0.8,
shadowColor: 'rgba(0, 0, 0, 0.5)', // 阴影颜色 shadowColor: 'rgba(0, 0, 0, 0.5)', // 阴影颜色
shadowBlur: 0 // 阴影模糊值 shadowBlur: 0 // 阴影模糊值
@ -239,8 +304,10 @@ const option = {
label: { label: {
show: false show: false
}, },
color: '#041133',
data: maxData data: maxData
}, },
// 阴影顶部
{ {
type: 'pictorialBar', // 象形柱图 type: 'pictorialBar', // 象形柱图
symbol: 'diamond', symbol: 'diamond',

@ -317,6 +317,7 @@ export default {
} else { } else {
option.series = [ option.series = [
{ {
id: 'barTopColor', //
type: 'pictorialBar', // type: 'pictorialBar', //
symbol: 'diamond', symbol: 'diamond',
symbolOffset: [0, '-50%'], // symbolOffset: [0, '-50%'], //
@ -333,20 +334,22 @@ export default {
color: '#27a7ce' color: '#27a7ce'
} }
}, },
color: '#2DB1EF', color: option.seriesCustom.barTopColor,
data: yData data: yData
}, },
{ {
id: 'barBottomColor', //
type: 'pictorialBar', type: 'pictorialBar',
symbol: 'diamond', symbol: 'diamond',
symbolSize: [30, 15], symbolSize: [30, 15],
symbolOffset: ['0%', '50%'], // symbolOffset: ['0%', '50%'], //
// symbolOffset: [0, 7], // // symbolOffset: [0, 7], //
z: 12, z: 12,
color: '#187dcb', color: option.seriesCustom.barBottomColor,
data: yData data: yData
}, },
{ {
id: 'barColor', //
type: 'bar', type: 'bar',
barWidth: 30, barWidth: 30,
z: 10, z: 10,
@ -355,11 +358,11 @@ export default {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ {
offset: 0, offset: 0,
color: '#115ba6' color: option.seriesCustom.barColor1
}, },
{ {
offset: 1, offset: 1,
color: '#1db0dd' color: option.seriesCustom.barColor2
} }
]), ]),
opacity: 0.8, opacity: 0.8,
@ -370,12 +373,13 @@ export default {
data: yData data: yData
}, },
{ {
id: 'shadowColor', //
type: 'bar', type: 'bar',
barWidth: 30, barWidth: 30,
xAxisIndex: 1, xAxisIndex: 1,
itemStyle: { itemStyle: {
normal: { normal: {
color: '#041133', color: option.seriesCustom.shadowColor,
opacity: 0.8, opacity: 0.8,
shadowColor: 'rgba(0, 0, 0, 0.5)', // shadowColor: 'rgba(0, 0, 0, 0.5)', //
shadowBlur: 0 // shadowBlur: 0 //
@ -390,6 +394,7 @@ export default {
data: shadowData data: shadowData
}, },
{ {
id: 'shadowTopColor', //
type: 'pictorialBar', // type: 'pictorialBar', //
xAxisIndex: 1, xAxisIndex: 1,
symbol: 'diamond', symbol: 'diamond',
@ -407,7 +412,7 @@ export default {
color: '#27a7ce' color: '#27a7ce'
} }
}, },
color: '#142f5a', color: option.seriesCustom.shadowTopColor,
tooltip: { tooltip: {
show: false show: false
}, },
@ -417,6 +422,15 @@ export default {
} }
return option return option
}, },
// series
seriesStyle (config) {
//
for (const item of config.option.seriesCustom) {
if (item.id === 'shadowTopColor') {
item.color = config.seriesCustom.shadowTopColor
}
}
},
// config // config
changeStyle (config, isUpdateTheme) { changeStyle (config, isUpdateTheme) {
config = { ...this.config, ...config } config = { ...this.config, ...config }

@ -16,7 +16,7 @@ export default {
// 兼容边框配置 // 兼容边框配置
data.chartList.forEach((item) => { data.chartList.forEach((item) => {
if (!item.border) { if (!item.border) {
item.border={type:'',titleHeight:60,fontSize:30,isTitle:true,paddingTop:10} item.border = { type: '', titleHeight: 60, fontSize: 30, isTitle: true, paddingTop: 10 }
} }
}) })
const pageInfo = handleResData(data) const pageInfo = handleResData(data)
@ -84,7 +84,7 @@ export function handleResData (data) {
pageInfo.pageConfig.refreshConfig = pageInfo.pageConfig.refreshConfig || [] pageInfo.pageConfig.refreshConfig = pageInfo.pageConfig.refreshConfig || []
let originalConfig = {} let originalConfig = {}
pageInfo.chartList.forEach((chart) => { pageInfo.chartList.forEach((chart) => {
if (!['customComponent', 'remoteComponent'].includes(chart.type)) { if (!['customComponent', 'remoteComponent', 'echartsComponent'].includes(chart.type)) {
originalConfig = { option: { ...setModules[chart.type] }, ...dataModules[chart.type] } originalConfig = { option: { ...setModules[chart.type] }, ...dataModules[chart.type] }
// 如果没有版本号,或者版本号修改了则需要进行旧数据兼容 // 如果没有版本号,或者版本号修改了则需要进行旧数据兼容
if ((!chart.version) || chart.version !== originalConfig.version) { if ((!chart.version) || chart.version !== originalConfig.version) {

@ -13,7 +13,7 @@ export function settingToTheme (config, type) {
const theme = { dark: { ...config?.theme?.dark }, light: { ...config?.theme?.light } } const theme = { dark: { ...config?.theme?.dark }, light: { ...config?.theme?.light } }
// 根据组件的type来判断主题的转化方式 // 根据组件的type来判断主题的转化方式
// 如果是g2组件或者远程组件 // 如果是g2组件或者远程组件
if (['customComponent', 'remoteComponent'].includes(config.type)) { if (['customComponent', 'remoteComponent', 'echartsComponent'].includes(config.type)) {
config.setting.forEach((setItem) => { config.setting.forEach((setItem) => {
if (['gradual', 'colorPicker', 'colorSelect'].includes(setItem.type)) { if (['gradual', 'colorPicker', 'colorSelect'].includes(setItem.type)) {
theme[type][setItem.field] = setItem.value theme[type][setItem.field] = setItem.value
@ -75,7 +75,7 @@ function chartThemeToSetting (chart, type) {
chart.option.theme = type === 'dark' ? 'transparent' : 'light' 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', 'echartsComponent'].includes(chart.type)) {
for (const item of chart.setting) { for (const item of chart.setting) {
// 检查 obj 中是否存在与 item.field 相对应的属性 // 检查 obj 中是否存在与 item.field 相对应的属性
if (Object.prototype.hasOwnProperty.call(chart.theme[type], item.field)) { if (Object.prototype.hasOwnProperty.call(chart.theme[type], item.field)) {

Loading…
Cancel
Save