I'm using this library to show charts in my app.
With my data, the x-axis is always a DateTime
All I want to do is explicitly set the x-axis labels to show and WHERE to show them if possible, e.g.
- Show 2 or 4 labels evenly spaced, beginning (so centred under the y-axis) and at end of the x-axis
Like this:
or this:
Here's what I have so far which doesn't quite work, but I'm not sure why:
return DateTimeAxis(
dateFormat: (showXAxisAsName) ? DateFormat("MMM") : DateFormat("dd/MM"),
majorGridLines: MajorGridLines(width: 0),
majorTickLines: MajorTickLines(width: 0),
axisLine: AxisLine(
width: 1,
color: (axesColour != null) ? axesColour : GTColors.lightGrey,
),
labelStyle: GTTextStyle.caption2.copyWith(
color: (axesColour != null) ? axesColour : GTColors.lightGrey,
),
minimum: (hasData) ? DateTime(first.year, first.month) : null,
maximum: (hasData) ? DateTime(last.year, last.month) : null,
intervalType: DateTimeIntervalType.months,
);