Hi,
I am using the Raw Data Table and I’d like to render timestamp columns in ‘DD MMM, YYYY HH:mm:ss’ format. Is there an easy way to do this custom formatting?
Formatting timestamp column in table
noah
#1
jorge
#2
Hi @noah,
You can use the Raw Data Table’s formatting cells functionality described here:
In short, set the “cellFormat” property with the following configuration:
{
fields: 'TIME',
format: function(field, value) {
return {
value: moment(value).format('DD MMM, YYYY HH:mm:ss')
}
}
}
It is saying: format all time field values in the table with the format function provided. The full code to render your table would something like this:
let provider = cf.provider("MyDataProivder");
let source = provider.source('logstash-2015.05.*'); // assuming this is the name of your source
// Define chart options
var moment = cf.getDependency('moment');
let myChart = source.fields()
.graph("Raw Data Table")
.set("showRowNumber", true)
.set("autoSizeColumns", true)
.set("cellFormat",
{
fields: 'TIME',
format: function(field, value) {
return {
value: moment(value).format('DD MMM, YYYY HH:mm:ss')
}
}
}
)
.execute();
Hope it helps.