Vue/Resource panel
Loading live demo…from dhtmlx.github.io
Vue
Resource panel
Show resource assignments and a histogram panel alongside the Gantt timeline.
- Demo.vue
- shared/resourceData.ts
src/examples/resource-panel/Demo.vue View on GitHub
<script setup lang="ts">
import { computed, ref } from "vue";
import { VueGantt } from "@dhtmlx/trial-vue-gantt";
import "@dhtmlx/trial-vue-gantt/dist/vue-gantt.css";
import { createResourceDemoData } from "../shared/resourceData";
const dataSet = createResourceDemoData();
const tasks = ref(dataSet.tasks);
const links = ref(dataSet.links);
const resources = ref(dataSet.resources);
const selectedResourceId = ref("");
const resourceFilter = computed(() => {
if (!selectedResourceId.value) {
return undefined;
}
return (resource: any) => String(resource.id) === selectedResourceId.value;
});
const resourceConfig = {
scale_height: 30,
row_height: 40,
scales: [{ unit: "day", step: 1, date: "%d %M" }],
columns: [
{
name: "name",
label: "Name",
tree: true,
width: 220,
template: (resource: any) => resource.text,
resize: true
}
]
};
const config = {
columns: [
{ name: "text", tree: true, width: 220, resize: true },
{ name: "start_date", align: "center", width: 120, resize: true },
{ name: "duration", align: "center", width: 80, resize: true },
{ name: "add", width: 44 }
],
resources: true,
resource_store: "resource",
resource_property: "owner",
resource_render_empty_cells: true,
open_tree_initially: true,
layout: {
css: "gantt_container",
rows: [
{
gravity: 2,
cols: [
{ view: "grid", group: "grids", scrollY: "scrollVer" },
{ resizer: true, width: 1 },
{ view: "timeline", scrollX: "scrollHor", scrollY: "scrollVer" },
{ view: "scrollbar", id: "scrollVer", group: "vertical" }
]
},
{ resizer: true, width: 1, next: "resources" },
{
gravity: 1,
id: "resources",
config: resourceConfig,
cols: [
{ view: "resourceGrid", group: "grids", scrollY: "resourceVScroll" },
{ resizer: true, width: 1 },
{ view: "resourceHistogram", capacity: 24, scrollX: "scrollHor", scrollY: "resourceVScroll" },
{ view: "scrollbar", id: "resourceVScroll", group: "vertical" }
]
},
{ view: "scrollbar", id: "scrollHor" }
]
}
};
</script>
<template>
<section class="demo-panel" data-cy="resource-panel-demo">
<div class="demo-toolbar">
<label for="resource-filter">Resource</label>
<select id="resource-filter" data-cy="resource-filter" v-model="selectedResourceId">
<option value="">All</option>
<option v-for="resource in resources" :key="resource.id" :value="String(resource.id)">
{{ resource.text }}
</option>
</select>
</div>
<VueGantt
class="demo-gantt"
:tasks="tasks"
:links="links"
:resources="resources"
:config="config"
:resourceFilter="resourceFilter"
/>
</section>
</template>
src/examples/shared/resourceData.ts View on GitHub
import type { SerializedLink, SerializedTask } from "@dhtmlx/trial-vue-gantt";
export interface ResourceDemoData {
tasks: SerializedTask[];
links: SerializedLink[];
resources: any[];
}
const baseData: ResourceDemoData = {
tasks: [
{ id: 1, text: "Office itinerancy", type: "project", start_date: "02-05-2026 00:00", duration: 12, progress: 0.4, owner: [{ resource_id: "6", value: 3 }], parent: 0, open: true },
{ id: 2, text: "Office facing", type: "project", start_date: "02-05-2026 00:00", duration: 8, progress: 0.6, owner: [{ resource_id: "6", value: 4 }], parent: 1, open: true },
{ id: 3, text: "Furniture installation", type: "task", start_date: "11-05-2026 00:00", duration: 6, progress: 0.6, owner: [{ resource_id: "7", value: 5 }], parent: 2 },
{ id: 4, text: "Integration", type: "task", start_date: "13-05-2026 00:00", duration: 4, progress: 0.5, owner: [{ resource_id: "8", value: 2 }], parent: 2 },
{ id: 5, text: "Testing", type: "task", start_date: "16-05-2026 00:00", duration: 3, progress: 0.3, owner: [{ resource_id: "9", value: 4 }], parent: 2 },
{ id: 6, text: "Documentation", type: "task", start_date: "20-05-2026 00:00", duration: 5, progress: 0.2, owner: [{ resource_id: "6", value: 2 }], parent: 2 }
],
links: [
{ id: 1, source: 1, target: 2, type: "0" },
{ id: 2, source: 2, target: 3, type: "0" },
{ id: 3, source: 3, target: 4, type: "0" },
{ id: 4, source: 4, target: 5, type: "0" },
{ id: 5, source: 5, target: 6, type: "0" }
],
resources: [
{ id: 6, text: "John", unit: "hours/day" },
{ id: 7, text: "Mike", unit: "hours/day" },
{ id: 8, text: "Anna", unit: "hours/day" },
{ id: 9, text: "Bill", unit: "hours/day" }
]
};
const cloneObject = <T>(source: T): T => JSON.parse(JSON.stringify(source));
export function createResourceDemoData(): ResourceDemoData {
return {
tasks: cloneObject(baseData.tasks),
links: cloneObject(baseData.links),
resources: cloneObject(baseData.resources)
};
}