# up history linechart x-axis
This commit is contained in:
parent
076c486cf4
commit
ae878dbca2
|
@ -27,6 +27,9 @@ export default {
|
||||||
},
|
},
|
||||||
chartData: {
|
chartData: {
|
||||||
type: Object
|
type: Object
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
type: Array
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -35,6 +38,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
console.log(this.xAxis)
|
||||||
this.initChart()
|
this.initChart()
|
||||||
if (this.autoResize) {
|
if (this.autoResize) {
|
||||||
this.__resizeHanlder = debounce(() => {
|
this.__resizeHanlder = debounce(() => {
|
||||||
|
@ -75,8 +79,12 @@ export default {
|
||||||
setOptions({ totalHistoryData, actualData } = {}) {
|
setOptions({ totalHistoryData, actualData } = {}) {
|
||||||
this.chart.setOption({
|
this.chart.setOption({
|
||||||
xAxis: {
|
xAxis: {
|
||||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
// data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||||
|
data: this.xAxis,
|
||||||
boundaryGap: false,
|
boundaryGap: false,
|
||||||
|
axisLabel: {
|
||||||
|
interval: 0
|
||||||
|
},
|
||||||
axisTick: {
|
axisTick: {
|
||||||
show: false
|
show: false
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</panel-group>
|
</panel-group>
|
||||||
|
|
||||||
<el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
|
<el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
|
||||||
<line-chart :chart-data="lineChartData"></line-chart>
|
<line-chart :chart-data="lineChartData" :xAxis="this.lineChartData.xAxis"></line-chart>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-row>
|
<el-row>
|
||||||
|
@ -74,7 +74,9 @@ import
|
||||||
|
|
||||||
const lineChartData = {
|
const lineChartData = {
|
||||||
historyData: {
|
historyData: {
|
||||||
totalHistoryData: []
|
totalHistoryData: [],
|
||||||
|
incrementHistoryData: [],
|
||||||
|
xAxis: []
|
||||||
},
|
},
|
||||||
messages: {
|
messages: {
|
||||||
expectedData: [200, 192, 120, 144, 160, 130, 140],
|
expectedData: [200, 192, 120, 144, 160, 130, 140],
|
||||||
|
@ -134,10 +136,13 @@ export default {
|
||||||
},
|
},
|
||||||
handleHistoryLine(historyList) {
|
handleHistoryLine(historyList) {
|
||||||
var totalList = []
|
var totalList = []
|
||||||
|
var dateList = []
|
||||||
historyList.forEach((item, index) => {
|
historyList.forEach((item, index) => {
|
||||||
totalList.push(item.total)
|
totalList.push(item.total)
|
||||||
|
dateList.push(item.date.substr(5))
|
||||||
})
|
})
|
||||||
this.lineChartData.totalHistoryData = totalList.reverse()
|
this.lineChartData.totalHistoryData = totalList.reverse()
|
||||||
|
this.lineChartData.xAxis = dateList.reverse()
|
||||||
// console.log(this.lineChartData.totalHistoryData)
|
// console.log(this.lineChartData.totalHistoryData)
|
||||||
}
|
}
|
||||||
// getLogStatisticHistory() {
|
// getLogStatisticHistory() {
|
||||||
|
|
Loading…
Reference in New Issue