Skip to content

Commit 4d824d9

Browse files
committed
Fix custom coloring.
1 parent 244f4ed commit 4d824d9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netdata/charts",
3-
"version": "5.6.2",
3+
"version": "5.6.3",
44
"description": "Netdata frontend SDK and chart utilities",
55
"main": "dist/index.js",
66
"module": "dist/es6/index.js",

src/sdk/makeChart/makeDimensions.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,16 @@ export default (chart, sdk) => {
161161
}
162162

163163
const getNextColor = () => {
164-
const colorsAttribute = chart.getAttribute("colors")
164+
const colorsAttribute = chart.getAttribute("colors") || []
165165
const index = colorCursor++ % (colorsAttribute.length + dimensionColors.length)
166166

167167
const nextColor =
168168
index < colorsAttribute.length
169169
? typeof colorsAttribute[index] === "number"
170170
? dimensionColors[colorsAttribute[index]]
171-
: colorsAttribute[index]
171+
: !colorsAttribute[index]
172+
? dimensionColors[index]
173+
: colorsAttribute[index]
172174
: dimensionColors[index - colorsAttribute.length]
173175

174176
return nextColor
@@ -237,7 +239,7 @@ export default (chart, sdk) => {
237239
const key = getMemKey()
238240
const colorsAttr = chart.getAttribute("colors")
239241
const sparkline = chart.isSparkline()
240-
if (sparkline && colorsAttr && colorsAttr.length === 1) return colorsAttr[0]
242+
if (sparkline && Array.isArray(colorsAttr)) return colorsAttr[0]
241243

242244
const isSelected = id === "selected"
243245
id = !id || isSelected ? chart.getAttribute("selectedDimensions")[0] || id : id

0 commit comments

Comments
 (0)