@@ -34,6 +34,7 @@ import GGanttBarTooltip from "./GGanttBarTooltip.vue"
3434import GGanttCurrentTime from " ./GGanttCurrentTime.vue"
3535import GGanttConnector from " ./GGanttConnector.vue"
3636import GGanttRow from " ./GGanttRow.vue"
37+ import GGanttMilestone from " ./GGanttMilestone.vue"
3738
3839// Internal Imports - Composables
3940import { useConnections } from " ../composables/useConnections"
@@ -46,7 +47,12 @@ import { useRows } from "../composables/useRows"
4647import { colorSchemes , type ColorScheme , type ColorSchemeKey } from " ../color-schemes"
4748import { DEFAULT_DATE_FORMAT } from " ../composables/useDayjsHelper"
4849import { BOOLEAN_KEY , CONFIG_KEY , EMIT_BAR_EVENT_KEY } from " ../provider/symbols"
49- import type { GanttBarObject , GGanttChartProps , SortDirection } from " ../types"
50+ import type {
51+ GanttBarObject ,
52+ GGanttChartProps ,
53+ SortDirection ,
54+ GGanttTimeaxisInstance
55+ } from " ../types"
5056import type { CSSProperties } from " vue"
5157
5258// Props & Emits Definition
@@ -65,7 +71,7 @@ const props = withDefaults(defineProps<GGanttChartProps>(), {
6571 highlightedUnits : () => [],
6672 font: " inherit" ,
6773 labelColumnTitle: " " ,
68- labelColumnWidth: 150 ,
74+ labelColumnWidth: 120 ,
6975 commands: true ,
7076 enableMinutes: false ,
7177 enableConnections: true ,
@@ -79,7 +85,8 @@ const props = withDefaults(defineProps<GGanttChartProps>(), {
7985 initialRows : () => [],
8086 multiColumnLabel : () => [],
8187 sortable: true ,
82- labelResizable: true
88+ labelResizable: true ,
89+ milestones : () => []
8390})
8491
8592const id = ref (crypto .randomUUID ())
@@ -144,14 +151,23 @@ const emit = defineEmits<{
144151const chartStartDayjs = computed (() => dayjs (props .chartStart , props .dateFormat as string , true ))
145152const chartEndDayjs = computed (() => dayjs (props .chartEnd , props .dateFormat as string , true ))
146153
147- const diffDays = computed (() => chartEndDayjs .value .diff (chartStartDayjs .value , " day" ) + 1 )
154+ // const diffDays = computed(() => chartEndDayjs.value.diff(chartStartDayjs.value, "day") + 1)
148155const diffHours = computed (() => chartEndDayjs .value .diff (chartStartDayjs .value , " hour" ))
156+ const diffPrecision = computed (
157+ () =>
158+ chartEndDayjs .value .diff (
159+ chartStartDayjs .value ,
160+ props .precision === " hour" ? " day" : props .precision
161+ ) + 1
162+ )
149163
150164// Chart Elements Refs
151165const ganttChart = ref <HTMLElement | null >(null )
152166const chartSize = useElementSize (ganttChart )
153167const ganttWrapper = ref <HTMLElement | null >(null )
154- const timeaxisComponent = ref <InstanceType <typeof GGanttTimeaxis > | null >(null )
168+ const timeaxisComponent = ref <
169+ (InstanceType < typeof GGanttTimeaxis > & GGanttTimeaxisInstance ) | null
170+ > (null )
155171const ganttContainer = ref <HTMLElement | null >(null )
156172
157173// Composables
@@ -181,7 +197,7 @@ const {
181197 isAtBottom
182198} = useChartNavigation (
183199 {
184- diffDays: diffDays .value ,
200+ diffDays: diffPrecision .value ,
185201 diffHours: diffHours .value ,
186202 scrollRefs: {
187203 rowsContainer ,
@@ -208,7 +224,7 @@ const navigationControls = {
208224
209225const { handleKeyDown } = useKeyboardNavigation (navigationControls , ganttWrapper , ganttContainer )
210226
211- // Derived State
227+ // Computed property per timeaxisUnits
212228const widthNumber = computed (() => zoomFactor .value * 100 )
213229const customWidth = computed (() => ` ${widthNumber .value }% ` )
214230
@@ -426,6 +442,12 @@ provide("id", id)
426442 </template >
427443 </g-gantt-current-time >
428444
445+ <g-gantt-milestone
446+ v-for =" milestone in milestones"
447+ :key =" milestone.date.toString()"
448+ :milestone =" milestone"
449+ />
450+
429451 <!-- Rows Container -->
430452 <div
431453 class =" g-gantt-rows-container"
0 commit comments