mirror of
https://github.com/tenrok/vue-ganttastic.git
synced 2026-06-25 02:20:34 +03:00
rename "timeaxisMode" to "precision"
This commit is contained in:
@@ -1,23 +1,29 @@
|
|||||||
# vue-ganttastic
|
# vue-ganttastic
|
||||||
|
|
||||||
<img src="https://user-images.githubusercontent.com/28678851/77186503-45358300-6ad3-11ea-9392-7f670eb1ca8c.png" width="600"/>
|
<img src="https://user-images.githubusercontent.com/28678851/77186503-45358300-6ad3-11ea-9392-7f670eb1ca8c.png" width="600"/>
|
||||||
|
|
||||||
A simple and easy-to-use Gantt chart component for Vue.js
|
A simple and easy-to-use Gantt chart component for Vue.js
|
||||||
|
|
||||||
## Homepage
|
## Homepage
|
||||||
|
|
||||||
[Homepage of the project](https://infectoone.github.io/vue-ganttastic-homepage/#/docs)
|
[Homepage of the project](https://infectoone.github.io/vue-ganttastic-homepage/#/docs)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
You can install and use Vue-Ganttastic in your project using <kbd>npm</kbd>:
|
You can install and use Vue-Ganttastic in your project using <kbd>npm</kbd>:
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install vue-ganttastic
|
npm install vue-ganttastic
|
||||||
```
|
```
|
||||||
|
|
||||||
[Moment.js](https://momentjs.com/) is a peer-dependency of Vue-Ganttastic. In order for Vue-Ganttastic to work correctly, you need to install it in your project:
|
[Moment.js](https://momentjs.com/) is a peer-dependency of Vue-Ganttastic. In order for Vue-Ganttastic to work correctly, you need to install it in your project:
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install moment
|
npm install moment
|
||||||
```
|
```
|
||||||
|
|
||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
Import the components <code>GGanttChart</code> and <code>GGanttRow</code>.
|
Import the components <code>GGanttChart</code> and <code>GGanttRow</code>.
|
||||||
Use <code>g-gantt-chart</code> in your template, pass the desired chart start and chart end time as props (<code>chart-start</code> and <code>chart-end</code>) and add <code>g-gantt-row</code>s
|
Use <code>g-gantt-chart</code> in your template, pass the desired chart start and chart end time as props (<code>chart-start</code> and <code>chart-end</code>) and add <code>g-gantt-row</code>s
|
||||||
to the default template slot.
|
to the default template slot.
|
||||||
@@ -26,6 +32,7 @@ Pass an array containing your bar objects to every row using the <code>bars</cod
|
|||||||
For more detailed information, such as how to style the bars or additional configuration options, please refer to the [docs](https://infectoone.github.io/vue-ganttastic-homepage/#/docs) on the project's homepage (coming soon).
|
For more detailed information, such as how to style the bars or additional configuration options, please refer to the [docs](https://infectoone.github.io/vue-ganttastic-homepage/#/docs) on the project's homepage (coming soon).
|
||||||
|
|
||||||
The following code showcases a simple usage example in a .vue SFC (Single File Component)
|
The following code showcases a simple usage example in a .vue SFC (Single File Component)
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<template>
|
<template>
|
||||||
...
|
...
|
||||||
@@ -33,6 +40,9 @@ The following code showcases a simple usage example in a .vue SFC (Single File C
|
|||||||
<g-gantt-chart
|
<g-gantt-chart
|
||||||
:chart-start="myChartStart"
|
:chart-start="myChartStart"
|
||||||
:chart-end="myChartEnd"
|
:chart-end="myChartEnd"
|
||||||
|
precision="day"
|
||||||
|
:is-magnetic="true"
|
||||||
|
locale="en"
|
||||||
>
|
>
|
||||||
<g-gantt-row
|
<g-gantt-row
|
||||||
v-for="row in rows"
|
v-for="row in rows"
|
||||||
@@ -95,13 +105,14 @@ export default {
|
|||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Pull requests are warmly welcomed, while every major change or proposal ought to be discussed in an issue first. As the project is still new, I will gladly accept suggestions, proposals, contributions etc.
|
Pull requests are warmly welcomed, while every major change or proposal ought to be discussed in an issue first. As the project is still new, I will gladly accept suggestions, proposals, contributions etc.
|
||||||
|
|
||||||
### Contributing - How to run the project
|
### Contributing - How to run the project
|
||||||
|
|
||||||
1. Clone the project
|
1. Clone the project
|
||||||
2. Install the Vue CLI service, if you don't already have it installed:
|
2. Install the Vue CLI service, if you don't already have it installed:
|
||||||
```
|
```
|
||||||
@@ -113,8 +124,11 @@ Pull requests are warmly welcomed, while every major change or proposal ought to
|
|||||||
```
|
```
|
||||||
vue serve src/Playground.vue
|
vue serve src/Playground.vue
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
[Moment.js](https://momentjs.com/)
|
[Moment.js](https://momentjs.com/)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[MIT](https://choosealicense.com/licenses/mit/)
|
[MIT](https://choosealicense.com/licenses/mit/)
|
||||||
|
|||||||
Generated
+9081
-1837
File diff suppressed because it is too large
Load Diff
+2
-4
@@ -84,11 +84,9 @@ export default {
|
|||||||
barEndBeforeDrag: null,
|
barEndBeforeDrag: null,
|
||||||
timeUnit: this.getTimeUnit(),
|
timeUnit: this.getTimeUnit(),
|
||||||
timeChildKey:
|
timeChildKey:
|
||||||
this.ganttChartProps.timeaxisMode === 'month_days'
|
this.ganttChartProps.precision === 'month' ? 'hours' : 'minutes',
|
||||||
? 'hours'
|
|
||||||
: 'minutes',
|
|
||||||
timeChildFormat:
|
timeChildFormat:
|
||||||
this.ganttChartProps.timeaxisMode === 'month_days' ? 'MM-DD' : 'HH:mm',
|
this.ganttChartProps.precision === 'month' ? 'MM-DD' : 'HH:mm',
|
||||||
timeFormat: this.getTimeFormat(),
|
timeFormat: this.getTimeFormat(),
|
||||||
barStartKey: this.ganttChartProps.barStartKey,
|
barStartKey: this.ganttChartProps.barStartKey,
|
||||||
barEndKey: this.ganttChartProps.barEndKey,
|
barEndKey: this.ganttChartProps.barEndKey,
|
||||||
|
|||||||
+6
-11
@@ -65,13 +65,10 @@ export default {
|
|||||||
pushOnOverlap: { type: Boolean },
|
pushOnOverlap: { type: Boolean },
|
||||||
isMagnetic: { type: Boolean },
|
isMagnetic: { type: Boolean },
|
||||||
snapBackOnOverlap: { type: Boolean },
|
snapBackOnOverlap: { type: Boolean },
|
||||||
minGapBetweenBars: {
|
minGapBetweenBars: { type: Number, default: 0 },
|
||||||
type: Number,
|
|
||||||
default: 0,
|
|
||||||
},
|
|
||||||
defaultBarLength: { type: Number, default: 1 },
|
defaultBarLength: { type: Number, default: 1 },
|
||||||
// ["month_days", "day_hours"]
|
// ["month", "day"]
|
||||||
timeaxisMode: { type: String, default: 'month_days' },
|
precision: { type: String, default: 'month' },
|
||||||
barStartKey: { type: String, default: 'start' }, // property name of the bar objects that represents the start datetime
|
barStartKey: { type: String, default: 'start' }, // property name of the bar objects that represents the start datetime
|
||||||
barEndKey: { type: String, default: 'end' }, // property name of the bar objects that represents the end datetime,
|
barEndKey: { type: String, default: 'end' }, // property name of the bar objects that represents the end datetime,
|
||||||
},
|
},
|
||||||
@@ -80,11 +77,9 @@ export default {
|
|||||||
return {
|
return {
|
||||||
timemarkerOffset: 0,
|
timemarkerOffset: 0,
|
||||||
movedBarsInDrag: new Set(),
|
movedBarsInDrag: new Set(),
|
||||||
timeUnit: this.timeaxisMode === 'month_days' ? 'days' : 'hours',
|
timeUnit: this.precision === 'month' ? 'days' : 'hours',
|
||||||
timeFormat:
|
timeFormat:
|
||||||
this.timeaxisMode === 'month_days'
|
this.precision === 'month' ? 'YYYY-MM-DD HH' : 'YYYY-MM-DD HH:mm',
|
||||||
? 'YYYY-MM-DD HH'
|
|
||||||
: 'YYYY-MM-DD HH:mm',
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -198,7 +193,7 @@ export default {
|
|||||||
let { left, right /*, move*/ } = action
|
let { left, right /*, move*/ } = action
|
||||||
|
|
||||||
movedBars.forEach((bar) => {
|
movedBars.forEach((bar) => {
|
||||||
if (this.timeaxisMode === 'month_days') {
|
if (this.precision === 'month') {
|
||||||
if (left && bar == ganttBar.bar) {
|
if (left && bar == ganttBar.bar) {
|
||||||
if (moment(bar[this.barStartKey]).hours() < 12) {
|
if (moment(bar[this.barStartKey]).hours() < 12) {
|
||||||
bar[this.barStartKey] = moment(bar[this.barStartKey])
|
bar[this.barStartKey] = moment(bar[this.barStartKey])
|
||||||
|
|||||||
+3
-3
@@ -37,12 +37,12 @@ export default {
|
|||||||
let momentChartStart = moment(this.chartStart)
|
let momentChartStart = moment(this.chartStart)
|
||||||
let momentChartEnd = moment(this.chartEnd)
|
let momentChartEnd = moment(this.chartEnd)
|
||||||
let res = []
|
let res = []
|
||||||
const timeaxisMode = this.ganttChartProps.timeaxisMode
|
const precision = this.ganttChartProps.precision
|
||||||
while (momentChartStart.isSameOrBefore(momentChartEnd)) {
|
while (momentChartStart.isSameOrBefore(momentChartEnd)) {
|
||||||
if (timeaxisMode === 'month_days') {
|
if (precision === 'month') {
|
||||||
res.push(momentChartStart.date())
|
res.push(momentChartStart.date())
|
||||||
momentChartStart.add(1, 'day')
|
momentChartStart.add(1, 'day')
|
||||||
} else if (timeaxisMode === 'day_hours') {
|
} else if (precision === 'day') {
|
||||||
res.push(momentChartStart.date())
|
res.push(momentChartStart.date())
|
||||||
momentChartStart.add(1, 'hour')
|
momentChartStart.add(1, 'hour')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ export default {
|
|||||||
childPointCount: null,
|
childPointCount: null,
|
||||||
timemarker: null,
|
timemarker: null,
|
||||||
hourFontSize: '11px',
|
hourFontSize: '11px',
|
||||||
dayFormat: 'MM-DD', // ISO 8601
|
dayFormat: 'DD MMMM',
|
||||||
mode: this.ganttChartProps.timeaxisMode,
|
precision: this.ganttChartProps.precision,
|
||||||
timeUnit: this.getTimeUnit(),
|
timeUnit: this.getTimeUnit(),
|
||||||
timeFormat: this.getTimeFormat(),
|
timeFormat: this.getTimeFormat(),
|
||||||
}
|
}
|
||||||
@@ -94,9 +94,9 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
initAxis() {
|
initAxis() {
|
||||||
if (this.mode === 'month_days') {
|
if (this.precision === 'month') {
|
||||||
this.initAxisMonthsAndDays()
|
this.initAxisMonthsAndDays()
|
||||||
} else if (this.mode === 'day_hours') {
|
} else if (this.precision === 'day') {
|
||||||
this.initAxisDaysAndHours()
|
this.initAxisDaysAndHours()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -196,9 +196,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
pointFormatted(point) {
|
pointFormatted(point) {
|
||||||
if (this.mode === 'month_days') {
|
if (this.precision === 'month') {
|
||||||
return this.monthFormatted(point)
|
return this.monthFormatted(point)
|
||||||
} else if (this.mode === 'day_hours') {
|
} else if (this.precision === 'day') {
|
||||||
return this.dayFormatted(point)
|
return this.dayFormatted(point)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
:hide-timeaxis="hideTimeaxis"
|
:hide-timeaxis="hideTimeaxis"
|
||||||
:push-on-overlap="pushOnOverlap"
|
:push-on-overlap="pushOnOverlap"
|
||||||
snap-back-on-overlap
|
snap-back-on-overlap
|
||||||
timeaxisMode="day_hours"
|
precision="day"
|
||||||
:is-magnetic="isMagnetic"
|
:is-magnetic="isMagnetic"
|
||||||
:highlighted-hours="highlightedHours"
|
:highlighted-hours="highlightedHours"
|
||||||
:row-label-width="rowLabelWidth"
|
:row-label-width="rowLabelWidth"
|
||||||
|
|||||||
Reference in New Issue
Block a user