diff --git a/src/NeatCharts/NeatChart.php b/src/NeatCharts/NeatChart.php
index dec61fa..08aaa0a 100644
--- a/src/NeatCharts/NeatChart.php
+++ b/src/NeatCharts/NeatChart.php
@@ -141,7 +141,7 @@ namespace NeatCharts {
'days' => [24 * 60 * 60, 'M j'],
'years' => [365 * 24 * 60 * 60, 'Y']
];
- $numXLabels = 1 + round($this->width / $this->options['fontSize'] / 10);
+ $numXLabels = round($this->width / $this->options['fontSize'] / 12);
$scale = 'years';
$xLabelFormat = $timeIntervals[$scale][1];
foreach ($timeIntervals as $period => $duration) {
@@ -161,7 +161,15 @@ namespace NeatCharts {
$labelXCoord = $this->transformX($labelX);
$gridLines .= 'M'.$labelXCoord.' 0 '.$labelXCoord.' '.$this->height.' ';
$xLabelAlignment = ($this->width - $labelXCoord > $this->options['fontSize'] * 2 ? ($labelXCoord > $this->options['fontSize'] * 2 ? 'middle' : 'start') : 'end');
- $gridText .= ''.date($xLabelFormat, $labelX).'';
+ if ($this->width - $labelXCoord > $this->options['fontSize'] * 2) {
+ if ($labelXCoord > $this->options['fontSize'] * 2) {
+ $gridText .= ''.date($xLabelFormat, $labelX).'';
+ } else {
+ $gridText .= ''.date($xLabelFormat, $labelX).'';
+ };
+ } else {
+ $gridText .= ''.date($xLabelFormat, $labelX).'';
+ }
}
}