提交 39a0c761 authored 作者: liujiaxing's avatar liujiaxing

时间类型显示开始和结束时间为整点

上级 b3508a7c
...@@ -155,8 +155,11 @@ function initChart() { ...@@ -155,8 +155,11 @@ function initChart() {
if (firstTime < 1) { if (firstTime < 1) {
firstTime = new Date(series1Data.value[0][0]).getTime() firstTime = new Date(series1Data.value[0][0]).getTime()
} }
firstTime = new Date(series1Data.value[0][0]).getTime() < firstTime ? new Date(series1Data.value[0][0]).getTime() : firstTime // firstTime = new Date(series1Data.value[0][0]).getTime() < firstTime ? new Date(series1Data.value[0][0]).getTime() : firstTime
lastTime = new Date(series1Data.value[series1Data.value.length - 1][0]).getTime() > lastTime ? new Date((series1Data.value[series1Data.value.length - 1][0])).getTime() : lastTime firstTime = new Date(series1Data.value[0][0]).getTime() < firstTime ? new Date((series1Data.value[0][0]).split(' ')[0] + ' 00:00:00').getTime() : firstTime
// lastTime = new Date(series1Data.value[series1Data.value.length - 1][0]).getTime() > lastTime ? new Date((series1Data.value[series1Data.value.length - 1][0])).getTime() : lastTime
lastTime = new Date(series1Data.value[series1Data.value.length - 1][0]).getTime() > lastTime ? new Date((series1Data.value[series1Data.value.length - 1][0]).split(' ')[0] + ' 23:59:59').getTime() : lastTime
seriesArr.push({ seriesArr.push({
color: props.color[index], color: props.color[index],
name: props.legendName[index], name: props.legendName[index],
...@@ -209,8 +212,10 @@ function initChart() { ...@@ -209,8 +212,10 @@ function initChart() {
if (props.data[0]?.x?.includes(':')) { if (props.data[0]?.x?.includes(':')) {
xAxisType = 'time'; xAxisType = 'time';
if (dataX.value.length > 0) { if (dataX.value.length > 0) {
firstTime = props.data[0]?.x // firstTime = props.data[0]?.x
lastTime = props.data[props.data.length - 1]?.x firstTime = new Date((props.data[0]?.x).split(' ')[0] + ' 00:00:00').getTime()
// lastTime = props.data[props.data.length - 1]?.x
lastTime = new Date((props.data[props.data.length - 1]?.x.split(' ')[0]) + ' 23:59:59').getTime()
} }
series1Data.value = props.data.map((item, idx) => [item.x, item?.y && Object.prototype.toString(item?.y) === '[object Object]' && item.y?.errorRate !== undefined ? item.y.dropRate : item.y]); series1Data.value = props.data.map((item, idx) => [item.x, item?.y && Object.prototype.toString(item?.y) === '[object Object]' && item.y?.errorRate !== undefined ? item.y.dropRate : item.y]);
// console.log(series1Data.value, '最终数据'); // console.log(series1Data.value, '最终数据');
...@@ -320,6 +325,7 @@ function initChart() { ...@@ -320,6 +325,7 @@ function initChart() {
hideOverlap: false, // 防重叠(很关键) hideOverlap: false, // 防重叠(很关键)
showMinLabel: true, // 显示最小刻度标签 showMinLabel: true, // 显示最小刻度标签
showMaxLabel: true, // 显示最大刻度标签 showMaxLabel: true, // 显示最大刻度标签
formatter: function (value) { formatter: function (value) {
if (!props.lineArray) { if (!props.lineArray) {
if (xAxisType == 'time') { if (xAxisType == 'time') {
...@@ -366,6 +372,13 @@ function initChart() { ...@@ -366,6 +372,13 @@ function initChart() {
color: "#DCE2E8",//设置x轴轴线颜色 color: "#DCE2E8",//设置x轴轴线颜色
} }
}, },
max: lastTime,
// 单独设置最大值标签
maxLabel: {
formatter: function (value) {
return '终点 ' + value;
}
},
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论