@@ -78,9 +78,12 @@ charts or filled areas).
78
78
i = 0 , j = 0 , l , m ;
79
79
80
80
while ( true ) {
81
+ // browse all points from the current series and from the previous series
81
82
if ( i >= points . length && j >= otherpoints . length )
82
83
break ;
83
84
85
+ // newpoints will replace current series with
86
+ // as many points as different timestamps we have in the 2 (current & previous) series
84
87
l = newpoints . length ;
85
88
px = points [ i + keyOffset ] ;
86
89
py = points [ i + accumulateOffset ] ;
@@ -89,30 +92,32 @@ charts or filled areas).
89
92
bottom = 0 ;
90
93
91
94
if ( i < points . length && px == null ) {
92
- // ignore point
95
+ // let's ignore null points from current series, nothing to do with them
93
96
i += ps ;
94
97
}
95
98
else if ( j < otherpoints . length && qx == null ) {
96
- // ignore point
99
+ // let's ignore null points from previous series, nothing to do with them
97
100
j += otherps ;
98
101
}
99
102
else if ( i >= points . length ) {
100
- // take the remaining points from the previous series
103
+ // no more points in the current series, simply take the remaining points
104
+ // from the previous series so that next series will correctly stack
101
105
for ( m = 0 ; m < ps ; ++ m )
102
106
newpoints . push ( otherpoints [ j + m ] ) ;
103
107
bottom = qy ;
104
108
j += otherps ;
105
109
}
106
110
else if ( j >= otherpoints . length ) {
107
- // take the remaining points from the current series
111
+ // no more points in the previous series, of course let's take
112
+ // the remaining points from the current series
108
113
for ( m = 0 ; m < ps ; ++ m )
109
114
newpoints . push ( points [ i + m ] ) ;
110
115
i += ps ;
111
116
}
112
117
else {
113
- // cases where we actually got two points
118
+ // next available points from current and previous series have the same timestamp
114
119
if ( px == qx ) {
115
- // take the point from the current series and skip the previous' one
120
+ // so take the point from the current series and skip the previous' one
116
121
for ( m = 0 ; m < ps ; ++ m )
117
122
newpoints . push ( points [ i + m ] ) ;
118
123
@@ -122,8 +127,9 @@ charts or filled areas).
122
127
i += ps ;
123
128
j += otherps ;
124
129
}
130
+ // next available point with the smallest timestamp is from the previous series
125
131
else if ( px > qx ) {
126
- // take the point from the previous series so that the next series can stack over it
132
+ // so take the point from the previous series so that next series will correctly stack
127
133
for ( m = 0 ; m < ps ; ++ m )
128
134
newpoints . push ( otherpoints [ j + m ] ) ;
129
135
@@ -135,8 +141,9 @@ charts or filled areas).
135
141
136
142
j += otherps ;
137
143
}
138
- else { // px < qx
139
- // take the point from the current series
144
+ // (px < qx) next available point with the smallest timestamp is from the current series
145
+ else {
146
+ // so of course let's take the point from the current series
140
147
for ( m = 0 ; m < ps ; ++ m )
141
148
newpoints . push ( points [ i + m ] ) ;
142
149
0 commit comments