R ggplot甘特图中没有显示条形图

No bars shown in R ggplot Gantt chart

我有以下数据集作为来源:

structure(list(JobName = structure(c(1L, 1L, 1L, 2L, 2L, 2L), .Label = ("ATLAS_Admin_DeployClientDatabase", "ATLAS_Admin_ParseMasterCubeDatabase", ATLAS_Admin_xBackup_DeleteOldTable", "BDC_DatabaseMaintenanceJob_ALL_DATABASES", collection_set_1_noncached_collect_and_upload", "CoreX_SAP_B23_dreprecated", CoreXBI_ETL_1014_01Stage", "CoreXBI_ETL_1014_02DWH_Cube", "CoreXBI_ETL_1114_02DWH_Cube", "CoreXBI_ETL_1294_B23", CoreXBI_ETL_AutoTest", "Cycle_Log", "Delphi DEV Load", "Delphi DEV Monthly", mdw_purge_data_[Z_MAS_MDW]", "QA_CoreXBI_ETL_1010", "QA_CoreXBI_ETL_1294", Shrink_the_Logs", "SSIS Server Maintenance Job", "syspolicy_purge_history", sysutility_get_cache_tables_data_into_aggregate_tables_daily", "sysutility_get_cache_tables_data_into_aggregate_tables_hourly", "sysutility_get_views_data_into_cache_tables", "Z_MAS_ADMIN_ALRS", "Z_MAS_ADMIN_Backup_AMOTables", "Z_MAS_ADMIN_Check_Cube_Space", "Z_MAS_ADMIN_Check_Disk_Space", "Z_MAS_ADMIN_Extract_Job_History", "Z_MAS_ADMIN_Monitoring", "Z_MAS_MaintenancePlan.weekly_bak_clean", "Z_MICE_System_Database_Backup_weekly"), class = "factor"), RunDateTime = tructure(c(1478788776, 1479292645, 1479307979, 1479292220, 1479307916, 479314398), class = c("POSIXct", "POSIXt"), tzone = ""), StartWeekday = tructure(c(5L, 7L, 7L, 7L, 7L, 7L), .Label = c("Friday", "Monday", Saturday", "Sunday", "Thursday", "Tuesday", "Wednesday"), class = "factor"), tartTime = structure(c(-2209108824, -2209123355, -2209108021, -2209123780, 2209108084, -2209101602), class = c("POSIXct", "POSIXt"), tzone = ""), ndRunDateTime = structure(c(1478790159, 1479294190, 1479309546, 1479292284, 479307977, 1479314459), class = c("POSIXct", "POSIXt"), tzone = ""), ndWeekday = structure(c(5L, 7L, 7L, 7L, 7L, 7L), .Label = c("Friday", Monday", "Saturday", "Sunday", "Thursday", "Tuesday", "Wednesday"), class = factor"), EndTime = structure(c(-2209107441, -2209121810, -2209106454, 2209123716, -2209108023, -2209101541), class = c("POSIXct", "POSIXt"), tzone  "")), .Names = c("JobName", "RunDateTime", "StartWeekday", StartTime", "EndRunDateTime", "EndWeekday", "EndTime"), row.names = c(NA, L), class = "data.frame")

现在,我使用以下脚本根据数据创建甘特图,该图应显示时间轴中不同作业的持续时间。

library(reshape2)
vars <- c("RunDateTime", "EndRunDateTime", "StartTime", "EndTime")
dataset[vars] <- lapply(dataset[vars], as.POSIXct, format = "%Y-%m-%dT%H:%M:%S")
df <- with(dataset, data.frame(name = JobName, start = RunDateTime, end = EndRunDateTime))
mdfr <- melt(df, measure.vars = c("start", "end"))

library(ggplot2)
ggplot(mdfr, aes( x = value, y = name, color = variable))
geom_line(size = 6)
xlab(NULL)
ylab(NULL)

我的问题是,我得到一个图表,其中 y 轴为 JobNames,x 轴为 DateTimes,但其中没有值或条形。

知道这是关于什么的吗?

编辑:下一个问题是,它将第一个开始时间与最后一个结束时间联系起来...

您没有将 geom 添加到绘图中。尝试:

ggplot(mdfr, aes( x = value, y = name, color = variable)) +
    geom_line(size = 6) +
    xlab(NULL) +
    ylab(NULL)