+ The responsive alternative of this component is ResponsiveCalendar,
+ it also offers a canvas implementations, see{' '}
+ CalendarCanvas.
+
See the dedicated guide on how to setup
legends for this component.
diff --git a/website/src/components/charts/calendar/CalendarCanvas.js b/website/src/components/charts/calendar/CalendarCanvas.js
new file mode 100644
index 000000000..413763e73
--- /dev/null
+++ b/website/src/components/charts/calendar/CalendarCanvas.js
@@ -0,0 +1,166 @@
+/*
+ * This file is part of the nivo project.
+ *
+ * Copyright 2016-present, Raphaël Benitte.
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+import React, { Component } from 'react'
+import { Link } from 'react-router-dom'
+import MediaQuery from 'react-responsive'
+import ChartHeader from '../../ChartHeader'
+import ChartTabs from '../../ChartTabs'
+import generateCode from '../../../lib/generateChartCode'
+import CalendarControls from './CalendarControls'
+import { ResponsiveCalendarCanvas, CalendarCanvasDefaultProps } from '@nivo/calendar'
+import ComponentPropsDocumentation from '../../properties/ComponentPropsDocumentation'
+import nivoTheme from '../../../nivoTheme'
+import properties from './props'
+import propsMapper from './propsMapper'
+
+const Tooltip = data => {
+ /* return custom tooltip */
+}
+
+export default class CalendarCanvas extends Component {
+ state = {
+ settings: {
+ pixelRatio: window && window.devicePixelRatio ? window.devicePixelRatio : 1,
+
+ from: '2013-03-01',
+ to: '2019-07-12',
+
+ emptyColor: '#eeeeee',
+ colors: ['#61cdbb', '#97e3d5', '#e8c1a0', '#f47560'],
+ minValue: 0,
+ maxValue: 'auto',
+
+ margin: {
+ top: 40,
+ right: 40,
+ bottom: 50,
+ left: 40,
+ },
+ direction: 'vertical',
+
+ yearSpacing: 30,
+ yearLegendPosition: 'before',
+ yearLegendOffset: 10,
+
+ monthBorderWidth: 2,
+ monthBorderColor: '#ffffff',
+ monthLegendPosition: 'before',
+ monthLegendOffset: 10,
+
+ daySpacing: 0,
+ dayBorderWidth: 2,
+ dayBorderColor: '#ffffff',
+
+ isInteractive: true,
+ 'custom tooltip example': false,
+ tooltip: null,
+
+ legends: [
+ {
+ anchor: 'bottom',
+ direction: 'row',
+ translateY: 40,
+ itemCount: 4,
+ itemWidth: 34,
+ itemHeight: 36,
+ itemDirection: 'top-to-bottom',
+ },
+ ],
+
+ theme: {
+ ...nivoTheme,
+ labels: {
+ ...nivoTheme.labels,
+ text: {
+ ...nivoTheme.labels.text,
+ fontSize: 10,
+ },
+ },
+ },
+ },
+ }
+
+ handleSettingsUpdate = settings => {
+ this.setState({ settings })
+ }
+
+ handleNodeClick = (node, event) => {
+ alert(`${node.day}: ${node.value}\nclicked at x: ${event.clientX}, y: ${event.clientY}`)
+ }
+
+ render() {
+ const { data } = this.props
+ const { settings } = this.state
+
+ const mappedSettings = propsMapper(settings)
+
+ const code = generateCode(
+ 'ResponsiveCalendarCanvas',
+ {
+ ...mappedSettings,
+ tooltip: mappedSettings.tooltip ? Tooltip : undefined,
+ },
+ {
+ pkg: '@nivo/calendar',
+ defaults: CalendarCanvasDefaultProps,
+ }
+ )
+
+ const header =
+
+ const description = (
+
+
+ A variation around the Calendar component. Well
+ suited for large data sets as it does not impact DOM tree depth, however you'll
+ lose the isomorphic rendering ability.
+
+
+ The responsive alternative of this component is{' '}
+ ResponsiveCalendarCanvas.
+
+
+ )
+
+ return (
+
+
+
+ {header}
+ {description}
+
+
+
+
+
+
+
+
+
+ {header}
+ {description}
+
+
+
+ )
+ }
+}
diff --git a/website/src/components/charts/calendar/CalendarControls.js b/website/src/components/charts/calendar/CalendarControls.js
index 42c7389f3..95d6a6983 100644
--- a/website/src/components/charts/calendar/CalendarControls.js
+++ b/website/src/components/charts/calendar/CalendarControls.js
@@ -14,6 +14,7 @@ import properties from './props'
const groupsByScope = {
Calendar: getPropertiesGroupsControls(properties, 'Calendar'),
+ CalendarCanvas: getPropertiesGroupsControls(properties, 'CalendarCanvas'),
api: getPropertiesGroupsControls(properties, 'api'),
}
diff --git a/website/src/components/charts/calendar/CalendarPage.js b/website/src/components/charts/calendar/CalendarPage.js
index ff708515d..40fb0e421 100644
--- a/website/src/components/charts/calendar/CalendarPage.js
+++ b/website/src/components/charts/calendar/CalendarPage.js
@@ -15,7 +15,7 @@ class CalendarPage extends Component {
super(props)
const from = new Date(2015, 3, 1)
- const to = new Date(2016, 7, 12)
+ const to = new Date(2018, 7, 12)
this.state = {
from,
diff --git a/website/src/components/charts/calendar/props.js b/website/src/components/charts/calendar/props.js
index b642c48e4..301cc3fea 100644
--- a/website/src/components/charts/calendar/props.js
+++ b/website/src/components/charts/calendar/props.js
@@ -49,8 +49,8 @@ export default [
docScopes: '*',
description: (
- not required if using
- <ResponsiveCalendar />.
+ not required if using responsive alternative of the component{' '}
+ <Responsive*/>.
),
help: 'Chart width.',
@@ -71,8 +71,8 @@ export default [
docScopes: '*',
description: (
- not required if using
- <ResponsiveCalendar />.
+ not required if using responsive alternative of the component{' '}
+ <Responsive*/>.
),
help: 'Chart height.',
@@ -176,6 +176,20 @@ export default [
controlType: 'colorPicker',
controlGroup: 'Base',
},
+ {
+ key: 'pixelRatio',
+ scopes: ['CalendarCanvas'],
+ description: `Adjust pixel ratio, useful for HiDPI screens.`,
+ required: false,
+ default: 'Depends on device',
+ type: `{number}`,
+ controlType: 'range',
+ controlGroup: 'Base',
+ controlOptions: {
+ min: 1,
+ max: 2,
+ },
+ },
// Years
{
key: 'yearSpacing',
@@ -227,6 +241,7 @@ export default [
// Months
{
key: 'monthBorderWidth',
+ scopes: ['Calendar', 'api'],
description: 'width of month borders.',
type: '{number}',
required: false,
@@ -241,6 +256,7 @@ export default [
},
{
key: 'monthBorderColor',
+ scopes: ['Calendar', 'api'],
description: 'color to use for months border.',
type: '{string}',
required: false,
@@ -321,7 +337,7 @@ export default [
...marginProperties,
{
key: 'isInteractive',
- scopes: ['Calendar'],
+ scopes: ['Calendar', 'CalendarCanvas'],
description: 'Enable/disable interactivity.',
type: '{boolean}',
required: false,
@@ -331,14 +347,14 @@ export default [
},
{
key: 'onClick',
- scopes: ['Calendar'],
+ scopes: ['Calendar', 'CalendarCanvas'],
description: 'onClick handler, it receives clicked day data and mouse event.',
type: '{Function}',
required: false,
},
{
key: 'custom tooltip example',
- scopes: ['Calendar'],
+ scopes: ['Calendar', 'CalendarCanvas'],
excludeFromDoc: true,
description: (
@@ -352,7 +368,7 @@ export default [
},
{
key: 'tooltip',
- scopes: ['Calendar'],
+ scopes: ['Calendar', 'CalendarCanvas'],
type: '{Function}',
required: false,
description: (
diff --git a/website/src/components/charts/waffle/WaffleCanvas.js b/website/src/components/charts/waffle/WaffleCanvas.js
index 5fa1d22fa..b28da7240 100644
--- a/website/src/components/charts/waffle/WaffleCanvas.js
+++ b/website/src/components/charts/waffle/WaffleCanvas.js
@@ -198,7 +198,7 @@ export default class WaffleCanvas extends Component {
The responsive alternative of this component is{' '}
- ResponsiveWaffleHtml, it also offers other implementations, see{' '}
+ ResponsiveWaffleCanvas, it also offers other implementations, see{' '}
Waffle and WaffleHtml.