import React from 'react';
import Scheduler from 'devextreme-react/scheduler';
import {
generateResources,
generateAppointments
} from './data.js';
const currentDate = new Date(2021, 8, 6);
const views = [{
type: 'day',
groupOrientation: 'vertical',
name: '2 Days',
intervalCount: 2
}, {
type: 'day',
groupOrientation: 'vertical',
name: '3 Days',
intervalCount: 3
}, {
type: 'workWeek',
name: 'Work Week',
groupOrientation: 'vertical'
}];
const scrolling = { mode: 'virtual' };
const resourceData = generateResources();
const resources = [{
fieldExpr: 'resourceId',
dataSource: resourceData
}];
const groups = ['resourceId'];
const appointments = generateAppointments();
class App extends React.Component {
render() {
return (
<Scheduler
dataSource={appointments}
height={600}
views={views}
defaultCurrentView="3 Days"
defaultCurrentDate={currentDate}
startDayHour={9}
endDayHour={18}
scrolling={scrolling}
showAllDayPanel={false}
groups={groups}
resources={resources}
/>
);
}
}
export default App;
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.js';
ReactDOM.render(
<App />,
document.getElementById('app')
);
<!DOCTYPE html>
<html>
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.5/css/dx.common.css" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.5/css/dx.light.css" />
<script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
<script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript">
System.import('./index.js');
</script>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body class="dx-viewport">
<div class="demo-container">
<div id="app"></div>
</div>
</body>
</html>
const resourcesAmount = 100;
const colors = [
'rgba(88, 116, 255, 0.8)',
'rgba(234, 128, 252, 0.8)',
'rgba(198, 86, 144, 0.85)',
'rgba(254, 194, 0, 0.7)'
];
const dataSet = [{
text: 'Website Re-Design Plan',
startDate: new Date(2021, 8, 6, 9, 30),
endDate: new Date(2021, 8, 6, 11, 30)
}, {
text: 'Book Flights to San Fran for Sales Trip',
startDate: new Date(2021, 8, 6, 12, 0),
endDate: new Date(2021, 8, 6, 13, 0),
allDay: true
}, {
text: 'Install New Router in Dev Room',
startDate: new Date(2021, 8, 6, 14, 30),
endDate: new Date(2021, 8, 6, 15, 30)
}, {
text: 'Approve Personal Computer Upgrade Plan',
startDate: new Date(2021, 8, 7, 10, 0),
endDate: new Date(2021, 8, 7, 11, 0)
}, {
text: 'Final Budget Review',
startDate: new Date(2021, 8, 7, 12, 0),
endDate: new Date(2021, 8, 7, 13, 35)
}, {
text: 'New Brochures',
startDate: new Date(2021, 8, 7, 14, 30),
endDate: new Date(2021, 8, 7, 15, 45)
}, {
text: 'Install New Database',
startDate: new Date(2021, 8, 8, 9, 45),
endDate: new Date(2021, 8, 8, 11, 15)
}, {
text: 'Approve New Online Marketing Strategy',
startDate: new Date(2021, 8, 8, 12, 0),
endDate: new Date(2021, 8, 8, 14, 0)
}, {
text: 'Upgrade Personal Computers',
startDate: new Date(2021, 8, 8, 15, 15),
endDate: new Date(2021, 8, 8, 16, 30)
}, {
text: 'Customer Workshop',
startDate: new Date(2021, 8, 9, 11, 0),
endDate: new Date(2021, 8, 9, 12, 0),
allDay: true
}, {
text: 'Prepare 2015 Marketing Plan',
startDate: new Date(2021, 8, 9, 11, 0),
endDate: new Date(2021, 8, 9, 13, 30)
}, {
text: 'Brochure Design Review',
startDate: new Date(2021, 8, 9, 14, 0),
endDate: new Date(2021, 8, 9, 15, 30)
}, {
text: 'Create Icons for Website',
startDate: new Date(2021, 8, 10, 10, 0),
endDate: new Date(2021, 8, 10, 11, 30)
}, {
text: 'Upgrade Server Hardware',
startDate: new Date(2021, 8, 10, 14, 30),
endDate: new Date(2021, 8, 10, 16, 0)
}, {
text: 'Submit New Website Design',
startDate: new Date(2021, 8, 10, 16, 30),
endDate: new Date(2021, 8, 10, 18, 0)
}, {
text: 'Launch New Website',
startDate: new Date(2021, 8, 10, 12, 20),
endDate: new Date(2021, 8, 10, 14, 0)
}
];
export function generateResources() {
const resources = [];
for(let i = 0; i < resourcesAmount; ++i) {
const color = colors[i % colors.length];
resources.push({
id: i,
text: `Resource ${i}`,
color: color
});
}
return resources;
}
export function generateAppointments() {
const data = [];
for(let resourceId = 0; resourceId < resourcesAmount; ++resourceId) {
dataSet.forEach(item => {
data.push({
text: item.text,
startDate: item.startDate,
endDate: item.endDate,
resourceId
});
});
}
return data;
}
System.config({
transpiler: 'plugin-babel',
meta: {
'devextreme/localization.js': {
"esModule": true
},
},
paths: {
'npm:': 'https://unpkg.com/'
},
defaultExtension: 'js',
map: {
'react': 'npm:react@16.14.0/umd/react.development.js',
'react-dom': 'npm:react-dom@16.14.0/umd/react-dom.development.js',
'prop-types': 'npm:prop-types@15.7.2/prop-types.js',
'rrule': 'npm:rrule@2.6.6/dist/es5/rrule.js',
'luxon': 'npm:luxon@1.25.0/build/global/luxon.min.js',
'es6-object-assign': 'npm:es6-object-assign@1.1.0',
'devextreme': 'npm:devextreme@20.2.5',
'devextreme-react': 'npm:devextreme-react@20.2.5',
'jszip': 'npm:jszip@3.5.0/dist/jszip.min.js',
'devextreme-quill': 'npm:devextreme-quill@0.9.8/dist/dx-quill.min.js',
'devexpress-diagram': 'npm:devexpress-diagram@2.0.11/dist/dx-diagram.js',
'devexpress-gantt': 'npm:devexpress-gantt@2.0.18/dist/dx-gantt.js',
'preact': 'npm:preact@10.5.11/dist/preact.js',
'preact/hooks': 'npm:preact@10.5.11/hooks/dist/hooks.js',
// SystemJS plugins
'plugin-babel': 'npm:systemjs-plugin-babel@0.0.25/plugin-babel.js',
'systemjs-babel-build': 'npm:systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js'
},
packages: {
'devextreme': {
defaultExtension: 'js'
},
'devextreme-react': {
main: 'index.js'
},
'devextreme/events/utils': {
main: 'index'
},
'devextreme/events': {
main: 'index'
},
'es6-object-assign': {
main: './index.js',
defaultExtension: 'js'
}
},
babelOptions: {
sourceMaps: false,
stage0: true,
react: true
}
});