Skip to content

Commit 29043f1

Browse files
authored
Consider all timestamps for bar measuring (chartjs#7421)
* Consider all timestamps for bar measuring * Fix watched tests for updated file names * Add test of sparse bar time scales
1 parent e590a97 commit 29043f1

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

karma.conf.js

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

2020
if (args.watch) {

src/scales/scale.time.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ class TimeScale extends Scale {
686686
me._majorUnit = !tickOpts.major.enabled || me._unit === 'year' ? undefined
687687
: determineMajorUnit(me._unit);
688688
me._table = buildLookupTable(getTimestampsForTable(me), min, max, distribution);
689-
me._offsets = computeOffsets(me._table, getDataTimestamps(me), min, max, options);
689+
me._offsets = computeOffsets(me._table, timestamps, min, max, options);
690690

691691
if (options.reverse) {
692692
ticks.reverse();
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
var date = moment('May 24 2020', 'MMM DD YYYY');
2+
3+
module.exports = {
4+
threshold: 0.05,
5+
config: {
6+
type: 'bar',
7+
data: {
8+
datasets: [{
9+
backgroundColor: 'rgba(255, 0, 0, 0.5)',
10+
data: [
11+
{
12+
x: date.clone().add(-2, 'day'),
13+
y: 20,
14+
},
15+
{
16+
x: date.clone().add(-1, 'day'),
17+
y: 30,
18+
},
19+
{
20+
x: date,
21+
y: 40,
22+
},
23+
{
24+
x: date.clone().add(1, 'day'),
25+
y: 50,
26+
},
27+
{
28+
x: date.clone().add(7, 'day'),
29+
y: 10,
30+
}
31+
]
32+
}]
33+
},
34+
options: {
35+
legend: false,
36+
scales: {
37+
x: {
38+
display: false,
39+
type: 'time',
40+
distribution: 'linear',
41+
ticks: {
42+
source: 'auto'
43+
},
44+
time: {
45+
unit: 'day'
46+
}
47+
},
48+
y: {
49+
display: false
50+
}
51+
}
52+
}
53+
},
54+
options: {
55+
spriteText: true
56+
}
57+
};
Loading

0 commit comments

Comments
 (0)