Skip to content

Commit

Permalink
init some vars (fixes a few NaNs and undefineds)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeoniya committed Oct 17, 2019
1 parent 1c29ef5 commit 9d71ac9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
12 changes: 9 additions & 3 deletions dist/uPlot.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ var max = M.max;
var pow = M.pow;
var log10 = M.log10;

var inf = Infinity;

/*
export function incrRound() {
return round(num/incr)*incr;
Expand Down Expand Up @@ -635,8 +637,8 @@ function uPlot(opts, data) {

if (!(key in scales)) {
scales[key] = {
min: Infinity,
max: -Infinity,
min: inf,
max: -inf,
};
}

Expand Down Expand Up @@ -700,7 +702,11 @@ function uPlot(opts, data) {

ctx.beginPath();

var prevX, minY, maxY, prevY, x, y, halfStroke = width/2;
var minY = inf,
maxY = -inf,
halfStroke = width/2,
prevX = halfStroke,
prevY, x, y;

for (var i = i0; i <= i1; i++) {
x = getXPos(xdata[i], scaleX, can[WIDTH]) + halfStroke;
Expand Down
12 changes: 9 additions & 3 deletions dist/uPlot.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ var uPlot = (function () {
var pow = M.pow;
var log10 = M.log10;

var inf = Infinity;

/*
export function incrRound() {
return round(num/incr)*incr;
Expand Down Expand Up @@ -636,8 +638,8 @@ var uPlot = (function () {

if (!(key in scales)) {
scales[key] = {
min: Infinity,
max: -Infinity,
min: inf,
max: -inf,
};
}

Expand Down Expand Up @@ -701,7 +703,11 @@ var uPlot = (function () {

ctx.beginPath();

var prevX, minY, maxY, prevY, x, y, halfStroke = width/2;
var minY = inf,
maxY = -inf,
halfStroke = width/2,
prevX = halfStroke,
prevY, x, y;

for (var i = i0; i <= i1; i++) {
x = getXPos(xdata[i], scaleX, can[WIDTH]) + halfStroke;
Expand Down
2 changes: 1 addition & 1 deletion dist/uPlot.iife.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/uPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from './fmtDate';

import {
inf,

abs,
floor,
round,
Expand Down Expand Up @@ -291,8 +293,8 @@ export default function uPlot(opts, data) {

if (!(key in scales)) {
scales[key] = {
min: Infinity,
max: -Infinity,
min: inf,
max: -inf,
};
}

Expand Down Expand Up @@ -356,7 +358,11 @@ export default function uPlot(opts, data) {

ctx.beginPath();

let prevX, minY, maxY, prevY, x, y, halfStroke = width/2;
let minY = inf,
maxY = -inf,
halfStroke = width/2,
prevX = halfStroke,
prevY, x, y;

for (let i = i0; i <= i1; i++) {
x = getXPos(xdata[i], scaleX, can[WIDTH]) + halfStroke;
Expand Down
2 changes: 2 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export const max = M.max;
export const pow = M.pow;
export const log10 = M.log10;

export const inf = Infinity;

/*
export function incrRound() {
return round(num/incr)*incr;
Expand Down

0 comments on commit 9d71ac9

Please sign in to comment.