Open cee-ramraj opened 11 months ago
Initiation of the timeline function The timeline function should be initiated as follows: -
Closing of timeline function
Feature ready.
Additional requirements to be completed by PM 03 Jan 24
Creating a period selector in a timeline tape form with zooming involves combining the timeline component, period selector, and zoom functionality. In this example, we'll use the react-d3-timeline
library for the timeline, the react-slider
library for the period selector, and the react-zoom-pan-pinch
library for zooming.
First, install the necessary packages:
npm install react-d3-timeline react-slider react-zoom-pan-pinch
Now, you can create your combined component:
// TimelineWithPeriodSelector.js
import React, { useState } from 'react';
import { Timeline } from 'react-d3-timeline';
import Slider from 'react-slider';
import { ReactZoomPanPinch } from 'react-zoom-pan-pinch';
import './TimelineWithPeriodSelector.css'; // Import or create a stylesheet for styling
const eventsData = [
{ "label": "Event 1", "start": new Date("2024-01-01"), "end": new Date("2024-01-03") },
{ "label": "Event 2", "start": new Date("2024-01-05"), "end": new Date("2024-01-08") },
// Add more events as needed
];
const TimelineWithPeriodSelector = () => {
const timelineStart = new Date("2024-01-01");
const timelineEnd = new Date("2024-01-10");
const [selectedPeriod, setSelectedPeriod] = useState([timelineStart, timelineEnd]);
const [zoom, setZoom] = useState(1);
const handlePeriodChange = (value) => {
setSelectedPeriod(value);
};
const handleZoomChange = (newZoom) => {
setZoom(newZoom);
};
return (
<div>
<ReactZoomPanPinch
initialZoom={zoom}
initialPan={{ x: 0, y: 0 }}
minZoom={0.1}
maxZoom={3}
onZoomChange={handleZoomChange}
>
<Timeline
data={eventsData}
width={800} // Adjust the width as needed
height={100}
margin={{ left: 50, right: 10, top: 0, bottom: 0 }}
/>
</ReactZoomPanPinch>
<div className="period-selector">
<Slider
value={selectedPeriod}
min={timelineStart}
max={timelineEnd}
onChange={handlePeriodChange}
withBars
/>
<div className="selected-period-label">
Selected Period: {selectedPeriod[0].toLocaleDateString()} - {selectedPeriod[1].toLocaleDateString()}
</div>
</div>
</div>
);
};
export default TimelineWithPeriodSelector;
Don't forget to create or import the stylesheet for styling (TimelineWithPeriodSelector.css
):
/* TimelineWithPeriodSelector.css */
.period-selector {
margin: 20px;
}
.selected-period-label {
margin-top: 10px;
text-align: center;
}
Now, you can use this combined component in your main application file:
// App.js
import React from 'react';
import TimelineWithPeriodSelector from './TimelineWithPeriodSelector';
const App = () => {
return (
<div>
<h1>Timeline with Period Selector and Zoom</h1>
<TimelineWithPeriodSelector />
</div>
);
};
export default App;
Adjust the code according to your specific requirements, and feel free to further customize the styling and functionality based on your needs.
The features in Live playback/ timeline feature should be replicated in history timeline feature.
Have a single component for both live and history to be called by either live or history. This should have the following: -
In the History Map page, a feature for playback should be provided. It will be activated from the 'Load History' tab. Upon activating the playback, the following should happen: