Hi, there!
I'm trying to sort a vertical bar Chart by a agregation of maximum date like this:

"cc_mes_ano_registro" is a scripted field that returns the Month
and Year of a date field(data_de_registro) as a string (because string fields are aligned in the center of bars as you can see in "December - 2018"), but there's a problem:

As you can see, March, July and August - 2018 are ahead of July 2019.
In other words, it is not ordered by the maximum date in each bucket.
And if I order by descending it goes like this:

It's completely different.
This is the "cc_mes_ano_registro" script:
if(doc['data_de_registro'].size() > 0 ){
def registroMillis = doc['data_de_registro'].value.getMillis();
ZoneId timeZone = ZoneId.of(ZoneId.SHORT_IDS.get('BET'));
LocalDate dataRegistro =
LocalDateTime.ofInstant(Instant.ofEpochMilli(registroMillis),timeZone).toLocalDate();
def mesAno = dataRegistro.getMonth()+" - "+dataRegistro.getYear();
return mesAno;
}
return "N/A";
Some solution, something wrong that I can't see or it's just a bug?
Thank you!
