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

**URL:** <https://discourse.julialang.org/t/how-to-put-text-on-a-gantt-chart-vega-lite/103515>\
**Category:** Visualization\
**Tags:** vegalite\
**Created:** [September 4, 2023, 4:20pm UTC](https://discourse.julialang.org/t/how-to-put-text-on-a-gantt-chart-vega-lite/103515 "2023-09-04T16:20:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josa9321](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josa9321/32/12170_2.png) [@Josa9321](https://discourse.julialang.org/u/Josa9321)\
**Post date:** [September 4, 2023, 4:20pm UTC](https://discourse.julialang.org/t/how-to-put-text-on-a-gantt-chart-vega-lite/103515/1 "2023-09-04T16:20:18Z")

</div>

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.

```julia
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
)

```

 ![plot_no_names](https://global.discourse-cdn.com/julialang/original/3X/a/4/a475d06b6f6141970bcf782812f141e9e91fe61a.png)

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

 ![plot_names](https://global.discourse-cdn.com/julialang/original/3X/4/d/4df270dbcc996d5aa9cc486bb875977fef46e136.png)

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…

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [September 4, 2023, 5:36pm UTC](https://discourse.julialang.org/t/how-to-put-text-on-a-gantt-chart-vega-lite/103515/2 "2023-09-04T17:36:39Z")

</div>

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](https://www.queryverse.org/VegaLite.jl/stable/examples/examples_barcharts/#Bar-Chart-with-Labels-1) is an example of a general layered graph, let me know if you need more pointers.
