Skip to content

Commit 37a04b4

Browse files
author
Robert Crocker
committed
Updated the scatter plot colors.
1 parent a92c963 commit 37a04b4

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function App() {
6969
legend={'right'}
7070
legendLabel="Markets"
7171
/>
72-
{/* <ScatterPlot
72+
<ScatterPlot
7373
theme="light"
7474
height="100%"
7575
width="100%"
@@ -83,7 +83,7 @@ function App() {
8383
yGrid={true}
8484
yAxis="right"
8585
yAxisLabel="Body Mass"
86-
/> */}
86+
/>
8787
</Container>
8888
);
8989
}

src/charts/ScatterPlot/ScatterPlot.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,13 @@ export default function ScatterPlot({
144144
// ********************
145145

146146
// discreteColors must be between 3 and 9, so here we create a range.
147+
const numberOfKeys = Array.from(keys).length;
147148
const discreteColors =
148-
Array.from(keys).length < 4 ? 3 : Math.min(Array.from(keys).length, 9);
149-
const computedScheme = d3[`${colorScheme}`][discreteColors];
150-
const colorScale = d3.scaleOrdinal(Array.from(computedScheme).reverse());
149+
numberOfKeys < 4 ? 3 : Math.min(Array.from(keys).length, 9);
150+
const computedScheme = Array.from(
151+
d3[`${colorScheme}`][discreteColors]
152+
).reverse();
153+
const colorScale = d3.scaleOrdinal(computedScheme);
151154
colorScale.domain(keys);
152155

153156
// ********************

0 commit comments

Comments
 (0)