Giter Site home page Giter Site logo

guiqui / react-timeline-gantt Goto Github PK

View Code? Open in Web Editor NEW
530.0 17.0 128.0 5.04 MB

A react Timeline component with virtual rendering

License: MIT License

JavaScript 93.94% CSS 5.85% Shell 0.21%
timeline react reactjs react-redux gantt scheduler calendar calendar-component timelines timeline-component

react-timeline-gantt's Introduction

react-gantt-timeline

npm MIT License Travis codecov Backers on Open Collective Sponsors on Open Collective downloads

A react timeline gantt component.

screencast

About

React-timeline-gantt is a component built to display and manage calendar gantt charts. It use virtual rendering to be reactive an efficient.

Buy Me A Coffee

The component is capable of:

  • Can handle 100 thousands records.
  • Infinite calendar scrolling
  • Three Zoom levels : day, week, month
  • Fully customisable.
  • Support all CRUD operations.
  • Task and Link creation.
  • Support Paging.
  • Can be easily integrated with Redux

To watch a demo take a look at video that shows how to use the component.

To play with a live demo .

K8Studio.io is our Golden Sponsor

alt text

Release Notes version 0.3.9

  • Better and optimize header
  • Add "year" mode option.

Release Notes version 0.4.0

  • Touch Event Support for scrolling and task movement

Coming up in version 0.4.1

  • Subtask implementation
  • Add start and end date columns to the task list
  • Beter UX to create links
  • Scroll up/donw in viewPort

Installation

npm install react-gantt-timeline

The component has the following dependencies: moment, react-sizeme

Getting started

The first thing to once the component has been install and all it dependencies is create the data that the timeline component consume.The time line has two data providers data and links.

Data :is an array of objects that contains the task to be shown. Each one of the object that are part of the array need to have the following compulsory fields

Property value Descriptions
id String/Number An unique identifier for the class
start Date The start date of the task
end Date The end date of the task
name String The name of the task to be diplayed
color (optional) String The color of the task to be diplayed

An example of data definition:

 let data=[ {id:1,start:new Date(), end:new Date()+1 ,name:'Demo Task 1'},
			{id:2,start:new Date(), end:new Date()+1 ,name:'Demo Task 2'}]

Links :is also an array of objects that contains links between task. Each one of the object that are part of the array need to have the following compulsory fields:

Property value Descriptions
id String/Number An unique identifier for the class
start String/Number The id of the start task
end String/Number The id of the end task

An example of data definition:

 let links=[ {id:1,start:1, end:2},
			{id:2,start:1, end:3}]

Once the data is define we just need to declare the component and populate it with both data providers.

<TimeLine data={data} links={links} />

Here is the demo code:

Edit 1y2on87jj

Handling Inserts,Updates and Deletes

The React-timeline-gantt was build to be use under a Flux architecture, this means that the component should not be managing the state of the application, is up the store and only the store to modify the state of the application. What our component does is to give you callbacks to know when the component is asking for a change.

The TimeLine component is responsible for two things:

  • Updating task:Changing name ,start and end date
  • Creating Links

Adding,Deleting Task or links can be manage with logic outside the component. For this reason the react-timeline-gantt component provides the following callbacks:

name params Descriptions
onCreateLink link:Object This callback is trigger when the component is notifying the creating of a link between two tasks
onUpdateTask task:Object,props:Object This callback is trigger when the component is notifying the updating of a Task, Sen the task we want to changes, and the properties we want to change
onSelectItem item:Object This callback is trigger when an item is selected this can be a task or a link

Here is a simple demo of how to handle updates task and link creation:

Edit 3rl69y5ylq

  • When you drag a task or resize an update will be triggered.
  • You can create a task by clicking in the black dot at the end of a task and drag and drop it to the beginning of another task.A demo of how it works can be seen here

Here is a full crud example: This demo illustrate how to do a simple application

Edit 3x8nl16p65

Here is a fully working Redux demo

Edit 613vkoq8nr

Paging

Paging is manage using the event onHorizonChange.The timeline component preload a certain date range of data, once the user start scrolling when the timeline realise that needs data for a new range, it trigger the onHorizonChange event. This method then can be use to support serverside paging or client filtering.

