How to put text on a Gantt chart (Vega-Lite)?

Hi,

This plot using Vega-Lite for Gantt charts is almost perfect for me, but I want the text of the task on the plot. Here is my code with the image generated.

using DataFrames, VegaLite

# Create a DataFrame
df = DataFrame(
    Task = ["Job A", "Job B", "Job C", "Maintenance 1"],
    Machine = ["1", "2", "1", "2"],
    Type = ["Job", "Job", "Job", "Maintenance"],
    Start = [0, 0, 5, 3],
    Finish = [5, 2, 7, 5],
)

# Ploting the Gantt chart
@vlplot(
    data=df,
    :bar,
    y="Machine:n",
    x=:Start,
    x2=:Finish,
    color={
        :Type, 
        scale={range=["#393996", "#ff002f", "#000000"]}
    },
    width=800,
    height=300
)

Here is what I would like to have the names of the tasks on the plot.

Is there anyone that knows how to do that easily on Julia? Also, if there is a way of doing that on PlotlyJS on Julia…

1 Like

You’ll probably have to go with a layered plot, with one layer for the existing plot and a second one for the text. Here is an example of a general layered graph, let me know if you need more pointers.

1 Like