-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type annotations #4789
Type annotations #4789
Changes from 7 commits
ddf45a1
4ff150c
896571e
84693b0
ffaeea3
4251274
607acf9
fe447a0
c9d9656
72aea12
c917914
56a2e63
429ca48
f05e895
c87c9f4
817f841
5f81617
f5d4e75
08e84c9
064fa80
6a01ce0
a6d86d4
4d75aa3
f25aab5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,10 @@ export default { | |
mounted() { | ||
eventHelpers.extend(this); | ||
|
||
if (!this.axisType) { | ||
throw new Error("axis-type prop expected") | ||
} | ||
|
||
this.axis = this.getAxisFromConfig(); | ||
|
||
this.tickCount = 4; | ||
|
@@ -119,15 +123,16 @@ export default { | |
}, | ||
methods: { | ||
getAxisFromConfig() { | ||
if (!this.axisType) { | ||
return; | ||
} | ||
|
||
const configId = this.openmct.objects.makeKeyString(this.domainObject.identifier); | ||
|
||
/** @type {import('./configuration/PlotConfigurationModel').default} */ | ||
let config = configStore.get(configId); | ||
if (config) { | ||
return config[this.axisType]; | ||
|
||
if (!config) { | ||
throw new Error('config is missing') | ||
} | ||
|
||
return config[this.axisType]; | ||
}, | ||
/** | ||
* Determine whether ticks should be regenerated for a given range. | ||
|
@@ -203,8 +208,8 @@ export default { | |
if (this.shouldRegenerateTicks(range, forceRegeneration)) { | ||
let newTicks = this.getTicks(); | ||
this.tickRange = { | ||
min: Math.min.apply(Math, newTicks), | ||
max: Math.max.apply(Math, newTicks), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our coverage tool has recently been updated, we can freely use modern syntax now. |
||
min: Math.min(...newTicks), | ||
max: Math.max(...newTicks), | ||
step: newTicks[1] - newTicks[0] | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
|
||
import eventHelpers from '../lib/eventHelpers'; | ||
|
||
/** @abstract */ | ||
export default class MCTChartSeriesElement { | ||
constructor(series, chart, offset) { | ||
this.series = series; | ||
|
@@ -72,21 +73,22 @@ export default class MCTChartSeriesElement { | |
} | ||
} | ||
|
||
removePoint(point, index, count) { | ||
// by default, do nothing. | ||
} | ||
/** @abstract */ | ||
removePoint(index) {} | ||
|
||
/** @abstract */ | ||
addPoint(point, index) {} | ||
|
||
remove(point, index, series) { | ||
const vertexCount = this.vertexCountForPointAtIndex(index); | ||
const removalPoint = this.startIndexForPointAtIndex(index); | ||
|
||
this.removeSegments(removalPoint, vertexCount); | ||
|
||
this.removePoint( | ||
this.makePoint(point, series), | ||
removalPoint, | ||
vertexCount | ||
); | ||
// TODO useless makePoint call? | ||
this.makePoint(point, series); | ||
this.removePoint(removalPoint); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the point of this Seems like copy/paste left overs from a long time ago. What's the point of making a point just to remove a another point? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shefalijoshi can you take a look at this? |
||
this.count -= (vertexCount / 2); | ||
} | ||
|
||
|
@@ -106,11 +108,7 @@ export default class MCTChartSeriesElement { | |
const insertionPoint = this.startIndexForPointAtIndex(index); | ||
this.growIfNeeded(pointsRequired); | ||
this.makeInsertionPoint(insertionPoint, pointsRequired); | ||
this.addPoint( | ||
this.makePoint(point, series), | ||
insertionPoint, | ||
pointsRequired | ||
); | ||
this.addPoint(this.makePoint(point, series), insertionPoint); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed another unused arg that didn't do anything. |
||
this.count += (pointsRequired / 2); | ||
} | ||
|
||
|
@@ -155,3 +153,18 @@ export default class MCTChartSeriesElement { | |
} | ||
|
||
} | ||
|
||
/** @typedef {any} TODO */ | ||
|
||
/** @typedef {import('../configuration/PlotSeries').default} PlotSeries */ | ||
|
||
/** | ||
@typedef {{ | ||
x: (x: number) => number | ||
y: (y: number) => number | ||
xVal: (point: Point, pSeries: PlotSeries) => number | ||
yVal: (point: Point, pSeries: PlotSeries) => number | ||
xKey: TODO | ||
yKey: TODO | ||
}} Offset | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't update the packages we're currently using, this only adds types (hence the
@types/
) of the package's we're using which gives us intellisense in IDEs.