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

Plot legends expand by default when enabled #7453

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@
"WCAG",
"stackedplot",
"Andale",
"unnnormalized",
"unnormalized",
scottbell marked this conversation as resolved.
Show resolved Hide resolved
"checksnapshots",
"specced",
"composables",
Expand Down
60 changes: 60 additions & 0 deletions e2e/tests/functional/plugins/plot/overlayPlot.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,66 @@ test.describe('Overlay Plot', () => {
await expect(seriesColorSwatch).toHaveCSS('background-color', 'rgb(255, 166, 61)');
});

test('Plot legend expands by default', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/nasa/openmct/issues/7403'
});
const overlayPlot = await createDomainObjectWithDefaults(page, {
type: 'Overlay Plot'
});

await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});

await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});

await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});

await page.goto(overlayPlot.url);

await page.getByRole('tab', { name: 'Config' }).click();

// Assert that the legend is collapsed by default
await expect(page.getByLabel('Plot Legend Collapsed')).toBeVisible();
await expect(page.getByLabel('Plot Legend Expanded')).toBeHidden();
await expect(page.getByLabel('Expand by Default')).toHaveText('No');

expect(await page.getByLabel('Plot Legend Item').count()).toBe(3);

// Change the legend to expand by default
await page.getByLabel('Edit Object').click();
await page.getByLabel('Expand By Default').check();
await page.getByLabel('Save').click();
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
// Assert that the legend is now open
await expect(page.getByLabel('Plot Legend Collapsed')).toBeHidden();
await expect(page.getByLabel('Plot Legend Expanded')).toBeVisible();
await expect(page.getByRole('cell', { name: 'Name' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Value' })).toBeVisible();
await expect(page.getByLabel('Expand by Default')).toHaveText('Yes');
await expect(page.getByLabel('Plot Legend Item')).toHaveCount(3);

// Assert that the legend is expanded on page load
await page.reload();
await expect(page.getByLabel('Plot Legend Collapsed')).toBeHidden();
await expect(page.getByLabel('Plot Legend Expanded')).toBeVisible();
await expect(page.getByRole('cell', { name: 'Name' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Timestamp' })).toBeVisible();
await expect(page.getByRole('cell', { name: 'Value' })).toBeVisible();
await expect(page.getByLabel('Expand by Default')).toHaveText('Yes');
await expect(page.getByLabel('Plot Legend Item')).toHaveCount(3);
});

test('Limit lines persist when series is moved to another Y Axis and on refresh', async ({
page
}) => {
Expand Down
50 changes: 50 additions & 0 deletions e2e/tests/functional/plugins/plot/stackedPlot.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,56 @@ test.describe('Stacked Plot', () => {

await assertAggregateLegendIsVisible(page);
});

test('can toggle between aggregate and per child legends', async ({ page }) => {
// make some an overlay plot
const overlayPlot = await createDomainObjectWithDefaults(page, {
type: 'Overlay Plot',
parent: stackedPlot.uuid
});

// make some SWGs for the overlay plot
await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});
await createDomainObjectWithDefaults(page, {
type: 'Sine Wave Generator',
parent: overlayPlot.uuid
});

await page.goto(stackedPlot.url);
await page.getByLabel('Edit Object').click();
await page.getByRole('tab', { name: 'Config' }).click();
await page.getByLabel('Inspector Views').getByRole('checkbox').uncheck();
await page.getByLabel('Expand By Default').check();
await page.getByLabel('Save').click();
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
await expect(page.getByLabel('Plot Legend Expanded')).toHaveCount(1);
await expect(page.getByLabel('Plot Legend Item')).toHaveCount(5);

// reload and ensure the legend is still expanded
await page.reload();
await expect(page.getByLabel('Plot Legend Expanded')).toHaveCount(1);
await expect(page.getByLabel('Plot Legend Item')).toHaveCount(5);

// change to collapsed by default
await page.getByLabel('Edit Object').click();
await page.getByLabel('Expand By Default').uncheck();
await page.getByLabel('Save').click();
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
await expect(page.getByLabel('Plot Legend Collapsed')).toHaveCount(1);
await expect(page.getByLabel('Plot Legend Item')).toHaveCount(5);

// change it to individual legends
await page.getByLabel('Edit Object').click();
await page.getByRole('tab', { name: 'Config' }).click();
await page.getByLabel('Show Legends For Children').check();
await page.getByLabel('Save').click();
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
await expect(page.getByLabel('Plot Legend Collapsed')).toHaveCount(4);
await expect(page.getByLabel('Plot Legend Item')).toHaveCount(5);
});
});

/**
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/persistence/couch/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
const LEGACY_SPACE = 'mct';

export default function CouchPlugin(options) {
function normalizeOptions(unnnormalizedOptions) {
function normalizeOptions(unnormalizedOptions) {
const normalizedOptions = {};
if (typeof unnnormalizedOptions === 'string') {
if (typeof unnormalizedOptions === 'string') {
normalizedOptions.databases = [
{
url: options,
Expand All @@ -41,19 +41,19 @@
indicator: true
}
];
} else if (!unnnormalizedOptions.databases) {
} else if (!unnormalizedOptions.databases) {
normalizedOptions.databases = [
{
url: unnnormalizedOptions.url,
url: unnormalizedOptions.url,
namespace: DEFAULT_NAMESPACE,
additionalNamespaces: [LEGACY_SPACE],
readOnly: false,
useDesignDocuments: unnnormalizedOptions.useDesignDocuments,
useDesignDocuments: unnormalizedOptions.useDesignDocuments,
indicator: true
}
];
} else {
normalizedOptions.databases = unnnormalizedOptions.databases;
normalizedOptions.databases = unnormalizedOptions.databases;

Check warning on line 56 in src/plugins/persistence/couch/plugin.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/persistence/couch/plugin.js#L56

Added line #L56 was not covered by tests
}

// final sanity check, ensure we have all options
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plot/configuration/XAxisModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class XAxisModel extends Model {
*/
defaultModel(options) {
const bounds = options.openmct.time.bounds();
const timeSystem = options.openmct.time.timeSystem();
const timeSystem = options.openmct.time.getTimeSystem();
scottbell marked this conversation as resolved.
Show resolved Hide resolved
const format = options.openmct.telemetry.getFormatter(timeSystem.timeFormat);

/** @type {XAxisModelType} */
Expand Down
22 changes: 14 additions & 8 deletions src/plugins/plot/inspector/PlotOptionsBrowse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</div>
<div class="grid-cell value">{{ showLegendsForChildren ? 'Yes' : 'No' }}</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div
class="grid-cell label"
title="The position of the legend relative to the plot display area."
Expand All @@ -88,25 +88,27 @@
</div>
<div class="grid-cell value capitalize">{{ position }}</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div class="grid-cell label" title="Hide the legend when the plot is small">
Hide when plot small
</div>
<div class="grid-cell value">{{ hideLegendWhenSmall ? 'Yes' : 'No' }}</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div class="grid-cell label" title="Show the legend expanded by default">
Expand by Default
</div>
<div class="grid-cell value">{{ expandByDefault ? 'Yes' : 'No' }}</div>
<div aria-label="Expand by Default" class="grid-cell value">
{{ expandByDefault ? 'Yes' : 'No' }}
</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div class="grid-cell label" title="What to display in the legend when it's collapsed.">
Show when collapsed:
</div>
<div class="grid-cell value">{{ valueToShowWhenCollapsed.replace('nearest', '') }}</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div class="grid-cell label" title="What to display in the legend when it's expanded.">
Show when expanded:
</div>
Expand Down Expand Up @@ -164,6 +166,11 @@ export default {
pathObjIndex === 0 && pathObject.type === 'telemetry.plot.stacked'
);
},
showLegendDetails() {
return (
!this.isStackedPlotObject || (this.isStackedPlotObject && !this.showLegendsForChildren)
);
},
yAxesWithSeries() {
return this.yAxes.filter((yAxis) => yAxis.seriesCount > 0);
}
Expand All @@ -174,9 +181,8 @@ export default {
if (!this.isStackedPlotObject) {
this.initYAxesConfiguration();
this.registerListeners();
} else {
this.initLegendConfiguration();
}
this.initLegendConfiguration();
scottbell marked this conversation as resolved.
Show resolved Hide resolved

this.loaded = true;
},
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/plot/inspector/PlotOptionsItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ export default {
},
data() {
return {
expanded: false
expanded: false,
status: null
scottbell marked this conversation as resolved.
Show resolved Hide resolved
};
},
computed: {
Expand Down
23 changes: 17 additions & 6 deletions src/plugins/plot/inspector/forms/LegendForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
<div class="grid-cell value">
<input
v-model="showLegendsForChildren"
aria-label="Show Legends For Children"
type="checkbox"
@change="updateForm('showLegendsForChildren')"
/>
</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div
class="grid-cell label"
title="The position of the legend relative to the plot display area."
Expand All @@ -47,7 +48,7 @@
</select>
</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div class="grid-cell label" title="Hide the legend when the plot is small">
Hide when plot small
</div>
Expand All @@ -59,15 +60,20 @@
/>
</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div class="grid-cell label" title="Show the legend expanded by default">
Expand by default
</div>
<div class="grid-cell value">
<input v-model="expandByDefault" type="checkbox" @change="updateForm('expandByDefault')" />
<input
v-model="expandByDefault"
aria-label="Expand By Default"
type="checkbox"
@change="updateForm('expandByDefault')"
/>
</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div class="grid-cell label" title="What to display in the legend when it's collapsed.">
When collapsed show
</div>
Expand All @@ -82,7 +88,7 @@
</select>
</div>
</li>
<li class="grid-row">
<li v-if="showLegendDetails" class="grid-row">
<div class="grid-cell label" title="What to display in the legend when it's expanded.">
When expanded show
</div>
Expand Down Expand Up @@ -169,6 +175,11 @@ export default {
(pathObject, pathObjIndex) =>
pathObjIndex === 0 && pathObject?.type === 'telemetry.plot.stacked'
);
},
showLegendDetails() {
return (
!this.isStackedPlotObject || (this.isStackedPlotObject && !this.showLegendsForChildren)
);
}
},
mounted() {
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/plot/inspector/forms/SeriesForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export default {
limitLines: this.series.get('limitLines'),
markerSize: this.series.get('markerSize'),
validation: {},
swatchActive: false
swatchActive: false,
status: null
};
},
computed: {
Expand Down
Loading
Loading