mirror of
https://github.com/nasa/openmct.git
synced 2025-06-13 12:48:14 +00:00
[Plot] Organize plot elements
Place elements of the PlotController into a separate directory inside of the source folder for the plot plug-in, in preparation for review and integration. Part of ongoing plot transition to Angular, WTD-533.
This commit is contained in:
38
platform/features/plot/src/elements/PlotPosition.js
Normal file
38
platform/features/plot/src/elements/PlotPosition.js
Normal file
@ -0,0 +1,38 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
function PlotPosition(x, y, width, height, panZoomStack) {
|
||||
var panZoom = panZoomStack.getPanZoom(),
|
||||
origin = panZoom.origin,
|
||||
dimensions = panZoom.dimensions,
|
||||
position;
|
||||
|
||||
if (!dimensions || !origin) {
|
||||
position = [];
|
||||
} else {
|
||||
position = [ x / width, (height - y) / height ].map(function (v, i) {
|
||||
return v * dimensions[i] + origin[i];
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
getDomain: function () {
|
||||
return position[0];
|
||||
},
|
||||
getRange: function () {
|
||||
return position[1];
|
||||
},
|
||||
getPosition: function () {
|
||||
return position;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return PlotPosition;
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user