-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parallel-coords): migrate to TypeScript
- Loading branch information
Showing
34 changed files
with
647 additions
and
837 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
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 |
---|---|---|
@@ -1,37 +1,40 @@ | ||
import random from 'lodash/random' | ||
import range from 'lodash/range' | ||
import shuffle from 'lodash/shuffle' | ||
|
||
interface IdSpec { | ||
id: string | ||
label?: string | ||
} | ||
|
||
interface VariableSpec { | ||
id: string | ||
range: [number, number] | ||
} | ||
|
||
type Options = Partial<{ | ||
size: number | ||
keys: Array<{ | ||
key: string | ||
random?: [number, number] | ||
shuffle?: string[] | ||
}> | ||
ids: IdSpec[] | ||
variables: VariableSpec[] | ||
}> | ||
|
||
export const generateParallelCoordinatesData = ({ | ||
size = 26, | ||
keys = [ | ||
{ key: 'temp', random: [-10, 40] }, | ||
{ key: 'cost', random: [200, 400000] }, | ||
{ key: 'color', shuffle: ['red', 'yellow', 'green'] }, | ||
{ key: 'target', shuffle: ['A', 'B', 'C', 'D', 'E'] }, | ||
{ key: 'volume', random: [0.2, 7.6] }, | ||
ids = [{ id: 'A' }, { id: 'B' }, { id: 'C' }, { id: 'D' }, { id: 'E' }], | ||
variables = [ | ||
{ id: 'temp', range: [-10, 40] }, | ||
{ id: 'cost', range: [200, 40000] }, | ||
{ id: 'weight', range: [10, 300] }, | ||
{ id: 'volume', range: [0.2, 7.6] }, | ||
], | ||
}: Options = {}) => { | ||
const datumGenerator = () => | ||
keys.reduce((acc, key) => { | ||
let value | ||
if (key.random !== undefined) { | ||
value = random(...key.random) | ||
} else if (key.shuffle !== undefined) { | ||
value = shuffle(key.shuffle)[0] | ||
} | ||
variables.reduce((acc, variable) => { | ||
const value = random(...variable.range) | ||
|
||
return { ...acc, [key.key]: value } | ||
return { ...acc, [variable.id]: value } | ||
}, {}) | ||
|
||
return range(size).map(datumGenerator) | ||
return ids.map(id => { | ||
return { | ||
...datumGenerator(), | ||
...id, | ||
} | ||
}) | ||
} |
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 was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
packages/parallel-coordinates/src/ParallelCoordinatesAxisDensity.js
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
packages/parallel-coordinates/src/ParallelCoordinatesAxisDensityCircles.js
This file was deleted.
Oops, something went wrong.
83 changes: 0 additions & 83 deletions
83
packages/parallel-coordinates/src/ParallelCoordinatesAxisDensityPoly.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.