Skip to content

Commit

Permalink
fix(可视化): 设备详情中可视化图表日期显示问题
Browse files Browse the repository at this point in the history
格式化日期时间戳

fix #175
  • Loading branch information
Lind-pro committed Sep 3, 2020
1 parent 594013c commit 4a2d902
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pages/device/visualization/charts/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ComponentProps } from "..";
import apis from "@/services";
import styles from '../index.less';
import { getWebsocket } from "@/layouts/GlobalWebSocket";
import moment from "moment";

interface Props extends ComponentProps {
config: any;
Expand Down Expand Up @@ -80,7 +81,7 @@ const LineChart = (props: Props) => {
).subscribe(
(resp: any) => {
const { payload } = resp;
data.push({ year: payload.timestamp, value: payload.value.value });
data.push({ year: moment(payload.timestamp).format('YYYY-MM-DD HH:mm:ss'), value: payload.value.value });
if (data.length > props.config.history) data.shift();
setData([...data]);
}
Expand All @@ -91,7 +92,7 @@ const LineChart = (props: Props) => {
apis.visualization.getDashboardData(params).then(response => {
if (response.status === 200) {
const { result } = response;
const tempData = result.map((item: any) => ({ year: item.data.timestamp, value: item.data.value.value }));
const tempData = result.map((item: any) => ({ year: moment(item.data.timestamp).format('YYYY-MM-DD HH:mm:ss'), value: item.data.value.value }));
setData(tempData);
}
})
Expand Down

0 comments on commit 4a2d902

Please sign in to comment.