I'm not being able to specify where the grid lines should go for my date axis in amCharts 4. Here is my code:
let dateAxis = this.chart.xAxes.push(new am4charts.DateAxis());
dateAxis.dataFields.date="submittedDtm";
dateAxis.gridIntervals.setAll([
{ timeUnit: "month", count: 1 },
]);
As you can see I'm trying to make the chart have a grid line for every month. But instead, I only get grid lines for April, July, October, and next January:
This is for the data points "2023-04-05 14:48:00" and "2023-12-05 14:46:00".
In addition, my gridIntervals seems to cause my data to group into months, even though as I understand it, that's only supposed to happen if I set dateAxis.groupData = true; and set the appropriate dateAxis.groupIntervals.
I've tried many things such as dateAxis.groupData = true; and dateAxis.renderer.grid.template.location = 0.5;. Currently I don't have dateAxis.renderer.minGridDistance set to anything, but I've tried different values for that and it didn't work either.
EDIT: Resolved. This was an issue with data granularity. Even though my data is given with accuracy to the second, since I only gave a small number of data points, amcharts thought my granularity was much larger. When I set my base interval with
dateAxis.baseInterval = {
"timeUnit": "second",
"count": 1
}
it now works correctly.