├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── docs
└── README_zh.md
├── index.html
├── index.js
├── package-lock.json
├── package.json
├── src
├── App.vue
├── assets
│ ├── data.js
│ └── logo.png
├── components
│ ├── Gantt.vue
│ └── excel.js
├── main.js
└── util
│ └── index.js
└── vite.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode
17 | .vscode/*
18 | !.vscode/extensions.json
19 | .idea
20 | .DS_Store
21 | *.suo
22 | *.ntvs*
23 | *.njsproj
24 | *.sln
25 | *.sw?
26 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | dd@ddamy.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Vue3 Gantt Chart Component
2 |
3 | 
4 |
5 | [简体中文](https://github.com/ddmy/vue3-gantt/blob/master/docs/README_zh.md)
6 |
7 | ### Introduction
8 | A simplified Gantt chart component developed based on vue3.x:
9 | - [x] Supports exporting the Gantt chart to an Excel file.
10 | - [x] Supports exporting the Gantt chart as an image.
11 | - [x] Supports displaying overlapping schedules.
12 | - [x] Supports dynamic configuration for responsive updates.
13 | - [x] Responsive layout, compatible with small screens.
14 |
15 | > If you encounter any issues during use, feel free to raise issues 😊.
16 |
17 | [Demo Online Preview](https://blog.ddamy.com/assets/demo/gantt/)
18 |
19 | ### Usage
20 | ```html
21 |
27 | ```
28 | ```js
29 | import { ref } from 'vue'
30 | import Gantt from 'vue3-gantt'
31 | import 'vue3-gantt/dist/style.css'
32 | const dateRangeList = ref(['2022-01-01', '2022-03-05'])
33 | const data = ref([
34 | {
35 | type: 'normal',
36 | color: '',
37 | name: 'Project 1',
38 | schedule: [
39 | {
40 | id: 333330,
41 | name: '900 Warriors Simultaneous Online Celebration Event',
42 | desc: 'This event is very important, generating millions of revenue. It is a cross-departmental collaboration and a major project with the CEO personally present to command. Everyone must work together!',
43 | backgroundColor: 'rgb(253, 211, 172)',
44 | textColor: 'rgb(245, 36, 9)',
45 | days: ["2022-01-15","2022-02-05"]
46 | },
47 | {
48 | id: 555550,
49 | name: 'XXXXXX',
50 | desc: 'This event is very important, generating millions of revenue. It is a cross-departmental collaboration and a major project with the CEO personally present to command. Everyone must work together!',
51 | backgroundColor: '#28f',
52 | textColor: '#fff',
53 | days: ["2022-02-15","2022-02-25"]
54 | },
55 | ],
56 | },
57 | {
58 | type: 'normal',
59 | color: '',
60 | name: 'Meteor Butterfly Sword',
61 | schedule: [
62 | {
63 | id: 222221,
64 | name: 'Chinese New Year Event',
65 | desc: 'This event is very important, generating millions of revenue. It is a cross-departmental collaboration and a major project with the CEO personally present to command. Everyone must work together!',
66 | backgroundColor: '#482',
67 | textColor: '#fff',
68 | days: ["2022-02-25","2022-03-10"]
69 | }
70 | ],
71 | },
72 | ])
73 | ```
74 |
75 | ### Component Props
76 |
77 | | Key | Type | Default | Description |
78 | | ------ | ------ | -------- | ------------ |
79 | | data | Array[Object] | [] | antt chart data |
80 | | dateRangeList | Array | [] | The date range within the current chart. This array should have a length of 2, with elements as the start and end date in the format 'YYYY-MM-DD'. |
81 | | itemText | String | null | The header description for the items in the Gantt chart. |
82 | | dateText | String | null | The header description for the dates in the Gantt chart. |
83 | | activeDate | String | Today | The day to be highlighted on the timeline (does not override schedule styles). Format: 'YYYY-MM-DD'. |
84 | | repeatMode | Object | See below | Configuration for handling overlapping schedules. |
85 | | itemWidth | Number | 40 | - | The width of date cells, minimum 40. |
86 | | itemHeight | Number | 40 | - | The height of date cells, minimum 40. |
87 | | scheduleTitle | Function | null | - | A function to display custom text above the schedule. It receives the schedule information as a parameter and should return the text to be rendered. |
88 | | borderColor | String | '#eee' | - | The color of the table borders. |
89 |
90 | > The content width of the component needs to be controlled manually to ensure the minimum width.
91 |
92 | ### Component Events
93 |
94 | | Event | Type | Description |
95 | | ------ | ------ | ------------ |
96 | | scheduleClick | Function | Callback event when clicking on a schedule. Receives the schedule details as a parameter. |
97 | | scrollXEnd | Function | Event triggered when the horizontal scrollbar reaches the end. |
98 | | scrollYEnd | Function | Event triggered when the vertical scrollbar reaches the end. |
99 |
100 | ### Data Configuration: data Array[Object]
101 |
102 | | Key | Value | Description |
103 | | ------ | ------ | ------ |
104 | | type | 'alike'\|\|'normal' | The project type (display style). |
105 | | color | CSS color format | Background color for the current project. Applicable when the type is 'alike'. |
106 | | name | String | The name of the current project. |
107 | | schedule | Array[Object] | The project schedules. |
108 |
109 | ### Schedule Configuration: schedule Object
110 |
111 | > For easier development, you can extend additional fields based on the following.
112 |
113 | | Key | Description |
114 | | ------ | -------------------- |
115 | | id | A globally unique ID for the schedule. |
116 | | name | The name of the schedule. |
117 | | desc | Description of the schedule. |
118 | | backgroundColor | Background color for the schedule. |
119 | | textColor | Text color for the schedule name. |
120 | | days | Array of Schedule Dates | The array contains valid and consecutive dates in the format YYYY-MM-DD. Alternatively, it can be represented as an array of two elements denoting the start and end dates. |
121 |
122 | ### repeatMode Configuration: Object
123 |
124 | | Key | Options | Default | 说Description明 |
125 | | ------ | ------ | -------- | ---------- |
126 | | mode | 'cover'\|\|'extract' | 'cover' | Handling mode for overlapping schedules. 'cover' will simply overlap schedules, while 'extract' will extract and group overlapping schedules separately. |
127 | | backgroundColor | CSS color format | '#FFFFCC' | Background color for the extracted schedules in 'extract' mode. |
128 | | textColor | CSS color format | '#336666' | Text color for the extracted schedules in 'extract' mode. |
129 | | name | `String`\|\|`Function` | 'Overlapping Schedules' | Text to display for overlapping schedules. If it's a function, it receives a list of overlapping schedules as a parameter. |
130 | | desc | `String`\|\|`Function` | 'These are multiple schedules.' | Description to display for overlapping schedules. If it's a function, it receives a list of overlapping schedules as a parameter. |
131 |
132 |
133 | ### Component Instance Methods
134 |
135 | #### Export Full Snapshot Image of the Current Gantt Chart
136 |
137 | ```html
138 |
142 |
143 | ```
144 |
145 | ```js
146 | const gantt = ref(null)
147 |
148 | const exportImg = () => {
149 | gantt.value.exportImg({ download: true, waterValue: 'Made by YiJio' })
150 | }
151 | ```
152 | > The exportImg method accepts an Object to configure the behavior of exporting the image. It returns a Promise, and upon successful completion, it receives the base64 value of the image.
153 | > | Parameter | Optional Values | Default Value | Description |
154 | > | ------ | ------ | -------- | ---------- |
155 | > | download | `Boolean` | `true` | Whether to automatically download the image. |
156 | > | waterValue | `String` | `''` | Watermark text to be added to the image. If empty, no watermark will be added. Customizing the text style is not supported at the moment. |
157 |
158 |
159 | #### Exporting Current Gantt Chart to Excel
160 |
161 | ```html
162 |
166 |
167 | ```
168 | ```js
169 | const gantt = ref(null)
170 |
171 | const exportGanttExcel = () => {
172 | gantt.value.exportGanttExcel({ fileName: 'TestList' })
173 | }
174 | ```
175 | > The exportGanttExcel method receives an Object named file to configure the export file information.
176 | > | Parameter | Optional Values | Default Value | Description |
177 | > | ------ | ------ | -------- | ---------- |
178 | > | fileName | `String` | '数据' | The name of the exported file. |
179 |
--------------------------------------------------------------------------------
/docs/README_zh.md:
--------------------------------------------------------------------------------
1 | ### Vue3甘特图插件
2 |
3 | 
4 |
5 | ### 简介
6 | 基于`vue3.x`开发的精简版甘特图
7 | - [x] 支持导出甘特图Excel文件
8 | - [x] 支持导出甘特图图片
9 | - [x] 支持日程重叠展示
10 | - [x] 支持动态配置响应更新
11 | - [x] 响应式布局,兼容小屏幕展示
12 |
13 | > 如果您在使用过程中遇到任何相关问题,欢迎您提 issues😊,
14 |
15 | [Demo在线预览](https://blog.ddamy.com/assets/demo/gantt/)
16 |
17 | ### 使用方式
18 | ```html
19 |
25 | ```
26 | ```js
27 | import { ref } from 'vue'
28 | import Gantt from 'vue3-gantt'
29 | import 'vue3-gantt/dist/style.css'
30 | const dateRangeList = ref(['2022-01-01', '2022-03-05'])
31 | const data = ref([
32 | {
33 | type: 'normal',
34 | color: '',
35 | name: '项目1',
36 | schedule: [
37 | {
38 | id: 333330,
39 | name: '900勇士同时在线庆祝活动',
40 | desc: '这个活动很重要,6666666营收数百万,跨部门合作的一个大项目,BOSS亲自下场坐镇指挥,大家一定要团结一心!',
41 | backgroundColor: 'rgb(253, 211, 172)',
42 | textColor: 'rgb(245, 36, 9)',
43 | days: ["2022-01-15","2022-02-05"]
44 | },
45 | {
46 | id: 555550,
47 | name: 'XXXXXX',
48 | desc: '这个活动很重要,6666666营收数百万,跨部门合作的一个大项目,BOSS亲自下场坐镇指挥,大家一定要团结一心!',
49 | backgroundColor: '#28f',
50 | textColor: '#fff',
51 | days: ["2022-02-15","2022-02-25"]
52 | },
53 | ],
54 | },
55 | {
56 | type: 'normal',
57 | color: '',
58 | name: '流星蝴蝶剑',
59 | schedule: [
60 | {
61 | id: 222221,
62 | name: '小年活动',
63 | desc: '这个活动很重要,6666666营收数百万,跨部门合作的一个大项目,BOSS亲自下场坐镇指挥,大家一定要团结一心!',
64 | backgroundColor: '#482',
65 | textColor: '#fff',
66 | days: ["2022-02-25","2022-03-10"]
67 | }
68 | ],
69 | },
70 | ])
71 | ```
72 |
73 | ### 组件接收参数
74 |
75 | | 参数名 | 类型 | 默认值 | 说明 |
76 | | ------ | ------ | -------- | ------------ |
77 | | data | Array[Object] | [] | 甘特图数据 |
78 | | dateRangeList | Array | [] | 当前图表内的日期区间,此数组长度为2,内容为起始时间, 格式为'YYYY-MM-DD' |
79 | | itemText | String | null | 表头描述文字 |
80 | | dateText | String | null | 表头描述文字 |
81 | | activeDate | String | 今天 | 当前时间轴高亮显示的一天,(不会覆盖日程样式),'YYYY-MM-DD'格式时间字符串 |
82 | | repeatMode | Object | 见下方 | 重叠日程展示模式配置 |
83 | | itemWidth | Number | 40 | 日期格子的宽度,最小40 |
84 | | itemHeight | Number | 40 | 日期格子的高度度,最小40 |
85 | | scheduleTitle | Function | null | 日程上面展示的文本,function接收日程信息为参数,最终使用该方法返回值渲染 |
86 | | borderColor | String | '#eee' | 表格边框颜色 |
87 |
88 | > 组件内容宽度需要自行控制把握最小宽度
89 |
90 | ### 组件事件
91 |
92 | | 参数名 | 类型 | 说明 |
93 | | ------ | ------ | ------------ |
94 | | scheduleClick | Function | 点击日程的回调事件,接收一个日程详情参数 |
95 | | scrollXEnd | Function | 横向滚动条滚动到底部的事件 |
96 | | scrollYEnd | Function | 竖向滚动条滚动到底部的事件 |
97 |
98 | ### data配置 Array[Object]
99 |
100 | | 参数名 | 取值 |说明 |
101 | | ------ | ------ | ------ |
102 | | type | 'alike'\|\|'normal' | 项目类型(展示风格) |
103 | | color | css颜色格式 | 当前项目背景色, type为'alike'时生效 |
104 | | name | String | 当前项目名称 |
105 | | schedule | Array[Object] | 项目日程 |
106 |
107 | ### schedule 项目日程配置
108 |
109 | > 为了便于业务开发,可以在以下基础上任意拓展字段
110 |
111 | | 参数名 |说明 |
112 | | ------ | -------------------- |
113 | | id | 日程全局唯一id |
114 | | name | 日程名称 |
115 | | desc | 日程描述 |
116 | | backgroundColor | 日程背景色 |
117 | | textColor | 日程名称展示文字颜色 |
118 | | days | 日程日期列表`Array`, 数组内容为合法的连续的日期,日期格式为 `YYYY-MM-DD`,也可以简写为长度为2的数组,数组内容分别为起始日期 |
119 |
120 | ### repeatMode配置 Object
121 |
122 | | 参数名 | 可选值 | 默认值 | 说明 |
123 | | ------ | ------ | -------- | ---------- |
124 | | mode | 'cover'\|\|'extract' | 'cover' | 重叠日程的处理方式,正常覆盖或者单独提取重复日程再组合, cover会忽略repeatMode其余选项 |
125 | | backgroundColor | css颜色格式 | '#FFFFCC' | extract模式下的背景色 |
126 | | textColor | css颜色格式 | '#336666' | extract模式下的文字颜色 |
127 | | name | `String`\|\|`Function` | '重叠日程' | 重叠日程的展示文字,Function接收一个list参数,参数为重叠日程Array |
128 | | desc | `String`\|\|`Function` | '这是多个日程' | 重叠日程的描述文字,Function接收一个list参数,参数为重叠日程Array |
129 |
130 |
131 | ### 组件实例对外暴露的方法
132 |
133 | #### 导出当前甘特图的完整快照图片
134 |
135 | ```html
136 |
140 |
141 | ```
142 |
143 | ```js
144 | const gantt = ref(null)
145 |
146 | const exportImg = () => {
147 | gantt.value.exportImg({ download: true, waterValue: 'YiJio制作' })
148 | }
149 | ```
150 | > `exportImg` 方法接收一个`Object`, 配置图片的导出行为, `exportImg` 返回一个`Promise`, 成功状态会接收到图片的base64值
151 | > | 参数名 | 可选值 | 默认值 | 说明 |
152 | > | ------ | ------ | -------- | ---------- |
153 | > | download | `Boolean` | `true` | 是否自动下载图片 |
154 | > | waterValue | `String` | `''` | 图片水印文字, 为空就不添加水印,暂不支持自定义文字样式 |
155 |
156 |
157 | #### 导出当前甘特图Excel
158 |
159 | ```html
160 |
164 |
165 | ```
166 | ```js
167 | const gantt = ref(null)
168 |
169 | const exportGanttExcel = () => {
170 | gantt.value.exportGanttExcel({ fileName: '测试列表' })
171 | }
172 | ```
173 | > `exportGanttExcel`接收一个对象`file`,配置导出文件的信息
174 | > | 参数名 | 可选值 | 默认值 | 说明 |
175 | > | ------ | ------ | -------- | ---------- |
176 | > | fileName | `String` | '数据' | 导出文件名称 |
177 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |