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

Josa9321
Mon, 04 Sep 2023 16:20:18 +0000
Visualization

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…

2 posts - 2 participants