max = isFinite(max) && !isNaN(max) ? max : +adapter.endOf(Date.now(), unit) + 1;
// Make sure that max is strictly higher than min (required by the timeseries lookup table)
- me.min = Math.min(min, max);
+ me.min = Math.min(min, max - 1);
me.max = Math.max(min + 1, max);
}
end = (last - me.getDecimalForValue(timestamps[timestamps.length - 2])) / 2;
}
}
- start = _limitValue(start, 0, 0.25);
- end = _limitValue(end, 0, 0.25);
+ const limit = timestamps.length < 3 ? 0.5 : 0.25;
+ start = _limitValue(start, 0, limit);
+ end = _limitValue(end, 0, limit);
me._offsets = {start, end, factor: 1 / (start + 1 + end)};
}
--- /dev/null
+const data = {
+ datasets: [
+ {
+ label: 6,
+ backgroundColor: 'red',
+ data: [
+ {
+ x: '2021-03-24',
+ y: 464
+ }
+ ]
+ },
+ {
+ label: 1,
+ backgroundColor: 'red',
+ data: [
+ {
+ x: '2021-03-24',
+ y: 464
+ }
+ ]
+ },
+ {
+ label: 17,
+ backgroundColor: 'blue',
+ data: [
+ {
+ x: '2021-03-24',
+ y: 390
+ }
+ ]
+ }
+ ]
+};
+
+module.exports = {
+ description: 'https://github.com/chartjs/Chart.js/issues/8718',
+ config: {
+ type: 'bar',
+ data,
+ options: {
+ scales: {
+ x: {
+ type: 'time',
+ time: {
+ unit: 'day',
+ },
+ },
+ y: {
+ display: false
+ }
+ }
+ }
+ },
+ options: {
+ spriteText: true,
+ canvas: {width: 256, height: 128}
+ }
+};
--- /dev/null
+const data = {
+ datasets: [
+ {
+ label: 1,
+ backgroundColor: 'orange',
+ data: [
+ {
+ x: '2021-03-24',
+ y: 464
+ }
+ ]
+ },
+ {
+ label: 2,
+ backgroundColor: 'red',
+ data: [
+ {
+ x: '2021-03-24',
+ y: 464
+ }
+ ]
+ },
+ {
+ label: 3,
+ backgroundColor: 'blue',
+ data: [
+ {
+ x: '2021-03-24',
+ y: 390
+ }
+ ]
+ },
+ {
+ label: 4,
+ backgroundColor: 'purple',
+ data: [
+ {
+ x: '2021-03-25',
+ y: 464
+ }
+ ]
+ },
+ {
+ label: 5,
+ backgroundColor: 'black',
+ data: [
+ {
+ x: '2021-03-25',
+ y: 464
+ }
+ ]
+ },
+ {
+ label: 6,
+ backgroundColor: 'cyan',
+ data: [
+ {
+ x: '2021-03-25',
+ y: 390
+ }
+ ]
+ }
+ ]
+};
+
+module.exports = {
+ description: 'https://github.com/chartjs/Chart.js/issues/8718',
+ config: {
+ type: 'bar',
+ data,
+ options: {
+ scales: {
+ x: {
+ type: 'time',
+ time: {
+ unit: 'day',
+ },
+ },
+ y: {
+ display: false
+ }
+ }
+ }
+ },
+ options: {
+ spriteText: true,
+ canvas: {width: 256, height: 128}
+ }
+};