getClassLabels

Helper function to extract nice-looking labels from d3.scaleThreshold.

const color = d3.scaleThreshold()
  .domain([0, 1])
  .range(["red", "white", "green"])

getClassLabels(color) // ['< 0', '0 - 1', '≥ 1']

Arguments

Argument Required Type(s) Default Unit(s)
thresholdScale true Function undefined d3.scaleThreshold
format false Function x => x -

Return value

Returns an Array of Strings containing formatted labels.