|
@@ -11,7 +11,6 @@
|
|
:id="chatId"
|
|
:id="chatId"
|
|
style="width: 100%;height: 100%"
|
|
style="width: 100%;height: 100%"
|
|
/>
|
|
/>
|
|
- <!-- <span style="color:#ffffff">{{config.option.data}}</span>-->
|
|
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
@@ -81,7 +80,7 @@ export default {
|
|
},
|
|
},
|
|
beforeDestroy () {
|
|
beforeDestroy () {
|
|
if (this.chart) {
|
|
if (this.chart) {
|
|
- this.chart.destroy()
|
|
|
|
|
|
+ this.chart.dispose()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -212,7 +211,7 @@ export default {
|
|
const { xData, yData } = this.getxDataAndYData(xField, yField, data, hasSeries)
|
|
const { xData, yData } = this.getxDataAndYData(xField, yField, data, hasSeries)
|
|
// const xData = [...new Set(data.map(item => item[xField]))]
|
|
// const xData = [...new Set(data.map(item => item[xField]))]
|
|
// const yData = data.map(item => item[yField])
|
|
// const yData = data.map(item => item[yField])
|
|
- const maxY = Math.max(...yData)
|
|
|
|
|
|
+ const maxY = Math.max(...yData) + Math.max(...yData) * 0.2
|
|
// 生成阴影柱子的值
|
|
// 生成阴影柱子的值
|
|
const shadowData = Array.from({ length: xData.length }, () => maxY)
|
|
const shadowData = Array.from({ length: xData.length }, () => maxY)
|
|
option.xAxis = option.xAxis.map(item => {
|
|
option.xAxis = option.xAxis.map(item => {
|
|
@@ -226,6 +225,28 @@ export default {
|
|
const seriesField = config.setting.find(item => item.optionField === 'seriesField')?.value
|
|
const seriesField = config.setting.find(item => item.optionField === 'seriesField')?.value
|
|
const seriesFieldList = [...new Set(data.map(item => item[seriesField]))]
|
|
const seriesFieldList = [...new Set(data.map(item => item[seriesField]))]
|
|
option.series = []
|
|
option.series = []
|
|
|
|
+ const offsetArr = []
|
|
|
|
+ let index = 0
|
|
|
|
+ let barWidth = 10
|
|
|
|
+ if (seriesFieldList.length % 2 === 0) {
|
|
|
|
+ const length = seriesFieldList.length / 2
|
|
|
|
+ for (let i = 0; i < length; i++) {
|
|
|
|
+ const offsetX = (parseInt('10%') + parseInt('50%')) * (2 * i + 1)
|
|
|
|
+ offsetArr.push(offsetX)
|
|
|
|
+ offsetArr.unshift(-offsetX)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ const length = Math.ceil(seriesFieldList.length / 2)
|
|
|
|
+ for (let i = 0; i < length; i++) {
|
|
|
|
+ if (i === 0) {
|
|
|
|
+ offsetArr.push(0)
|
|
|
|
+ } else {
|
|
|
|
+ const offsetX = (parseInt('20%') + parseInt('100%')) * i
|
|
|
|
+ offsetArr.push(offsetX)
|
|
|
|
+ offsetArr.unshift(-offsetX)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
for (const seriesFieldItem of seriesFieldList) {
|
|
for (const seriesFieldItem of seriesFieldList) {
|
|
const seriesData = (data.filter(item => item[seriesField] === seriesFieldItem))?.map(item => item[yField])
|
|
const seriesData = (data.filter(item => item[seriesField] === seriesFieldItem))?.map(item => item[yField])
|
|
const seriesItem = [
|
|
const seriesItem = [
|
|
@@ -234,8 +255,8 @@ export default {
|
|
type: 'pictorialBar',
|
|
type: 'pictorialBar',
|
|
tooltip: { show: false },
|
|
tooltip: { show: false },
|
|
symbol: 'diamond',
|
|
symbol: 'diamond',
|
|
- symbolSize: [30, 10],
|
|
|
|
- symbolOffset: ['-60%', -5],
|
|
|
|
|
|
+ symbolSize: [barWidth, barWidth / 2],
|
|
|
|
+ symbolOffset: [offsetArr[index] + '%', -barWidth / 4],
|
|
symbolPosition: 'end',
|
|
symbolPosition: 'end',
|
|
z: 15,
|
|
z: 15,
|
|
zlevel: 2,
|
|
zlevel: 2,
|
|
@@ -246,7 +267,7 @@ export default {
|
|
name: seriesFieldItem,
|
|
name: seriesFieldItem,
|
|
type: 'bar',
|
|
type: 'bar',
|
|
barGap: '20%',
|
|
barGap: '20%',
|
|
- barWidth: 30,
|
|
|
|
|
|
+ barWidth: barWidth,
|
|
itemStyle: {
|
|
itemStyle: {
|
|
normal: {
|
|
normal: {
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
@@ -277,8 +298,8 @@ export default {
|
|
type: 'pictorialBar',
|
|
type: 'pictorialBar',
|
|
tooltip: { show: false },
|
|
tooltip: { show: false },
|
|
symbol: 'diamond',
|
|
symbol: 'diamond',
|
|
- symbolSize: [30, 10],
|
|
|
|
- symbolOffset: ['-60%', 5],
|
|
|
|
|
|
+ symbolSize: [barWidth, barWidth / 2],
|
|
|
|
+ symbolOffset: [offsetArr[index] + '%', barWidth / 4],
|
|
zlevel: 2,
|
|
zlevel: 2,
|
|
z: 15,
|
|
z: 15,
|
|
color: 'rgb(2, 192, 255)',
|
|
color: 'rgb(2, 192, 255)',
|
|
@@ -292,7 +313,7 @@ export default {
|
|
barGap: '20%',
|
|
barGap: '20%',
|
|
data: shadowData,
|
|
data: shadowData,
|
|
zlevel: 1,
|
|
zlevel: 1,
|
|
- barWidth: 30,
|
|
|
|
|
|
+ barWidth: barWidth,
|
|
itemStyle: {
|
|
itemStyle: {
|
|
normal: {
|
|
normal: {
|
|
color: 'rgba(9, 44, 76,.8)'
|
|
color: 'rgba(9, 44, 76,.8)'
|
|
@@ -304,8 +325,8 @@ export default {
|
|
type: 'pictorialBar',
|
|
type: 'pictorialBar',
|
|
tooltip: { show: false },
|
|
tooltip: { show: false },
|
|
symbol: 'diamond',
|
|
symbol: 'diamond',
|
|
- symbolSize: [30, 10],
|
|
|
|
- symbolOffset: ['-60%', -5],
|
|
|
|
|
|
+ symbolSize: [barWidth, barWidth / 2],
|
|
|
|
+ symbolOffset: [offsetArr[index] + '%', -barWidth / 4],
|
|
symbolPosition: 'end',
|
|
symbolPosition: 'end',
|
|
z: 15,
|
|
z: 15,
|
|
color: 'rgb(15, 69, 133)',
|
|
color: 'rgb(15, 69, 133)',
|
|
@@ -313,6 +334,7 @@ export default {
|
|
data: shadowData
|
|
data: shadowData
|
|
}
|
|
}
|
|
]
|
|
]
|
|
|
|
+ index++
|
|
option.series.push(...seriesItem)
|
|
option.series.push(...seriesItem)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|