change timeSeriesToTable to transform date into ISO format; update time based on format
parent
119d4f208b
commit
8dd3507948
|
@ -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 = () => {}
|
||||
|
||||
|
|
|
@ -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]}
|
||||
|
|
|
@ -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]}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue