pissang commented on a change in pull request #11479: fix(time): bar bandWidth
with time axis #11145
URL:
https://github.com/apache/incubator-echarts/pull/11479#discussion_r339529383
##########
File path: src/layout/barGrid.js
##########
@@ -115,28 +116,31 @@ function getTimeAxesMinGaps(barSeries) {
for (var i = 0, cnt = data.count(); i < cnt; ++i) {
var value = data.get(baseAxis.dim, i);
if (!axisValues[axisId]) {
- // No time value for the time axis
+ // No previous data for the axis
axisValues[axisId] = [value];
}
- else if (axisValues[axisId].indexOf(value) < 0) {
- // No time value in previous series
+ else {
+ // No value in previous series
axisValues[axisId].push(value);
}
- // Ignore duplicated time values in the same time axis
+ // Ignore duplicated time values in the same axis
}
});
var axisMinGaps = [];
for (var i = 0; i < axisValues.length; ++i) {
if (axisValues[i]) {
- // Sort time values into ascending order to calculate gaps
- axisValues[i] = axisValues[i].sort(function (a, b) {
+ // Sort axis values into ascending order to calculate gaps
+ axisValues[i].sort(function (a, b) {
return a - b;
});
var min = Number.MAX_VALUE;
for (var j = 1; j < axisValues[i].length; ++j) {
- min = Math.min(min, axisValues[i][j] - axisValues[i][j - 1]);
+ // Ignore 0 delta because they are of the same axis value
+ var delta = axisValues[i][j] - axisValues[i][j - 1];
+ delta = delta === 0 ? Number.MAX_VALUE : delta;
+ min = Math.min(min, delta);
Review comment:
I suggested changing these two lines to
```js
if (delta > 0) {
min = Math.min(min, delta)
}
```
to make it more clear and effecient.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]