Skip to content

Commit 33cf742

Browse files
committed
fixup first month and improve test
1 parent 42d4d8d commit 33cf742

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

src/plots/cartesian/align_period.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function alignPeriod(trace, ax, axLetter, vals) {
4040
var dateStr = ms2DateTime(vals[i], 0, ax.calendar);
4141
var d = new Date(dateStr);
4242
var year = d.getFullYear();
43-
var month = d.getMonth();
43+
var month = d.getMonth() + 1;
4444

4545
var totalDaysInMonths = 0;
4646
for(var k = 0; k < period; k++) {
24.3 KB
Loading

test/image/mocks/period_positioning3.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
"x": ["2001-01-01", "2001-02-01", "2001-03-01", "2001-04-01"],
1111
"xperiodalignment": "middle"
1212
},
13+
{
14+
"xaxis": "x",
15+
"yaxis": "y",
16+
"xperiod": "M1",
17+
"name": "scatter (M1)",
18+
"type": "scatter",
19+
"y": [1, 2, 3, 4],
20+
"x": ["2001-01-01", "2001-02-01", "2001-03-01", "2001-04-01"],
21+
"xperiodalignment": "end"
22+
},
23+
1324
{
1425
"xaxis": "x2",
1526
"yaxis": "y2",
@@ -20,6 +31,16 @@
2031
"x": ["2001-01-01", "2001-03-01", "2001-05-01", "2001-07-01"],
2132
"xperiodalignment": "middle"
2233
},
34+
{
35+
"xaxis": "x2",
36+
"yaxis": "y2",
37+
"xperiod": "M2",
38+
"name": "scatter (M2)",
39+
"type": "scatter",
40+
"y": [1, 2, 3, 4],
41+
"x": ["2001-01-01", "2001-03-01", "2001-05-01", "2001-07-01"],
42+
"xperiodalignment": "end"
43+
},
2344

2445
{
2546
"xaxis": "x3",
@@ -31,6 +52,17 @@
3152
"x": ["2001-01-01", "2001-04-01", "2001-07-01", "2001-10-01"],
3253
"xperiodalignment": "middle"
3354
},
55+
{
56+
"xaxis": "x3",
57+
"yaxis": "y3",
58+
"xperiod": "M3",
59+
"name": "scatter (M3)",
60+
"type": "scatter",
61+
"y": [1, 2, 3, 4],
62+
"x": ["2001-01-01", "2001-04-01", "2001-07-01", "2001-10-01"],
63+
"xperiodalignment": "end"
64+
},
65+
3466
{
3567
"xaxis": "x4",
3668
"yaxis": "y4",
@@ -41,6 +73,17 @@
4173
"x": ["2001-01-01", "2001-07-01", "2002-01-01", "2002-07-01"],
4274
"xperiodalignment": "middle"
4375
},
76+
{
77+
"xaxis": "x4",
78+
"yaxis": "y4",
79+
"xperiod": "M6",
80+
"name": "scatter (M6)",
81+
"type": "scatter",
82+
"y": [1, 2, 3, 4],
83+
"x": ["2001-01-01", "2001-07-01", "2002-01-01", "2002-07-01"],
84+
"xperiodalignment": "end"
85+
},
86+
4487
{
4588
"xaxis": "x5",
4689
"yaxis": "y5",
@@ -51,6 +94,17 @@
5194
"x": ["2001-01-01", "2002-01-01", "2003-01-01", "2004-01-01"],
5295
"xperiodalignment": "middle"
5396
},
97+
{
98+
"xaxis": "x5",
99+
"yaxis": "y5",
100+
"xperiod": "M12",
101+
"name": "scatter (M12)",
102+
"type": "scatter",
103+
"y": [1, 2, 3, 4],
104+
"x": ["2001-01-01", "2002-01-01", "2003-01-01", "2004-01-01"],
105+
"xperiodalignment": "end"
106+
},
107+
54108
{
55109
"xaxis": "x6",
56110
"yaxis": "y6",
@@ -60,6 +114,16 @@
60114
"y": [1, 2, 3, 4],
61115
"x": ["2001-01-01", "2002-01-01", "2003-01-01", "2004-01-01"],
62116
"xperiodalignment": "middle"
117+
},
118+
{
119+
"xaxis": "x6",
120+
"yaxis": "y6",
121+
"xperiod": 31557600000,
122+
"name": "scatter (AVG-YEAR)",
123+
"type": "scatter",
124+
"y": [1, 2, 3, 4],
125+
"x": ["2001-01-01", "2002-01-01", "2003-01-01", "2004-01-01"],
126+
"xperiodalignment": "end"
63127
}
64128
],
65129
"layout": {

0 commit comments

Comments
 (0)