Comparing version
@@ -40,6 +40,9 @@ 'use strict'; | ||
function generateColors(colorScheme, index) { | ||
var colorIndex = index % colorScheme.length, | ||
rgbColor = (0, _colors.hexToRgb)(colorScheme[colorIndex]); | ||
function generateRandomColors(colorScheme, index) { | ||
var colorIndex = index % colorScheme.length; | ||
return generateColors(colorScheme[colorIndex]); | ||
} | ||
function generateColors(color) { | ||
var rgbColor = (0, _colors.hexToRgb)(color); | ||
return { | ||
@@ -71,2 +74,3 @@ backgroundColor: (0, _colors.rgbToString)(rgbColor, 0.2), | ||
}) : dataset.data; | ||
var colors = dataset.options.color ? generateColors(dataset.options.color) : generateRandomColors(colorScheme, index); | ||
@@ -78,3 +82,3 @@ return Object.assign({ | ||
data: data | ||
}, generateColors(colorScheme, index)); | ||
}, colors); | ||
}); | ||
@@ -114,4 +118,5 @@ | ||
var colors = graph.labels.map(function (label, index) { | ||
return generateColors(colorScheme, index); | ||
return generateRandomColors(colorScheme, index); | ||
}); | ||
return { | ||
@@ -118,0 +123,0 @@ datasets: [{ |
{ | ||
"name": "reportjs", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Report Library", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -20,6 +20,9 @@ import Chart from 'chart.js'; | ||
function generateColors(colorScheme, index) { | ||
let colorIndex = index % colorScheme.length, | ||
rgbColor = hexToRgb(colorScheme[colorIndex]); | ||
function generateRandomColors(colorScheme, index) { | ||
let colorIndex = index % colorScheme.length; | ||
return generateColors(colorScheme[colorIndex]); | ||
} | ||
function generateColors(color) { | ||
const rgbColor = hexToRgb(color); | ||
return { | ||
@@ -46,2 +49,5 @@ backgroundColor: rgbToString(rgbColor, 0.2), | ||
: dataset.data; | ||
const colors = dataset.options.color | ||
? generateColors(dataset.options.color) | ||
: generateRandomColors(colorScheme, index); | ||
@@ -53,3 +59,3 @@ return Object.assign({ | ||
data | ||
}, generateColors(colorScheme, index)); | ||
}, colors); | ||
}); | ||
@@ -89,3 +95,4 @@ | ||
const colorScheme = defaultScheme; | ||
const colors = graph.labels.map((label, index) => generateColors(colorScheme, index)); | ||
const colors = graph.labels.map((label, index) => generateRandomColors(colorScheme, index)); | ||
return { | ||
@@ -92,0 +99,0 @@ datasets: [{ |
92712
0.46%1806
0.56%