-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor derivation of layer data (#44)
- Loading branch information
Showing
19 changed files
with
1,039 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest All", | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"args": ["--runInBand"], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"disableOptimisticBPs": true, | ||
"windows": { | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest", | ||
} | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest Current File", | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"args": [ | ||
"${fileBasenameNoExtension}", | ||
"--config", | ||
"jest.config.js" | ||
], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"disableOptimisticBPs": true, | ||
"windows": { | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest", | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export {getLineTable, getLineMappings, getLineScales} from './line' | ||
export {getScatterTable, getScatterMappings, getScatterScales} from './scatter' | ||
export {getHeatmapTable, getHeatmapMappings, getHeatmapScales} from './heatmap' | ||
export { | ||
getHistogramTable, | ||
getHistogramMappings, | ||
getHistogramScales, | ||
} from './histogram' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Table, LineLayerConfig, LineMappings, LineScales} from '../types' | ||
import {getFillScale} from '../utils/getFillScale' | ||
import {appendGroupingCol} from '../utils/appendGroupingCol' | ||
import {FILL_COL_KEY} from '../constants' | ||
|
||
export const getLineTable = (table: Table, fill: string[]): Table => | ||
appendGroupingCol(table, fill, FILL_COL_KEY) | ||
|
||
export const getLineMappings = ( | ||
layerConfig: LineLayerConfig | ||
): LineMappings => ({ | ||
x: layerConfig.x, | ||
y: layerConfig.y, | ||
fill: layerConfig.fill, | ||
}) | ||
|
||
export const getLineScales = (table: Table, colors: string[]): LineScales => ({ | ||
fill: getFillScale(table, colors), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {Table, ScatterLayerConfig, ScatterMappings} from '../types' | ||
import {getFillScale} from '../utils/getFillScale' | ||
import {getSymbolScale} from '../utils/getSymbolScale' | ||
import {appendGroupingCol} from '../utils/appendGroupingCol' | ||
import {SYMBOL_COL_KEY, FILL_COL_KEY} from '../constants' | ||
|
||
export const getScatterTable = ( | ||
table: Table, | ||
fill: string[], | ||
symbol: string[] | ||
): Table => { | ||
const withFillCol = appendGroupingCol(table, fill, FILL_COL_KEY) | ||
const withSymbolCol = appendGroupingCol(withFillCol, symbol, SYMBOL_COL_KEY) | ||
|
||
return withSymbolCol | ||
} | ||
|
||
export const getScatterMappings = ( | ||
layerConfig: ScatterLayerConfig | ||
): ScatterMappings => ({ | ||
x: layerConfig.x, | ||
y: layerConfig.y, | ||
fill: layerConfig.fill, | ||
symbol: layerConfig.symbol, | ||
}) | ||
|
||
export const getScatterScales = (table: Table, colors: string[]) => ({ | ||
fill: getFillScale(table, colors), | ||
symbol: getSymbolScale(table), | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import memoizeOne from 'memoize-one' | ||
|
||
/* | ||
Stores a cache of memoized functions which can be looked up by an arbitrary | ||
key. The memoized functions are instatiated lazily. | ||
Example: | ||
``` | ||
const f = () => { | ||
console.log('f called') | ||
return 2 | ||
} | ||
const cache = new MemoizedFunctionCache() | ||
const fMemoized = cache.get('myKey', f) | ||
fMemoized() // logs "f called", returns 2 | ||
fMemoized() // returns 2 | ||
``` | ||
*/ | ||
export class MemoizedFunctionCache { | ||
private memoizedFunctions: {[key: string]: Function} = {} | ||
|
||
public get<T extends (...args: any[]) => any>(key: string, fn: T): T { | ||
if (!this.memoizedFunctions[key]) { | ||
this.memoizedFunctions[key] = memoizeOne(fn) | ||
} | ||
|
||
return this.memoizedFunctions[key] as T | ||
} | ||
} |
Oops, something went wrong.