Bar chart ticks labels format

I’m using a Bar Chart object to show some values, where the categories are DateTime values. I cannot find a way to format the Category Axis labels as yyyy-MM-dd instead of what you can see in the following screenshot:

Thanks in advance, regards

You can try to format those DateTime values as strings before bringing them into the Bar Charts Dataset.

I don’t believe that the bar chart component uses JFreeCharts DateAxis Class for it’s Domain Axis and uses the CategoryAxis Class. If that is the case then you won’t be able to format the DateTime values that you see in the Category Axis easily.

Thanks snngeru, I was just thinking the same, however I tried to see if there was a way through standard chart properties.

You can possibly do this on the configureChart extension function for the standard chart component

from java.text import SimpleDateFormat	
dateFormat = SimpleDateFormat("yyyy-MM-dd")
chart.getPlot().getDomainAxis().setDateFormatOverride(dateFormat)
1 Like

Yeah, this will work great, but the Bar Chart is just calling toString if the first column isn’t already a string, so the best answer (using the bar chart component) is what @snngeru first suggested with formatting the column in the query/script.

1 Like