Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into bugfix/166502072-download-button-style
Browse files Browse the repository at this point in the history
  • Loading branch information
lingyun1010 committed Jun 19, 2019
2 parents b2024d9 + ee31a31 commit 8e3cabd
Show file tree
Hide file tree
Showing 19 changed files with 4,598 additions and 765 deletions.
4 changes: 2 additions & 2 deletions __test__/GeneExpressionTSnePlot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe(`GeneExpressionTSnePlot colourize function`, () => {

_colourizeExpressionLevel(gradientColourRanges(), [])(plotData(randomSeries)).forEach((series) => {
series.data.forEach((point) => {
expect(point).toHaveProperty(`colorValue`)
expect(point).toHaveProperty(`expressionLevel`)
})
})
})
Expand All @@ -66,7 +66,7 @@ describe(`GeneExpressionTSnePlot colourize function`, () => {

expect(maxExpressionLevelPoints.length).toBeGreaterThanOrEqual(1)
maxExpressionLevelPoints.forEach((point) => {
expect(point).toHaveProperty(`colorValue`, maximum)
expect(point).toHaveProperty(`expressionLevel`, maximum)
})
})

Expand Down
20 changes: 10 additions & 10 deletions __test__/__snapshots__/ClusterTSnePlot.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ Array [
t-SNE Perplexity
</label>
<div
className="css-1pcexqc-container"
className=" css-2b097c-container"
onKeyDown={[Function]}
>
<div
className="css-12emboz"
className=" css-tinoic"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
<div
className="css-1hwfws3"
className=" css-1hwfws3"
>
<div
className="css-dvua67-singleValue"
className=" css-1uccc91-singleValue"
>
0
</div>
Expand Down Expand Up @@ -87,7 +87,7 @@ Array [
</div>
</div>
<div
className="css-1wy0on6"
className=" css-1wy0on6"
>
<span
className="sc-bdVaJa hUYIaS"
Expand All @@ -104,19 +104,19 @@ Array [
Colour plot by:
</label>
<div
className="css-1pcexqc-container"
className=" css-2b097c-container"
onKeyDown={[Function]}
>
<div
className="css-12emboz"
className=" css-tinoic"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
<div
className="css-1hwfws3"
className=" css-1hwfws3"
>
<div
className="css-151xaom-placeholder"
className=" css-1wa3eu0-placeholder"
>
Select...
</div>
Expand Down Expand Up @@ -179,7 +179,7 @@ Array [
</div>
</div>
<div
className="css-1wy0on6"
className=" css-1wy0on6"
>
<span
className="sc-bdVaJa hUYIaS"
Expand Down
10 changes: 5 additions & 5 deletions __test__/__snapshots__/PlotSettingsDropdown.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

exports[`PlotSettingsDropdown with no data matches snapshot 1`] = `
<div
className="css-1pcexqc-container"
className=" css-2b097c-container"
onKeyDown={[Function]}
>
<div
className="css-12emboz"
className=" css-tinoic"
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
<div
className="css-1hwfws3"
className=" css-1hwfws3"
>
<div
className="css-151xaom-placeholder"
className=" css-1wa3eu0-placeholder"
>
Select...
</div>
Expand Down Expand Up @@ -77,7 +77,7 @@ exports[`PlotSettingsDropdown with no data matches snapshot 1`] = `
</div>
</div>
<div
className="css-1wy0on6"
className=" css-1wy0on6"
>
<span
className="sc-bdVaJa hUYIaS"
Expand Down
67 changes: 67 additions & 0 deletions __test__/colorize.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import Color from 'color'
import colorize from '../src/colorize'

// The maximum is exclusive and the minimum is inclusive
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#Getting_a_random_number_between_two_values
const generateRandomArbitrary = (min, max) => Math.random() * (max - min) + min
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#Getting_a_random_integer_between_two_values
const generateRandomInt = (min, max) => {
min = Math.ceil(min)
max = Math.floor(max)
return Math.floor(Math.random() * (max - min)) + min
}

const stops = [
// The last stop acts as a
{
cutoff: 0.1,
color: `#e1e9f4`
},
{
cutoff: 1,
color: `#d4e4fb`
},
{
cutoff: 10,
color: `#95adde`
},
{
cutoff: 100,
color: `#6077bf`
},
{
cutoff: 1000,
color: `#1151d1`
},
{
cutoff: 10000,
color: `#35419b`
},
{
cutoff: 100000,
color: `#0e0573`
},
{
cutoff: 1000000,
color: `#07004c`
}
]
const defaultColor = `#eeeeee`

describe(`Colorize`, () => {
const _colorize = colorize(stops, defaultColor)

test(`assigns the maximum colour for values greater than or equal to 1,000,000`, () => {
expect(_colorize(generateRandomInt(stops[stops.length - 1].cutoff, Number.MAX_SAFE_INTEGER))).toEqual(Color(stops[stops.length - 1].color).toString())
})

test(`returns defaultColor if value is less than 0`, () => {
expect(_colorize(generateRandomArbitrary(0, stops[0].cutoff))).toEqual(Color(defaultColor).alpha(0.65).toString())
})

test(`exact color`, () => {
const foo = generateRandomInt(0, stops.length)

expect(_colorize(stops[foo].cutoff)).toEqual(Color(stops[foo].color).toString())
})
})
4 changes: 2 additions & 2 deletions __test__/plotloader/ScatterPlot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe(`ScatterPlot`, () => {
expect(tree).toMatchSnapshot()
})

test(`marker radius does not change depending on number of total points`, () => {
test(`marker radius changes depending on number of total points`, () => {
const wrapper = mount(<ScatterPlot series={[]}/>)

const longSeriesName = `Series with 5,000 points`
Expand Down Expand Up @@ -74,7 +74,7 @@ describe(`ScatterPlot`, () => {
wrapper.setProps({ series: [shortSeries] }).mount()
const markerRadiusShortSeries = wrapper.find(`n`).prop(`config`).plotOptions.series.marker.radius

expect(markerRadiusLongSeries).toBe(markerRadiusShortSeries)
expect(markerRadiusLongSeries).not.toBe(markerRadiusShortSeries)
})

test(`matches snapshot with randomized series`, () => {
Expand Down
27 changes: 12 additions & 15 deletions __test__/plotloader/__snapshots__/ScatterPlot.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ScatterPlot doesn’t check for unique names in the same series or among different series 1`] = `
<div
key="chart"
>
<div>
<n
callback={[Function]}
config={
Object {
"boost": Object {
"seriesThreshold": 5000,
"seriesThreshold": null,
"useGPUTranslations": true,
"usePreAllocated": true,
},
Expand Down Expand Up @@ -76,8 +74,9 @@ exports[`ScatterPlot doesn’t check for unique names in the same series or amon
"plotOptions": Object {
"series": Object {
"animation": false,
"boostThreshold": 10000,
"marker": Object {
"radius": 3,
"radius": 4,
},
"stickyTracking": false,
"turboThreshold": 0,
Expand Down Expand Up @@ -174,15 +173,13 @@ exports[`ScatterPlot doesn’t check for unique names in the same series or amon
`;

exports[`ScatterPlot matches snapshot with randomized series 1`] = `
<div
key="chart"
>
<div>
<n
callback={[Function]}
config={
Object {
"boost": Object {
"seriesThreshold": 5000,
"seriesThreshold": null,
"useGPUTranslations": true,
"usePreAllocated": true,
},
Expand Down Expand Up @@ -249,8 +246,9 @@ exports[`ScatterPlot matches snapshot with randomized series 1`] = `
"plotOptions": Object {
"series": Object {
"animation": false,
"boostThreshold": 10000,
"marker": Object {
"radius": 3,
"radius": 4,
},
"stickyTracking": false,
"turboThreshold": 0,
Expand Down Expand Up @@ -19623,15 +19621,13 @@ exports[`ScatterPlot matches snapshot with randomized series 1`] = `
`;

exports[`ScatterPlot with no series matches snapshot 1`] = `
<div
key="chart"
>
<div>
<n
callback={[Function]}
config={
Object {
"boost": Object {
"seriesThreshold": 5000,
"seriesThreshold": null,
"useGPUTranslations": true,
"usePreAllocated": true,
},
Expand Down Expand Up @@ -19698,8 +19694,9 @@ exports[`ScatterPlot with no series matches snapshot 1`] = `
"plotOptions": Object {
"series": Object {
"animation": false,
"boostThreshold": 10000,
"marker": Object {
"radius": 3,
"radius": 4,
},
"stickyTracking": false,
"turboThreshold": 0,
Expand Down
Loading

0 comments on commit 8e3cabd

Please sign in to comment.