name params Descriptions
onHorizonChange start,end:Date This callback is trigger when the component is notifying that needs to load data for a new range of dates.

Here is a demo app that shows how to use onHorizonChange, to only display the relvant data for a period:

Edit n09l7m400j

Customisation

To customise the look and feel the react-timeline-gantt component provides a configuration object that can be pass as a property. Here is the structure of the config object :

{
	header:{ //Targert the time header containing the information month/day of the week, day and time.
		top:{//Tartget the month elements
			style:{backgroundColor:"#333333"} //The style applied to the month elements
		},
		middle:{//Tartget elements displaying the day of week info
			style:{backgroundColor:"chocolate"}, //The style applied to the day of week elements
			selectedStyle:{backgroundColor:"#b13525"}//The style applied to the day of week elements when is selected
		},
		bottom:{//Tartget elements displaying the day number or time 
			style:{background:"grey",fontSize:9},//the style tp be applied 
			selectedStyle:{backgroundColor:"#b13525",fontWeight:  'bold'}//the style tp be applied  when selected
		}
	},
	taskList:{//the right side task list
		title:{//The title od the task list
			label:"Projects",//The caption to display as title
			style:{backgroundColor:  '#333333',borderBottom:  'solid 1px silver',
				   color:  'white',textAlign:  'center'}//The style to be applied to the title
		},
		task:{// The items inside the list diplaying the task
			style:{backgroundColor:  '#fbf9f9'}// the style to be applied
		},
		verticalSeparator:{//the vertical seperator use to resize he width of the task list
			style:{backgroundColor:  '#333333',},//the style
			grip:{//the four square grip inside the vertical separator
				style:{backgroundColor:  '#cfcfcd'}//the style to be applied
			}
		}
	},
	dataViewPort:{//The are where we display the task
		rows:{//the row constainting a task
			style:{backgroundColor:"#fbf9f9",borderBottom:'solid 0.5px #cfcfcd'}
			},
		task:{the task itself
			showLabel:false,//If the task display the a lable
			style:{position:  'absolute',borderRadius:14,color:  'white',
				   textAlign:'center',backgroundColor:'grey'},
			 selectedStyle:{}//the style tp be applied  when selected
		}
	},
	links:{//The link between two task
		color:'black',
		selectedColor:'#ff00fa'
	}
}

Once the object is defined we just need to pass the config object to the timeline config property.

<TimeLine data={data} links={links} />

This diagram shows the different elements of timeline component and where are they place:

configMap

Here is a demo:

Edit 2w93lvmqv0

Other properties

