Skip to content

Commit

Permalink
Fixed issue #99 - minor ticks draw crash when minorTicks=0 for exact …
Browse files Browse the repository at this point in the history
…ticks linear gauges
  • Loading branch information
Mikhus committed Jan 10, 2017
1 parent dd6b3e2 commit df0be3e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gauge.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gauge.min.js.map

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions lib/LinearGauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,13 +761,14 @@ function drawLinearMinorTicks(context, options) {
let [hasLeft, hasRight] = drawings.prepareTicks(options);
let ticks = [];
let i = options.minValue;
let valuePerNonExactTick = (options.maxValue - options.minValue) /
(options.minorTicks * (options.majorTicks.length - 1));
let minTicks = Math.abs(options.minorTicks) || 0;
let valuePerNonExactTick = minTicks ? (options.maxValue - options.minValue) /
(minTicks * (options.majorTicks.length - 1)) : 0;

if (options.exactTicks) {
let delta = options.majorTicks[0] % options.minorTicks;
let delta = (options.majorTicks[0] % minTicks) || 0;

for (; i < options.maxValue; i += options.minorTicks) {
for (; i < options.maxValue; i += minTicks) {
ticks.push(delta + i);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test-coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit df0be3e

Please sign in to comment.