|
| 1 | +--- |
| 2 | +category: examples |
| 3 | +group: gantt |
| 4 | +title: Task Bar Locate (Offscreen Indicator) |
| 5 | +cover: https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/gantt/gantt-locate-taskbar.gif |
| 6 | +link: gantt/Getting_Started |
| 7 | +option: Gantt#taskBar |
| 8 | +--- |
| 9 | + |
| 10 | +# Task Bar Locate (Offscreen Indicator) |
| 11 | + |
| 12 | +When the timeline is long, task bars may be outside the current viewport. This demo shows how to enable the locate icon feature: when a task bar is horizontally outside the viewport, an icon is displayed at the left/right edge of the gantt view; hover highlights it, and click scrolls the task bar into view. |
| 13 | + |
| 14 | +## Key Option |
| 15 | + |
| 16 | +- `taskBar.locateIcon: true` |
| 17 | + |
| 18 | +## Live Demo |
| 19 | + |
| 20 | +```javascript livedemo template=vtable |
| 21 | +// import * as VTableGantt from '@visactor/vtable-gantt'; |
| 22 | +let ganttInstance; |
| 23 | + |
| 24 | +const records = [ |
| 25 | + { id: 1, title: 'Offscreen on the left', start: '2024-02-05', end: '2024-02-20', progress: 20 }, |
| 26 | + { id: 2, title: 'Offscreen on the left', start: '2024-03-10', end: '2024-03-18', progress: 60 }, |
| 27 | + { id: 5, title: 'Visible in viewport', start: '2024-05-28', end: '2024-06-05', progress: 50 }, |
| 28 | + { id: 3, title: 'Offscreen on the right', start: '2024-10-05', end: '2024-10-20', progress: 40 }, |
| 29 | + { id: 4, title: 'Offscreen on the right', start: '2024-11-10', end: '2024-11-25', progress: 80 } |
| 30 | +]; |
| 31 | + |
| 32 | +const columns = [ |
| 33 | + { field: 'title', title: 'title', width: 160, sort: true }, |
| 34 | + { field: 'start', title: 'start', width: 120, sort: true }, |
| 35 | + { field: 'end', title: 'end', width: 120, sort: true }, |
| 36 | + { field: 'progress', title: 'progress', width: 100, sort: true } |
| 37 | +]; |
| 38 | + |
| 39 | +const option = { |
| 40 | + records, |
| 41 | + taskKeyField: 'id', |
| 42 | + taskListTable: { |
| 43 | + columns, |
| 44 | + tableWidth: 280, |
| 45 | + minTableWidth: 240, |
| 46 | + maxTableWidth: 600 |
| 47 | + }, |
| 48 | + taskBar: { |
| 49 | + startDateField: 'start', |
| 50 | + endDateField: 'end', |
| 51 | + progressField: 'progress', |
| 52 | + locateIcon: true |
| 53 | + }, |
| 54 | + minDate: '2024-01-01', |
| 55 | + maxDate: '2024-12-31', |
| 56 | + timelineHeader: { |
| 57 | + colWidth: 30, |
| 58 | + scales: [{ unit: 'day', step: 1 }] |
| 59 | + }, |
| 60 | + scrollStyle: { |
| 61 | + visible: 'scrolling' |
| 62 | + }, |
| 63 | + grid: { |
| 64 | + verticalLine: { lineWidth: 1, lineColor: '#e1e4e8' }, |
| 65 | + horizontalLine: { lineWidth: 1, lineColor: '#e1e4e8' } |
| 66 | + } |
| 67 | +}; |
| 68 | + |
| 69 | +ganttInstance = new VTableGantt.Gantt(document.getElementById(CONTAINER_ID), option); |
| 70 | +window['ganttInstance'] = ganttInstance; |
| 71 | + |
| 72 | +setTimeout(() => { |
| 73 | + const x = ganttInstance.getXByTime(new Date('2024-06-01 00:00:00').getTime()); |
| 74 | + ganttInstance.scrollLeft = x; |
| 75 | +}, 0); |
| 76 | +``` |
| 77 | + |
0 commit comments