Skip to content

Commit

Permalink
feat(colors): add defautl nivo categorical colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Benitte committed Apr 20, 2016
1 parent c094087 commit 4c5f708
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/ColorUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,26 @@ 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 => {
if (instruction === 'data') {
return dataColor;
}

if (instruction === 'nivo') {
return nivoCategoricalColors();
}

if (_.isFunction(instruction)) {
return instruction;
}
Expand Down
9 changes: 6 additions & 3 deletions src/Nivo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import d3 from 'd3';

import d3 from 'd3';
import { nivoCategoricalColors } from './ColorUtils';

const defaults = {
transitionDuration: 600,
Expand All @@ -15,5 +15,8 @@ const defaults = {


export default {
defaults
defaults,
colors: {
nivoCategoricalColors
}
};

0 comments on commit 4c5f708

Please sign in to comment.