diff --git a/src/components/readingChart/index.vue b/src/components/readingChart/index.vue index f10c4c9c..e2518c14 100644 --- a/src/components/readingChart/index.vue +++ b/src/components/readingChart/index.vue @@ -62,7 +62,8 @@ export default { zIndex: 9, chart: null, loading: false, - key: 'readingChart' + key: 'readingChart', + isInteger: false }; }, methods: { @@ -101,12 +102,13 @@ export default { let res = await getReportsChartData(params) this.loading = false if (res.IsSuccess) { + this.isInteger = res.Result.Type === 'number' && res.Result.ValueType === 0 let LatestScanDateList = res.Result.LatestScanDateList.map(item => item.split(" ")[0]) let obj = { title: QuestionName, xAxisData: LatestScanDateList || [], series: [], - unit: this.$fd("ValueUnit", res.Result.Unit), + unit: res.Result.Unit === 0 ? '' : res.Result.Unit === 4 ? res.Result.CustomUnit : this.$fd("ValueUnit", res.Result.Unit), visitName: res.Result.VisitTaskNameList, min: null, max: null @@ -123,43 +125,6 @@ export default { type: 'line' }) }); - // if (Array.isArray(res.Result.LatestScanDateList) && res.Result.LatestScanDateList.length >= 2) { - // let hours = moment(res.Result.LatestScanDateList[res.Result.LatestScanDateList.length - 1]).diff(moment(res.Result.LatestScanDateList[0]), 'hours'); - // let days = moment(res.Result.LatestScanDateList[res.Result.LatestScanDateList.length - 1]).diff(moment(res.Result.LatestScanDateList[0]), 'days'); - // let months = moment(res.Result.LatestScanDateList[res.Result.LatestScanDateList.length - 1]).diff(moment(res.Result.LatestScanDateList[0]), 'months'); - // console.log(hours, 'hours') - // console.log(days, 'days') - // console.log(months, 'months') - // if (hours < 24) { - // obj.min = moment(res.Result.LatestScanDateList[0]).format('YYYY-MM-DD') + ' 00:00:00' - // obj.max = moment(res.Result.LatestScanDateList[0]).format('YYYY-MM-DD') + ' 23:59:59' - // } - // if (days >= 1 && days <= 7) { - // obj.min = moment(res.Result.LatestScanDateList[0]).format('YYYY-MM-DD') + ' 00:00:00' - // obj.max = moment(res.Result.LatestScanDateList[0]).add(7, 'days').format('YYYY-MM-DD') + ' 23:59:59' - // } - // if (days > 7 && days < 30) { - // obj.min = moment(res.Result.LatestScanDateList[0]).startOf('month').format('YYYY-MM-DD') + ' 00:00:00' - // obj.max = moment(res.Result.LatestScanDateList[0]).endOf('month').format('YYYY-MM-DD') + ' 23:59:59' - // } - // if (months >= 1 && months <= 3) { - // obj.min = moment(res.Result.LatestScanDateList[0]).startOf('month').format('YYYY-MM-DD') + ' 00:00:00' - // obj.max = moment(res.Result.LatestScanDateList[0]).add(4, 'months').startOf('month').format('YYYY-MM-DD') + ' 23:59:59' - // } - // if (months > 3 && months <= 6) { - // obj.min = moment(res.Result.LatestScanDateList[0]).startOf('month').format('YYYY-MM-DD') + ' 00:00:00' - // obj.max = moment(res.Result.LatestScanDateList[0]).add(7, 'months').startOf('month').format('YYYY-MM-DD') + ' 23:59:59' - // } - // if (months > 6 && months <= 12) { - // obj.min = moment(res.Result.LatestScanDateList[0]).startOf('month').format('YYYY-MM-DD') + ' 00:00:00' - // obj.max = moment(res.Result.LatestScanDateList[0]).add(13, 'months').startOf('month').format('YYYY-MM-DD') + ' 23:59:59' - // } - // if (months > 12) { - // obj.min = moment(res.Result.LatestScanDateList[0]).startOf('month').format('YYYY-MM-DD') + ' 00:00:00' - // obj.max = moment(res.Result.LatestScanDateList[res.Result.LatestScanDateList.length - 1]).add(1, 'months').startOf('month').format('YYYY-MM-DD') + ' 23:59:59' - // } - // } - // console.log(obj) this.initChart(obj) } } catch (err) { @@ -236,6 +201,9 @@ export default { }, series: obj.series }; + if (this.isInteger) { + option.yAxis.minInterval = 1 + } // 4. 使用配置项渲染图表 this.chart.setOption(option); },