mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 21:28:12 +00:00
ESLint one-var, no-var rules (#3239)
* fixed issues for eslint one-var and no-var rules Co-authored-by: Joshi <simplyrender@gmail.com> Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
@ -62,7 +62,7 @@ define([
|
||||
PlotTemplate
|
||||
) {
|
||||
|
||||
var installed = false;
|
||||
let installed = false;
|
||||
|
||||
function PlotPlugin() {
|
||||
return function install(openmct) {
|
||||
|
@ -35,7 +35,7 @@ define(
|
||||
}
|
||||
|
||||
PlotViewPolicy.prototype.hasNumericTelemetry = function (domainObject) {
|
||||
var adaptedObject = domainObject.useCapability('adapter');
|
||||
const adaptedObject = domainObject.useCapability('adapter');
|
||||
|
||||
if (!adaptedObject.telemetry) {
|
||||
return domainObject.hasCapability('delegation')
|
||||
@ -43,8 +43,8 @@ define(
|
||||
.doesDelegateCapability('telemetry');
|
||||
}
|
||||
|
||||
var metadata = this.openmct.telemetry.getMetadata(adaptedObject);
|
||||
var rangeValues = metadata.valuesForHints(['range']);
|
||||
const metadata = this.openmct.telemetry.getMetadata(adaptedObject);
|
||||
const rangeValues = metadata.valuesForHints(['range']);
|
||||
if (rangeValues.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -39,9 +39,8 @@ function (
|
||||
DrawLoader,
|
||||
eventHelpers
|
||||
) {
|
||||
|
||||
var MARKER_SIZE = 6.0,
|
||||
HIGHLIGHT_SIZE = MARKER_SIZE * 2.0;
|
||||
const MARKER_SIZE = 6.0;
|
||||
const HIGHLIGHT_SIZE = MARKER_SIZE * 2.0;
|
||||
|
||||
/**
|
||||
* Offsetter adjusts x and y values by a fixed amount,
|
||||
@ -94,14 +93,14 @@ function (
|
||||
return;
|
||||
}
|
||||
|
||||
var elements = this.seriesElements.get(series);
|
||||
const elements = this.seriesElements.get(series);
|
||||
elements.lines.forEach(function (line) {
|
||||
this.lines.splice(this.lines.indexOf(line), 1);
|
||||
line.destroy();
|
||||
}, this);
|
||||
elements.lines = [];
|
||||
|
||||
var newLine = this.lineForSeries(series);
|
||||
const newLine = this.lineForSeries(series);
|
||||
if (newLine) {
|
||||
elements.lines.push(newLine);
|
||||
this.lines.push(newLine);
|
||||
@ -113,7 +112,7 @@ function (
|
||||
return;
|
||||
}
|
||||
|
||||
var elements = this.seriesElements.get(series);
|
||||
const elements = this.seriesElements.get(series);
|
||||
if (elements.alarmSet) {
|
||||
elements.alarmSet.destroy();
|
||||
this.alarmSets.splice(this.alarmSets.indexOf(elements.alarmSet), 1);
|
||||
@ -130,14 +129,14 @@ function (
|
||||
return;
|
||||
}
|
||||
|
||||
var elements = this.seriesElements.get(series);
|
||||
const elements = this.seriesElements.get(series);
|
||||
elements.pointSets.forEach(function (pointSet) {
|
||||
this.pointSets.splice(this.pointSets.indexOf(pointSet), 1);
|
||||
pointSet.destroy();
|
||||
}, this);
|
||||
elements.pointSets = [];
|
||||
|
||||
var pointSet = this.pointSetForSeries(series);
|
||||
const pointSet = this.pointSetForSeries(series);
|
||||
if (pointSet) {
|
||||
elements.pointSets.push(pointSet);
|
||||
this.pointSets.push(pointSet);
|
||||
@ -177,7 +176,7 @@ function (
|
||||
return;
|
||||
}
|
||||
|
||||
var offsets = {
|
||||
const offsets = {
|
||||
x: series.getXVal(offsetPoint),
|
||||
y: series.getYVal(offsetPoint)
|
||||
};
|
||||
@ -212,10 +211,10 @@ function (
|
||||
DrawLoader.releaseDrawAPI(this.drawAPI);
|
||||
// Have to throw away the old canvas elements and replace with new
|
||||
// canvas elements in order to get new drawing contexts.
|
||||
var div = document.createElement('div');
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = this.TEMPLATE;
|
||||
var mainCanvas = div.querySelectorAll("canvas")[1];
|
||||
var overlayCanvas = div.querySelectorAll("canvas")[0];
|
||||
const mainCanvas = div.querySelectorAll("canvas")[1];
|
||||
const overlayCanvas = div.querySelectorAll("canvas")[0];
|
||||
this.canvas.parentNode.replaceChild(mainCanvas, this.canvas);
|
||||
this.canvas = mainCanvas;
|
||||
this.overlay.parentNode.replaceChild(overlayCanvas, this.overlay);
|
||||
@ -225,7 +224,7 @@ function (
|
||||
};
|
||||
|
||||
MCTChartController.prototype.removeChartElement = function (series) {
|
||||
var elements = this.seriesElements.get(series);
|
||||
const elements = this.seriesElements.get(series);
|
||||
|
||||
elements.lines.forEach(function (line) {
|
||||
this.lines.splice(this.lines.indexOf(line), 1);
|
||||
@ -282,18 +281,18 @@ function (
|
||||
};
|
||||
|
||||
MCTChartController.prototype.makeChartElement = function (series) {
|
||||
var elements = {
|
||||
const elements = {
|
||||
lines: [],
|
||||
pointSets: []
|
||||
};
|
||||
|
||||
var line = this.lineForSeries(series);
|
||||
const line = this.lineForSeries(series);
|
||||
if (line) {
|
||||
elements.lines.push(line);
|
||||
this.lines.push(line);
|
||||
}
|
||||
|
||||
var pointSet = this.pointSetForSeries(series);
|
||||
const pointSet = this.pointSetForSeries(series);
|
||||
if (pointSet) {
|
||||
elements.pointSets.push(pointSet);
|
||||
this.pointSets.push(pointSet);
|
||||
@ -338,21 +337,22 @@ function (
|
||||
};
|
||||
|
||||
MCTChartController.prototype.updateViewport = function () {
|
||||
var xRange = this.config.xAxis.get('displayRange'),
|
||||
yRange = this.config.yAxis.get('displayRange');
|
||||
const xRange = this.config.xAxis.get('displayRange');
|
||||
const yRange = this.config.yAxis.get('displayRange');
|
||||
|
||||
if (!xRange || !yRange) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dimensions = [
|
||||
xRange.max - xRange.min,
|
||||
yRange.max - yRange.min
|
||||
],
|
||||
origin = [
|
||||
this.offset.x(xRange.min),
|
||||
this.offset.y(yRange.min)
|
||||
];
|
||||
const dimensions = [
|
||||
xRange.max - xRange.min,
|
||||
yRange.max - yRange.min
|
||||
];
|
||||
|
||||
const origin = [
|
||||
this.offset.x(xRange.min),
|
||||
this.offset.y(yRange.min)
|
||||
];
|
||||
|
||||
this.drawAPI.setDimensions(
|
||||
dimensions,
|
||||
@ -399,13 +399,14 @@ function (
|
||||
};
|
||||
|
||||
MCTChartController.prototype.drawHighlight = function (highlight) {
|
||||
var points = new Float32Array([
|
||||
this.offset.xVal(highlight.point, highlight.series),
|
||||
this.offset.yVal(highlight.point, highlight.series)
|
||||
]),
|
||||
color = highlight.series.get('color').asRGBAArray(),
|
||||
pointCount = 1,
|
||||
shape = highlight.series.get('markerShape');
|
||||
const points = new Float32Array([
|
||||
this.offset.xVal(highlight.point, highlight.series),
|
||||
this.offset.yVal(highlight.point, highlight.series)
|
||||
]);
|
||||
|
||||
const color = highlight.series.get('color').asRGBAArray();
|
||||
const pointCount = 1;
|
||||
const shape = highlight.series.get('markerShape');
|
||||
|
||||
this.drawAPI.drawPoints(points, color, pointCount, HIGHLIGHT_SIZE, shape);
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ define([
|
||||
MCTChartController
|
||||
) {
|
||||
|
||||
var TEMPLATE = "<canvas style='position: absolute; background: none; width: 100%; height: 100%;'></canvas>";
|
||||
let TEMPLATE = "<canvas style='position: absolute; background: none; width: 100%; height: 100%;'></canvas>";
|
||||
TEMPLATE += TEMPLATE;
|
||||
|
||||
/**
|
||||
@ -43,8 +43,8 @@ define([
|
||||
template: TEMPLATE,
|
||||
link: function ($scope, $element, attrs, ctrl) {
|
||||
ctrl.TEMPLATE = TEMPLATE;
|
||||
var mainCanvas = $element.find("canvas")[1];
|
||||
var overlayCanvas = $element.find("canvas")[0];
|
||||
const mainCanvas = $element.find("canvas")[1];
|
||||
const overlayCanvas = $element.find("canvas")[0];
|
||||
|
||||
if (ctrl.initializeCanvas(mainCanvas, overlayCanvas)) {
|
||||
ctrl.draw();
|
||||
|
@ -26,7 +26,7 @@ define([
|
||||
MCTChartSeriesElement
|
||||
) {
|
||||
|
||||
var MCTChartLineLinear = MCTChartSeriesElement.extend({
|
||||
const MCTChartLineLinear = MCTChartSeriesElement.extend({
|
||||
addPoint: function (point, start, count) {
|
||||
this.buffer[start] = point.x;
|
||||
this.buffer[start + 1] = point.y;
|
||||
|
@ -26,7 +26,7 @@ define([
|
||||
MCTChartSeriesElement
|
||||
) {
|
||||
|
||||
var MCTChartLineStepAfter = MCTChartSeriesElement.extend({
|
||||
const MCTChartLineStepAfter = MCTChartSeriesElement.extend({
|
||||
removePoint: function (point, index, count) {
|
||||
if (index > 0 && index / 2 < this.count) {
|
||||
this.buffer[index + 1] = this.buffer[index - 1];
|
||||
|
@ -26,7 +26,7 @@ define([
|
||||
MCTChartSeriesElement
|
||||
) {
|
||||
|
||||
var MCTChartPointSet = MCTChartSeriesElement.extend({
|
||||
const MCTChartPointSet = MCTChartSeriesElement.extend({
|
||||
addPoint: function (point, start, count) {
|
||||
this.buffer[start] = point.x;
|
||||
this.buffer[start + 1] = point.y;
|
||||
|
@ -69,11 +69,11 @@ define([
|
||||
};
|
||||
|
||||
MCTChartSeriesElement.prototype.removeSegments = function (index, count) {
|
||||
var target = index,
|
||||
start = index + count,
|
||||
end = this.count * 2;
|
||||
const target = index;
|
||||
const start = index + count;
|
||||
const end = this.count * 2;
|
||||
this.buffer.copyWithin(target, start, end);
|
||||
for (var zero = end - count; zero < end; zero++) {
|
||||
for (let zero = end - count; zero < end; zero++) {
|
||||
this.buffer[zero] = 0;
|
||||
}
|
||||
};
|
||||
@ -83,8 +83,8 @@ define([
|
||||
};
|
||||
|
||||
MCTChartSeriesElement.prototype.remove = function (point, index, series) {
|
||||
var vertexCount = this.vertexCountForPointAtIndex(index);
|
||||
var removalPoint = this.startIndexForPointAtIndex(index);
|
||||
const vertexCount = this.vertexCountForPointAtIndex(index);
|
||||
const removalPoint = this.startIndexForPointAtIndex(index);
|
||||
|
||||
this.removeSegments(removalPoint, vertexCount);
|
||||
|
||||
@ -108,8 +108,8 @@ define([
|
||||
};
|
||||
|
||||
MCTChartSeriesElement.prototype.append = function (point, index, series) {
|
||||
var pointsRequired = this.vertexCountForPointAtIndex(index);
|
||||
var insertionPoint = this.startIndexForPointAtIndex(index);
|
||||
const pointsRequired = this.vertexCountForPointAtIndex(index);
|
||||
const insertionPoint = this.startIndexForPointAtIndex(index);
|
||||
this.growIfNeeded(pointsRequired);
|
||||
this.makeInsertionPoint(insertionPoint, pointsRequired);
|
||||
this.addPoint(
|
||||
@ -127,8 +127,8 @@ define([
|
||||
this.isTempBuffer = true;
|
||||
}
|
||||
|
||||
var target = insertionPoint + pointsRequired,
|
||||
start = insertionPoint;
|
||||
const target = insertionPoint + pointsRequired;
|
||||
let start = insertionPoint;
|
||||
for (; start < target; start++) {
|
||||
this.buffer.splice(start, 0, 0);
|
||||
}
|
||||
@ -146,8 +146,8 @@ define([
|
||||
};
|
||||
|
||||
MCTChartSeriesElement.prototype.growIfNeeded = function (pointsRequired) {
|
||||
var remainingPoints = this.buffer.length - this.count * 2;
|
||||
var temp;
|
||||
const remainingPoints = this.buffer.length - this.count * 2;
|
||||
let temp;
|
||||
|
||||
if (remainingPoints <= pointsRequired) {
|
||||
temp = new Float32Array(this.buffer.length + 20000);
|
||||
|
@ -93,7 +93,7 @@ define([
|
||||
|
||||
Collection.prototype.add = function (model) {
|
||||
model = this.modelFn(model);
|
||||
var index = this.models.length;
|
||||
const index = this.models.length;
|
||||
this.models.push(model);
|
||||
this.emit('add', model, index);
|
||||
};
|
||||
@ -109,7 +109,7 @@ define([
|
||||
};
|
||||
|
||||
Collection.prototype.remove = function (model) {
|
||||
var index = this.indexOf(model);
|
||||
const index = this.indexOf(model);
|
||||
|
||||
if (index === -1) {
|
||||
throw new Error('model not found in collection.');
|
||||
|
@ -28,7 +28,7 @@ define([
|
||||
/**
|
||||
* TODO: doc strings.
|
||||
*/
|
||||
var LegendModel = Model.extend({
|
||||
const LegendModel = Model.extend({
|
||||
listenToSeriesCollection: function (seriesCollection) {
|
||||
this.seriesCollection = seriesCollection;
|
||||
this.listenTo(this.seriesCollection, 'add', this.setHeight, this);
|
||||
@ -37,7 +37,7 @@ define([
|
||||
this.set('expanded', this.get('expandByDefault'));
|
||||
},
|
||||
setHeight: function () {
|
||||
var expanded = this.get('expanded');
|
||||
const expanded = this.get('expanded');
|
||||
if (this.get('position') !== 'top') {
|
||||
this.set('height', '0px');
|
||||
} else {
|
||||
|
@ -40,7 +40,7 @@ define([
|
||||
this.id = options.id;
|
||||
this.model = options.model;
|
||||
this.collection = options.collection;
|
||||
var defaults = this.defaults(options);
|
||||
const defaults = this.defaults(options);
|
||||
if (!this.model) {
|
||||
this.model = options.model = defaults;
|
||||
} else {
|
||||
@ -86,14 +86,14 @@ define([
|
||||
};
|
||||
|
||||
Model.prototype.set = function (attribute, value) {
|
||||
var oldValue = this.model[attribute];
|
||||
const oldValue = this.model[attribute];
|
||||
this.model[attribute] = value;
|
||||
this.emit('change', attribute, value, oldValue, this);
|
||||
this.emit('change:' + attribute, value, oldValue, this);
|
||||
};
|
||||
|
||||
Model.prototype.unset = function (attribute) {
|
||||
var oldValue = this.model[attribute];
|
||||
const oldValue = this.model[attribute];
|
||||
delete this.model[attribute];
|
||||
this.emit('change', attribute, undefined, oldValue, this);
|
||||
this.emit('change:' + attribute, undefined, oldValue, this);
|
||||
|
@ -44,7 +44,7 @@ define([
|
||||
* handle setting defaults and updating in response to various changes.
|
||||
*
|
||||
*/
|
||||
var PlotConfigurationModel = Model.extend({
|
||||
const PlotConfigurationModel = Model.extend({
|
||||
|
||||
/**
|
||||
* Initializes all sub models and then passes references to submodels
|
||||
@ -91,7 +91,7 @@ define([
|
||||
* Retrieve the persisted series config for a given identifier.
|
||||
*/
|
||||
getPersistedSeriesConfig: function (identifier) {
|
||||
var domainObject = this.get('domainObject');
|
||||
const domainObject = this.get('domainObject');
|
||||
if (!domainObject.configuration || !domainObject.configuration.series) {
|
||||
return;
|
||||
}
|
||||
@ -105,8 +105,8 @@ define([
|
||||
* Retrieve the persisted filters for a given identifier.
|
||||
*/
|
||||
getPersistedFilters: function (identifier) {
|
||||
var domainObject = this.get('domainObject'),
|
||||
keystring = this.openmct.objects.makeKeyString(identifier);
|
||||
const domainObject = this.get('domainObject');
|
||||
const keystring = this.openmct.objects.makeKeyString(identifier);
|
||||
|
||||
if (!domainObject.configuration || !domainObject.configuration.filters) {
|
||||
return;
|
||||
|
@ -70,7 +70,7 @@ define([
|
||||
* telemetry point.
|
||||
* `formats`: the Open MCT format map for this telemetry point.
|
||||
*/
|
||||
var PlotSeries = Model.extend({
|
||||
const PlotSeries = Model.extend({
|
||||
constructor: function (options) {
|
||||
this.metadata = options
|
||||
.openmct
|
||||
@ -97,7 +97,7 @@ define([
|
||||
* Set defaults for telemetry series.
|
||||
*/
|
||||
defaults: function (options) {
|
||||
var range = this.metadata.valuesForHints(['range'])[0];
|
||||
const range = this.metadata.valuesForHints(['range'])[0];
|
||||
|
||||
return {
|
||||
name: options.domainObject.name,
|
||||
@ -174,7 +174,7 @@ define([
|
||||
.telemetry
|
||||
.request(this.domainObject, options)
|
||||
.then(function (points) {
|
||||
var newPoints = _(this.data)
|
||||
const newPoints = _(this.data)
|
||||
.concat(points)
|
||||
.sortBy(this.getXVal)
|
||||
.uniq(true, point => [this.getXVal(point), this.getYVal(point)].join())
|
||||
@ -187,7 +187,7 @@ define([
|
||||
* Update x formatter on x change.
|
||||
*/
|
||||
onXKeyChange: function (xKey) {
|
||||
var format = this.formats[xKey];
|
||||
const format = this.formats[xKey];
|
||||
this.getXVal = format.parse.bind(format);
|
||||
},
|
||||
/**
|
||||
@ -199,7 +199,7 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
var valueMetadata = this.metadata.value(newKey);
|
||||
const valueMetadata = this.metadata.value(newKey);
|
||||
if (!this.persistedConfig || !this.persistedConfig.interpolate) {
|
||||
if (valueMetadata.format === 'enum') {
|
||||
this.set('interpolate', 'stepAfter');
|
||||
@ -211,7 +211,7 @@ define([
|
||||
this.evaluate = function (datum) {
|
||||
return this.limitEvaluator.evaluate(datum, valueMetadata);
|
||||
}.bind(this);
|
||||
var format = this.formats[newKey];
|
||||
const format = this.formats[newKey];
|
||||
this.getYVal = format.parse.bind(format);
|
||||
},
|
||||
|
||||
@ -249,17 +249,17 @@ define([
|
||||
* Return the point closest to a given x value.
|
||||
*/
|
||||
nearestPoint: function (xValue) {
|
||||
var insertIndex = this.sortedIndex(xValue),
|
||||
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,
|
||||
nearestPoint = highDistance < lowDistance ? highPoint : lowPoint;
|
||||
const insertIndex = this.sortedIndex(xValue);
|
||||
const lowPoint = this.data[insertIndex - 1];
|
||||
const highPoint = this.data[insertIndex];
|
||||
const indexVal = this.getXVal(xValue);
|
||||
const lowDistance = lowPoint
|
||||
? indexVal - this.getXVal(lowPoint)
|
||||
: Number.POSITIVE_INFINITY;
|
||||
const highDistance = highPoint
|
||||
? this.getXVal(highPoint) - indexVal
|
||||
: Number.POSITIVE_INFINITY;
|
||||
const nearestPoint = highDistance < lowDistance ? highPoint : lowPoint;
|
||||
|
||||
return nearestPoint;
|
||||
},
|
||||
@ -291,9 +291,9 @@ define([
|
||||
* @private
|
||||
*/
|
||||
updateStats: function (point) {
|
||||
var value = this.getYVal(point);
|
||||
var stats = this.get('stats');
|
||||
var changed = false;
|
||||
const value = this.getYVal(point);
|
||||
let stats = this.get('stats');
|
||||
let changed = false;
|
||||
if (!stats) {
|
||||
stats = {
|
||||
minValue: value,
|
||||
@ -338,9 +338,9 @@ define([
|
||||
* a point to the end without dupe checking.
|
||||
*/
|
||||
add: function (point, appendOnly) {
|
||||
var insertIndex = this.data.length,
|
||||
currentYVal = this.getYVal(point),
|
||||
lastYVal = this.getYVal(this.data[insertIndex - 1]);
|
||||
let insertIndex = this.data.length;
|
||||
const currentYVal = this.getYVal(point);
|
||||
const lastYVal = this.getYVal(this.data[insertIndex - 1]);
|
||||
|
||||
if (this.isValueInvalid(currentYVal) && this.isValueInvalid(lastYVal)) {
|
||||
console.warn('[Plot] Invalid Y Values detected');
|
||||
@ -378,7 +378,7 @@ define([
|
||||
* @private
|
||||
*/
|
||||
remove: function (point) {
|
||||
var index = this.data.indexOf(point);
|
||||
const index = this.data.indexOf(point);
|
||||
this.data.splice(index, 1);
|
||||
this.emit('remove', point, index, this);
|
||||
},
|
||||
@ -393,16 +393,16 @@ define([
|
||||
* @param {number} range.max maximum x value to keep.
|
||||
*/
|
||||
purgeRecordsOutsideRange: function (range) {
|
||||
var startIndex = this.sortedIndex(range.min);
|
||||
var endIndex = this.sortedIndex(range.max) + 1;
|
||||
var pointsToRemove = startIndex + (this.data.length - endIndex + 1);
|
||||
const startIndex = this.sortedIndex(range.min);
|
||||
const endIndex = this.sortedIndex(range.max) + 1;
|
||||
const pointsToRemove = startIndex + (this.data.length - endIndex + 1);
|
||||
if (pointsToRemove > 0) {
|
||||
if (pointsToRemove < 1000) {
|
||||
this.data.slice(0, startIndex).forEach(this.remove, this);
|
||||
this.data.slice(endIndex, this.data.length).forEach(this.remove, this);
|
||||
this.resetStats();
|
||||
} else {
|
||||
var newData = this.data.slice(startIndex, endIndex);
|
||||
const newData = this.data.slice(startIndex, endIndex);
|
||||
this.reset(newData);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ define([
|
||||
_
|
||||
) {
|
||||
|
||||
var SeriesCollection = Collection.extend({
|
||||
const SeriesCollection = Collection.extend({
|
||||
modelClass: PlotSeries,
|
||||
initialize: function (options) {
|
||||
this.plot = options.plot;
|
||||
@ -43,7 +43,7 @@ define([
|
||||
this.listenTo(this, 'remove', this.onSeriesRemove, this);
|
||||
this.listenTo(this.plot, 'change:domainObject', this.trackPersistedConfig, this);
|
||||
|
||||
var domainObject = this.plot.get('domainObject');
|
||||
const domainObject = this.plot.get('domainObject');
|
||||
if (domainObject.telemetry) {
|
||||
this.addTelemetryObject(domainObject);
|
||||
} else {
|
||||
@ -52,22 +52,22 @@ define([
|
||||
},
|
||||
trackPersistedConfig: function (domainObject) {
|
||||
domainObject.configuration.series.forEach(function (seriesConfig) {
|
||||
var series = this.byIdentifier(seriesConfig.identifier);
|
||||
const series = this.byIdentifier(seriesConfig.identifier);
|
||||
if (series) {
|
||||
series.persistedConfig = seriesConfig;
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
watchTelemetryContainer: function (domainObject) {
|
||||
var composition = this.openmct.composition.get(domainObject);
|
||||
const composition = this.openmct.composition.get(domainObject);
|
||||
this.listenTo(composition, 'add', this.addTelemetryObject, this);
|
||||
this.listenTo(composition, 'remove', this.removeTelemetryObject, this);
|
||||
composition.load();
|
||||
},
|
||||
addTelemetryObject: function (domainObject, index) {
|
||||
var seriesConfig = this.plot.getPersistedSeriesConfig(domainObject.identifier);
|
||||
var filters = this.plot.getPersistedFilters(domainObject.identifier);
|
||||
var plotObject = this.plot.get('domainObject');
|
||||
let seriesConfig = this.plot.getPersistedSeriesConfig(domainObject.identifier);
|
||||
const filters = this.plot.getPersistedFilters(domainObject.identifier);
|
||||
const plotObject = this.plot.get('domainObject');
|
||||
|
||||
if (!seriesConfig) {
|
||||
seriesConfig = {
|
||||
@ -99,14 +99,14 @@ define([
|
||||
}));
|
||||
},
|
||||
removeTelemetryObject: function (identifier) {
|
||||
var plotObject = this.plot.get('domainObject');
|
||||
const plotObject = this.plot.get('domainObject');
|
||||
if (plotObject.type === 'telemetry.plot.overlay') {
|
||||
|
||||
var persistedIndex = plotObject.configuration.series.findIndex(s => {
|
||||
const persistedIndex = plotObject.configuration.series.findIndex(s => {
|
||||
return _.isEqual(identifier, s.identifier);
|
||||
});
|
||||
|
||||
var configIndex = this.models.findIndex(m => {
|
||||
const configIndex = this.models.findIndex(m => {
|
||||
return _.isEqual(m.domainObject.identifier, identifier);
|
||||
});
|
||||
|
||||
@ -122,8 +122,8 @@ define([
|
||||
// to defer mutation of our plot object, otherwise we might
|
||||
// mutate an outdated version of the plotObject.
|
||||
setTimeout(function () {
|
||||
var newPlotObject = this.plot.get('domainObject');
|
||||
var cSeries = newPlotObject.configuration.series.slice();
|
||||
const newPlotObject = this.plot.get('domainObject');
|
||||
const cSeries = newPlotObject.configuration.series.slice();
|
||||
cSeries.splice(persistedIndex, 1);
|
||||
this.openmct.objects.mutate(newPlotObject, 'configuration.series', cSeries);
|
||||
}.bind(this));
|
||||
@ -131,7 +131,7 @@ define([
|
||||
}
|
||||
},
|
||||
onSeriesAdd: function (series) {
|
||||
var seriesColor = series.get('color');
|
||||
let seriesColor = series.get('color');
|
||||
if (seriesColor) {
|
||||
if (!(seriesColor instanceof color.Color)) {
|
||||
seriesColor = color.Color.fromHexString(seriesColor);
|
||||
@ -152,7 +152,7 @@ define([
|
||||
},
|
||||
updateColorPalette: function (newColor, oldColor) {
|
||||
this.palette.remove(newColor);
|
||||
var seriesWithColor = this.filter(function (series) {
|
||||
const seriesWithColor = this.filter(function (series) {
|
||||
return series.get('color') === newColor;
|
||||
})[0];
|
||||
if (!seriesWithColor) {
|
||||
@ -161,7 +161,7 @@ define([
|
||||
},
|
||||
byIdentifier: function (identifier) {
|
||||
return this.filter(function (series) {
|
||||
var seriesIdentifier = series.get('identifier');
|
||||
const seriesIdentifier = series.get('identifier');
|
||||
|
||||
return seriesIdentifier.namespace === identifier.namespace
|
||||
&& seriesIdentifier.key === identifier.key;
|
||||
|
@ -28,7 +28,7 @@ define([
|
||||
/**
|
||||
* TODO: doc strings.
|
||||
*/
|
||||
var XAxisModel = Model.extend({
|
||||
const XAxisModel = Model.extend({
|
||||
initialize: function (options) {
|
||||
this.plot = options.plot;
|
||||
this.set('label', options.model.name || '');
|
||||
@ -51,10 +51,10 @@ define([
|
||||
this.listenTo(this, 'change:key', this.changeKey, this);
|
||||
},
|
||||
changeKey: function (newKey) {
|
||||
var series = this.plot.series.first();
|
||||
const series = this.plot.series.first();
|
||||
if (series) {
|
||||
var xMetadata = series.metadata.value(newKey);
|
||||
var xFormat = series.formats[newKey];
|
||||
const xMetadata = series.metadata.value(newKey);
|
||||
const xFormat = series.formats[newKey];
|
||||
this.set('label', xMetadata.name);
|
||||
this.set('format', xFormat.format.bind(xFormat));
|
||||
} else {
|
||||
@ -70,9 +70,9 @@ define([
|
||||
});
|
||||
},
|
||||
defaults: function (options) {
|
||||
var bounds = options.openmct.time.bounds();
|
||||
var timeSystem = options.openmct.time.timeSystem();
|
||||
var format = options.openmct.$injector.get('formatService')
|
||||
const bounds = options.openmct.time.bounds();
|
||||
const timeSystem = options.openmct.time.timeSystem();
|
||||
const format = options.openmct.$injector.get('formatService')
|
||||
.getFormat(timeSystem.timeFormat);
|
||||
|
||||
return {
|
||||
|
@ -48,7 +48,7 @@ define([
|
||||
* disabled.
|
||||
*
|
||||
*/
|
||||
var YAxisModel = Model.extend({
|
||||
const YAxisModel = Model.extend({
|
||||
initialize: function (options) {
|
||||
this.plot = options.plot;
|
||||
this.listenTo(this, 'change:stats', this.calculateAutoscaleExtents, this);
|
||||
@ -82,7 +82,7 @@ define([
|
||||
}
|
||||
},
|
||||
applyPadding: function (range) {
|
||||
var padding = Math.abs(range.max - range.min) * this.get('autoscalePadding');
|
||||
let padding = Math.abs(range.max - range.min) * this.get('autoscalePadding');
|
||||
if (padding === 0) {
|
||||
padding = 1;
|
||||
}
|
||||
@ -116,8 +116,8 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
var stats = this.get('stats');
|
||||
var changed = false;
|
||||
const stats = this.get('stats');
|
||||
let changed = false;
|
||||
if (stats.min > seriesStats.minValue) {
|
||||
changed = true;
|
||||
stats.min = seriesStats.minValue;
|
||||
@ -171,9 +171,9 @@ define([
|
||||
* Update yAxis format, values, and label from known series.
|
||||
*/
|
||||
updateFromSeries: function (series) {
|
||||
var plotModel = this.plot.get('domainObject');
|
||||
var label = _.get(plotModel, 'configuration.yAxis.label');
|
||||
var sampleSeries = series.first();
|
||||
const plotModel = this.plot.get('domainObject');
|
||||
const label = _.get(plotModel, 'configuration.yAxis.label');
|
||||
const sampleSeries = series.first();
|
||||
if (!sampleSeries) {
|
||||
if (!label) {
|
||||
this.unset('label');
|
||||
@ -182,13 +182,13 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
var yKey = sampleSeries.get('yKey');
|
||||
var yMetadata = sampleSeries.metadata.value(yKey);
|
||||
var yFormat = sampleSeries.formats[yKey];
|
||||
const yKey = sampleSeries.get('yKey');
|
||||
const yMetadata = sampleSeries.metadata.value(yKey);
|
||||
const yFormat = sampleSeries.formats[yKey];
|
||||
this.set('format', yFormat.format.bind(yFormat));
|
||||
this.set('values', yMetadata.values);
|
||||
if (!label) {
|
||||
var labelName = series.map(function (s) {
|
||||
const labelName = series.map(function (s) {
|
||||
return s.metadata.value(s.get('yKey')).name;
|
||||
}).reduce(function (a, b) {
|
||||
if (a === undefined) {
|
||||
@ -208,7 +208,7 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
var labelUnits = series.map(function (s) {
|
||||
const labelUnits = series.map(function (s) {
|
||||
return s.metadata.value(s.get('yKey')).units;
|
||||
}).reduce(function (a, b) {
|
||||
if (a === undefined) {
|
||||
|
@ -42,7 +42,7 @@ define([
|
||||
return this.store[id];
|
||||
};
|
||||
|
||||
var STORE = new ConfigStore();
|
||||
const STORE = new ConfigStore();
|
||||
|
||||
return STORE;
|
||||
});
|
||||
|
@ -66,7 +66,7 @@ define([
|
||||
|
||||
// Set the color to be used for drawing operations
|
||||
Draw2D.prototype.setColor = function (color) {
|
||||
var mappedColor = color.map(function (c, i) {
|
||||
const mappedColor = color.map(function (c, i) {
|
||||
return i < 3 ? Math.floor(c * 255) : (c);
|
||||
}).join(',');
|
||||
this.c2d.strokeStyle = "rgba(" + mappedColor + ")";
|
||||
@ -85,7 +85,7 @@ define([
|
||||
};
|
||||
|
||||
Draw2D.prototype.drawLine = function (buf, color, points) {
|
||||
var i;
|
||||
let i;
|
||||
|
||||
this.setColor(color);
|
||||
|
||||
@ -108,10 +108,10 @@ define([
|
||||
};
|
||||
|
||||
Draw2D.prototype.drawSquare = function (min, max, color) {
|
||||
var x1 = this.x(min[0]),
|
||||
y1 = this.y(min[1]),
|
||||
w = this.x(max[0]) - x1,
|
||||
h = this.y(max[1]) - y1;
|
||||
const x1 = this.x(min[0]);
|
||||
const y1 = this.y(min[1]);
|
||||
const w = this.x(max[0]) - x1;
|
||||
const h = this.y(max[1]) - y1;
|
||||
|
||||
this.setColor(color);
|
||||
this.c2d.fillRect(x1, y1, w, h);
|
||||
@ -145,12 +145,12 @@ define([
|
||||
};
|
||||
|
||||
Draw2D.prototype.drawLimitPoints = function (points, color, pointSize) {
|
||||
var limitSize = pointSize * 2;
|
||||
var offset = limitSize / 2;
|
||||
const limitSize = pointSize * 2;
|
||||
const offset = limitSize / 2;
|
||||
|
||||
this.setColor(color);
|
||||
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
this.drawLimitPoint(
|
||||
this.x(points[i].x) - offset,
|
||||
this.y(points[i].y) - offset,
|
||||
|
@ -27,7 +27,7 @@ define(
|
||||
],
|
||||
function (DrawWebGL, Draw2D) {
|
||||
|
||||
var CHARTS = [
|
||||
const CHARTS = [
|
||||
{
|
||||
MAX_INSTANCES: 16,
|
||||
API: DrawWebGL,
|
||||
@ -53,7 +53,7 @@ define(
|
||||
the draw API to.
|
||||
*/
|
||||
getDrawAPI: function (canvas, overlay) {
|
||||
var api;
|
||||
let api;
|
||||
|
||||
CHARTS.forEach(function (CHART_TYPE) {
|
||||
if (api) {
|
||||
@ -89,7 +89,7 @@ define(
|
||||
* Returns a fallback draw api.
|
||||
*/
|
||||
getFallbackDrawAPI: function (canvas, overlay) {
|
||||
var api = new CHARTS[1].API(canvas, overlay);
|
||||
const api = new CHARTS[1].API(canvas, overlay);
|
||||
CHARTS[1].ALLOCATIONS.push(api);
|
||||
|
||||
return api;
|
||||
|
@ -285,16 +285,16 @@ define([
|
||||
};
|
||||
|
||||
DrawWebGL.prototype.drawLimitPoints = function (points, color, pointSize) {
|
||||
var limitSize = pointSize * 2;
|
||||
var offset = limitSize / 2;
|
||||
const limitSize = pointSize * 2;
|
||||
const offset = limitSize / 2;
|
||||
|
||||
var mappedColor = color.map(function (c, i) {
|
||||
const mappedColor = color.map(function (c, i) {
|
||||
return i < 3 ? Math.floor(c * 255) : (c);
|
||||
}).join(',');
|
||||
this.c2d.strokeStyle = "rgba(" + mappedColor + ")";
|
||||
this.c2d.fillStyle = "rgba(" + mappedColor + ")";
|
||||
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
this.drawLimitPoint(
|
||||
this.x(points[i].x) - offset,
|
||||
this.y(points[i].y) - offset,
|
||||
|
@ -30,7 +30,7 @@ define(function () {
|
||||
return {
|
||||
restrict: "A",
|
||||
link: function ($scope, $element) {
|
||||
var splitter = $element.parent();
|
||||
let splitter = $element.parent();
|
||||
|
||||
while (splitter[0].tagName !== 'MCT-SPLIT-PANE') {
|
||||
splitter = splitter.parent();
|
||||
@ -40,7 +40,7 @@ define(function () {
|
||||
'.split-pane-component.pane.bottom',
|
||||
'mct-splitter'
|
||||
].forEach(function (selector) {
|
||||
var element = splitter[0].querySelectorAll(selector)[0];
|
||||
const element = splitter[0].querySelectorAll(selector)[0];
|
||||
element.style.maxHeight = '0px';
|
||||
element.style.minHeight = '0px';
|
||||
});
|
||||
|
@ -46,7 +46,7 @@ define(
|
||||
* @private
|
||||
*/
|
||||
InspectorRegion.prototype.buildRegion = function () {
|
||||
var metadataRegion = {
|
||||
const metadataRegion = {
|
||||
name: 'metadata',
|
||||
title: 'Metadata Region',
|
||||
// Which modes should the region part be visible in? If
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2018, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
@ -26,7 +27,7 @@ define([
|
||||
Region
|
||||
) {
|
||||
|
||||
var PlotBrowseRegion = new Region({
|
||||
const PlotBrowseRegion = new Region({
|
||||
name: "plot-options",
|
||||
title: "Plot Options",
|
||||
modes: ['browse'],
|
||||
|
@ -26,7 +26,7 @@ define([
|
||||
Region
|
||||
) {
|
||||
|
||||
var PlotEditRegion = new Region({
|
||||
const PlotEditRegion = new Region({
|
||||
name: "plot-options",
|
||||
title: "Plot Options",
|
||||
modes: ['edit'],
|
||||
|
@ -30,7 +30,7 @@ define([
|
||||
PlotEditRegion
|
||||
) {
|
||||
|
||||
var plotInspector = new InspectorRegion();
|
||||
const plotInspector = new InspectorRegion();
|
||||
|
||||
plotInspector.addRegion(PlotBrowseRegion);
|
||||
plotInspector.addRegion(PlotEditRegion);
|
||||
|
@ -26,7 +26,7 @@ define([
|
||||
PlotModelFormController
|
||||
) {
|
||||
|
||||
var PlotLegendFormController = PlotModelFormController.extend({
|
||||
const PlotLegendFormController = PlotModelFormController.extend({
|
||||
fields: [
|
||||
{
|
||||
modelProp: 'position',
|
||||
|
@ -121,7 +121,7 @@ define([
|
||||
formProp = prop;
|
||||
}
|
||||
|
||||
var formPath = 'form.' + formProp;
|
||||
const formPath = 'form.' + formProp;
|
||||
let self = this;
|
||||
|
||||
if (!coerce) {
|
||||
@ -137,7 +137,7 @@ define([
|
||||
}
|
||||
|
||||
if (objectPath && !_.isFunction(objectPath)) {
|
||||
var staticObjectPath = objectPath;
|
||||
const staticObjectPath = objectPath;
|
||||
objectPath = function () {
|
||||
return staticObjectPath;
|
||||
};
|
||||
@ -149,7 +149,7 @@ define([
|
||||
}
|
||||
});
|
||||
this.model.listenTo(this.$scope, 'change:' + formPath, (newVal, oldVal) => {
|
||||
var validationResult = validate(newVal, this.model);
|
||||
const validationResult = validate(newVal, this.model);
|
||||
if (validationResult === true) {
|
||||
delete this.$scope.validation[formProp];
|
||||
} else {
|
||||
|
@ -52,7 +52,7 @@ define([
|
||||
};
|
||||
|
||||
PlotOptionsController.prototype.setUpScope = function () {
|
||||
var config = configStore.get(this.configId);
|
||||
const config = configStore.get(this.configId);
|
||||
if (!config) {
|
||||
this.$timeout(this.setUpScope.bind(this));
|
||||
|
||||
|
@ -32,8 +32,8 @@ define([
|
||||
|
||||
function dynamicPathForKey(key) {
|
||||
return function (object, model) {
|
||||
var modelIdentifier = model.get('identifier');
|
||||
var index = object.configuration.series.findIndex(s => {
|
||||
const modelIdentifier = model.get('identifier');
|
||||
const index = object.configuration.series.findIndex(s => {
|
||||
return _.isEqual(s.identifier, modelIdentifier);
|
||||
});
|
||||
|
||||
@ -41,22 +41,22 @@ define([
|
||||
};
|
||||
}
|
||||
|
||||
var PlotSeriesFormController = PlotModelFormController.extend({
|
||||
const PlotSeriesFormController = PlotModelFormController.extend({
|
||||
|
||||
/**
|
||||
* Set the color for the current plot series. If the new color was
|
||||
* already assigned to a different plot series, then swap the colors.
|
||||
*/
|
||||
setColor: function (color) {
|
||||
var oldColor = this.model.get('color');
|
||||
var otherSeriesWithColor = this.model.collection.filter(function (s) {
|
||||
const oldColor = this.model.get('color');
|
||||
const otherSeriesWithColor = this.model.collection.filter(function (s) {
|
||||
return s.get('color') === color;
|
||||
})[0];
|
||||
|
||||
this.model.set('color', color);
|
||||
|
||||
var getPath = dynamicPathForKey('color');
|
||||
var seriesColorPath = getPath(this.domainObject, this.model);
|
||||
const getPath = dynamicPathForKey('color');
|
||||
const seriesColorPath = getPath(this.domainObject, this.model);
|
||||
|
||||
this.openmct.objects.mutate(
|
||||
this.domainObject,
|
||||
@ -67,7 +67,7 @@ define([
|
||||
if (otherSeriesWithColor) {
|
||||
otherSeriesWithColor.set('color', oldColor);
|
||||
|
||||
var otherSeriesColorPath = getPath(
|
||||
const otherSeriesColorPath = getPath(
|
||||
this.domainObject,
|
||||
otherSeriesWithColor
|
||||
);
|
||||
@ -86,7 +86,7 @@ define([
|
||||
initialize: function () {
|
||||
this.$scope.setColor = this.setColor.bind(this);
|
||||
|
||||
var metadata = this.model.metadata;
|
||||
const metadata = this.model.metadata;
|
||||
this.$scope.yKeyOptions = metadata
|
||||
.valuesForHints(['range'])
|
||||
.map(function (o) {
|
||||
|
@ -26,7 +26,7 @@ define([
|
||||
PlotModelFormController
|
||||
) {
|
||||
|
||||
var PlotYAxisFormController = PlotModelFormController.extend({
|
||||
const PlotYAxisFormController = PlotModelFormController.extend({
|
||||
fields: [
|
||||
{
|
||||
modelProp: 'label',
|
||||
@ -53,7 +53,7 @@ define([
|
||||
};
|
||||
}
|
||||
|
||||
var newRange = {};
|
||||
const newRange = {};
|
||||
if (typeof range.min !== 'undefined' && range.min !== null) {
|
||||
newRange.min = Number(range.min);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
define(function () {
|
||||
|
||||
var COLOR_PALETTE = [
|
||||
const COLOR_PALETTE = [
|
||||
[0x20, 0xB2, 0xAA],
|
||||
[0x9A, 0xCD, 0x32],
|
||||
[0xFF, 0x8C, 0x00],
|
||||
@ -56,7 +56,7 @@ define(function () {
|
||||
];
|
||||
|
||||
function isDefaultColor(color) {
|
||||
var a = color.asIntegerArray();
|
||||
const a = color.asIntegerArray();
|
||||
|
||||
return COLOR_PALETTE.some(function (b) {
|
||||
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
||||
@ -139,11 +139,11 @@ define(function () {
|
||||
* @constructor
|
||||
*/
|
||||
function ColorPalette() {
|
||||
var allColors = this.allColors = COLOR_PALETTE.map(function (color) {
|
||||
const allColors = this.allColors = COLOR_PALETTE.map(function (color) {
|
||||
return new Color(color);
|
||||
});
|
||||
this.colorGroups = [[], [], []];
|
||||
for (var i = 0; i < allColors.length; i++) {
|
||||
for (let i = 0; i < allColors.length; i++) {
|
||||
this.colorGroups[i % 3].push(allColors[i]);
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ define(function () {
|
||||
};
|
||||
|
||||
ColorPalette.prototype.getByHexString = function (hexString) {
|
||||
var color = Color.fromHexString(hexString);
|
||||
const color = Color.fromHexString(hexString);
|
||||
|
||||
return color;
|
||||
};
|
||||
|
@ -27,13 +27,13 @@ define([
|
||||
|
||||
) {
|
||||
|
||||
var helperFunctions = {
|
||||
const helperFunctions = {
|
||||
listenTo: function (object, event, callback, context) {
|
||||
if (!this._listeningTo) {
|
||||
this._listeningTo = [];
|
||||
}
|
||||
|
||||
var listener = {
|
||||
const listener = {
|
||||
object: object,
|
||||
event: event,
|
||||
callback: callback,
|
||||
@ -41,7 +41,7 @@ define([
|
||||
_cb: context ? callback.bind(context) : callback
|
||||
};
|
||||
if (object.$watch && event.indexOf('change:') === 0) {
|
||||
var scopePath = event.replace('change:', '');
|
||||
const scopePath = event.replace('change:', '');
|
||||
listener.unlisten = object.$watch(scopePath, listener._cb, true);
|
||||
} else if (object.$on) {
|
||||
listener.unlisten = object.$on(event, listener._cb);
|
||||
|
@ -29,9 +29,10 @@ define([
|
||||
|
||||
function extend(props) {
|
||||
// eslint-disable-next-line no-invalid-this
|
||||
var parent = this,
|
||||
child,
|
||||
Surrogate;
|
||||
const parent = this;
|
||||
|
||||
let child;
|
||||
let Surrogate;
|
||||
|
||||
if (props && Object.prototype.hasOwnProperty.call(props, 'constructor')) {
|
||||
child = props.constructor;
|
||||
|
@ -59,10 +59,10 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
var domainOffset = domainValue - this._domain.min,
|
||||
rangeFraction = domainOffset - this._domainDenominator,
|
||||
rangeOffset = rangeFraction * this._rangeDenominator,
|
||||
rangeValue = rangeOffset + this._range.min;
|
||||
const domainOffset = domainValue - this._domain.min;
|
||||
const rangeFraction = domainOffset - this._domainDenominator;
|
||||
const rangeOffset = rangeFraction * this._rangeDenominator;
|
||||
const rangeValue = rangeOffset + this._range.min;
|
||||
|
||||
return rangeValue;
|
||||
};
|
||||
@ -72,10 +72,10 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
var rangeOffset = rangeValue - this._range.min,
|
||||
domainFraction = rangeOffset / this._rangeDenominator,
|
||||
domainOffset = domainFraction * this._domainDenominator,
|
||||
domainValue = domainOffset + this._domain.min;
|
||||
const rangeOffset = rangeValue - this._range.min;
|
||||
const domainFraction = rangeOffset / this._rangeDenominator;
|
||||
const domainOffset = domainFraction * this._domainDenominator;
|
||||
const domainValue = domainOffset + this._domain.min;
|
||||
|
||||
return domainValue;
|
||||
};
|
||||
|
@ -123,8 +123,8 @@ define([
|
||||
|
||||
// set yAxisLabel if none is set yet
|
||||
if (this.$scope.yAxisLabel === 'none') {
|
||||
let yKey = this.$scope.series[0].model.yKey,
|
||||
yKeyModel = this.$scope.yKeyOptions.filter(o => o.key === yKey)[0];
|
||||
let yKey = this.$scope.series[0].model.yKey;
|
||||
let yKeyModel = this.$scope.yKeyOptions.filter(o => o.key === yKey)[0];
|
||||
|
||||
this.$scope.yAxisLabel = yKeyModel.name;
|
||||
}
|
||||
@ -151,7 +151,7 @@ define([
|
||||
this.$scope.tickWidth = width;
|
||||
} else {
|
||||
// Otherwise, only accept tick with if it's larger.
|
||||
var newWidth = Math.max(width, this.$scope.tickWidth);
|
||||
const newWidth = Math.max(width, this.$scope.tickWidth);
|
||||
if (newWidth !== this.$scope.tickWidth) {
|
||||
this.$scope.tickWidth = newWidth;
|
||||
this.$scope.$digest();
|
||||
@ -314,9 +314,9 @@ define([
|
||||
};
|
||||
|
||||
MCTPlotController.prototype.endMarquee = function () {
|
||||
var startPixels = this.marquee.startPixels;
|
||||
var endPixels = this.marquee.endPixels;
|
||||
var marqueeDistance = Math.sqrt(
|
||||
const startPixels = this.marquee.startPixels;
|
||||
const endPixels = this.marquee.endPixels;
|
||||
const marqueeDistance = Math.sqrt(
|
||||
Math.pow(startPixels.x - endPixels.x, 2)
|
||||
+ Math.pow(startPixels.y - endPixels.y, 2)
|
||||
);
|
||||
@ -342,8 +342,8 @@ define([
|
||||
};
|
||||
|
||||
MCTPlotController.prototype.zoom = function (zoomDirection, zoomFactor) {
|
||||
var currentXaxis = this.$scope.xAxis.get('displayRange'),
|
||||
currentYaxis = this.$scope.yAxis.get('displayRange');
|
||||
const currentXaxis = this.$scope.xAxis.get('displayRange');
|
||||
const currentYaxis = this.$scope.yAxis.get('displayRange');
|
||||
|
||||
// when there is no plot data, the ranges can be undefined
|
||||
// in which case we should not perform zoom
|
||||
@ -354,8 +354,8 @@ define([
|
||||
this.freeze();
|
||||
this.trackHistory();
|
||||
|
||||
var xAxisDist = (currentXaxis.max - currentXaxis.min) * zoomFactor,
|
||||
yAxisDist = (currentYaxis.max - currentYaxis.min) * zoomFactor;
|
||||
const xAxisDist = (currentXaxis.max - currentXaxis.min) * zoomFactor;
|
||||
const yAxisDist = (currentYaxis.max - currentYaxis.min) * zoomFactor;
|
||||
|
||||
if (zoomDirection === 'in') {
|
||||
this.$scope.xAxis.set('displayRange', {
|
||||
@ -390,8 +390,8 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
let xDisplayRange = this.$scope.xAxis.get('displayRange'),
|
||||
yDisplayRange = this.$scope.yAxis.get('displayRange');
|
||||
let xDisplayRange = this.$scope.xAxis.get('displayRange');
|
||||
let yDisplayRange = this.$scope.yAxis.get('displayRange');
|
||||
|
||||
// when there is no plot data, the ranges can be undefined
|
||||
// in which case we should not perform zoom
|
||||
@ -402,16 +402,16 @@ define([
|
||||
this.freeze();
|
||||
window.clearTimeout(this.stillZooming);
|
||||
|
||||
let xAxisDist = (xDisplayRange.max - xDisplayRange.min),
|
||||
yAxisDist = (yDisplayRange.max - yDisplayRange.min),
|
||||
xDistMouseToMax = xDisplayRange.max - this.positionOverPlot.x,
|
||||
xDistMouseToMin = this.positionOverPlot.x - xDisplayRange.min,
|
||||
yDistMouseToMax = yDisplayRange.max - this.positionOverPlot.y,
|
||||
yDistMouseToMin = this.positionOverPlot.y - yDisplayRange.min,
|
||||
xAxisMaxDist = xDistMouseToMax / xAxisDist,
|
||||
xAxisMinDist = xDistMouseToMin / xAxisDist,
|
||||
yAxisMaxDist = yDistMouseToMax / yAxisDist,
|
||||
yAxisMinDist = yDistMouseToMin / yAxisDist;
|
||||
let xAxisDist = (xDisplayRange.max - xDisplayRange.min);
|
||||
let yAxisDist = (yDisplayRange.max - yDisplayRange.min);
|
||||
let xDistMouseToMax = xDisplayRange.max - this.positionOverPlot.x;
|
||||
let xDistMouseToMin = this.positionOverPlot.x - xDisplayRange.min;
|
||||
let yDistMouseToMax = yDisplayRange.max - this.positionOverPlot.y;
|
||||
let yDistMouseToMin = this.positionOverPlot.y - yDisplayRange.min;
|
||||
let xAxisMaxDist = xDistMouseToMax / xAxisDist;
|
||||
let xAxisMinDist = xDistMouseToMin / xAxisDist;
|
||||
let yAxisMaxDist = yDistMouseToMax / yAxisDist;
|
||||
let yAxisMinDist = yDistMouseToMin / yAxisDist;
|
||||
|
||||
let plotHistoryStep;
|
||||
|
||||
@ -474,10 +474,10 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
var dX = this.pan.start.x - this.positionOverPlot.x,
|
||||
dY = this.pan.start.y - this.positionOverPlot.y,
|
||||
xRange = this.config.xAxis.get('displayRange'),
|
||||
yRange = this.config.yAxis.get('displayRange');
|
||||
const dX = this.pan.start.x - this.positionOverPlot.x;
|
||||
const dY = this.pan.start.y - this.positionOverPlot.y;
|
||||
const xRange = this.config.xAxis.get('displayRange');
|
||||
const yRange = this.config.yAxis.get('displayRange');
|
||||
|
||||
this.config.xAxis.set('displayRange', {
|
||||
min: xRange.min + dX,
|
||||
@ -514,7 +514,7 @@ define([
|
||||
};
|
||||
|
||||
MCTPlotController.prototype.back = function () {
|
||||
var previousAxisRanges = this.plotHistory.pop();
|
||||
const previousAxisRanges = this.plotHistory.pop();
|
||||
if (this.plotHistory.length === 0) {
|
||||
this.clear();
|
||||
|
||||
|
@ -27,18 +27,17 @@ define([
|
||||
_,
|
||||
eventHelpers
|
||||
) {
|
||||
|
||||
var e10 = Math.sqrt(50),
|
||||
e5 = Math.sqrt(10),
|
||||
e2 = Math.sqrt(2);
|
||||
const e10 = Math.sqrt(50);
|
||||
const e5 = Math.sqrt(10);
|
||||
const e2 = Math.sqrt(2);
|
||||
|
||||
/**
|
||||
* Nicely formatted tick steps from d3-array.
|
||||
*/
|
||||
function tickStep(start, stop, count) {
|
||||
var step0 = Math.abs(stop - start) / Math.max(0, count),
|
||||
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
|
||||
error = step0 / step1;
|
||||
const step0 = Math.abs(stop - start) / Math.max(0, count);
|
||||
let step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10));
|
||||
const error = step0 / step1;
|
||||
if (error >= e10) {
|
||||
step1 *= 10;
|
||||
} else if (error >= e5) {
|
||||
@ -55,13 +54,13 @@ define([
|
||||
* ticks to precise values.
|
||||
*/
|
||||
function getPrecision(step) {
|
||||
var exponential = step.toExponential(),
|
||||
i = exponential.indexOf('e');
|
||||
const exponential = step.toExponential();
|
||||
const i = exponential.indexOf('e');
|
||||
if (i === -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var precision = Math.max(0, -(Number(exponential.slice(i + 1))));
|
||||
let precision = Math.max(0, -(Number(exponential.slice(i + 1))));
|
||||
|
||||
if (precision > 20) {
|
||||
precision = 20;
|
||||
@ -74,8 +73,8 @@ define([
|
||||
* Linear tick generation from d3-array.
|
||||
*/
|
||||
function ticks(start, stop, count) {
|
||||
var step = tickStep(start, stop, count),
|
||||
precision = getPrecision(step);
|
||||
const step = tickStep(start, stop, count);
|
||||
const precision = getPrecision(step);
|
||||
|
||||
return _.range(
|
||||
Math.ceil(start / step) * step,
|
||||
@ -87,9 +86,9 @@ define([
|
||||
}
|
||||
|
||||
function commonPrefix(a, b) {
|
||||
var maxLen = Math.min(a.length, b.length);
|
||||
var breakpoint = 0;
|
||||
for (var i = 0; i < maxLen; i++) {
|
||||
const maxLen = Math.min(a.length, b.length);
|
||||
let breakpoint = 0;
|
||||
for (let i = 0; i < maxLen; i++) {
|
||||
if (a[i] !== b[i]) {
|
||||
break;
|
||||
}
|
||||
@ -103,9 +102,9 @@ define([
|
||||
}
|
||||
|
||||
function commonSuffix(a, b) {
|
||||
var maxLen = Math.min(a.length, b.length);
|
||||
var breakpoint = 0;
|
||||
for (var i = 0; i <= maxLen; i++) {
|
||||
const maxLen = Math.min(a.length, b.length);
|
||||
let breakpoint = 0;
|
||||
for (let i = 0; i <= maxLen; i++) {
|
||||
if (a[a.length - i] !== b[b.length - i]) {
|
||||
break;
|
||||
}
|
||||
@ -164,9 +163,9 @@ define([
|
||||
};
|
||||
|
||||
MCTTicksController.prototype.getTicks = function () {
|
||||
var number = this.tickCount;
|
||||
var clampRange = this.axis.get('values');
|
||||
var range = this.axis.get('displayRange');
|
||||
const number = this.tickCount;
|
||||
const clampRange = this.axis.get('values');
|
||||
const range = this.axis.get('displayRange');
|
||||
if (clampRange) {
|
||||
return clampRange.filter(function (value) {
|
||||
return value <= range.max && value >= range.min;
|
||||
@ -177,7 +176,7 @@ define([
|
||||
};
|
||||
|
||||
MCTTicksController.prototype.updateTicks = function () {
|
||||
var range = this.axis.get('displayRange');
|
||||
const range = this.axis.get('displayRange');
|
||||
if (!range) {
|
||||
delete this.$scope.min;
|
||||
delete this.$scope.max;
|
||||
@ -189,7 +188,7 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
var format = this.axis.get('format');
|
||||
const format = this.axis.get('format');
|
||||
if (!format) {
|
||||
return;
|
||||
}
|
||||
@ -198,7 +197,7 @@ define([
|
||||
this.$scope.max = range.max;
|
||||
this.$scope.interval = Math.abs(range.min - range.max);
|
||||
if (this.shouldRegenerateTicks(range)) {
|
||||
var newTicks = this.getTicks();
|
||||
let newTicks = this.getTicks();
|
||||
this.tickRange = {
|
||||
min: Math.min.apply(Math, newTicks),
|
||||
max: Math.max.apply(Math, newTicks),
|
||||
@ -214,11 +213,11 @@ define([
|
||||
}, this);
|
||||
|
||||
if (newTicks.length && typeof newTicks[0].text === 'string') {
|
||||
var tickText = newTicks.map(function (t) {
|
||||
const tickText = newTicks.map(function (t) {
|
||||
return t.text;
|
||||
});
|
||||
var prefix = tickText.reduce(commonPrefix);
|
||||
var suffix = tickText.reduce(commonSuffix);
|
||||
const prefix = tickText.reduce(commonPrefix);
|
||||
const suffix = tickText.reduce(commonSuffix);
|
||||
newTicks.forEach(function (t, i) {
|
||||
t.fullText = t.text;
|
||||
if (suffix.length) {
|
||||
@ -248,11 +247,12 @@ define([
|
||||
MCTTicksController.prototype.doTickUpdate = function () {
|
||||
if (this.shouldCheckWidth) {
|
||||
this.$scope.$digest();
|
||||
var element = this.$element[0],
|
||||
tickElements = element.querySelectorAll('.gl-plot-tick > span'),
|
||||
tickWidth = Number([].reduce.call(tickElements, function (memo, first) {
|
||||
return Math.max(memo, first.offsetWidth);
|
||||
}, 0));
|
||||
const element = this.$element[0];
|
||||
const tickElements = element.querySelectorAll('.gl-plot-tick > span');
|
||||
|
||||
const tickWidth = Number([].reduce.call(tickElements, function (memo, first) {
|
||||
return Math.max(memo, first.offsetWidth);
|
||||
}, 0));
|
||||
|
||||
this.$scope.tickWidth = tickWidth;
|
||||
this.$scope.$emit('plot:tickWidth', tickWidth);
|
||||
|
@ -52,32 +52,34 @@ define(
|
||||
* @returns {promise}
|
||||
*/
|
||||
ExportImageService.prototype.renderElement = function (element, imageType, className) {
|
||||
const dialogService = this.dialogService;
|
||||
|
||||
var dialogService = this.dialogService,
|
||||
dialog = dialogService.showBlockingMessage({
|
||||
title: "Capturing...",
|
||||
hint: "Capturing an image",
|
||||
unknownProgress: true,
|
||||
severity: "info",
|
||||
delay: true
|
||||
});
|
||||
const dialog = dialogService.showBlockingMessage({
|
||||
title: "Capturing...",
|
||||
hint: "Capturing an image",
|
||||
unknownProgress: true,
|
||||
severity: "info",
|
||||
delay: true
|
||||
});
|
||||
|
||||
var mimeType = "image/png";
|
||||
let mimeType = "image/png";
|
||||
if (imageType === "jpg") {
|
||||
mimeType = "image/jpeg";
|
||||
}
|
||||
|
||||
let exportId = undefined;
|
||||
let oldId = undefined;
|
||||
if (className) {
|
||||
var exportId = 'export-element-' + this.exportCount;
|
||||
exportId = 'export-element-' + this.exportCount;
|
||||
this.exportCount++;
|
||||
var oldId = element.id;
|
||||
oldId = element.id;
|
||||
element.id = exportId;
|
||||
}
|
||||
|
||||
return html2canvas(element, {
|
||||
onclone: function (document) {
|
||||
if (className) {
|
||||
var clonedElement = document.getElementById(exportId);
|
||||
const clonedElement = document.getElementById(exportId);
|
||||
clonedElement.classList.add(className);
|
||||
}
|
||||
|
||||
@ -93,7 +95,7 @@ define(
|
||||
}, function (error) {
|
||||
console.log('error capturing image', error);
|
||||
dialog.dismiss();
|
||||
var errorDialog = dialogService.showBlockingMessage({
|
||||
const errorDialog = dialogService.showBlockingMessage({
|
||||
title: "Error capturing image",
|
||||
severity: "error",
|
||||
hint: "Image was not captured successfully!",
|
||||
@ -153,12 +155,11 @@ define(
|
||||
if (!HTMLCanvasElement.prototype.toBlob) {
|
||||
Object.defineProperty(HTMLCanvasElement.prototype, "toBlob", {
|
||||
value: function (callback, mimeType, quality) {
|
||||
const binStr = atob(this.toDataURL(mimeType, quality).split(',')[1]);
|
||||
const len = binStr.length;
|
||||
const arr = new Uint8Array(len);
|
||||
|
||||
var binStr = atob(this.toDataURL(mimeType, quality).split(',')[1]),
|
||||
len = binStr.length,
|
||||
arr = new Uint8Array(len);
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
for (let i = 0; i < len; i++) {
|
||||
arr[i] = binStr.charCodeAt(i);
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ define([
|
||||
}
|
||||
|
||||
this.startLoading();
|
||||
var options = {
|
||||
const options = {
|
||||
size: this.$element[0].offsetWidth,
|
||||
domain: this.config.xAxis.get('key')
|
||||
};
|
||||
@ -150,10 +150,10 @@ define([
|
||||
};
|
||||
|
||||
PlotController.prototype.getConfig = function (domainObject) {
|
||||
var configId = domainObject.getId();
|
||||
var config = configStore.get(configId);
|
||||
const configId = domainObject.getId();
|
||||
let config = configStore.get(configId);
|
||||
if (!config) {
|
||||
var newDomainObject = domainObject.useCapability('adapter');
|
||||
const newDomainObject = domainObject.useCapability('adapter');
|
||||
config = new PlotConfigurationModel({
|
||||
id: configId,
|
||||
domainObject: newDomainObject,
|
||||
@ -202,7 +202,7 @@ define([
|
||||
* Track latest display bounds. Forces update when not receiving ticks.
|
||||
*/
|
||||
PlotController.prototype.updateDisplayBounds = function (bounds, isTick) {
|
||||
var newRange = {
|
||||
const newRange = {
|
||||
min: bounds.start,
|
||||
max: bounds.end
|
||||
};
|
||||
@ -216,7 +216,7 @@ define([
|
||||
// Drop any data that is more than 1x (max-min) before min.
|
||||
// Limit these purges to once a second.
|
||||
if (!this.nextPurge || this.nextPurge < Date.now()) {
|
||||
var keepRange = {
|
||||
const keepRange = {
|
||||
min: newRange.min - (newRange.max - newRange.min),
|
||||
max: newRange.max
|
||||
};
|
||||
@ -247,7 +247,7 @@ define([
|
||||
PlotController.prototype.synchronized = function (value) {
|
||||
if (typeof value !== 'undefined') {
|
||||
this._synchronized = value;
|
||||
var isUnsynced = !value && this.openmct.time.clock();
|
||||
const isUnsynced = !value && this.openmct.time.clock();
|
||||
if (this.$scope.domainObject.getCapability('status')) {
|
||||
this.$scope.domainObject.getCapability('status')
|
||||
.set('timeconductor-unsynced', isUnsynced);
|
||||
@ -263,8 +263,8 @@ define([
|
||||
* @private
|
||||
*/
|
||||
PlotController.prototype.onUserViewportChangeEnd = function () {
|
||||
var xDisplayRange = this.config.xAxis.get('displayRange');
|
||||
var xRange = this.config.xAxis.get('range');
|
||||
const xDisplayRange = this.config.xAxis.get('displayRange');
|
||||
const xRange = this.config.xAxis.get('range');
|
||||
|
||||
if (!this.skipReloadOnInteraction) {
|
||||
this.loadMoreData(xDisplayRange);
|
||||
@ -290,7 +290,7 @@ define([
|
||||
* Export view as JPG.
|
||||
*/
|
||||
PlotController.prototype.exportJPG = function () {
|
||||
var plotElement = this.$element.children()[1];
|
||||
const plotElement = this.$element.children()[1];
|
||||
|
||||
this.exportImageService.exportJPG(plotElement, 'plot.jpg', 'export-plot');
|
||||
};
|
||||
@ -299,7 +299,7 @@ define([
|
||||
* Export view as PNG.
|
||||
*/
|
||||
PlotController.prototype.exportPNG = function () {
|
||||
var plotElement = this.$element.children()[1];
|
||||
const plotElement = this.$element.children()[1];
|
||||
|
||||
this.exportImageService.exportPNG(plotElement, 'plot.png', 'export-plot');
|
||||
};
|
||||
|
@ -22,11 +22,11 @@
|
||||
|
||||
define([], function () {
|
||||
function StackedPlotController($scope, openmct, objectService, $element, exportImageService) {
|
||||
var tickWidth = 0,
|
||||
composition,
|
||||
currentRequest,
|
||||
unlisten,
|
||||
tickWidthMap = {};
|
||||
let tickWidth = 0;
|
||||
let composition;
|
||||
let currentRequest;
|
||||
let unlisten;
|
||||
let tickWidthMap = {};
|
||||
|
||||
this.$element = $element;
|
||||
this.exportImageService = exportImageService;
|
||||
@ -36,13 +36,13 @@ define([], function () {
|
||||
$scope.telemetryObjects = [];
|
||||
|
||||
function onDomainObjectChange(domainObject) {
|
||||
var thisRequest = {
|
||||
const thisRequest = {
|
||||
pending: 0
|
||||
};
|
||||
currentRequest = thisRequest;
|
||||
$scope.currentRequest = thisRequest;
|
||||
var telemetryObjects = $scope.telemetryObjects = [];
|
||||
var thisTickWidthMap = {};
|
||||
const telemetryObjects = $scope.telemetryObjects = [];
|
||||
const thisTickWidthMap = {};
|
||||
tickWidthMap = thisTickWidthMap;
|
||||
|
||||
if (unlisten) {
|
||||
@ -51,25 +51,25 @@ define([], function () {
|
||||
}
|
||||
|
||||
function addChild(child) {
|
||||
var id = openmct.objects.makeKeyString(child.identifier);
|
||||
const id = openmct.objects.makeKeyString(child.identifier);
|
||||
thisTickWidthMap[id] = 0;
|
||||
thisRequest.pending += 1;
|
||||
objectService.getObjects([id])
|
||||
.then(function (objects) {
|
||||
thisRequest.pending -= 1;
|
||||
var childObj = objects[id];
|
||||
const childObj = objects[id];
|
||||
telemetryObjects.push(childObj);
|
||||
});
|
||||
}
|
||||
|
||||
function removeChild(childIdentifier) {
|
||||
var id = openmct.objects.makeKeyString(childIdentifier);
|
||||
const id = openmct.objects.makeKeyString(childIdentifier);
|
||||
delete thisTickWidthMap[id];
|
||||
var childObj = telemetryObjects.filter(function (c) {
|
||||
const childObj = telemetryObjects.filter(function (c) {
|
||||
return c.getId() === id;
|
||||
})[0];
|
||||
if (childObj) {
|
||||
var index = telemetryObjects.indexOf(childObj);
|
||||
const index = telemetryObjects.indexOf(childObj);
|
||||
telemetryObjects.splice(index, 1);
|
||||
$scope.$broadcast('plot:tickWidth', Math.max(...Object.values(tickWidthMap)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user