Property value Descriptions
mode string set the zoom level.The possible values are:"month","week","day","year"

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! ๐Ÿ™ [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

Free Apps we have created:

react-timeline-gantt's People

Contributors

cscatolini avatar danielsogl avatar dependabot[bot] avatar dominikengel avatar domino987 avatar ericreis avatar guiqui avatar maksimkurb avatar monkeywithacupcake avatar superpepote avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-timeline-gantt's Issues

change the default time horizon

Hi,
Not sure if this is an issue; but is there a way I can change the current default time horizon (it starts from today's date and I wanted it to start from today's date minus X days ...

How to use the "mode" setting in config ?

Hi,
First of all, thank you for the 0.3.9 update ๐Ÿ‘
I have several questions :
1- How can I use the mode property in config obj ?
2- Is it still possible to use the dateFormat ?
3- Is it possible to delete a part of the header, like the middle or the bottom part ?

Again thank you so much :)

Main Task Drag

when i drag main task then all the dependent(linked) tasks should move, how can i do this using this plugin.

Individual Labeling of Tasks

Hey there! First of all - thank you for providing this great package!
For my use case, it would be great if the labeling of the task displayed in the timeline could be given another value other than the already given task-name.
Is there a possible workaround or is this only applyable by creating this as a new feature? If so, I'd be very happy to contribute this additional feature.

LOCAL DATETIME

Hi,
as I wrote to you by email I want to fix your code to see datetime in local format. For example in my case italian format.
I want to add in Config class this portion of code:
,
moment : {
locale : 'it'
}
So I can set moment.locale in the language that i wants in the page where I use your package.
After I want to set moment.locale(Config.moment.locale); into headers.js to apply the correct datetime format.
I try to rebuild your package but no fix seems applyed

Thanks Alex

Cannot assign to read only property 'backgroundColor' of object '#<Object>'

I am trying to style the chart by taking help from the following demo:

https://codesandbox.io/s/2w93lvmqv0?file=/src/index.js:182-1455

But getting error. I am using config property. I am on version 0.4.3 but the demo above provided is on version 0.3.9. I am not sure whether the version update caused something. The error is as follows:

Uncaught TypeError: Cannot assign to read only property 'backgroundColor' of object '#<Object>'

Any kind of help would be much appreciated

Can't resolve 'moment'

FYI After fresh install:

Module not found: Can't resolve 'moment' in 'C:\SQLI\Projects\airline-sciences-indus_new\airline-sciences-react2\node_modules\react-gantt-timeline\dist'

ReferenceError: window is not defined

I am using the nextjs , the chart cannot show .

error msg:

Server Error
ReferenceError: window is not defined

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
external%20%22react-gantt-timeline%22 (1:0) @ Object.react-gantt-timeline

1 | module.exports = require("react-gantt-timeline");
Call Stack
webpack_require
webpack\bootstrap (21:0)
Show collapsed frames
ๆ“ทๅ–

Adjustable Tasklist height.

Is there currently a way to adjust the height of the tasks? Would like a little more height for each, right now they feel a little cramped.

how's the state gettig updated below :

Here you are changing the item but after de-structuring data array you are not updating the manipulated item. Can you please explain because according to my knowledge de-structuring prevents mutability and gives an exact copy

case Actions.AC_UPDATE_TASK:
debugger
item = action.payload.item;
props = action.payload.props;
console.log('update item', item);
console.log('update prop', props);
item.start = props.start ? props.start : item.start;
item.end = props.end ? props.end : item.end;
item.name = props.name ? props.name : item.name;
return {
data: [...state.data],
links: [...state.links],
selectedItem: state.selectedItem
};

Cannot make task name in the task list non editable

Hi,

I was trying to use this component but in my use case, I cannot allow the user to edit the task name by clicking it. I looked at the code and saw that this is not currently possible.

@guiqui is this repository still maintained? I would gladly open a PR to make this configuration possible, but I haven't seen much activity lately here.

Edit Header with only years and months

Hello, I would like to know if it's possible using the config object maybe or something else, to show in the header the years and 12 months under them instead of the months and 30 days under them ?

thanks !

Is there support for a horizontal slider/cursor?

Hi, I'd like to be able to move a slider/cursor back and forth horizontally, which would be indicated with a vertical line. As I move it, I'd get events indicating which records the cursor intersects. Is this supported by this timeline?
Thanks.

Customisation of components

Hello,
I would like to have a way to fully customize some of the components. For example inserting a row with 3 inputs inside the taskList section.
something like this:

const config = {
  taskList: {
    title: {
      label: "Task Todo",
      style: {
        background: "linear-gradient( grey, black)"
      }
    },
    task: (props) => <CustomTaskComponent {...props} />,
  },
};

If this is not supported, I don't mind implementing this myself and open a pull request for it.
Wondering if this project is still active.

Thanks

Two time zones in day view

Can I show tow time header for day view ?
One is for one time zone in hour format and other one is for other time zone in hour format ?

Header days/times disappear on horizontal scroll

Hey thanks for the timeline. I looks like a great start to a project. One issue I found was when dragging the timeline to the right, the header days/hours disappear in the Day and Week mode. This makes these modes hard to use.

Custom Task Card

Is it possible to using render Props So I Can for example render custom task Card

Function to move horizontally to a specified date

Hello,

Thank you for this! It's easy to setup and really helpful.

Is there a way to tell the Timeline to scroll horizontally to the start date of the earliest/first task when the component is created? Currently it focuses on the current date. Unless I'm doing something wrong?

It would be nice to have an option to bring any task into view on the right when clicking on it's name on the left hand side.

Show more info columns on "Task column"

Is there a way to show more information on the left column?, Basically, add more columns apart from task name. I mean for example my data source include a task owner, status, completed percent, etc.

If currently not supported, would you consider a PR with this feature?

Thanks,
Jonathan

Can't add an image instead of a color on a task

I want to replace the background color of the task with an image of any format or an svg or any other graphical substitute .
I also don't know if it is possible to pass such props through the config variable

Conditional styling for the days in timeline

Hello, is there a way to style a single day of the timeline individually?
In my use case, I am required to mark holidays / non-working days in the timeline by coloring the background differently. Is there a way to do this?
So far as I understand, I can only change the background color for all days but not for a single day.
Also, as it is shown in the demo (https://codesandbox.io/s/brave-rgb-c72g7) the today-date is colored red. This is not the case for the "basic" demo (https://codesandbox.io/s/1y2on87jj) but I cannot figure out how you did that. Can you help?
Thanks!

supporting jalali-date

I'm trying to use gantt chart with Jalali calendar with moment-jalali.
I've changed getFormat and so far it's ok, except Jalali year month starts in March so I had to change getStartDate function.

getStartDate = (date, mode) => {
    let year = null;
    switch (mode) {
        case 'year':
            return date.startOf('jYear');
        case 'month':
            return date.startOf('jMonth');
        case 'week':
            return date.subtract(date.day(), 'days');
        default:
            return date
    }
}

but now I'm getting bugs in the calender...
on scrolling chart month and year not showing and disappears...
is there any other function I should change?

WEEK and DAY View

Hi,
Noticed a couple of things on the URL below.
https://guiqui.github.io/react-timeline-gantt/index.html

  1. Initially the week and day view doesn't appear, however as soon scrolling happens(right or left) the dates appear.
  2. The day view appears to be confusing. Somehow the dates are NOT displaying in day view.

Is this an issue or do I have a old version of libraries?

Thanks,

multiple bars on the same task row

Hi!
Is it possible for one task to have multiple time bars on the same row? for example one going from the 1st may to the 3rd of may. and then another one going from 5th of may to the 10th ?.
Moreover is it possible to disable the link creation and animation (such that when clicking on the right side of a bar we don't have the link arrow spawning and moving?)
Thanks for you time and answer.

Rest Api Call

Hey,

Thanks for the react-timeline-gantt. Was wondering if there is any sample with a rest api call to fetch data?

OnHorizonChange

Hi,

I am trying to figure out what would be the value for start and end in Month view on the timeline?

When the component renders twice, I see 2 different date values for start and end like below.

Calculating in Horizon
Start Sun May 05 2019 08:00:00 GMT-0700 (Pacific Daylight Time)
End Sat Jul 27 2019 16:00:00 GMT-0700 (Pacific Daylight Time)

Start Sun May 05 2019 08:00:00 GMT-0700 (Pacific Daylight Time)
End Fri Sep 13 2019 16:19:41 GMT-0700 (Pacific Daylight Time)

TimeLine render code triples the view if extended into a child class

I wish to extend the TimeLine component's render function. If I extend the class and have render as follows:
render() { return TimeLine.prototype.render.call(this);
Then the calendar displays normally.

However, if I copy the contents of the render function from TimeLine.js into my child class's render() function, the calendar repeats itself across the screen multiple times:
image

How can I avoid this happening? I have already imported all the correct modules.

Updating a component in webpack-dev-server causes Uncaught TypeError

When using react-timeline-gantt in webpack-dev-server, a hot reload triggers the following during rendering:

index.js:1 Uncaught TypeError: Cannot assign to read only property 'backgroundColor' of object '#'
at e.value (index.js:1)
at e.value (index.js:1)
at e.value (index.js:1)
at e.value (index.js:1)
at e.load (index.js:1)
at new t (index.js:1)
at constructClassInstance (react-dom.development.js:11361)
at updateClassComponent (react-dom.development.js:14687)
at beginWork (react-dom.development.js:15644)
at performUnitOfWork (react-dom.development.js:19312)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.