-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
158 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,5 +103,6 @@ export namespace Gantt { | |
from: string | ||
to: string | ||
type: DependenceType | ||
color?: string | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,59 @@ | ||
import dayjs from 'dayjs' | ||
import RcGantt from 'rc-gantt' | ||
import React from 'react' | ||
import React, { useState } from 'react' | ||
|
||
interface Data { | ||
id: number | ||
name: string | ||
startDate: string | ||
endDate: string | ||
} | ||
|
||
const data = Array.from({ length: 100 }).fill({ | ||
name: 'TitleTitleTitleTitleTitle', | ||
startDate: dayjs().format('YYYY-MM-DD'), | ||
endDate: dayjs().add(1, 'week').format('YYYY-MM-DD'), | ||
}) as Data[] | ||
function createData(len: number) { | ||
const result: Data[] = [] | ||
for (let i = 0; i < len; i++) { | ||
result.push({ | ||
id: i, | ||
name: 'Title' + i, | ||
startDate: dayjs().subtract(-i, 'day').format('YYYY-MM-DD'), | ||
endDate: dayjs().add(i, 'day').format('YYYY-MM-DD'), | ||
}) | ||
} | ||
return result | ||
} | ||
|
||
const App = () => ( | ||
<div style={{ width: '100%', height: 500 }}> | ||
<RcGantt<Data> | ||
lang='en-US' | ||
data={data} | ||
columns={[ | ||
{ | ||
name: 'name', | ||
label: 'Title', | ||
width: 100, | ||
}, | ||
]} | ||
onUpdate={async (row, startDate, endDate) => { | ||
console.log('update', row, startDate, endDate) | ||
return true | ||
}} | ||
/> | ||
</div> | ||
) | ||
const App = () => { | ||
const [data, setData] = useState(createData(20)) | ||
console.log('data', data) | ||
return ( | ||
<div style={{ width: '100%', height: 500 }}> | ||
<RcGantt<Data> | ||
data={data} | ||
columns={[ | ||
{ | ||
name: 'name', | ||
label: 'Custom Title', | ||
width: 100, | ||
}, | ||
]} | ||
lang='en-US' | ||
onUpdate={async (row, startDate, endDate) => { | ||
console.log('update', row, startDate, endDate) | ||
setData(prev => { | ||
const newList = [...prev] | ||
const index = newList.findIndex(val => val.id === row.id) | ||
newList[index] = { | ||
...row, | ||
startDate: dayjs(startDate).format('YYYY-MM-DD'), | ||
endDate: dayjs(endDate).format('YYYY-MM-DD'), | ||
} | ||
return newList | ||
}) | ||
return true | ||
}} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default App |
Oops, something went wrong.