Browse Source

fixed catch for undefined in options when using stacking in graph2d

v3_develop
Alex de Mulder 10 years ago
parent
commit
65664e178b
5 changed files with 197 additions and 88 deletions
  1. +178
    -69
      dist/vis.js
  2. +1
    -1
      dist/vis.map
  3. +13
    -14
      dist/vis.min.js
  4. +1
    -0
      lib/timeline/Core.js
  5. +4
    -4
      lib/timeline/component/LineGraph.js

+ 178
- 69
dist/vis.js View File

@ -1454,7 +1454,7 @@ return /******/ (function(modules) { // webpackBootstrap
/***/ function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(global, module) {//! moment.js
//! version : 2.8.4
//! version : 2.9.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
@ -1465,9 +1465,9 @@ return /******/ (function(modules) { // webpackBootstrap
************************************/
var moment,
VERSION = '2.8.4',
VERSION = '2.9.0',
// the global-scope this is NOT the global object in Node.js
globalScope = typeof global !== 'undefined' ? global : this,
globalScope = (typeof global !== 'undefined' && (typeof window === 'undefined' || window === global.window)) ? global : this,
oldGlobalMoment,
round = Math.round,
hasOwnProperty = Object.prototype.hasOwnProperty,
@ -1544,7 +1544,7 @@ return /******/ (function(modules) { // webpackBootstrap
['HH', /(T| )\d\d/]
],
// timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-15', '30']
// timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-', '15', '30']
parseTimezoneChunker = /([\+\-]|\d\d)/gi,
// getter and setter names
@ -1704,7 +1704,7 @@ return /******/ (function(modules) { // webpackBootstrap
return leftZeroFill(this.milliseconds(), 3);
},
Z : function () {
var a = -this.zone(),
var a = this.utcOffset(),
b = '+';
if (a < 0) {
a = -a;
@ -1713,7 +1713,7 @@ return /******/ (function(modules) { // webpackBootstrap
return b + leftZeroFill(toInt(a / 60), 2) + ':' + leftZeroFill(toInt(a) % 60, 2);
},
ZZ : function () {
var a = -this.zone(),
var a = this.utcOffset(),
b = '+';
if (a < 0) {
a = -a;
@ -1740,7 +1740,9 @@ return /******/ (function(modules) { // webpackBootstrap
deprecations = {},
lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'];
lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'],
updateInProgress = false;
// Pick the first defined of two or three arguments. dfl comes from
// default.
@ -1809,6 +1811,26 @@ return /******/ (function(modules) { // webpackBootstrap
};
}
function monthDiff(a, b) {
// difference in months
var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
// b is in (anchor - 1 month, anchor + 1 month)
anchor = a.clone().add(wholeMonthDiff, 'months'),
anchor2, adjust;
if (b - anchor < 0) {
anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor - anchor2);
} else {
anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor2 - anchor);
}
return -(wholeMonthDiff + adjust);
}
while (ordinalizeTokens.length) {
i = ordinalizeTokens.pop();
formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i);
@ -1820,6 +1842,31 @@ return /******/ (function(modules) { // webpackBootstrap
formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);
function meridiemFixWrap(locale, hour, meridiem) {
var isPm;
if (meridiem == null) {
// nothing to do
return hour;
}
if (locale.meridiemHour != null) {
return locale.meridiemHour(hour, meridiem);
} else if (locale.isPM != null) {
// Fallback
isPm = locale.isPM(meridiem);
if (isPm && hour < 12) {
hour += 12;
}
if (!isPm && hour === 12) {
hour = 0;
}
return hour;
} else {
// thie is not supposed to happen
return hour;
}
}
/************************************
Constructors
************************************/
@ -1834,6 +1881,13 @@ return /******/ (function(modules) { // webpackBootstrap
}
copyConfig(this, config);
this._d = new Date(+config._d);
// Prevent infinite loop in case updateOffset creates new moment
// objects.
if (updateInProgress === false) {
updateInProgress = true;
moment.updateOffset(this);
updateInProgress = false;
}
}
// Duration Constructor
@ -2237,7 +2291,8 @@ return /******/ (function(modules) { // webpackBootstrap
return locales[name];
}
// Return a moment from input, that is local/utc/zone equivalent to model.
// Return a moment from input, that is local/utc/utcOffset equivalent to
// model.
function makeAs(input, model) {
var res, diff;
if (model._isUTC) {
@ -2386,6 +2441,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
},
_calendar : {
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
@ -2450,6 +2506,14 @@ return /******/ (function(modules) { // webpackBootstrap
doy : 6 // The week that contains Jan 1st is the first week of the year.
},
firstDayOfWeek : function () {
return this._week.dow;
},
firstDayOfYear : function () {
return this._week.doy;
},
_invalidDate: 'Invalid date',
invalidDate: function () {
return this._invalidDate;
@ -2616,14 +2680,14 @@ return /******/ (function(modules) { // webpackBootstrap
}
}
function timezoneMinutesFromString(string) {
function utcOffsetFromString(string) {
string = string || '';
var possibleTzMatches = (string.match(parseTokenTimezone) || []),
tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [],
parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
minutes = +(parts[1] * 60) + toInt(parts[2]);
return parts[0] === '+' ? -minutes : minutes;
return parts[0] === '+' ? minutes : -minutes;
}
// function to convert string input to date
@ -2687,7 +2751,8 @@ return /******/ (function(modules) { // webpackBootstrap
// AM / PM
case 'a' : // fall through to A
case 'A' :
config._isPm = config._locale.isPM(input);
config._meridiem = input;
// config._isPm = config._locale.isPM(input);
break;
// HOUR
case 'h' : // fall through to hh
@ -2727,7 +2792,7 @@ return /******/ (function(modules) { // webpackBootstrap
case 'Z' : // fall through to ZZ
case 'ZZ' :
config._useUTC = true;
config._tzm = timezoneMinutesFromString(input);
config._tzm = utcOffsetFromString(input);
break;
// WEEKDAY - human
case 'dd':
@ -2865,10 +2930,10 @@ return /******/ (function(modules) { // webpackBootstrap
}
config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input);
// Apply timezone offset from input. The actual zone can be changed
// Apply timezone offset from input. The actual utcOffset can be changed
// with parseZone.
if (config._tzm != null) {
config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm);
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
}
if (config._nextDay) {
@ -2964,14 +3029,9 @@ return /******/ (function(modules) { // webpackBootstrap
if (config._pf.bigHour === true && config._a[HOUR] <= 12) {
config._pf.bigHour = undefined;
}
// handle am pm
if (config._isPm && config._a[HOUR] < 12) {
config._a[HOUR] += 12;
}
// if is 12 am, change hours to 0
if (config._isPm === false && config._a[HOUR] === 12) {
config._a[HOUR] = 0;
}
// handle meridiem
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR],
config._meridiem);
dateFromConfig(config);
checkOverflow(config);
}
@ -3413,6 +3473,8 @@ return /******/ (function(modules) { // webpackBootstrap
s: parseIso(match[7]),
w: parseIso(match[8])
};
} else if (duration == null) {// checks for null or undefined
duration = {};
} else if (typeof duration === 'object' &&
('from' in duration || 'to' in duration)) {
diffRes = momentsDifference(moment(duration.from), moment(duration.to));
@ -3577,6 +3639,8 @@ return /******/ (function(modules) { // webpackBootstrap
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
};
moment.isDate = isDate;
/************************************
Moment Prototype
************************************/
@ -3589,7 +3653,7 @@ return /******/ (function(modules) { // webpackBootstrap
},
valueOf : function () {
return +this._d + ((this._offset || 0) * 60000);
return +this._d - ((this._offset || 0) * 60000);
},
unix : function () {
@ -3652,16 +3716,16 @@ return /******/ (function(modules) { // webpackBootstrap
},
utc : function (keepLocalTime) {
return this.zone(0, keepLocalTime);
return this.utcOffset(0, keepLocalTime);
},
local : function (keepLocalTime) {
if (this._isUTC) {
this.zone(0, keepLocalTime);
this.utcOffset(0, keepLocalTime);
this._isUTC = false;
if (keepLocalTime) {
this.add(this._dateTzOffset(), 'm');
this.subtract(this._dateUtcOffset(), 'm');
}
}
return this;
@ -3678,29 +3742,20 @@ return /******/ (function(modules) { // webpackBootstrap
diff : function (input, units, asFloat) {
var that = makeAs(input, this),
zoneDiff = (this.zone() - that.zone()) * 6e4,
diff, output, daysAdjust;
zoneDiff = (that.utcOffset() - this.utcOffset()) * 6e4,
anchor, diff, output, daysAdjust;
units = normalizeUnits(units);
if (units === 'year' || units === 'month') {
// average number of days in the months in the given dates
diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2
// difference in months
output = ((this.year() - that.year()) * 12) + (this.month() - that.month());
// adjust by taking difference in days, average number of days
// and dst in the given months.
daysAdjust = (this - moment(this).startOf('month')) -
(that - moment(that).startOf('month'));
// same as above but with zones, to negate all dst
daysAdjust -= ((this.zone() - moment(this).startOf('month').zone()) -
(that.zone() - moment(that).startOf('month').zone())) * 6e4;
output += daysAdjust / diff;
if (units === 'year') {
if (units === 'year' || units === 'month' || units === 'quarter') {
output = monthDiff(this, that);
if (units === 'quarter') {
output = output / 3;
} else if (units === 'year') {
output = output / 12;
}
} else {
diff = (this - that);
diff = this - that;
output = units === 'second' ? diff / 1e3 : // 1000
units === 'minute' ? diff / 6e4 : // 1000 * 60
units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60
@ -3721,7 +3776,8 @@ return /******/ (function(modules) { // webpackBootstrap
calendar : function (time) {
// We want to compare the start of today, vs this.
// Getting start-of-today depends on whether we're zone'd or not.
// Getting start-of-today depends on whether we're locat/utc/offset
// or not.
var now = time || moment(),
sod = makeAs(now, this).startOf('day'),
diff = this.diff(sod, 'days', true),
@ -3739,8 +3795,8 @@ return /******/ (function(modules) { // webpackBootstrap
},
isDST : function () {
return (this.zone() < this.clone().month(0).zone() ||
this.zone() < this.clone().month(5).zone());
return (this.utcOffset() > this.clone().month(0).utcOffset() ||
this.utcOffset() > this.clone().month(5).utcOffset());
},
day : function (input) {
@ -3830,6 +3886,10 @@ return /******/ (function(modules) { // webpackBootstrap
}
},
isBetween: function (from, to, units) {
return this.isAfter(from, units) && this.isBefore(to, units);
},
isSame: function (input, units) {
var inputMs;
units = normalizeUnits(units || 'millisecond');
@ -3858,9 +3918,27 @@ return /******/ (function(modules) { // webpackBootstrap
}
),
zone : deprecate(
'moment().zone is deprecated, use moment().utcOffset instead. ' +
'https://github.com/moment/moment/issues/1779',
function (input, keepLocalTime) {
if (input != null) {
if (typeof input !== 'string') {
input = -input;
}
this.utcOffset(input, keepLocalTime);
return this;
} else {
return -this.utcOffset();
}
}
),
// keepLocalTime = true means only change the timezone, without
// affecting the local hour. So 5:31:26 +0300 --[zone(2, true)]-->
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist int zone
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
// +0200, so we adjust the time as needed, to be valid.
//
// Keeping the time actually adds/subtracts (one hour)
@ -3868,38 +3946,51 @@ return /******/ (function(modules) { // webpackBootstrap
// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
zone : function (input, keepLocalTime) {
utcOffset : function (input, keepLocalTime) {
var offset = this._offset || 0,
localAdjust;
if (input != null) {
if (typeof input === 'string') {
input = timezoneMinutesFromString(input);
input = utcOffsetFromString(input);
}
if (Math.abs(input) < 16) {
input = input * 60;
}
if (!this._isUTC && keepLocalTime) {
localAdjust = this._dateTzOffset();
localAdjust = this._dateUtcOffset();
}
this._offset = input;
this._isUTC = true;
if (localAdjust != null) {
this.subtract(localAdjust, 'm');
this.add(localAdjust, 'm');
}
if (offset !== input) {
if (!keepLocalTime || this._changeInProgress) {
addOrSubtractDurationFromMoment(this,
moment.duration(offset - input, 'm'), 1, false);
moment.duration(input - offset, 'm'), 1, false);
} else if (!this._changeInProgress) {
this._changeInProgress = true;
moment.updateOffset(this, true);
this._changeInProgress = null;
}
}
return this;
} else {
return this._isUTC ? offset : this._dateTzOffset();
return this._isUTC ? offset : this._dateUtcOffset();
}
return this;
},
isLocal : function () {
return !this._isUTC;
},
isUtcOffset : function () {
return this._isUTC;
},
isUtc : function () {
return this._isUTC && this._offset === 0;
},
zoneAbbr : function () {
@ -3912,9 +4003,9 @@ return /******/ (function(modules) { // webpackBootstrap
parseZone : function () {
if (this._tzm) {
this.zone(this._tzm);
this.utcOffset(this._tzm);
} else if (typeof this._i === 'string') {
this.zone(this._i);
this.utcOffset(utcOffsetFromString(this._i));
}
return this;
},
@ -3924,10 +4015,10 @@ return /******/ (function(modules) { // webpackBootstrap
input = 0;
}
else {
input = moment(input).zone();
input = moment(input).utcOffset();
}
return (this.zone() - input) % 60 === 0;
return (this.utcOffset() - input) % 60 === 0;
},
daysInMonth : function () {
@ -3990,9 +4081,17 @@ return /******/ (function(modules) { // webpackBootstrap
},
set : function (units, value) {
units = normalizeUnits(units);
if (typeof this[units] === 'function') {
this[units](value);
var unit;
if (typeof units === 'object') {
for (unit in units) {
this.set(unit, units[unit]);
}
}
else {
units = normalizeUnits(units);
if (typeof this[units] === 'function') {
this[units](value);
}
}
return this;
},
@ -4029,11 +4128,12 @@ return /******/ (function(modules) { // webpackBootstrap
return this._locale;
},
_dateTzOffset : function () {
_dateUtcOffset : function () {
// On Firefox.24 Date#getTimezoneOffset returns a floating point.
// https://github.com/moment/moment/pull/1871
return Math.round(this._d.getTimezoneOffset() / 15) * 15;
return -Math.round(this._d.getTimezoneOffset() / 15) * 15;
}
});
function rawMonthSetter(mom, value) {
@ -4102,6 +4202,9 @@ return /******/ (function(modules) { // webpackBootstrap
// add aliased format methods
moment.fn.toJSON = moment.fn.toISOString;
// alias isUtc for dev-friendliness
moment.fn.isUTC = moment.fn.isUtc;
/************************************
Duration Prototype
************************************/
@ -4289,6 +4392,10 @@ return /******/ (function(modules) { // webpackBootstrap
localeData : function () {
return this._locale;
},
toJSON : function () {
return this.toISOString();
}
});
@ -13906,6 +14013,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
else {
console.log('WARNING: infinite loop in redraw?')
throw new Error("bla")
}
this.redrawCount = 0;
}
@ -19008,7 +19116,8 @@ return /******/ (function(modules) { // webpackBootstrap
};
TimeStep.prototype.getClassName = function() {
var date = moment(this.current).locale('en');
var m = moment(this.current);
var date = m.locale ? m.locale('en') : m.lang('en'); // old versions of moment have .lang() function
var step = this.step;
function even(value) {
@ -20563,12 +20672,12 @@ return /******/ (function(modules) { // webpackBootstrap
// this is here to make sure that if there are no items in the axis but there are groups, that there is no infinite draw/redraw loop.
for (var i = 0; i < groupIds.length; i++) {
var group = this.groups[groupIds[i]];
if (group && group.options.yAxisOrientation == 'left') {
if (group && group.options.yAxisOrientation != 'right') {
yAxisLeftUsed = true;
minLeft = 0;
maxLeft = 0;
}
else {
else if (group && group.options.yAxisOrientation) {
yAxisRightUsed = true;
minRight = 0;
maxRight = 0;
@ -20582,7 +20691,7 @@ return /******/ (function(modules) { // webpackBootstrap
minVal = groupRanges[groupIds[i]].min;
maxVal = groupRanges[groupIds[i]].max;
if (groupRanges[groupIds[i]].yAxisOrientation == 'left') {
if (groupRanges[groupIds[i]].yAxisOrientation != 'right') {
yAxisLeftUsed = true;
minLeft = minLeft > minVal ? minVal : minLeft;
maxLeft = maxLeft < maxVal ? maxVal : maxLeft;
@ -20605,6 +20714,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
resized = this._toggleAxisVisiblity(yAxisLeftUsed , this.yAxisLeft) || resized;
resized = this._toggleAxisVisiblity(yAxisRightUsed, this.yAxisRight) || resized;
if (yAxisRightUsed == true && yAxisLeftUsed == true) {
this.yAxisLeft.drawIcons = true;
this.yAxisRight.drawIcons = true;
@ -20614,7 +20724,6 @@ return /******/ (function(modules) { // webpackBootstrap
this.yAxisRight.drawIcons = false;
}
this.yAxisRight.master = !yAxisLeftUsed;
if (this.yAxisRight.master == false) {
if (yAxisRightUsed == true) {this.yAxisLeft.lineOffset = this.yAxisRight.width;}
else {this.yAxisLeft.lineOffset = 0;}

+ 1
- 1
dist/vis.map
File diff suppressed because it is too large
View File


+ 13
- 14
dist/vis.min.js
File diff suppressed because it is too large
View File


+ 1
- 0
lib/timeline/Core.js View File

@ -615,6 +615,7 @@ Core.prototype.redraw = function() {
}
else {
console.log('WARNING: infinite loop in redraw?')
throw new Error("bla")
}
this.redrawCount = 0;
}

+ 4
- 4
lib/timeline/component/LineGraph.js View File

@ -833,12 +833,12 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
// this is here to make sure that if there are no items in the axis but there are groups, that there is no infinite draw/redraw loop.
for (var i = 0; i < groupIds.length; i++) {
var group = this.groups[groupIds[i]];
if (group && group.options.yAxisOrientation == 'left') {
if (group && group.options.yAxisOrientation != 'right') {
yAxisLeftUsed = true;
minLeft = 0;
maxLeft = 0;
}
else {
else if (group && group.options.yAxisOrientation) {
yAxisRightUsed = true;
minRight = 0;
maxRight = 0;
@ -852,7 +852,7 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
minVal = groupRanges[groupIds[i]].min;
maxVal = groupRanges[groupIds[i]].max;
if (groupRanges[groupIds[i]].yAxisOrientation == 'left') {
if (groupRanges[groupIds[i]].yAxisOrientation != 'right') {
yAxisLeftUsed = true;
minLeft = minLeft > minVal ? minVal : minLeft;
maxLeft = maxLeft < maxVal ? maxVal : maxLeft;
@ -875,6 +875,7 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
}
resized = this._toggleAxisVisiblity(yAxisLeftUsed , this.yAxisLeft) || resized;
resized = this._toggleAxisVisiblity(yAxisRightUsed, this.yAxisRight) || resized;
if (yAxisRightUsed == true && yAxisLeftUsed == true) {
this.yAxisLeft.drawIcons = true;
this.yAxisRight.drawIcons = true;
@ -884,7 +885,6 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
this.yAxisRight.drawIcons = false;
}
this.yAxisRight.master = !yAxisLeftUsed;
if (this.yAxisRight.master == false) {
if (yAxisRightUsed == true) {this.yAxisLeft.lineOffset = this.yAxisRight.width;}
else {this.yAxisLeft.lineOffset = 0;}

Loading…
Cancel
Save