@influxdata/giraffe
Advanced tools
Comparing version 2.18.11 to 2.19.0
import { Formatter } from '../types'; | ||
export declare const calculateTicks: (domain: number[], rangeLength: number, tickSize: number, columnKey: string) => number[]; | ||
export declare const generateTicks: (domain: number[], columnKey: string, totalTicks: number, tickStart: number, tickStep: number) => number[]; | ||
export declare const getVerticalTicks: (domain: number[], rangeLength: number, tickFont: string, formatter: Formatter, totalTicks?: number, tickStart?: number, tickStep?: number) => number[]; | ||
export declare const getHorizontalTicks: (domain: number[], rangeLength: number, tickFont: string, formatter: Formatter, totalTicks?: number, tickStart?: number, tickStep?: number) => number[]; | ||
export declare const getVerticalTicks: import("memoize-one").MemoizedFn<(domain: number[], rangeLength: number, tickFont: string, formatter: Formatter, totalTicks?: number, tickStart?: number, tickStep?: number) => number[]>; | ||
export declare const getHorizontalTicks: import("memoize-one").MemoizedFn<(domain: number[], rangeLength: number, tickFont: string, formatter: Formatter, totalTicks?: number, tickStart?: number, tickStep?: number) => number[]>; |
{ | ||
"name": "@influxdata/giraffe", | ||
"version": "2.18.11", | ||
"version": "2.19.0", | ||
"main": "dist/index.js", | ||
@@ -50,3 +50,2 @@ "module": "src/index.js", | ||
"@types/jest": "^26.0.19", | ||
"@types/memoize-one": "^4.1.1", | ||
"@types/react": "^16.8.3", | ||
@@ -85,3 +84,3 @@ "@types/react-dom": "^16.8.2", | ||
"leaflet.markercluster": "^1.4.1", | ||
"memoize-one": "^5.0.2", | ||
"memoize-one": "^6.0.0", | ||
"node-sass": "^4.14.1", | ||
@@ -88,0 +87,0 @@ "papaparse": "^5.3.0", |
@@ -1,17 +0,28 @@ | ||
import {newTable} from '../utils/newTable' | ||
import memoizeOne from 'memoize-one' | ||
import {MosaicLayerSpec, Table} from '../types' | ||
import {DISPLAY_NAME, FILL, SERIES, X_MAX, X_MIN} from '../constants/columnKeys' | ||
import {createGroupIDColumn} from './' | ||
import {isEqual} from '../utils/isEqual' | ||
import {newTable} from '../utils/newTable' | ||
import {resolveDomain} from '../utils/resolveDomain' | ||
import {getNominalColorScale} from './' | ||
import {createGroupIDColumn, getNominalColorScale} from './' | ||
const memoizedSortTimeStamps = memoizeOne( | ||
(timeStamps: Iterable<number>) => [...timeStamps].sort(), | ||
isEqual | ||
) | ||
const memoizedSortDataMapKeys = memoizeOne( | ||
(dataMapKeys: Iterable<string>) => [...dataMapKeys].sort(), | ||
isEqual | ||
) | ||
export const mosaicTransform = ( | ||
inputTable: Table, | ||
xColumnKey: string, | ||
yColumnKeys: string[], | ||
yLabelColumns: string[], | ||
yColumnKeys: Array<string>, | ||
yLabelColumns: Array<string>, | ||
yLabelColumnSeparator: string, | ||
xDomain: number[], | ||
fillColKeys: string[], | ||
colors: string[] | ||
xDomain: Array<number>, | ||
fillColKeys: Array<string>, | ||
colors: Array<string> | ||
): MosaicLayerSpec => { | ||
@@ -37,16 +48,17 @@ const [fillColumn, fillColumnMap] = createGroupIDColumn( | ||
) | ||
const yInputCols = {} | ||
const yInputCols = new Map() | ||
if (Array.isArray(yColumnKeys)) { | ||
yColumnKeys.forEach(columnKey => { | ||
const column = inputTable.getColumn(columnKey, 'string') | ||
yInputCols[columnKey] = column | ||
if (columnKey) { | ||
const column = inputTable.getColumn(columnKey, 'string') | ||
yInputCols.set(columnKey, column) | ||
} | ||
}) | ||
} | ||
// Mosaic can only have one column as the fill value, | ||
// always the first fill column key | ||
// Mosaic can have only one column as the fill value: | ||
// always the first fill column key | ||
const valueKey = fillColumnMap.columnKeys[0] | ||
const timeStampMap = {} | ||
const timeStampMap = new Map() | ||
for (let i = 0; i < inputTable.length; i++) { | ||
@@ -56,4 +68,4 @@ const yColumnTick = Array.isArray(yColumnKeys) | ||
let value = '' | ||
if (yInputCols[key]) { | ||
value = yInputCols[key][i] | ||
if (yInputCols.has(key) && Array.isArray(yInputCols.get(key))) { | ||
value = yInputCols.get(key)[i] | ||
} | ||
@@ -66,4 +78,4 @@ return `${combinedValue}${value}` | ||
let value = '' | ||
if (yInputCols[key]) { | ||
value = yInputCols[key][i] | ||
if (yInputCols.has(key)) { | ||
value = yInputCols.get(key)[i] | ||
} | ||
@@ -78,6 +90,6 @@ return combinedValue | ||
if (!timeStampMap[currentX]) { | ||
timeStampMap[currentX] = [] | ||
if (!timeStampMap.has(currentX)) { | ||
timeStampMap.set(currentX, []) | ||
} | ||
timeStampMap[currentX].push({ | ||
timeStampMap.get(currentX).push({ | ||
yTickLabel, | ||
@@ -89,3 +101,3 @@ yColumnTick, | ||
const sortedTimeStamps = Object.keys(timeStampMap).sort() | ||
const sortedTimeStamps = memoizedSortTimeStamps([...timeStampMap.keys()]) | ||
let tableLength = 0 | ||
@@ -105,10 +117,10 @@ | ||
*/ | ||
const dataMap = {} | ||
const dataMap = new Map() | ||
sortedTimeStamps.forEach(timeStamp => { | ||
timeStampMap[timeStamp].forEach(data => { | ||
if (!dataMap[data.yColumnTick]) { | ||
dataMap[data.yColumnTick] = { | ||
xMin: [Number(timeStamp)], | ||
xMax: [Number(timeStamp)], | ||
timeStampMap.get(timeStamp).forEach(data => { | ||
if (!dataMap.has(data.yColumnTick)) { | ||
dataMap.set(data.yColumnTick, { | ||
xMin: [timeStamp], | ||
xMax: [timeStamp], | ||
fill: [data.fill], | ||
@@ -118,18 +130,17 @@ series: [data.yColumnTick], | ||
yTickLabel: data.yTickLabel, | ||
} | ||
}) | ||
tableLength += 1 | ||
} else { | ||
const prevMaxIndex = dataMap[data.yColumnTick].xMax.length - 1 | ||
const prevFill = | ||
dataMap[data.yColumnTick].fill[ | ||
dataMap[data.yColumnTick].fill.length - 1 | ||
] | ||
const prevMaxIndex = dataMap.get(data.yColumnTick).xMax.length - 1 | ||
const prevFill = dataMap.get(data.yColumnTick).fill[ | ||
dataMap.get(data.yColumnTick).fill.length - 1 | ||
] | ||
dataMap[data.yColumnTick].xMax[prevMaxIndex] = Number(timeStamp) | ||
dataMap.get(data.yColumnTick).xMax[prevMaxIndex] = timeStamp | ||
if (prevFill !== data.fill) { | ||
dataMap[data.yColumnTick].xMin.push(Number(timeStamp)) | ||
dataMap[data.yColumnTick].xMax.push(Number(timeStamp)) | ||
dataMap[data.yColumnTick].fill.push(data.fill) | ||
dataMap[data.yColumnTick].series.push(data.yColumnTick) | ||
dataMap[data.yColumnTick].displayedColumns.push(data.yTickLabel) | ||
dataMap.get(data.yColumnTick).xMin.push(timeStamp) | ||
dataMap.get(data.yColumnTick).xMax.push(timeStamp) | ||
dataMap.get(data.yColumnTick).fill.push(data.fill) | ||
dataMap.get(data.yColumnTick).series.push(data.yColumnTick) | ||
dataMap.get(data.yColumnTick).displayedColumns.push(data.yTickLabel) | ||
tableLength += 1 | ||
@@ -149,20 +160,17 @@ } | ||
for (const key in dataMap) { | ||
//combine all series into the proper shape | ||
xMinData = xMinData.concat(dataMap[key].xMin) | ||
xMaxData = xMaxData.concat(dataMap[key].xMax) | ||
fillData = fillData.concat(dataMap[key].fill) | ||
seriesData = seriesData.concat(dataMap[key].series) | ||
const sortedDataMapKeys = memoizedSortDataMapKeys([...dataMap.keys()]) | ||
sortedDataMapKeys.forEach(key => { | ||
// combine all series into the proper shape | ||
xMinData = xMinData.concat(dataMap.get(key).xMin) | ||
xMaxData = xMaxData.concat(dataMap.get(key).xMax) | ||
fillData = fillData.concat(dataMap.get(key).fill) | ||
seriesData = seriesData.concat(dataMap.get(key).series) | ||
displayedColumnsData = displayedColumnsData.concat( | ||
dataMap[key].displayedColumns | ||
dataMap.get(key).displayedColumns | ||
) | ||
ySeries.push(key) | ||
yTicks.push(dataMap[key].yTickLabel) | ||
} | ||
/* | ||
xMin (start time) | xMax (end time) | Value Category | host | cpu | ||
------------------------------------------------------------------- | ||
1554308748000 | 1554308758000 | 'eenie' | "a" | 1 | ||
1554308748000 | 1554308758000 | 'mo' | "b" | 2 | ||
*/ | ||
yTicks.push(dataMap.get(key).yTickLabel) | ||
}) | ||
const table = newTable(tableLength) | ||
@@ -169,0 +177,0 @@ .addColumn(X_MIN, 'system', 'number', xMinData) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67
10777641
34768