Commit c5411a99 by wangr

Merge remote-tracking branch 'origin/20210819' into wangrui

parents 25fddfb9 aad6f3a3
Subproject commit f4746173cf454453e2895964ec3ed3d6a13d0e42 Subproject commit 0a4f2d33af0abc1da40e1482e27708fb9bea6ac1
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
</template> </template>
<script> <script>
import * as echarts from 'echarts' import mixinChart from 'runner/common/mixins/mixinChart'
import mixinChart from '@/public/mixins/mixinChart'
export default { export default {
name: 'lineBar', name: 'lineBar',
...@@ -24,7 +22,10 @@ export default { ...@@ -24,7 +22,10 @@ export default {
layout: { layout: {
type: Object, type: Object,
default () { default () {
return {} return {
width: '100%',
height: '100%'
}
} }
}, },
...@@ -46,34 +47,44 @@ export default { ...@@ -46,34 +47,44 @@ export default {
methods: { methods: {
initComponents () { initComponents () {
const { width = '', height = '', id = '', className = 'line-bar-chart-class' } = this.mergeChartConf() || {} const { width = '', height = '' } = this.layout
// 基础配置, 不含series const option = this.getChartOption() || {}
const option = this.getChartOption(this.option.base) || {}
const seriesData = this.getSeriesData(this.option.seriesData || []) || []
// if (!seriesData.length) {
// throw Error('该组件图表数据只能接受length为2的数组')
// }
option.series = seriesData
this.barChartConf = { this.barChartConf = {
className,
id,
width, width,
height, height,
option option,
id: 'line-bar-chart-id' + this.utils.randomStr()
} }
}, },
/** /**
* @method mergeChartConf 合并图表配置项 * @method getSeriesData 图表数据
*/ */
mergeChartConf () { getSeriesData (data) {
const defaultChartConf = { const defSeriesOpts = {
width: '100%', name: 'back',
height: '100%', type: 'bar',
// 不同的id(防止id重复,同一个页面,无法展示多个同组件图表) barWidth: '4px',
id: 'line-bar-chart-id' + this.utils.randomStr() itemStyle: {
borderRadius: [0, 0, 0, 0],
normal: {
color: '#233549'
}
},
barGap: '-100%',
data: []
} }
return this.deepMerge({}, defaultChartConf, this.layout) let result = [defSeriesOpts]
const { seriesData = [] } = this.option
console.log(this.option)
if (seriesData.length) {
const temp = []
seriesData.forEach(item => {
temp.push(this.deepMerge({}, defSeriesOpts, item))
})
result = temp
}
return result
}, },
/** /**
...@@ -86,7 +97,7 @@ export default { ...@@ -86,7 +97,7 @@ export default {
}, },
grid: { grid: {
left: 0, left: 0,
right: 10, right: 5,
bottom: 0, bottom: 0,
top: 0, top: 0,
containLabel: true containLabel: true
...@@ -108,7 +119,7 @@ export default { ...@@ -108,7 +119,7 @@ export default {
}, },
yAxis: [ yAxis: [
{ {
type: 'category', type: 'category', // y 轴左侧的数据
axisTick: { axisTick: {
show: false show: false
}, },
...@@ -130,7 +141,7 @@ export default { ...@@ -130,7 +141,7 @@ export default {
}, },
data: [] data: []
}, { }, {
type: 'category', type: 'category', // y 轴右侧的数据
axisLine: { axisLine: {
show: false show: false
}, },
...@@ -161,57 +172,10 @@ export default { ...@@ -161,57 +172,10 @@ export default {
} }
] ]
} }
return this.deepMerge({}, defaultOption, customOption) const result = this.deepMerge({}, defaultOption, this.option.base)
}, result.series = this.getSeriesData()
/** return result
* @method getSeriesData 图表数据
*/
getSeriesData () {
if (this.option.seriesData.length !== 2) return []
const defSeriesData = [
{
name: 'back',
type: 'bar',
barWidth: '4px',
itemStyle: {
borderRadius: [0, 0, 0, 0],
normal: {
color: '#233549'
}
},
barGap: '-100%',
data: [1, 2, 3]
},
{
name: 'show',
type: 'bar',
barWidth: '4px',
itemStyle: {
borderRadius: [0, 0, 0, 0],
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
offset: 0,
color: 'rgba(59, 150, 235, 0.1)'
}, {
offset: 1,
color: '#3b96eb'
}], false)
}
},
markPoint: {
symbol: 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyVpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4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ksRXboTBC2KQl24kEILvghinybmMU1m7mTu3J6TTmAo1tnMvfd83znf+e657MILBQd8LLH+J0jfT7hV2iwZWjTHgF1G9hiythSoVz3JHy1Ux6vJRDxJvFPemLU09UmC/veXSF971zp0nP60p3OKJxWxWDa7UdosO7r6WAtTt790cmumBgXOwI4U+IGE+imnOTmqewudkFWeVMd/koKBbGZzeBiA8XzVz7XzNlTSOsxoHLIyArcbwjc8Xz6TCZ/ZPJxD/M0kmXMNLlYD565jwMkRG85hghNYfUhIcJs+TKFW9rvnfCibrfm43YjIbCIDGkos1nuWHLJghojFNEzjGtoCitQkJlmr+faPaas1Rvj1HZD9ylKRCaw2YoaTiptZqkjEYWtPVlNAVmOQLWAccX/28LHbGFChYm8P2/5Z6hENamNFaIl+ZcC9iwR3yvYqiFsk/OCeFUnY8M3Hpax4kzOCpw3fXIkr9nvGJCvDehBmuJitdszzhE8aFi3Wcl+vGo37R9LufIellrYDa0lIziwtUhOWGHWUd32rq98jHOGTE6bqHgSvt/MvT+d3vh91vAfHTHEJryqHbTS7vej9ase68rmRWSbcYMpYYrbJBK2QAjNtQArDFpI1JEuMiG4PvJgoB2R93/BLBPgEousIQmBkzrrbJ0QxRh30MAbBKDblv69qV4ABAOvFCo1MtxZ0AAAAAElFTkSuQmCC',
symbolSize: [10, 10],
data: []
},
data: [],
z: 3
}
]
const seriesData = [{}, {}]
seriesData[0] = this.deepMerge({}, defSeriesData[0], this.option.seriesData[0])
seriesData[1] = this.deepMerge({}, defSeriesData[1], this.option.seriesData[1])
return seriesData
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment