feat:修改chart-bar-statistics 的X轴显示

This commit is contained in:
zhangyu
2021-04-09 11:20:11 +08:00
parent 7fcebd4579
commit df7749666f
4 changed files with 32 additions and 5 deletions

View File

@@ -166,6 +166,13 @@ export default {
legend: { legend: {
show: false show: false
}, },
grid: {
top: 30,
left: 10,
right: 30,
containLabel: true,
bottom: 8// 156
},
tooltip: { tooltip: {
trigger: 'item', trigger: 'item',
backgroundColor: 'rgba(221,228,237,1)', backgroundColor: 'rgba(221,228,237,1)',
@@ -286,17 +293,34 @@ export default {
}, },
// 设置数据, filter区分 // 设置数据, filter区分
setData (chartItem, seriesItem, panelId, filter, legend, area, errorMsg) { setData (chartItem, seriesItem, panelId, filter, legend, area, errorMsg) {
console.log(chartItem, seriesItem, this.option,this.chartIndex); console.log(chartItem, seriesItem, this.option, this.chartIndex)
this.data = chartItem this.data = chartItem
const self = this
if (chartItem.type === 'bar') { if (chartItem.type === 'bar') {
this.option.xAxis = { this.option.xAxis = {
type: 'category', type: 'category',
axisLine: {
show: false
},
axisTick: {
show: false
},
showAllSymbol: false,
axisPointer: { // y轴上显示指针对应的值
show: false
},
axisLabel: { axisLabel: {
margin: 8, margin: 8,
formatter: function (params) { formatter: function (params) {
console.log(self.chartIndex);
console.log(document.getElementById('chart-' + self.chartIndex))
const dataLength = seriesItem.length || 1
const chartWidth = (document.getElementById('chart-' + chartItem.id).offsetWidth - 80) / dataLength// 容器宽 - padding - 空余
const length = Math.ceil((chartWidth) / 16)
console.log(chartWidth, length, dataLength , seriesItem.length)
let val = '' let val = ''
if (params.length > 4) { if (params.length > length) {
val = params.substr(0, 4) + '...' val = params.substr(0, length) + '...'
return val return val
} else { } else {
return params return params

View File

@@ -3,7 +3,7 @@
float:left; float:left;
padding: 0px 10px 10px 0; padding: 0px 10px 10px 0;
position:relative; position:relative;
box-sizing: content-box; box-sizing: border-box;
} }
.noData{ .noData{
text-align: center text-align: center

View File

@@ -611,6 +611,7 @@ export default {
const copies = maxValueCopies.copies const copies = maxValueCopies.copies
const unit = maxValueCopies.unit const unit = maxValueCopies.unit
const oldDot = maxValueCopies.oldDot const oldDot = maxValueCopies.oldDot
console.log(copies,maxValue,unit, chartDataFormat.Interval(maxValue, copies, unit.type, 'max') * Math.ceil(dataArg.length / 5))
let option = { let option = {
title: { title: {
show: false show: false
@@ -1898,6 +1899,7 @@ export default {
} }
const chartUnit = chartInfo.unit ? chartInfo.unit : 2 const chartUnit = chartInfo.unit ? chartInfo.unit : 2
const unit = chartDataFormat.getUnit(chartUnit) const unit = chartDataFormat.getUnit(chartUnit)
console.log(unit);
minValue = minValue > 0 ? 0 : minValue minValue = minValue > 0 ? 0 : minValue
maxValue = maxValue - minValue maxValue = maxValue - minValue
maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii) maxValue = chartDataFormat.formatDatas(maxValue, unit.type, 'ceil', unit.ascii)

View File

@@ -1733,7 +1733,8 @@ export default {
if (this.showPanel.id) { if (this.showPanel.id) {
this.panelId = this.showPanel.id this.panelId = this.showPanel.id
} }
this.$get('visual/panel/chart?id= ' + this.panelId).then(response => { console.log(this.panelId)
this.$get('visual/panel/chart?panelId=' + this.panelId).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.groupArr = [] this.groupArr = []
response.data.list.forEach((item, index) => { response.data.list.forEach((item, index) => {