Skip to content
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

fix(#6812): Align Plot and Plan X-Axes in Time Strips #7744

Merged
merged 26 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5aa6a03
DRAFT - alignment for axes
shefalijoshi Jun 8, 2024
b240519
Use alignmentContext to manage tick widths instead of passing around …
shefalijoshi Jun 11, 2024
eff6398
Merge branch 'master' of https://github.com/nasa/openmct into alignme…
shefalijoshi Jun 11, 2024
c14960f
Remove log statements
shefalijoshi Jun 11, 2024
d2f7458
Add ability to remove alignment widths for a given y axis
shefalijoshi Jun 18, 2024
7e28e18
Fix computation of left margin and width of plan when in the timestrip
shefalijoshi Jun 20, 2024
2167eef
Remove excess padding when there is no left y axis
shefalijoshi Jun 20, 2024
bea3a92
Use alignment composable to adjust left margin and width of time syst…
shefalijoshi Jun 20, 2024
7ab7dc3
Fix now marker visibility
shefalijoshi Jun 20, 2024
8e15ba2
refactor: use built in `Map()` data structure
ozyx Jun 24, 2024
ae90491
refactor: improve readability and conciseness
ozyx Jun 24, 2024
ee1a322
docs: improve jsdocs
ozyx Jun 24, 2024
8f5e2ed
refactor: move jsdoc typedefs to bottom of file
ozyx Jun 24, 2024
78e5ec9
refactor: axis to use vue reactivity
ozyx Jun 25, 2024
81e66fc
fix: return alignment as an object of refs
ozyx Jun 26, 2024
63ac403
alignmentMap needs to be shared state, move it out of the useAlignmen…
shefalijoshi Jun 26, 2024
a096829
Merge branch 'alignment-composable' of https://github.com/nasa/openmc…
shefalijoshi Jun 26, 2024
8288570
Fix now marker offset
shefalijoshi Jul 1, 2024
c76c339
Merge branch 'master' of https://github.com/nasa/openmct into alignme…
shefalijoshi Jul 2, 2024
2029b93
Add new visual test for time strips
shefalijoshi Jul 5, 2024
5b51761
Merge branch 'master' of https://github.com/nasa/openmct into alignme…
unlikelyzero Jul 17, 2024
7b13022
update with animation stabilization
unlikelyzero Jul 17, 2024
467d5c8
Fix failing test due to changed injected property (path -> objectPath)
shefalijoshi Jul 22, 2024
68fdd6d
change injected property from path to objectPath
shefalijoshi Jul 22, 2024
99c1657
Fix spelling
shefalijoshi Jul 22, 2024
548533f
Remove unused arguments to function call
shefalijoshi Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use alignment composable to adjust left margin and width of time syst…
…em axis
  • Loading branch information
shefalijoshi committed Jun 20, 2024
commit bea3a92479b8ab85f9fb6feab3a6196d39c8a951
10 changes: 8 additions & 2 deletions src/plugins/plan/components/ActivityTimeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,20 @@ export default {
},
computed: {
alignmentStyle() {
const leftOffset = this.alignmentData.multiple ? 2 * AXES_PADDING : AXES_PADDING;
let leftOffset = 0;
if (this.alignmentData.leftWidth) {
leftOffset = this.alignmentData.multiple ? 2 * AXES_PADDING : AXES_PADDING;
}
return {
marginLeft: `${this.alignmentData.leftWidth + leftOffset}px`
};
},
svgWidth() {
// Reduce the width by left axis width, then take off the right yaxis width as well
const leftOffset = this.alignmentData.multiple ? 2 * AXES_PADDING : AXES_PADDING;
let leftOffset = 0;
if (this.alignmentData.leftWidth) {
leftOffset = this.alignmentData.multiple ? 2 * AXES_PADDING : AXES_PADDING;
}
const rightOffset = this.alignmentData.rightWidth ? AXES_PADDING : 0;
return (
this.width -
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/timeline/TimelineViewLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@
TimelineAxis,
SwimLane
},
inject: ['openmct', 'domainObject', 'composition', 'objectPath'],
inject: ['openmct', 'domainObject', 'path', 'composition'],
setup() {
const domainObject = inject('domainObject');
const objectPath = inject('objectPath');
const path = inject('path');
const openmct = inject('openmct');
const { alignment: alignmentData, reset: resetAlignment } = useAlignment(
domainObject,
objectPath,
path,
openmct
);

Expand All @@ -94,7 +94,7 @@
};
},
beforeUnmount() {
this.resetAlignment();

Check warning on line 97 in src/plugins/timeline/TimelineViewLayout.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/timeline/TimelineViewLayout.vue#L97

Added line #L97 was not covered by tests
this.composition.off('add', this.addItem);
this.composition.off('remove', this.removeItem);
this.composition.off('reorder', this.reorder);
Expand All @@ -120,7 +120,7 @@
addItem(domainObject) {
let type = this.openmct.types.get(domainObject.type) || unknownObjectType;
let keyString = this.openmct.objects.makeKeyString(domainObject.identifier);
let objectPath = [domainObject].concat(this.objectPath.slice());
let objectPath = [domainObject].concat(this.path.slice());

Check warning on line 123 in src/plugins/timeline/TimelineViewLayout.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/timeline/TimelineViewLayout.vue#L123

Added line #L123 was not covered by tests
let rowCount = 0;
if (domainObject.type === 'plan') {
const planData = getValidatedData(domainObject);
Expand Down Expand Up @@ -210,7 +210,7 @@
setTimeContext() {
this.stopFollowingTimeContext();

this.timeContext = this.openmct.time.getContextForView(this.objectPath);
this.timeContext = this.openmct.time.getContextForView(this.path);
this.getTimeSystems();
this.updateViewBounds();
this.timeContext.on('boundsChanged', this.updateViewBounds);
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/timeline/TimelineViewProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export default function TimelineViewProvider(openmct) {
provide: {
openmct,
domainObject,
composition: openmct.composition.get(domainObject),
objectPath
path: objectPath,
composition: openmct.composition.get(domainObject)
},
template: '<timeline-view-layout></timeline-view-layout>'
},
Expand Down
57 changes: 40 additions & 17 deletions src/ui/components/TimeSystemAxis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
</template>

<script>
const AXES_PADDING = 20;

import { axisTop } from 'd3-axis';
import { scaleLinear, scaleUtc } from 'd3-scale';
import { select } from 'd3-selection';
import { onMounted, ref } from 'vue';
import { inject, onMounted, ref } from 'vue';

import utcMultiTimeFormat from '@/plugins/timeConductor/utcMultiTimeFormat';

import { useAlignment } from '../composables/alignmentContext';
import { useResizeObserver } from '../composables/resize';

//TODO: UI direction needed for the following property values
Expand All @@ -42,7 +45,7 @@
//This offset needs to be re-considered

export default {
inject: ['openmct', 'domainObject'],
inject: ['openmct', 'domainObject', 'path'],
props: {
bounds: {
type: Object,
Expand All @@ -67,12 +70,6 @@
default() {
return 'svg';
}
},
offset: {
type: Number,
default() {
return 0;
}
}
},
setup() {
Expand All @@ -81,16 +78,43 @@
onMounted(() => {
startObserving(axisHolder.value);
});

const domainObject = inject('domainObject');
const path = inject('path');
const openmct = inject('openmct');
const { alignment: alignmentData } = useAlignment(domainObject, path, openmct);

return {
axisHolder,
containerSize
containerSize,
alignmentData
};
},
watch: {
alignmentData: {
handler() {
let leftOffset = 0;

Check warning on line 96 in src/ui/components/TimeSystemAxis.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/components/TimeSystemAxis.vue#L96

Added line #L96 was not covered by tests
if (this.alignmentData.leftWidth) {
leftOffset = this.alignmentData.multiple ? 2 * AXES_PADDING : AXES_PADDING;
}
this.svgElement.attr(

Check warning on line 100 in src/ui/components/TimeSystemAxis.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/components/TimeSystemAxis.vue#L100

Added line #L100 was not covered by tests
'style',
`margin-left: ${this.alignmentData.leftWidth + leftOffset}px`
);

const rightOffset = this.alignmentData.rightWidth ? AXES_PADDING : 0;
this.alignmentOffset =

Check warning on line 106 in src/ui/components/TimeSystemAxis.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/components/TimeSystemAxis.vue#L106

Added line #L106 was not covered by tests
this.alignmentData.leftWidth + leftOffset + this.alignmentData.rightWidth + rightOffset;
this.setDimensions();

Check warning on line 108 in src/ui/components/TimeSystemAxis.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/components/TimeSystemAxis.vue#L108

Added line #L108 was not covered by tests
},
deep: true
},
bounds(newBounds) {
this.setDimensions();
this.drawAxis(newBounds, this.timeSystem);
},
timeSystem(newTimeSystem) {
this.setDimensions();

Check warning on line 117 in src/ui/components/TimeSystemAxis.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/components/TimeSystemAxis.vue#L117

Added line #L117 was not covered by tests
this.drawAxis(this.bounds, newTimeSystem);
},
contentHeight() {
Expand All @@ -110,7 +134,7 @@

this.container = select(this.axisHolder);
this.svgElement = this.container.append('svg:svg');
// draw x axis with labels. CSS is used to position them.
// draw x-axis with labels. CSS is used to position them.
this.axisElement = this.svgElement
.append('g')
.attr('class', 'axis')
Expand All @@ -126,7 +150,7 @@
},
methods: {
resize() {
if (this.axisHolder.clientWidth !== this.width) {
if (this.axisHolder.clientWidth - this.alignmentOffset !== this.width) {
this.setDimensions();
this.drawAxis(this.bounds, this.timeSystem);
this.updateNowMarker();
Expand All @@ -139,12 +163,11 @@
nowMarker.style.height = this.contentHeight + 'px';
const nowTimeStamp = this.openmct.time.now();
const now = this.xScale(nowTimeStamp);
nowMarker.style.left = now + this.offset + 'px';
nowMarker.style.left = now + 'px';
}
},
setDimensions() {
this.width = this.axisHolder.clientWidth;
this.offsetWidth = this.width - this.offset;
this.width = this.axisHolder.clientWidth - (this.alignmentOffset ?? 0);

this.height = Math.round(this.axisHolder.getBoundingClientRect().height);

Expand Down Expand Up @@ -180,16 +203,16 @@
this.xScale.domain([bounds.start, bounds.end]);
}

this.xScale.range([PADDING, this.offsetWidth - PADDING * 2]);
this.xScale.range([PADDING, this.width - PADDING * 2]);
},
setAxis() {
this.xAxis = axisTop(this.xScale);
this.xAxis.tickFormat(utcMultiTimeFormat);

if (this.width > 1800) {
this.xAxis.ticks(this.offsetWidth / PIXELS_PER_TICK_WIDE);
this.xAxis.ticks(this.width / PIXELS_PER_TICK_WIDE);

Check warning on line 213 in src/ui/components/TimeSystemAxis.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/components/TimeSystemAxis.vue#L213

Added line #L213 was not covered by tests
} else {
this.xAxis.ticks(this.offsetWidth / PIXELS_PER_TICK);
this.xAxis.ticks(this.width / PIXELS_PER_TICK);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/ui/components/timesystem-axis.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
svg {
$lineC: rgba($colorBodyFg, 0.3) !important;
text-rendering: geometricPrecision;
width: 100%;
height: 100%;

.domain {
Expand Down
Loading