change timeSeriesToTable to transform date into ISO format; update time based on format

pull/10616/head
Iris Scholten 2018-03-02 15:15:33 -08:00
parent 119d4f208b
commit 8dd3507948
3 changed files with 21 additions and 3 deletions

View File

@ -27,7 +27,7 @@ const formatColor = color => {
}
class TableOptions extends Component {
state = {TimeAxis: 'VERTICAL', TimeFormat: 'mm/dd/yyyy HH:mm:ss.ss'}
state = {TimeAxis: 'VERTICAL', TimeFormat: 'MM/DD/YYYY HH:mm:ss.ss'}
handleToggleSingleStatType = () => {}

View File

@ -1,9 +1,13 @@
import React, {PropTypes, Component} from 'react'
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import _ from 'lodash'
import {timeSeriesToTable} from 'src/utils/timeSeriesToDygraph'
import {MultiGrid} from 'react-virtualized'
import moment from 'moment'
class TableGraph extends Component {
state = {timeFormat: 'MM/DD/YYYY HH:mm:ss.ss'}
componentWillMount() {
this._labels = []
this._data = [[]]
@ -18,6 +22,12 @@ class TableGraph extends Component {
cellRenderer = ({columnIndex, key, rowIndex, style}) => {
const data = this._data
const {timeFormat} = this.state
if (columnIndex === 0 && rowIndex > 0) {
data[rowIndex][columnIndex] = moment(data[rowIndex][columnIndex]).format(
timeFormat
)
}
return (
<div key={key} style={style}>
{data[rowIndex][columnIndex]}

View File

@ -166,7 +166,15 @@ export default function timeSeriesToDygraph(raw = [], isInDataExplorer) {
export const timeSeriesToTable = data => {
const {labels, timeSeries} = timeSeriesToDygraph(data, false)
const tableData = timeSeries.length
? timeSeries.map(row => row.map(cell => (cell ? cell.toString() : 'null')))
? timeSeries.map(row =>
row.map(
cell =>
cell
? typeof cell === 'object' ? cell.toISOString() : cell.toString()
: 'null'
)
)
: [[]]
return {labels, data: [labels, ...tableData]}
}