Skip to content

Commit a92c963

Browse files
author
Robert Crocker
committed
Updated the area chart color.
1 parent 5801186 commit a92c963

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
@@ -40,7 +40,7 @@ function App() {
4040
legend={'bottom'}
4141
tooltipVisible={true}
4242
/>
43-
{/*<AreaChart
43+
<AreaChart
4444
theme="dark"
4545
height="100%"
4646
width="100%"
@@ -52,7 +52,7 @@ function App() {
5252
yGrid={true}
5353
xAxisLabel="Date"
5454
yAxisLabel="Value"
55-
/> */}
55+
/>
5656
<LineChart
5757
theme="light"
5858
height={'100%'}

src/charts/AreaChart/AreaChart.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,13 @@ export default function AreaChart({
185185
// Define how the data will drive your design
186186
// ********************
187187

188+
const numberOfKeys = Array.from(keys).length;
188189
const discreteColors =
189-
Array.from(keys).length < 4 ? 3 : Math.min(Array.from(keys).length, 9);
190-
const computedScheme = d3[`${colorScheme}`][discreteColors];
191-
const colorScale = d3.scaleOrdinal(Array.from(computedScheme).reverse());
190+
numberOfKeys < 4 ? 3 : Math.min(Array.from(keys).length, 9);
191+
const computedScheme = Array.from(
192+
d3[`${colorScheme}`][discreteColors]
193+
).reverse();
194+
const colorScale = d3.scaleOrdinal(computedScheme);
192195
colorScale.domain(keys);
193196

194197
// ********************

0 commit comments

Comments
 (0)