Use fast.js for map, reduce, and filter
parent
a4c42865a4
commit
dbb6a31a66
|
@ -5,6 +5,7 @@ import classnames from 'classnames'
|
||||||
|
|
||||||
import {MultiGrid, ColumnSizer} from 'react-virtualized'
|
import {MultiGrid, ColumnSizer} from 'react-virtualized'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
import {map, reduce, filter} from 'fast.js'
|
||||||
|
|
||||||
import {timeSeriesToTableGraph} from 'src/utils/timeSeriesToDygraph'
|
import {timeSeriesToTableGraph} from 'src/utils/timeSeriesToDygraph'
|
||||||
import {
|
import {
|
||||||
|
@ -24,8 +25,8 @@ import {generateThresholdsListHexs} from 'shared/constants/colorOperations'
|
||||||
|
|
||||||
const filterInvisibleColumns = (data, fieldNames) => {
|
const filterInvisibleColumns = (data, fieldNames) => {
|
||||||
const visibility = {}
|
const visibility = {}
|
||||||
const filteredData = data.map((row, i) => {
|
const filteredData = map(data, (row, i) => {
|
||||||
return row.filter((col, j) => {
|
return filter(row, (col, j) => {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
const foundField = fieldNames.find(field => field.internalName === col)
|
const foundField = fieldNames.find(field => field.internalName === col)
|
||||||
visibility[j] = foundField ? foundField.visible : true
|
visibility[j] = foundField ? foundField.visible : true
|
||||||
|
@ -48,7 +49,7 @@ const processData = (
|
||||||
data[0],
|
data[0],
|
||||||
..._.orderBy(_.drop(data, 1), sortIndex, [direction]),
|
..._.orderBy(_.drop(data, 1), sortIndex, [direction]),
|
||||||
]
|
]
|
||||||
const sortedTimeVals = sortedData.map(r => r[0])
|
const sortedTimeVals = map(sortedData, r => r[0])
|
||||||
const filteredData = filterInvisibleColumns(sortedData, fieldNames)
|
const filteredData = filterInvisibleColumns(sortedData, fieldNames)
|
||||||
const processedData = verticalTimeAxis ? filteredData : _.unzip(filteredData)
|
const processedData = verticalTimeAxis ? filteredData : _.unzip(filteredData)
|
||||||
|
|
||||||
|
@ -139,7 +140,8 @@ class TableGraph extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstDiff = Math.abs(hoverTime - sortedTimeVals[1]) // sortedTimeVals[0] is "time"
|
const firstDiff = Math.abs(hoverTime - sortedTimeVals[1]) // sortedTimeVals[0] is "time"
|
||||||
const hoverTimeFound = sortedTimeVals.reduce(
|
const hoverTimeFound = reduce(
|
||||||
|
sortedTimeVals,
|
||||||
(acc, currentTime, index) => {
|
(acc, currentTime, index) => {
|
||||||
const thisDiff = Math.abs(hoverTime - currentTime)
|
const thisDiff = Math.abs(hoverTime - currentTime)
|
||||||
if (thisDiff < acc.diff) {
|
if (thisDiff < acc.diff) {
|
||||||
|
|
Loading…
Reference in New Issue