Skip to content

Commit

Permalink
Conditionally define gradient per data (#6157)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbouslog authored Jul 8, 2024
1 parent 968683c commit 3bfe2fb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/lib-user/src/components/shared/BarChart/BarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ function BarChart({
.trim()
const typeLabel = type === 'count' ? 'Classifications' : 'Time'

// set gradient range based on data type (count or session_time) and max value of data type
const types = data.map((d) => d[type])
const max = Math.max(...types)
const gradient = [
{ value: 0, color: 'neutral-1' },
{ value: max, color: 'brand' }
]
// with no data set gradient as 'brand'
let gradient = 'brand'
// with data set gradient range based on data type (count or session_time) and max value of data type
if (data.length > 0) {
const types = data.map((d) => d[type])
const max = Math.max(...types)
gradient = [
{ value: 0, color: 'neutral-1' },
{ value: max, color: 'brand' }
]
}

// set chart options based on screen size and data length
const chartOptions = {
Expand Down

0 comments on commit 3bfe2fb

Please sign in to comment.