Consider all timestamps for bar measuring (#7421)

* Consider all timestamps for bar measuring
* Fix watched tests for updated file names
* Add test of sparse bar time scales
This commit is contained in:
Evert Timberg
2020-05-27 12:22:00 -04:00
parent 25ab011ed4
commit eb8cd13997
4 changed files with 59 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ module.exports = function(karma) {
// we will prefer the unminified build which is easier to browse and works
// better with source mapping. In other cases, pick the minified build to
// make sure that the minification process (terser) doesn't break anything.
const regex = args.watch ? /Chart\.js$/ : /Chart\.min\.js$/;
const regex = args.watch ? /chart\.js$/ : /chart\.min\.js$/;
const build = builds.filter(v => v.output.file.match(regex))[0];
if (args.watch) {

View File

@@ -686,7 +686,7 @@ class TimeScale extends Scale {
me._majorUnit = !tickOpts.major.enabled || me._unit === 'year' ? undefined
: determineMajorUnit(me._unit);
me._table = buildLookupTable(getTimestampsForTable(me), min, max, distribution);
me._offsets = computeOffsets(me._table, getDataTimestamps(me), min, max, options);
me._offsets = computeOffsets(me._table, timestamps, min, max, options);
if (options.reverse) {
ticks.reverse();

View File

@@ -0,0 +1,57 @@
var date = moment('May 24 2020', 'MMM DD YYYY');
module.exports = {
threshold: 0.05,
config: {
type: 'bar',
data: {
datasets: [{
backgroundColor: 'rgba(255, 0, 0, 0.5)',
data: [
{
x: date.clone().add(-2, 'day'),
y: 20,
},
{
x: date.clone().add(-1, 'day'),
y: 30,
},
{
x: date,
y: 40,
},
{
x: date.clone().add(1, 'day'),
y: 50,
},
{
x: date.clone().add(7, 'day'),
y: 10,
}
]
}]
},
options: {
legend: false,
scales: {
x: {
display: false,
type: 'time',
distribution: 'linear',
ticks: {
source: 'auto'
},
time: {
unit: 'day'
}
},
y: {
display: false
}
}
}
},
options: {
spriteText: true
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB