New eslint rules auto fix (#3058)

* no-implicit-coercion and no-unneeded-ternary

* End every line with a semicolon

* Spacing and formatting

* Enabled semi-spacing

* Applies npm run lint:fix to code after master merge

* Fix merge issues

* Switched operator-linebreak to 'before'

Co-authored-by: Joshi <simplyrender@gmail.com>
This commit is contained in:
Andrew Henry
2020-07-31 12:11:03 -07:00
committed by GitHub
parent 573a63d359
commit a09da30768
739 changed files with 4660 additions and 2339 deletions

View File

@ -71,6 +71,7 @@ define([
if (installed) {
return;
}
installed = true;
openmct.legacyRegistry.register("openmct/plot", {

View File

@ -38,8 +38,8 @@ define(
var adaptedObject = domainObject.useCapability('adapter');
if (!adaptedObject.telemetry) {
return domainObject.hasCapability('delegation') &&
domainObject.getCapability('delegation')
return domainObject.hasCapability('delegation')
&& domainObject.getCapability('delegation')
.doesDelegateCapability('telemetry');
}
@ -48,6 +48,7 @@ define(
if (rangeValues.length === 0) {
return false;
}
return !rangeValues.every(function (value) {
return value.format === 'string';
});

View File

@ -68,8 +68,6 @@ define([
this.stopListening();
};
eventHelpers.extend(MCTChartAlarmPointSet.prototype);
return MCTChartAlarmPointSet;

View File

@ -74,7 +74,7 @@ function (
this.$scope.$watch('highlights', this.scheduleDraw);
this.$scope.$watch('rectangles', this.scheduleDraw);
this.config.series.forEach(this.onSeriesAdd, this);
}
};
}
eventHelpers.extend(MCTChartController.prototype);
@ -94,6 +94,7 @@ function (
if (mode === o) {
return;
}
var elements = this.seriesElements.get(series);
elements.lines.forEach(function (line) {
this.lines.splice(this.lines.indexOf(line), 1);
@ -112,11 +113,13 @@ function (
if (mode === o) {
return;
}
var elements = this.seriesElements.get(series);
if (elements.alarmSet) {
elements.alarmSet.destroy();
this.alarmSets.splice(this.alarmSets.indexOf(elements.alarmSet), 1);
}
elements.alarmSet = this.alarmPointSetForSeries(series);
if (elements.alarmSet) {
this.alarmSets.push(elements.alarmSet);
@ -127,6 +130,7 @@ function (
if (mode === o) {
return;
}
var elements = this.seriesElements.get(series);
elements.pointSets.forEach(function (pointSet) {
this.pointSets.splice(this.pointSets.indexOf(pointSet), 1);
@ -200,7 +204,8 @@ function (
if (this.drawAPI) {
this.listenTo(this.drawAPI, 'error', this.fallbackToCanvas, this);
}
return !!this.drawAPI;
return Boolean(this.drawAPI);
};
MCTChartController.prototype.fallbackToCanvas = function () {
@ -235,6 +240,7 @@ function (
elements.alarmSet.destroy();
this.alarmSets.splice(this.alarmSets.indexOf(elements.alarmSet), 1);
}
this.seriesElements.delete(series);
};
@ -246,6 +252,7 @@ function (
this.offset
);
}
if (series.get('interpolate') === 'stepAfter') {
return new MCTChartLineStepAfter(
series,
@ -305,6 +312,7 @@ function (
if (!this.offset.x || !this.offset.y) {
return false;
}
return true;
};
@ -320,6 +328,7 @@ function (
if (this.isDestroyed) {
return;
}
this.drawAPI.clear();
if (this.canDraw()) {
this.updateViewport();

View File

@ -37,12 +37,14 @@ define([
if (index === 0 && this.count === 0) {
return 2;
}
return 4;
},
startIndexForPointAtIndex: function (index) {
if (index === 0) {
return 0;
}
return 2 + ((index - 1) * 4);
},
addPoint: function (point, start, count) {

View File

@ -53,6 +53,7 @@ define([
this.buffer = new Float32Array(this.buffer);
this.isTempBuffer = false;
}
return this.buffer;
};
@ -100,6 +101,7 @@ define([
if (!this.offset.xVal) {
this.chart.setOffset(point, undefined, series);
}
return {
x: this.offset.xVal(point, series),
y: this.offset.yVal(point, series)
@ -125,6 +127,7 @@ define([
this.buffer = Array.prototype.slice.apply(this.buffer);
this.isTempBuffer = true;
}
var target = insertionPoint + pointsRequired,
start = insertionPoint;
for (; start < target; start++) {

View File

@ -39,6 +39,7 @@ define([
} else {
this.models = [];
}
this.initialize(options);
}
@ -56,9 +57,11 @@ define([
Collection.prototype.modelFn = function (model) {
if (model instanceof this.modelClass) {
model.collection = this;
return model;
}
return new this.modelClass({
collection: this,
model: model

View File

@ -37,6 +37,7 @@ define([
if (!options) {
options = {};
}
this.id = options.id;
this.model = options.model;
this.collection = options.collection;
@ -46,6 +47,7 @@ define([
} else {
_.defaultsDeep(this.model, defaults);
}
this.initialize(options);
}

View File

@ -96,9 +96,10 @@ define([
if (!domainObject.configuration || !domainObject.configuration.series) {
return;
}
return domainObject.configuration.series.filter(function (seriesConfig) {
return seriesConfig.identifier.key === identifier.key &&
seriesConfig.identifier.namespace === identifier.namespace;
return seriesConfig.identifier.key === identifier.key
&& seriesConfig.identifier.namespace === identifier.namespace;
})[0];
},
/**

View File

@ -99,6 +99,7 @@ define([
*/
defaults: function (options) {
var range = this.metadata.valuesForHints(['range'])[0];
return {
name: options.domainObject.name,
xKey: options.collection.plot.xAxis.get('key'),
@ -150,7 +151,11 @@ define([
strategy = 'minmax';
}
options = Object.assign({}, { size: 1000, strategy, filters: this.filters }, options || {});
options = Object.assign({}, {
size: 1000,
strategy,
filters: this.filters
}, options || {});
if (!this.unsubscribe) {
this.unsubscribe = this.openmct
@ -193,6 +198,7 @@ define([
if (newKey === oldKey) {
return;
}
var valueMetadata = this.metadata.value(newKey);
if (!this.persistedConfig || !this.persistedConfig.interpolate) {
if (valueMetadata.format === 'enum') {
@ -201,6 +207,7 @@ define([
this.set('interpolate', 'linear');
}
}
this.evaluate = function (datum) {
return this.limitEvaluator.evaluate(datum, valueMetadata);
}.bind(this);
@ -246,12 +253,12 @@ define([
lowPoint = this.data[insertIndex - 1],
highPoint = this.data[insertIndex],
indexVal = this.getXVal(xValue),
lowDistance = lowPoint ?
indexVal - this.getXVal(lowPoint) :
Number.POSITIVE_INFINITY,
highDistance = highPoint ?
this.getXVal(highPoint) - indexVal :
Number.POSITIVE_INFINITY,
lowDistance = lowPoint
? indexVal - this.getXVal(lowPoint)
: Number.POSITIVE_INFINITY,
highDistance = highPoint
? this.getXVal(highPoint) - indexVal
: Number.POSITIVE_INFINITY,
nearestPoint = highDistance < lowDistance ? highPoint : lowPoint;
return nearestPoint;
@ -267,6 +274,7 @@ define([
return this.fetch(options)
.then(function (res) {
this.emit('load');
return res;
}.bind(this));
},
@ -300,12 +308,14 @@ define([
stats.maxPoint = point;
changed = true;
}
if (stats.minValue > value) {
stats.minValue = value;
stats.minPoint = point;
changed = true;
}
}
if (changed) {
this.set('stats', {
minValue: stats.minValue,
@ -334,6 +344,7 @@ define([
if (this.isValueInvalid(currentYVal) && this.isValueInvalid(lastYVal)) {
console.warn('[Plot] Invalid Y Values detected');
return;
}
@ -342,6 +353,7 @@ define([
if (this.getXVal(this.data[insertIndex]) === this.getXVal(point)) {
return;
}
if (this.getXVal(this.data[insertIndex - 1]) === this.getXVal(point)) {
return;
}
@ -410,6 +422,7 @@ define([
this.unsubscribe();
delete this.unsubscribe;
}
this.fetch();
} else {
this.filters = deepCopiedFilters;

View File

@ -84,6 +84,7 @@ define([
.getPersistedSeriesConfig(domainObject.identifier);
}
}
// Clone to prevent accidental mutation by ref.
seriesConfig = JSON.parse(JSON.stringify(seriesConfig));
@ -136,10 +137,12 @@ define([
seriesColor = color.Color.fromHexString(seriesColor);
series.set('color', seriesColor);
}
this.palette.remove(seriesColor);
} else {
series.set('color', this.palette.getNextColor());
}
this.listenTo(series, 'change:color', this.updateColorPalette, this);
},
onSeriesRemove: function (series) {
@ -159,8 +162,9 @@ define([
byIdentifier: function (identifier) {
return this.filter(function (series) {
var seriesIdentifier = series.get('identifier');
return seriesIdentifier.namespace === identifier.namespace &&
seriesIdentifier.key === identifier.key;
return seriesIdentifier.namespace === identifier.namespace
&& seriesIdentifier.key === identifier.key;
})[0];
}
});

View File

@ -47,6 +47,7 @@ define([
if (this.get('range')) {
this.set('range', this.get('range'));
}
this.listenTo(this, 'change:key', this.changeKey, this);
},
changeKey: function (newKey) {
@ -62,6 +63,7 @@ define([
});
this.set('label', newKey);
}
this.plot.series.forEach(function (plotSeries) {
plotSeries.set('xKey', newKey);
plotSeries.reset();

View File

@ -86,6 +86,7 @@ define([
if (padding === 0) {
padding = 1;
}
return {
min: range.min - padding,
max: range.max + padding
@ -111,18 +112,22 @@ define([
min: seriesStats.minValue,
max: seriesStats.maxValue
});
return;
}
var stats = this.get('stats');
var changed = false;
if (stats.min > seriesStats.minValue) {
changed = true;
stats.min = seriesStats.minValue;
}
if (stats.max < seriesStats.maxValue) {
changed = true;
stats.max = seriesStats.maxValue;
}
if (changed) {
this.set('stats', {
min: stats.min,
@ -173,6 +178,7 @@ define([
if (!label) {
this.unset('label');
}
return;
}
@ -188,14 +194,17 @@ define([
if (a === undefined) {
return b;
}
if (a === b) {
return a;
}
return '';
}, undefined);
if (labelName) {
this.set('label', labelName);
return;
}
@ -205,14 +214,17 @@ define([
if (a === undefined) {
return b;
}
if (a === b) {
return a;
}
return '';
}, undefined);
if (labelUnits) {
this.set('label', labelUnits);
return;
}
}

View File

@ -20,7 +20,6 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'EventEmitter',
'../lib/eventHelpers',
@ -61,8 +60,8 @@ define([
// Convert from logical to physical y coordinates
Draw2D.prototype.y = function (v) {
return this.height -
((v - this.origin[1]) / this.dimensions[1]) * this.height;
return this.height
- ((v - this.origin[1]) / this.dimensions[1]) * this.height;
};
// Set the color to be used for drawing operations
@ -74,7 +73,6 @@ define([
this.c2d.fillStyle = "rgba(" + mappedColor + ")";
};
Draw2D.prototype.clear = function () {
this.width = this.canvas.width = this.canvas.offsetWidth;
this.height = this.canvas.height = this.canvas.offsetHeight;
@ -161,6 +159,5 @@ define([
}
};
return Draw2D;
});

View File

@ -60,10 +60,12 @@ define(
if (api) {
return;
}
if (CHART_TYPE.ALLOCATIONS.length >=
CHART_TYPE.MAX_INSTANCES) {
if (CHART_TYPE.ALLOCATIONS.length
>= CHART_TYPE.MAX_INSTANCES) {
return;
}
try {
api = new CHART_TYPE.API(canvas, overlay);
CHART_TYPE.ALLOCATIONS.push(api);
@ -80,6 +82,7 @@ define(
if (!api) {
console.warn("Cannot initialize mct-chart.");
}
return api;
},
@ -89,6 +92,7 @@ define(
getFallbackDrawAPI: function (canvas, overlay) {
var api = new CHARTS[1].API(canvas, overlay);
CHARTS[1].ALLOCATIONS.push(api);
return api;
},

View File

@ -20,7 +20,6 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'EventEmitter',
'../lib/eventHelpers',
@ -91,8 +90,8 @@ define([
*/
function DrawWebGL(canvas, overlay) {
this.canvas = canvas;
this.gl = this.canvas.getContext("webgl", { preserveDrawingBuffer: true }) ||
this.canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true });
this.gl = this.canvas.getContext("webgl", { preserveDrawingBuffer: true })
|| this.canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true });
this.overlay = overlay;
this.c2d = overlay.getContext('2d');
@ -167,8 +166,8 @@ define([
// Convert from logical to physical y coordinates
DrawWebGL.prototype.y = function (v) {
return this.height -
((v - this.origin[1]) / this.dimensions[1]) * this.height;
return this.height
- ((v - this.origin[1]) / this.dimensions[1]) * this.height;
};
DrawWebGL.prototype.doDraw = function (drawType, buf, color, points, shape) {
@ -182,7 +181,7 @@ define([
this.gl.bufferData(this.gl.ARRAY_BUFFER, buf, this.gl.DYNAMIC_DRAW);
this.gl.vertexAttribPointer(this.aVertexPosition, 2, this.gl.FLOAT, false, 0, 0);
this.gl.uniform4fv(this.uColor, color);
this.gl.uniform1i(this.uMarkerShape, shapeCode)
this.gl.uniform1i(this.uMarkerShape, shapeCode);
this.gl.drawArrays(drawType, 0, points);
};
@ -190,6 +189,7 @@ define([
if (this.isContextLost) {
return;
}
this.height = this.canvas.height = this.canvas.offsetHeight;
this.width = this.canvas.width = this.canvas.offsetWidth;
this.overlay.height = this.overlay.offsetHeight;
@ -219,8 +219,9 @@ define([
if (this.isContextLost) {
return;
}
if (dimensions && dimensions.length > 0 &&
origin && origin.length > 0) {
if (dimensions && dimensions.length > 0
&& origin && origin.length > 0) {
this.gl.uniform2fv(this.uDimensions, dimensions);
this.gl.uniform2fv(this.uOrigin, origin);
}
@ -240,6 +241,7 @@ define([
if (this.isContextLost) {
return;
}
this.doDraw(this.gl.LINE_STRIP, buf, color, points);
};
@ -251,6 +253,7 @@ define([
if (this.isContextLost) {
return;
}
this.gl.uniform1f(this.uPointSize, pointSize);
this.doDraw(this.gl.POINTS, buf, color, points, shape);
};
@ -268,6 +271,7 @@ define([
if (this.isContextLost) {
return;
}
this.doDraw(this.gl.TRIANGLE_FAN, new Float32Array(
min.concat([min[0], max[1]]).concat(max).concat([max[0], min[1]])
), color, 4);

View File

@ -20,7 +20,6 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(
[
'./Region'

View File

@ -39,7 +39,6 @@ define([
this.openmct = openmct;
this.attrs = attrs;
if (this.isReady()) {
this.initializeScope();
} else {
@ -55,8 +54,8 @@ define([
eventHelpers.extend(PlotModelFormController.prototype);
PlotModelFormController.prototype.isReady = function () {
return !!this.$scope.formDomainObject &&
!!this.$scope.$eval(this.attrs.formModel);
return Boolean(this.$scope.formDomainObject)
&& Boolean(this.$scope.$eval(this.attrs.formModel));
};
/**
@ -121,23 +120,27 @@ define([
if (!formProp) {
formProp = prop;
}
var formPath = 'form.' + formProp;
if (!coerce) {
coerce = function (v) {
return v;
};
}
if (!validate) {
validate = function () {
return true;
};
}
if (objectPath && !_.isFunction(objectPath)) {
var staticObjectPath = objectPath;
objectPath = function () {
return staticObjectPath;
};
}
this.listenTo(this.model, 'change:' + prop, function (newVal, oldVal) {
if (!_.isEqual(coerce(_.get(this.$scope, formPath)), coerce(newVal))) {
_.set(this.$scope, formPath, coerce(newVal));
@ -149,11 +152,14 @@ define([
delete this.$scope.validation[formProp];
} else {
this.$scope.validation[formProp] = validationResult;
return;
}
if (_.isEqual(coerce(newVal), coerce(this.model.get(prop)))) {
return; // Don't trigger excessive mutations.
}
if (!_.isEqual(coerce(newVal), coerce(oldVal))) {
this.model.set(prop, coerce(newVal));
if (objectPath) {

View File

@ -55,6 +55,7 @@ define([
var config = configStore.get(this.configId);
if (!config) {
this.$timeout(this.setUpScope.bind(this));
return;
}

View File

@ -36,6 +36,7 @@ define([
var index = object.configuration.series.findIndex(s => {
return _.isEqual(s.identifier, modelIdentifier);
});
return 'configuration.series[' + index + '].' + key;
};
}
@ -52,7 +53,6 @@ define([
return s.get('color') === color;
})[0];
this.model.set('color', color);
var getPath = dynamicPathForKey('color');

View File

@ -52,37 +52,47 @@ define([
max: 0
};
}
var newRange = {};
if (typeof range.min !== 'undefined' && range.min !== null) {
newRange.min = Number(range.min);
}
if (typeof range.max !== 'undefined' && range.max !== null) {
newRange.max = Number(range.max);
}
return newRange;
},
validate: function validateRange(range, model) {
if (!range) {
return 'Need range';
}
if (range.min === '' || range.min === null || typeof range.min === 'undefined') {
return 'Must specify Minimum';
}
if (range.max === '' || range.max === null || typeof range.max === 'undefined') {
return 'Must specify Maximum';
}
if (Number.isNaN(Number(range.min))) {
return 'Minimum must be a number.';
}
if (Number.isNaN(Number(range.max))) {
return 'Maximum must be a number.';
}
if (Number(range.min) > Number(range.max)) {
return 'Minimum must be less than Maximum.';
}
if (model.get('autoscale')) {
return false;
}
return true;
}
}

View File

@ -20,7 +20,6 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(
[],
function () {

View File

@ -58,6 +58,7 @@ define(function () {
function isDefaultColor(color) {
var a = color.asIntegerArray();
return COLOR_PALETTE.some(function (b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
});
@ -76,11 +77,12 @@ define(function () {
Color.fromHexString = function (hexString) {
if (!/#([0-9a-fA-F]{2}){2}/.test(hexString)) {
throw new Error(
'Invalid input "' +
hexString +
'". Hex string must be in CSS format e.g. #00FF00'
'Invalid input "'
+ hexString
+ '". Hex string must be in CSS format e.g. #00FF00'
);
}
return new Color([
parseInt(hexString.slice(1, 3), 16),
parseInt(hexString.slice(3, 5), 16),
@ -145,6 +147,7 @@ define(function () {
for (var i = 0; i < allColors.length; i++) {
this.colorGroups[i % 3].push(allColors[i]);
}
this.reset();
}
@ -173,6 +176,7 @@ define(function () {
ColorPalette.prototype.getByHexString = function (hexString) {
var color = Color.fromHexString(hexString);
return color;
};
@ -185,6 +189,7 @@ define(function () {
console.warn('Color Palette empty, reusing colors!');
this.reset();
}
return this.availableColors.shift();
};
@ -197,7 +202,6 @@ define(function () {
return this.colors[index % this.colors.length];
};
return {
Color: Color,
ColorPalette: ColorPalette

View File

@ -32,6 +32,7 @@ define([
if (!this._listeningTo) {
this._listeningTo = [];
}
var listener = {
object: object,
event: event,
@ -49,6 +50,7 @@ define([
} else {
object.on(event, listener._cb);
}
this._listeningTo.push(listener);
},
@ -61,15 +63,19 @@ define([
if (object && object !== listener.object) {
return false;
}
if (event && event !== listener.event) {
return false;
}
if (callback && callback !== listener.callback) {
return false;
}
if (context && context !== listener.context) {
return false;
}
return true;
})
.map(function (listener) {
@ -80,6 +86,7 @@ define([
} else {
listener.object.off(listener.event, listener._cb);
}
return listener;
})
.forEach(function (listener) {

View File

@ -49,6 +49,7 @@ define([
Surrogate = function () {
this.constructor = child;
};
Surrogate.prototype = parent.prototype;
child.prototype = new Surrogate();

View File

@ -41,35 +41,45 @@ define([
this._domain = newDomain;
this._domainDenominator = newDomain.max - newDomain.min;
}
return this._domain;
};
LinearScale.prototype.range = function (newRange) {
if (newRange) {
this._range = newRange;
this._rangeDenominator = newRange.max - newRange.min;
}
return this._range;
};
LinearScale.prototype.scale = function (domainValue) {
if (!this._domain || !this._range) {
return;
}
var domainOffset = domainValue - this._domain.min,
rangeFraction = domainOffset - this._domainDenominator,
rangeOffset = rangeFraction * this._rangeDenominator,
rangeValue = rangeOffset + this._range.min;
return rangeValue;
};
LinearScale.prototype.invert = function (rangeValue) {
if (!this._domain || !this._range) {
return;
}
var rangeOffset = rangeValue - this._range.min,
domainFraction = rangeOffset / this._rangeDenominator,
domainOffset = domainFraction * this._domainDenominator,
domainValue = domainOffset + this._domain.min;
return domainValue;
};
return LinearScale;
});

View File

@ -54,7 +54,7 @@ define([
this.listenTo(this.$scope, 'plot:clearHistory', this.clear, this);
this.initialize();
}
};
}
MCTPlotController.$inject = ['$scope', '$element', '$window'];
@ -65,6 +65,7 @@ define([
if (this.$canvas) {
this.stopListening(this.$canvas);
}
this.$canvas = this.$element.find('canvas');
this.listenTo(this.$canvas, 'mousemove', this.trackMousePosition, this);
@ -160,13 +161,19 @@ define([
MCTPlotController.prototype.trackMousePosition = function ($event) {
this.trackChartElementBounds($event);
this.xScale.range({min: 0, max: this.chartElementBounds.width});
this.yScale.range({min: 0, max: this.chartElementBounds.height});
this.xScale.range({
min: 0,
max: this.chartElementBounds.width
});
this.yScale.range({
min: 0,
max: this.chartElementBounds.height
});
this.positionOverElement = {
x: $event.clientX - this.chartElementBounds.left,
y: this.chartElementBounds.height -
($event.clientY - this.chartElementBounds.top)
y: this.chartElementBounds.height
- ($event.clientY - this.chartElementBounds.top)
};
this.positionOverPlot = {
@ -177,6 +184,7 @@ define([
if (this.cursorGuide) {
this.updateCrosshairs($event);
}
this.highlightValues(this.positionOverPlot.x);
this.updateMarquee();
this.updatePan();
@ -199,6 +207,7 @@ define([
if (point === this.highlightPoint) {
return;
}
this.highlightValues(point);
};
@ -220,12 +229,14 @@ define([
return series.data.length > 0;
}).map(function (series) {
series.closest = series.nearestPoint(point);
return {
series: series,
point: series.closest
};
}, this);
}
this.$scope.$digest();
};
@ -275,12 +286,13 @@ define([
const { start, end } = this.marquee;
return start.x === end.x && start.y === end.y;
}
};
MCTPlotController.prototype.updateMarquee = function () {
if (!this.marquee) {
return;
}
this.marquee.end = this.positionOverPlot;
this.marquee.endPixels = this.positionOverElement;
};
@ -308,8 +320,8 @@ define([
var startPixels = this.marquee.startPixels;
var endPixels = this.marquee.endPixels;
var marqueeDistance = Math.sqrt(
Math.pow(startPixels.x - endPixels.x, 2) +
Math.pow(startPixels.y - endPixels.y, 2)
Math.pow(startPixels.x - endPixels.x, 2)
+ Math.pow(startPixels.y - endPixels.y, 2)
);
// Don't zoom if mouse moved less than 7.5 pixels.
if (marqueeDistance > 7.5) {
@ -327,6 +339,7 @@ define([
// if marquee zoom doesn't occur.
this.plotHistory.pop();
}
this.$scope.rectangles = [];
this.marquee = undefined;
};
@ -344,7 +357,7 @@ define([
this.freeze();
this.trackHistory();
var xAxisDist= (currentXaxis.max - currentXaxis.min) * zoomFactor,
var xAxisDist = (currentXaxis.max - currentXaxis.min) * zoomFactor,
yAxisDist = (currentYaxis.max - currentYaxis.min) * zoomFactor;
if (zoomDirection === 'in') {
@ -454,6 +467,7 @@ define([
};
$event.preventDefault();
this.trackHistory();
return false;
};
@ -462,6 +476,7 @@ define([
if (!this.pan) {
return;
}
var dX = this.pan.start.x - this.positionOverPlot.x,
dY = this.pan.start.y - this.positionOverPlot.y,
xRange = this.config.xAxis.get('displayRange'),
@ -505,8 +520,10 @@ define([
var previousAxisRanges = this.plotHistory.pop();
if (this.plotHistory.length === 0) {
this.clear();
return;
}
this.config.xAxis.set('displayRange', previousAxisRanges.x);
this.config.yAxis.set('displayRange', previousAxisRanges.y);
this.$scope.$emit('user:viewport:change:end');

View File

@ -46,6 +46,7 @@ define([
} else if (error >= e2) {
step1 *= 2;
}
return stop < start ? -step1 : step1;
}
@ -60,7 +61,7 @@ define([
return 0;
}
var precision = Math.max(0, -(+exponential.slice(i + 1)));
var precision = Math.max(0, -(Number(exponential.slice(i + 1))));
if (precision > 20) {
precision = 20;
@ -69,19 +70,19 @@ define([
return precision;
}
/**
* Linear tick generation from d3-array.
*/
function ticks(start, stop, count) {
var step = tickStep(start, stop, count),
precision = getPrecision(step);
return _.range(
Math.ceil(start / step) * step,
Math.floor(stop / step) * step + step / 2, // inclusive
step
).map(function round(tick) {
return +tick.toFixed(precision);
return Number(tick.toFixed(precision));
});
}
@ -92,10 +93,12 @@ define([
if (a[i] !== b[i]) {
break;
}
if (a[i] === ' ') {
breakpoint = i + 1;
}
}
return a.slice(0, breakpoint);
}
@ -106,10 +109,12 @@ define([
if (a[a.length - i] !== b[b.length - i]) {
break;
}
if ('. '.indexOf(a[a.length - i]) !== -1) {
breakpoint = i;
}
}
return a.slice(a.length - breakpoint);
}
@ -124,7 +129,7 @@ define([
this.listenTo(this.axis, 'change:format', this.updateTicks, this);
this.listenTo(this.$scope, '$destroy', this.stopListening, this);
this.updateTicks();
}
};
}
MCTTicksController.$inject = ['$scope', '$element'];
@ -142,15 +147,19 @@ define([
if (!this.tickRange || !this.$scope.ticks || !this.$scope.ticks.length) {
return true;
}
if (this.tickRange.max > range.max || this.tickRange.min < range.min) {
return true;
}
if (Math.abs(range.max - this.tickRange.max) > this.tickRange.step) {
return true;
}
if (Math.abs(this.tickRange.min - range.min) > this.tickRange.step) {
return true;
}
return false;
};
@ -163,6 +172,7 @@ define([
return value <= range.max && value >= range.min;
}, this);
}
return ticks(range.min, range.max, number);
};
@ -175,12 +185,15 @@ define([
delete this.tickRange;
delete this.$scope.ticks;
delete this.shouldCheckWidth;
return;
}
var format = this.axis.get('format');
if (!format) {
return;
}
this.$scope.min = range.min;
this.$scope.max = range.max;
this.$scope.interval = Math.abs(range.min - range.max);
@ -215,9 +228,11 @@ define([
}
});
}
this.$scope.ticks = newTicks;
this.shouldCheckWidth = true;
}
this.scheduleTickUpdate();
};
@ -225,6 +240,7 @@ define([
if (this.tickUpdate) {
return;
}
this.tickUpdate = true;
setTimeout(this.doTickUpdate.bind(this), 0);
};
@ -242,6 +258,7 @@ define([
this.$scope.$emit('plot:tickWidth', tickWidth);
this.shouldCheckWidth = false;
}
this.$scope.$digest();
this.tickUpdate = false;
};

View File

@ -80,11 +80,13 @@ define(
var clonedElement = document.getElementById(exportId);
clonedElement.classList.add(className);
}
element.id = oldId;
},
removeContainer: true // Set to false to debug what html2canvas renders
}).then(function (canvas) {
dialog.dismiss();
return new Promise(function (resolve, reject) {
return canvas.toBlob(resolve, mimeType);
});

View File

@ -97,8 +97,10 @@ define([
PlotController.prototype.loadSeriesData = function (series) {
if (this.$element[0].offsetWidth === 0) {
this.scheduleLoad(series);
return;
}
this.startLoading();
var options = {
size: this.$element[0].offsetWidth,
@ -117,6 +119,7 @@ define([
if (this.$element[0].offsetWidth === 0) {
return;
}
this.stopLoading();
this.scheduledLoads.forEach(this.loadSeriesData, this);
delete this.scheduledLoads;
@ -124,6 +127,7 @@ define([
delete this.checkForSize;
}.bind(this));
}
if (this.scheduledLoads.indexOf(series) === -1) {
this.scheduledLoads.push(series);
}
@ -157,6 +161,7 @@ define([
});
configStore.add(configId, config);
}
return config;
};
@ -172,6 +177,7 @@ define([
clearInterval(this.checkForSize);
delete this.checkForSize;
}
if (this.filterObserver) {
this.filterObserver();
}
@ -247,6 +253,7 @@ define([
.set('timeconductor-unsynced', isUnsynced);
}
}
return this._synchronized;
};
@ -263,8 +270,8 @@ define([
this.loadMoreData(xDisplayRange);
}
this.synchronized(xRange.min === xDisplayRange.min &&
xRange.max === xDisplayRange.max);
this.synchronized(xRange.min === xDisplayRange.min
&& xRange.max === xDisplayRange.max);
};
PlotController.prototype.updateFiltersAndResubscribe = function (updatedFilters) {

View File

@ -90,6 +90,7 @@ define([], function () {
if (thisRequest !== currentRequest) {
return;
}
composition = openmct.composition.get(obj);
composition.on('add', addChild);
composition.on('remove', removeChild);