Skip to content

Commit

Permalink
feat(calendar): add ability to customize empty day color
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Benitte committed May 12, 2016
1 parent d2394b8 commit 644cc8e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/charts/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Calendar extends Component {
data,
direction,
colorScale,
emptyColor,
yearSpacing, yearLegendOffset,
daySpacing, dayBorderWidth, dayBorderColor,
monthBorderWidth, monthBorderColor, monthLegendOffset,
Expand All @@ -43,6 +44,7 @@ class Calendar extends Component {
data,
direction,
colorScale,
emptyColor,
yearSpacing,
daySpacing
});
Expand Down
3 changes: 2 additions & 1 deletion src/components/charts/calendar/CalendarD3.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CalendarD3 extends Component {
from, to,
data,
direction,
colorScale,
colorScale, emptyColor,
yearSpacing, yearLegendOffset,
daySpacing, dayBorderWidth, dayBorderColor,
monthBorderWidth, monthBorderColor, monthLegendOffset,
Expand Down Expand Up @@ -60,6 +60,7 @@ class CalendarD3 extends Component {
data,
direction,
colorScale,
emptyColor,
yearSpacing,
daySpacing
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/charts/calendar/CalendarProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const calendarPropTypes = {
})).isRequired,
direction: oneOf([DIRECTION_HORIZONTAL, DIRECTION_VERTICAL]),
colorScale: scale.isRequired,
emptyColor: string.isRequired,
// years
yearSpacing: number.isRequired,
yearLegendOffset: number.isRequired,
Expand Down Expand Up @@ -66,6 +67,7 @@ export const calendarPropTypes = {
export const calendarDefaultProps = {
margin: Nivo.defaults.margin,
direction: DIRECTION_HORIZONTAL,
emptyColor: '#fff',
// years
yearSpacing: 30,
yearLegendOffset: 10,
Expand Down
4 changes: 3 additions & 1 deletion src/lib/charts/calendar/CalendarLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const CalendarLayout = () => {
* @param {array} data
* @param {string} direction
* @param {object} colorScale
* @param {string} emptyColor
* @param {number} yearSpacing
* @param {number} daySpacing
* @returns {object}
Expand All @@ -169,6 +170,7 @@ const CalendarLayout = () => {
data,
direction,
colorScale,
emptyColor,
yearSpacing,
daySpacing
}) {
Expand Down Expand Up @@ -242,7 +244,7 @@ const CalendarLayout = () => {
const color = scalePropToD3Scale(colorScale);

days.forEach(day => {
day.color = '#fff';
day.color = emptyColor;
data.forEach(dataDay => {
if (dataDay.day === day.day) {
day.color = color(dataDay.value);
Expand Down

0 comments on commit 644cc8e

Please sign in to comment.