Deneb - Limit data label width

Hi Team,

I have started working and exploring Deneb and I got a Gantt chart. I want to limit the width of data label like it should restrict the data label to the size of the bar and it should not cross the range of the data bar like in the below snapshot. I am attaching the pbix file. Can anyone please check and play around a bit to see if I can adjust the data labels?

Demo Report Gantt Chart Vega Lite V2.0.pbix (10.4 MB)

Hi @Niala.

You can use the “limit” property of the text mark to restrict the length, but a simple implementation will affect all text values, which is not what you want, I’m sure.

I’d guess that more date parsing might be necessary such that, say, a “_duration_in_hours” field might be created, and then used in the “limit” property … here’s a placeholder example that may be of some use:

        "limit": {
          "expr": "datum['_duration_in_hours'] <= 24 ? 50 : 200"
        },

Here’s a start, but still errors, unfortunately.

Hope this helps.
Greg
eDNA Forum - Deneb Gantt Chart Text Mark Length.pbix (10.4 MB)

2 Likes

Hello @Naila

Did the responses above help solve your query?

If not, can you let us know where you’re stuck and what additional assistance you need?

If it did, please mark the answer as the SOLUTION by clicking the three dots beside Reply and then tick the check box beside SOLUTION

Thank you

Hi @Greg,

Thank you so much for your response. I explored this option of using limit with someone else and got the work around. Below is the work around:

We used bar width using transform below:

  "transform": [
    {
      "calculate": "scale('concat_0_x', datum['StartDate'])",
      "as": "bar_x"
    },
    {
      "calculate": "scale('concat_0_x', datum['EndDate2'])",
      "as": "bar_x2"
    },
    {
      "calculate": "datum['bar_x2']-datum['bar_x']-(2*text_horizontal_padding)",
      "as": "bar_width"
    },

And then used this as a Limit in the Label.

“limit”: {
“expr”: “datum[‘bar_width’]”
}

and it worked out fine. Below is the snapshot after the implementation.

Thanks again for your time and guidance.

3 Likes

Hi @Naila.

I’m glad it wortked-out for you. For reference, could you please post the PBIX (and/or full JSON code) you came up with so that others can see your method of retrieving the start and end X co-ordinates?

Greg

Hi @Naila,

We’ve noticed that no response has been received from you on Greg’s request to share your PBIX (and/or full JSON code) you came up with to solve your inquiry.

Just like Greg, we believe that sharing your method with the community would be very beneficial. Many others may be facing similar challenges and could benefit from your insights.

I understand that you may be busy, but if you could take a few moments to share your PBIX (and/or full JSON code), it would be greatly appreciated.

Thank you for considering this request, and I look forward to hearing back from you soon.

Also please mark this thread as Solved.