influxdata / giraffe

A foundation for visualizations in the InfluxDB UI
https://influxdata.github.io/giraffe/
MIT License
180 stars 33 forks source link

Single Stat: allow timestamps to be displayed as the stat #698

Open TCL735 opened 2 years ago

TCL735 commented 2 years ago

Currently, Single Stat will only render strings or numbers without any interpretation of what they represent. For example, a timestamp in JavaScript is a number that can be interpreted as milliseconds from a certain time.

Proposal: Allow Single Stat to interpret numbers as timestamps and render a time rather than a number.

Here is an example .csv that will not show a timestamp, but rather just a number.

#group,false,false,true,true,true,true,false,false,true
#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string
#default,_result,,,,,,,,
,result,table,_field,_measurement,_start,_stop,_time,_value,url
,,0,traefik_config_last_reload_success,prometheus,2021-11-12T17:31:49.314450792Z,2021-11-12T18:31:49.314450792Z,2021-11-12T18:31:02.720095288Z,2021-11-12T14:43:33Z,https://www.google.com

The output is this but what we really want is a timestamp:

Screen Shot 2021-11-13 at 8 13 53 AM
TCL735 commented 2 years ago

This requires updating LatestValueTransform to preserve the column type, passing the column type down as props, and then updating formatStatValue to consider the column type.