Gantt Chart "Duration" format

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
OS Dashboards v 2.0.1

Describe the issue:
Documentation for Gantt Chart says: “The duration is the amount of time to add to the start time.”
Currently my Document contains a “creationDate” and “finalsiationDate”.
I have created a painless scripted field to extract the “task_duration” which looks like:

def diff = doc['finalisationDate'].value.getMillis() - doc['creationDate'].value.getMillis(); return new SimpleDateFormat('HH:mm:ss.SSS').format(diff);

Which has a type of “Date” - however selecting this as the Gantt Chart’s Event Duration appears to return no data.

I suspect that my return type just isn’t formatted correctly but I’m unsure how it should be formatted. Is it expecting an interval or duration data type? should I leave it as total milliseconds?

Thanks!

Hi @zane - I’m actually not sure, and I agree that the description text is ambiguous. It appears to me that you should probably just leave it in milliseconds, because a plain numeric type seems to work: playground example.

It’s also annoying that there doesn’t appear to be a way to specify the interval or duration type.

If you’re interested in exploring the source code or opening an issue for that visualization, you can do so here: Issues · opensearch-project/dashboards-visualizations · GitHub

1 Like

yeah it’d be nice if the chart itself allowed you specify either a duration as type of ??? seconds, minutes, hours, days, etc. OR as a start and end datetime.

Once I figure out a painless function that correctly extracts the delta of milliseconds between two dates I will post it here:

for context my new script which appears? to work is:

painless:

def diffInMs = doc['finalisationDate'].value.getMillis() - doc['creationDate'].value.getMillis();
return diffInMs

However I also noticed that since the gantt chart can’t seem to be expanded past 24 hours - so if the Event started more than 24 hours ago then the graph just draws nothing so while the script does work - the chart still doesn’t.

Maybe this chart type is just too specific - and perhaps a more generic “broken bar” would be easier to use for a general case