Skip to content

Commit

Permalink
Merge pull request #15 from ahwgs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ahwgs authored Mar 25, 2023
2 parents fc14996 + 6228881 commit 7279a23
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 33 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,32 @@
<p align="center">React Gantt Component</p>
</div>

## 官网
English | [简体中文](./README.zh-CN.md)

[https://ahwgs.github.io/react-gantt/#/](https://ahwgs.github.io/react-gantt/#/)
## WebSite

## 快速使用
[https://ahwgs.github.io/react-gantt/#/en-US](https://ahwgs.github.io/react-gantt/#/en-US)

## Quick Start

```bash
# 安装依赖
# Install Dependencies
$ yarn add rc-gantt

# 使用组件
# Use

import RcGantt, { GanttProps } from 'rc-gantt'

const data = new Array(100).fill({
name: '一个名称一个名称一个名称一个名称',
name: 'Title',
startDate: '2021-07-10',
endDate: '2021-07-12',
collapsed: false,
children: [
{
startDate: '2021-07-10',
endDate: '2021-07-12',
name: '一个名称',
name: 'TitleTitle',
collapsed: false,
content: '123123123',
},
Expand All @@ -41,10 +43,11 @@ const App = () => {
<div style={{ width: '100%', height: 500 }}>
<RcGantt
data={data}
lang='en-US'
columns={[
{
name: 'name',
label: '名称',
label: 'Title',
width: 200,
maxWidth: 200,
minWidth: 200,
Expand Down
70 changes: 70 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<div align="center">
<a href="#" target="_blank">
<img src="https://static.ahwgs.cn/gantt_logo.png" alt="Logo" width="160" height="80">
</a>
<h2>rc-gantt</h2>
<p align="center">React Gantt Component</p>
</div>

[English](./README.md) | 简体中文

## 官网

[https://ahwgs.github.io/react-gantt/#/](https://ahwgs.github.io/react-gantt/#/)

## 快速使用

```bash
# 安装依赖
$ yarn add rc-gantt

# 使用组件

import RcGantt, { GanttProps } from 'rc-gantt'

const data = new Array(100).fill({
name: '一个名称一个名称一个名称一个名称',
startDate: '2021-07-10',
endDate: '2021-07-12',
collapsed: false,
children: [
{
startDate: '2021-07-10',
endDate: '2021-07-12',
name: '一个名称',
collapsed: false,
content: '123123123',
},
],
})

const App = () => {
return (
<div style={{ width: '100%', height: 500 }}>
<RcGantt
data={data}
columns={[
{
name: 'name',
label: '名称',
width: 200,
maxWidth: 200,
minWidth: 200,
},
]}
onUpdate={async () => {
return true
}}
/>
</div>
)
}

ReactDOM.render(<App />, document.getElementById('root'))
```
## 问题反馈
请访问 [Github](https://github.com/ahwgs/react-gantt/issues) 或加微信,备注 `rc-gantt`
<img src='https://static.ahwgs.cn/wp-content/uploads/2020/03/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20200311210541.jpg' width="140">
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-gantt",
"version": "0.1.10",
"version": "0.2.0",
"homepage": "https://ahwgs.github.io/react-gantt/#/",
"repository": {
"type": "git",
Expand Down
48 changes: 24 additions & 24 deletions website/component.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,45 @@ click to create task`bar`

<code src="./demo/add.en-US.tsx"></code>

### 多级结构
### Multi-level structure

确保每个节点中包含 `children` 属性,即可实现多级结构
Ensure that each node contains the `children` attribute to achieve a multi-level structure

可以通过 `onExpand` 获取当前展开的状态
You can get the current expanded status with `onExpand`

<code src="./demo/child.tsx"></code>

### 自定义表格列
### Customizing table columns

`columns` 类型定义见类型定义
`columns` type definition see Type Definition

其中,如果每列都配置 `width` 属性。组件内部会计算总宽度。默认初始化表格宽度为总宽度
where if each column is configured with the `width` property. The total width is calculated internally by the component. The default initialized table width is the total width

<code src="./demo/column.tsx"></code>

### 依赖结构
### Dependency Structure

<code src="./demo/dependence.tsx"></code>

### 自定义渲染
### Custom Rendering

<code src="./demo/render.tsx"></code>

### 自定义筛选
### Customized filtering

默认当前日期筛选支持 日、周、月、季、年。支持传入配置,自定义筛选维度
Default current date filtering support Day, Week, Month, Quarter, Year. Support incoming configuration to customize the filtering dimension

<code src="./demo/filterUnit.tsx"></code>

### 高级用法
### Advanced Usage

主要介绍 `alwaysShowTaskBar` `unit` 以及 `innerRef` 上内置方法的使用
Introducing the use of the built-in methods on `alwaysShowTaskBar`, `unit` and `innerRef`.

<code src="./demo/custom.tsx"></code>

## 类型定义
## Type Definition

### `Column` 定义
### `Column` Definition

```typescript
export type ColumnAlign = 'center' | 'right' | 'left'
Expand All @@ -77,9 +77,9 @@ export interface Column<RecordType = DefaultRecordType> {
}
```

### `data` 定义
### `data` Definition

其中内置了如下几个字段,如果数据中包含如下属性会做特殊处理
The following fields are built in, and special treatment will be done if the data contains the following attributes

```typescript
export type Record<RecordType = DefaultRecordType> = RecordType & {
Expand All @@ -92,7 +92,7 @@ export type Record<RecordType = DefaultRecordType> = RecordType & {
}
```
### `Dependence` 定义
### `Dependence` Definition
```typescript
export type DependenceType = 'start_finish' | 'finish_start' | 'start_start' | 'finish_finish'
Expand All @@ -103,9 +103,9 @@ export interface Dependence {
}
```

### `Bar` 定义
### `Bar` Definition

在我们需要使用一些自定义函数时,会给我们返回如下类型数据,其中 `record` 为源数据
When we need to use some custom functions, we will be returned the following type of data, where `record` is the source data

```typescript
export interface Bar<RecordType = DefaultRecordType> {
Expand All @@ -130,7 +130,7 @@ export interface Bar<RecordType = DefaultRecordType> {
}
```

### `Sight` 定义
### `Sight` Definition

```typescript
export type Sight = 'day' | 'week' | 'month' | 'quarter' | 'halfYear'
Expand Down Expand Up @@ -166,11 +166,11 @@ export type Sight = 'day' | 'week' | 'month' | 'quarter' | 'halfYear'
| renderRightText | 自定义渲染右侧内容区 | `(barInfo: Gantt.Bar<RecordType>) => React.ReactNode` |
| onExpand | 点击展开图标时触发 | `(record: Gantt.Record<RecordType>,collapsed:boolean) => void` |
## 方法
## Methods
对外抛出 `innerRef`
has `innerRef`
| 参数 | 说明 | 类型 | 默认值 |
| -------------- | -------- | ---------- | ------ |
| backToday | 返回今日 | `Function` |
| getWidthByDate | 返回事件 | `Function` |
| backToday | backToday | `Function` |
| getWidthByDate | getWidthByDate | `Function` |
1 change: 1 addition & 0 deletions website/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import RcGantt from 'rc-gantt'
return (
<RcGantt
data={data}
lang='en-US'
columns={[
{
name: 'name',
Expand Down

0 comments on commit 7279a23

Please sign in to comment.