feat:3D固定柱状图添加底部阴影大小自适应

main
zhu.yawen 2 years ago
parent dc30dcedf8
commit 22e280878d

@ -1,14 +1,10 @@
import * as echarts from 'echarts' import * as echarts from 'echarts'
// 配置版本号 // 配置版本号
const version = '2023071001' const version = '2023091901'
// 分类
const category = 'Column'
// 标题 // 标题
const title = '3D固定柱状图' const title = '3D固定柱状图'
// 类别, new Line()
const chartType = 'Column'
// 用于标识,唯一,和文件夹名称一致 // 用于标识,唯一,和文件夹名称一致
const name = 'FenZuZhuZhuangTu' const name = '3DGuDingZhuZhuangTu'
// 右侧配置项 // 右侧配置项
const setting = [ const setting = [
@ -96,7 +92,6 @@ const setting = [
tabName: 'custom', tabName: 'custom',
groupName: 'graph' groupName: 'graph'
} }
] ]
// 配置处理脚本 // 配置处理脚本
@ -107,9 +102,9 @@ const dataHandler = ''
// 图表配置 new Line('domName', option) // 图表配置 new Line('domName', option)
const xData = ['本年话务总量', '本年人工话务量', '每万客户呼入量', '本年话务总量', '本年人工话务量', '每万客户呼入量'] const xData = ['本年话务总量', '本年人工话务量', '每万客户呼入量', '本年话务总量']
const yData = [300, 1230, 425, 300, 1230, 425] const yData = [300, 1230, 425, 300]
const maxData = [1500, 1500, 1500, 1500, 1500, 1500] const maxData = [1500, 1500, 1500, 1500]
const option = { const option = {
animation: false, animation: false,
tooltip: { tooltip: {
@ -333,10 +328,8 @@ const option = {
] ]
} }
export default { export default {
category,
version, version,
title, title,
chartType,
name, name,
option, option,
setting, setting,

@ -74,6 +74,22 @@ export default {
this.changeStyle(this.config, true) this.changeStyle(this.config, true)
} }
} }
},
'config.w': {
handler (val) {
if (val) {
console.log('this.config',this.config);
const chartDom = document.getElementById(this.chatId)
this.observeChart(chartDom, this.chart, this.config.option)
}
}
},
'config.h': {
handler (val) {
if (val) {
this.newChart(this.config)
}
}
} }
}, },
mounted () { mounted () {
@ -117,10 +133,34 @@ export default {
* 构造chart * 构造chart
*/ */
newChart (config) { newChart (config) {
// console.log('');
const chartDom = document.getElementById(this.chatId) const chartDom = document.getElementById(this.chatId)
this.chart = echarts.init(chartDom) this.chart = echarts.init(chartDom)
config.option && this.chart.setOption(config.option) config.option && this.chart.setOption(config.option)
}, },
/**
* 控制底部阴影大小
*/
observeChart (container, myChart, option) {
const resizeObserver = new ResizeObserver(entries => {
myChart.resize()
// entries[0].contentRect.width:
// entries[0].contentRect.height:
const width = entries[0].contentRect.width
const height = entries[0].contentRect.height
//
option.graphic.children[0].shape.width = width * 0.9
//
option.graphic.children[1].shape.points = [
[width / 10, -height / 6],
[width - width / 6, -height / 6],
[width * 0.9, 0],
[0, 0]
]
myChart.setOption(option)
})
resizeObserver.observe(container)
},
/** /**
* 注册事件 * 注册事件
*/ */
@ -160,6 +200,7 @@ export default {
return config return config
}, },
dataFormatting (config, data) { dataFormatting (config, data) {
console.log('config', config)
// //
if (data.success) { if (data.success) {
data = data.data data = data.data
@ -471,6 +512,7 @@ export default {
}, },
// config // config
changeStyle (config, isUpdateTheme) { changeStyle (config, isUpdateTheme) {
console.log('組件樣式改變',config)
config = { ...this.config, ...config } config = { ...this.config, ...config }
config = this.transformSettingToOption(config, 'custom') config = this.transformSettingToOption(config, 'custom')
// optionsettingeval,optionHandlerdataHandler // optionsettingeval,optionHandlerdataHandler

@ -24,6 +24,7 @@ import pcComponent from 'data-room-ui/js/utils/componentImport'
import { dataInit, destroyedEvent } from 'data-room-ui/js/utils/eventBus' import { dataInit, destroyedEvent } from 'data-room-ui/js/utils/eventBus'
import CustomComponent from '../PlotRender/index.vue' import CustomComponent from '../PlotRender/index.vue'
import Svgs from '../Svgs/index.vue' import Svgs from '../Svgs/index.vue'
import EchartsComponent from '../EchartsRender/index.vue'
import RemoteComponent from 'data-room-ui/RemoteComponents/index.vue' import RemoteComponent from 'data-room-ui/RemoteComponents/index.vue'
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
const components = {} const components = {}
@ -39,7 +40,8 @@ export default {
...components, ...components,
CustomComponent, CustomComponent,
Svgs, Svgs,
RemoteComponent RemoteComponent,
EchartsComponent
}, },
props: { props: {
// //

Loading…
Cancel
Save