英文:
Is there a way to get a drop-down hierarchical gantt in Deneb?
问题
我看到 @david-bacci 在 Deneb 方面做了一些出色的工作。具体来说,在这篇帖子中 https://stackoverflow.com/questions/76111573/deneb-vega-lite-hierarchial-y-axis-on-a-gantt-chart
不过我想知道,在 Deneb 中是否可以将那些顶级类别设置为可折叠的下拉菜单?
英文:
I've seen @david-bacci do some great work in Deneb . Specifically in this post https://stackoverflow.com/questions/76111573/deneb-vega-lite-hierarchial-y-axis-on-a-gantt-chart
I want to know though if it is possible to have those top categories be collapsable drop-down menus in Deneb?
答案1
得分: 1
以下是您提供的内容的中文翻译:
提供的Vega Lite规范创建了一个交互式甘特图,可可视化多个项目,将其划分为具有相应的开始和结束日期、状态("延迟"、"进度落后"、"按计划")以及详细描述的任务。
可视化分为两个主要部分 - 侧边栏和主图区域。侧边栏由"hconcat"创建,包含一个项目任务的交互式列表,根据其选择状态以及与当前组的对齐而突出显示。主图区域由"vconcat"组装,将任务的时间线表示为颜色与任务状态相对应的水平条。
用户可以单击侧边栏中的不同任务以查看不同的时间线。图表还包括一个垂直规则,指示当前日期,并在时间线条上提供详细信息的工具提示。
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{
"task": 0,
"group": "P01",
"name": "清洁房屋",
"start": "2023-03-10",
"end": "2023-07-15",
"status": "项目",
"description": "这是项目1的描述。"
},
// 其他任务数据...
]
},
"hconcat": [
// 侧边栏配置...
],
"vconcat": [
// 主图配置...
],
"config": {"view": {"stroke": null}}
}
希望这对您有所帮助!如果您需要进一步的信息,请告诉我。
英文:
The provided Vega Lite specification creates an interactive Gantt chart visualizing multiple projects divided into tasks with corresponding start and end dates, status ("Delayed", "Behind Schedule", "On Schedule"), and detailed descriptions.
The visualization is split into two main sections - a sidebar and the main chart area. The sidebar, created by "hconcat", contains an interactive list of project tasks, which are highlighted based on their selection state and their alignment with the current group. The main chart area, assembled by "vconcat", represents tasks' timelines as horizontal bars whose color corresponds to the task status.
Users can click on different tasks in the sidebar to view different timelines. The chart also includes a vertical rule indicating the current date and tooltips on the timeline bars providing detailed information.
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{
"task": 0,
"group": "P01",
"name": "Clean the house",
"start": "2023-03-10",
"end": "2023-07-15",
"status": "Project",
"description": "This is the description of project 1."
},
{
"task": 1,
"group": "P01",
"name": "House 1.1",
"start": "2023-03-10",
"end": "2023-04-15",
"status": "Delayed",
"description": "This is the description of project 2."
},
{
"task": 2,
"group": "P01",
"name": "House 1.2",
"start": "2023-04-15",
"end": "2023-05-15",
"status": "Behind schedule",
"description": "This is the description of project 3."
},
{
"task": 3,
"group": "P01",
"name": "House 1.3",
"start": "2023-05-15",
"end": "2023-07-15",
"status": "On schedule",
"description": "This is the description of project 3."
},
{
"task": 0,
"group": "P02",
"name": "Clean the car",
"start": "2023-06-10",
"end": "2023-07-15",
"status": "Project",
"description": "This is the description of project 1."
},
{
"task": 1,
"group": "P02",
"name": "Car 2.1",
"start": "2023-04-10",
"end": "2023-06-01",
"status": "Delayed",
"description": "This is the description of project 2."
},
{
"task": 2,
"group": "P02",
"name": "Car 2.2",
"start": "2023-07-01",
"end": "2023-07-15",
"status": "On schedule",
"description": "This is the description of project 3."
},
{
"task": 0,
"group": "P03",
"name": "Clean the garage",
"start": "2023-03-10",
"end": "2023-05-15",
"status": "Project",
"description": "This is the description of project 1."
},
{
"task": 1,
"group": "P03",
"name": "Garage 3.1",
"start": "2023-01-10",
"end": "2023-02-01",
"status": "Delayed",
"description": "This is the description of project 2."
},
{
"task": 2,
"group": "P03",
"name": "Garage 3.2",
"start": "2023-02-04",
"end": "2023-03-15",
"status": "On schedule",
"description": "This is the description of project 3."
},
{
"task": 3,
"group": "P03",
"name": "Garage 3.3",
"start": "2023-03-10",
"end": "2023-04-01",
"status": "Delayed",
"description": "This is the description of project 2."
},
{
"task": 4,
"group": "P03",
"name": "Garage 3.4",
"start": "2023-05-04",
"end": "2023-06-15",
"status": "On schedule",
"description": "This is the description of project 3."
}
]
},
"hconcat": [
{"height": 200, "width": 10, "mark": {"type": "text", "align": "left"}},
{
"params": [
{
"name": "selectedgroup",
"value": "P01",
"select": {"type": "point", "fields": ["group"]}
}
],
"transform": [
{"calculate": "toDate(utcFormat(now(), '%Y-%m-%d'))","as": "currentDate"},
{"calculate": "selectedgroup.group", "as": "pgroup"},
{"calculate": "datum.group == datum.pgroup ? 'Y' : 'N'", "as": "check"},
{"calculate": "datum.group == datum.pgroup ? 'A' : 'B'", "as": "sort"},
{"calculate": "datum.sort + '-' + datum.group + '-0' + format(datum.task, '.0f') ","as": "project_sort"},
{"calculate": "datum.group == datum.pgroup && datum.task == 0 ? '⯈' : datum.group !== datum.pgroup && datum.task == 0 ? '⭘' : ''","as": "icon"},
{"calculate": "datum.icon + ' ' + datum.name + '|' + format(datum.task, '.0f') + '|' + datum.check", "as": "project_full_descr"},
{"filter": "datum.group == datum.pgroup || datum.pgroup == null || datum.task == 0"}
],
"width": 140,
"height": {"step": 29},
"mark": {"type": "bar", "tooltip": false, "color": "transparent"},
"encoding": {
"y": {
"field": "project_full_descr",
"type": "nominal",
"sort": {"field": "project_sort"},
"axis": {
"orient": "right",
"domain": false,
"grid": false,
"ticks": false,
"labels": true,
"labelFontSize": { "expr": "indexof(datum.label, '|0') !== -1 && indexof(datum.label, '|Y') !== -1 ? 13: indexof(datum.label, '|0') !== -1 && indexof(datum.label, '|N') !== -1 ? 13: 12"
},
"labelPadding": { "expr": "indexof(datum.label, '|0') !== -1 ? -150:-120"
},
"labelExpr": "split(datum.label, '|')[0]",
"labelFontWeight": { "expr": "indexof(datum.label, '|0') !== -1 && indexof(datum.label, '|Y') !== -1 ? 'bold':'normal'"
},
"labelColor": { "expr": "indexof(datum.label, '|0') !== -1 && indexof(datum.label, '|Y') !== -1 ? '#000': indexof(datum.label, '|0') !== -1 && indexof(datum.label, '|N') !== -1 ? '#939191': '#E2E2E2'"
}
},
"title": null
}
}
},
{
"vconcat": [
{"height": 10, "width": 10, "mark": {"type": "text", "align": "left"}},
{
"width": 400,
"height": {"step": 28},
"transform": [
{
"calculate": "toDate(utcFormat(now(), '%Y-%m-%d'))",
"as": "currentDate"
},
{
"filter": {
"and": [
"datum['task'] != 0",
{"and": [{"param": "selectedgroup"}]}
]
}
}
],
"layer": [
{
"mark": {
"type": "rule",
"strokeDash": [2, 2],
"strokeWidth": 1,
"color": "#C690F1"
},
"encoding": {
"x": {
"field": "currentDate",
"type": "temporal",
"axis": {"format": "%d-%b"}
}
}
},
{
"mark": {
"type": "bar",
"height": {"band": 0.4},
"tooltip": true,
"cornerRadius": 4
},
"encoding": {
"y": {
"field": "name",
"type": "nominal",
"axis": {
"domain": false,
"grid": false,
"ticks": false,
"labels": false
},
"title": null
},
"x": {
"field": "start",
"type": "temporal",
"timeUnit": "yearmonthdate",
"axis": {
"format": "%d-%b",
"domain": true,
"grid": false,
"ticks": true,
"labels": true,
"labelFontSize": 11,
"labelColor": "#939191",
"labelPadding": 5
},
"title": null
},
"x2": {"field": "end"},
"color": {
"title": null,
"field": "status",
"type": "nominal",
"scale": {
"domain": ["Delayed", "Behind schedule", "On schedule"],
"range": ["#FAA43A", "#5DA5DA", "#60BD68"]
},
"legend": {
"labelFontSize": 11,
"labelColor": "#706D6C",
"symbolType": "circle",
"orient": "none",
"direction": "horizontal",
"legendY": 0,
"legendX": 260
}
},
"tooltip": [
{
"field": "start",
"type": "temporal",
"timeUnit": "yearmonthdate",
"title": "Start"
},
{
"field": "end",
"type": "temporal",
"timeUnit": "yearmonthdate",
"title": "End"
},
{"field": "description", "type": "nominal", "title": "Descr."}
]
}
},
{
"mark": {
"type": "text",
"align": "left",
"baseline": "middle",
"dy": -11,
"dx": 0,
"color": "#000",
"fontSize": 11
},
"encoding": {
"x": {"field": "start", "type": "temporal"},
"y": {"field": "name", "type": "nominal"},
"text": {"field": "name", "type": "nominal"}
}
}
]
}
]
}
],
"config": {"view": {"stroke": null}}
}
Adam
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论