Skip to content

Commit

Permalink
less checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane98c committed Feb 6, 2024
1 parent 1f0b6a4 commit bf94af0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/colorbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ const hexToRgb = (hex) => {

const Gradient = ({ colormap, discrete, horizontal, width, height }) => {
const step = (1 / colormap.length) * 100
const isHex = colormap[0].startsWith('#')
const values = colormap.map((color, i) => {
const rgbColor = color.startsWith('#') ? hexToRgb(color) : color
const rgbColor = isHex ? hexToRgb(color) : color
const position = `${i * step}% ${
discrete && i < colormap.length - 1 ? `${(i + 1) * step}%` : ''
}`
Expand Down

0 comments on commit bf94af0

Please sign in to comment.