From b8b8992f771ed6e7ccbe0385d1565237281d94da Mon Sep 17 00:00:00 2001 From: Raphael Benitte Date: Thu, 21 Apr 2016 07:58:09 +0900 Subject: [PATCH] feat(colors): add defautl nivo categorical colors --- src/ColorUtils.js | 13 +++++++++++++ src/Nivo.js | 9 ++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/ColorUtils.js b/src/ColorUtils.js index 87653e0c2..1808dcba9 100644 --- a/src/ColorUtils.js +++ b/src/ColorUtils.js @@ -42,6 +42,15 @@ const d3CategoricalColors = { d320c: d3.scale.category20c() }; +export const nivoCategoricalColors = () => d3.scale.ordinal().range([ + '#e8c1a0', + '#f47560', + '#f1e15b', + '#e8a838', + '#61cdbb', + '#97e3d5' +]); + const dataColor = d => (d.color || d.data.color); export const getColorRange = instruction => { @@ -49,6 +58,10 @@ export const getColorRange = instruction => { return dataColor; } + if (instruction === 'nivo') { + return nivoCategoricalColors(); + } + if (_.isFunction(instruction)) { return instruction; } diff --git a/src/Nivo.js b/src/Nivo.js index 39d95a51f..733d13faa 100644 --- a/src/Nivo.js +++ b/src/Nivo.js @@ -1,5 +1,5 @@ -import d3 from 'd3'; - +import d3 from 'd3'; +import { nivoCategoricalColors } from './ColorUtils'; const defaults = { transitionDuration: 600, @@ -15,5 +15,8 @@ const defaults = { export default { - defaults + defaults, + colors: { + nivoCategoricalColors + } };