Open lucaswerkmeister opened 8 years ago
If I get your point right, try to use c.addTimeAxis("x", "Year"), instead of addMeasureAxis Then you can apply date formatting as you want. Hope it helps. Scattolini
That only works if the x axis is a time axis, which might be the case in this example, but isn’t always true in general. So using a time axis is only a workaround for a few cases.
More to the point – why does the time axis not have the same problem? Because the time axis is initialized correctly:
} else if (axis._hasTimeField()) {
// Parse the dates and assign the min and max
axis._min = null;
axis._max = null;
// …
var dt = axis._parseDate(d[dimension]);
if (axis._min === null || dt < axis._min) {
axis._min = dt;
}
if (axis._max === null || dt > axis._max) {
axis._max = dt;
}
// …
}
The axis doesn’t start with min, max = 0, it starts with them being unset and overwrites them with the first actual min and max found in the data. This pull request suggests doing the same thing for numeric axes (except that we start with ±∞ instead).
If the minimum value is greater than 0, or the maximum value is less than 0, then initializing those values with 0 leads to incorrect results.
Example:
Without this patch, X and Y axis will start at 0, squashing all the data into a tiny area of an otherwise empty chart.