1.0.13 • Published 2 years ago

gantter-g v1.0.13

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Gantter-g with react

基于g引擎的甘特图组件

Install

npm install gantter-g
yarn add gantter-g

Usage

export default () => {
  return (
    <Gantter
      columns={[
        { key: 'name', name: '姓名', width: 200 },
        { key: 'gender', name: '性别', width: 100 },
        { key: 'age', name: '年龄', width: 200 }
      ]}
      dataSource={[
        {
          name: '张三',
          gender: '男',
          age: 20,
          distribution: [
            { name: '任务一', start: '2020-01-01', end: '2020-03-01', content: '任务介绍' },
            { name: '任务二', start: '2020-03-01', end: '2020-06-01', color: '#0000ff' },
            { name: '任务三', start: '2020-06-01', end: '2020-09-01' },
          ]
        },
        {
          name: '李四',
          gender: '男',
          age: 30,
          distribution: [
            { name: '任务一', start: '2020-01-01', end: '2020-03-01' },
            { name: '任务二', start: '2020-03-01', end: '2020-06-01' },
            { name: '任务三', start: '2020-06-01', end: '2020-09-01' },
          ]
        },
        {
          name: '赵五',
          gender: '男',
          age: 25,
          distribution: [
            { name: '任务一', start: '2020-01-01', end: '2020-03-01' },
            { name: '任务二', start: '2020-03-01', end: '2020-06-01' },
            { name: '任务三', start: '2020-06-01', end: '2020-09-01' },
          ]
        }
      ]}
      gantterReplaceKeys={{
        list: 'distribution',
        title: 'name'
      }}
      tooltip={{
        formatter: value => ([
          {
            text: value.name,
            style: {
              fontSize: 14,
              fontWeight: 'bold'
            }
          },
          {
            text: `${value.start} - ${value.end}`,
            style: {
              fontSize: 14
            }
          },
          {
            text: `周期:${(new Date(value.end).getTime() - new Date(value.start).getTime()) / (1000 * 3600 * 24)}天`,
            style: {
              fontSize: 14
            }
          }
        ])
      }}
      gantterBarText={{
        show: true,
        formatter: value =>({
          text: value.name
        })
      }}
      theme={{
        gantterStopColor: '#ececec',
        gantterProgressColor: '#64e25e',
        gantterUnbeginColor: '#4eacfd'
      }}
    />
  )
}

API

参数说明类型默认值
columns表头object[]-
dataSource数据数组object[]-
showOrder是否显示序号Booleantrue
gantterReplaceKeys进度替换字段object如下
tooltip提示框object如下
gantterBarText进度条上文字object如下
theme主题设置object如下

columns

参数说明类型默认值
key唯一标识string必填
name名称string必填
width列宽number100
tooltip是否显示提示booleanfalse

gantterReplaceKeys

参数说明类型默认值
list数组键名stringlist
start开始日期stringstart
end结束日期stringend
title标题stringtitle
content说明stringcontent
color进度条颜色stringcolor

tooltip

参数说明类型默认值
show是否显示booleantrue
formatter提示框显示内容(value: gantterReplaceKey) => object[]-

formatter返回格式

[
  {
    text: item[replaceKeys.title],
    style: {
      fontSize: 14,
      fontWeight: 'bold',
    }
  },
  {
    text: `${item[replaceKeys.start]} - ${item[replaceKeys.end]}`,
    style: {
      fontSize: 14
    }
  }
]

gantterBarText

参数说明类型默认值
show是否显示booleantrue
formatter进度条显示文字内容(value: gantterReplaceKey) => string-

theme

参数说明默认值
backgroundColor通用背景色
borderColor通用边框色
fontColor通用文字颜色
dragDividerColor拖动条颜色
dragDividerBorderColor拖动条边框颜色
scrollBarSlideColor滚动条滑道颜色
scrollBarThumbColor滚动条滑块颜色
scrollBarThumbHoverColor鼠标移入滑块颜色
scrollBarThumbDownColor鼠标按下滑块颜色
tableHeaderDividerColor表头分割线
tableHeaderBottomBorderColor表头下边线
tableHeaderBackgroundColor表头背景色
tableHeaderFontColor表头文字颜色
tableRowDividerColor表格横向分割线
tableColDividerColor表格纵向分割线
tableOddBackgroundColor表格奇数行背景
tableEvenBackgroundColor表格偶数行背景
tableCellFontColor表格文字背景
gantterStopColor已结束进度条颜色
gantterProgressColor进行中进度条颜色
gantterUnbeginColor未开始进度条颜色
gantterDividerColor甘特图分割线颜色
gantterBarShadowColor鼠标移入进度条阴影颜色
gantterbarLineColor进度条描边颜色
popoverBackground气泡卡片背景色
popoverShadowColor气泡卡片阴影颜色

组件调试

yarn dev
yarn dev story

运行测试用例

yarn test

按照社区规范和最佳实践,生成构建产物

yarn build

继续创建更多项目要素

yarn new

其他

yarn lint         # 检查和修复所有代码
yarn change       # 添加 changeset,用于发版时生成 changelog
yarn bump         # 生成发版相关的修改,比如更新版本号、生成 changelog
yarn release      # 根据 bump 自动修改和人工修改的发版要求,发布项目
1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago