How to create a derived field for time

Well it depends on what is the format of the field stored that you want to use as a time field. Time data is handled by ChartFactor Toolkit in the following format: YYYY-MM-DD HH:mm:ss.SSS. So to use a derived field you need to convert your field data to that format. So for example let’s say you have a field callled “year” that is an integer that you want to use as time:

let eventYear = {
    'name': 'event_year',
    'label': 'Event Year',
    'type': 'TIME',
    'function': year => `${year}-01-01 00:00:00`,
    'timestampGranularity': 'YEAR',
    'dependencies': ['year']
}

The important part here is the function property and how it expects the data as it is and returns the formated data as time.