From: Evert Timberg Date: Wed, 27 May 2020 16:22:00 +0000 (-0400) Subject: Consider all timestamps for bar measuring (#7421) X-Git-Tag: v3.0.0-beta.2~124 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29043f152bc51d3cb41412749b2936d729725536;p=thirdparty%2FChart.js.git 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 --- diff --git a/karma.conf.js b/karma.conf.js index a4ec3cd59..2f5f8d8f3 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -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) { diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index a6b505c7e..ec8d61e71 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -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(); diff --git a/test/fixtures/scale.time/bar-large-gap-between-data.js b/test/fixtures/scale.time/bar-large-gap-between-data.js new file mode 100644 index 000000000..7b1017251 --- /dev/null +++ b/test/fixtures/scale.time/bar-large-gap-between-data.js @@ -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 + } +}; diff --git a/test/fixtures/scale.time/bar-large-gap-between-data.png b/test/fixtures/scale.time/bar-large-gap-between-data.png new file mode 100644 index 000000000..c228f066d Binary files /dev/null and b/test/fixtures/scale.time/bar-large-gap-between-data.png differ