Date Database function is not getting sorted in correct order

Hello Helical Team,

I am applying database function to the date column for formatting the x-axis labels. After applying the function, the dates are not sorted in the correct order.

After applying date format function:

date-format-after

How do I show the date on x-axis in the required format and also sort the dates in the correct order?

Thank You
Linapag

1 Like

Hello Linapag,

This is happening because as soon as you apply a database function on the date, it will be converted to string/varchar. Sorting of the x-axis will take place by treating the date as a string.
Please apply the following script in JS editor:

hi_container.set(“preExecution”,function(c){
var viz_Options = c.get(“viz_Options”);
viz_Options.chartOptions = {
axis:{
	x: {
		type: ‘timeseries’;
		tick:{
			format: ‘%m-%d-%y’
        }
  }
}
}
};
c.set(“viz_Options”,viz_Options);
});

For more details, refer to https://c3js.org/samples/timeseries.html

Thank You
Team Helical