-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agora): migrate Agora to use shared boxplot component (AG-1460) (#…
- Loading branch information
1 parent
921c0bb
commit 9597389
Showing
36 changed files
with
456 additions
and
1,225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; | ||
import { WikiComponent } from '@sagebionetworks/agora/shared'; | ||
import { applicationConfig, moduleMetadata, type Meta, type StoryObj } from '@storybook/angular'; | ||
import { AboutComponent } from './about.component'; | ||
|
||
const meta: Meta<AboutComponent> = { | ||
component: AboutComponent, | ||
title: 'About', | ||
decorators: [ | ||
applicationConfig({ | ||
providers: [provideHttpClient(withInterceptorsFromDi())], | ||
}), | ||
moduleMetadata({ | ||
imports: [CommonModule, WikiComponent], | ||
}), | ||
], | ||
}; | ||
export default meta; | ||
type Story = StoryObj<AboutComponent>; | ||
|
||
export const Primary: Story = { | ||
args: {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
libs/agora/charts/src/lib/box-plot-chart/box-plot-chart-data-mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { boxPlotChartItem } from '@sagebionetworks/agora/models'; | ||
|
||
export const boxPlotChartItemsMock: boxPlotChartItem[] = [ | ||
{ | ||
key: 'CBE', | ||
value: [-0.5, -0.08, 0.5], | ||
circle: { | ||
value: -0.0752, | ||
tooltip: | ||
'MSN is not significantly differentially expressed in CBE with a log fold change value of -0.0752 and an adjusted p-value of 0.531.', | ||
}, | ||
quartiles: [-0.1, -0.08, 0.1], | ||
}, | ||
{ | ||
key: 'ACC', | ||
value: [-0.256, -0.0036, 0.2503], | ||
circle: { | ||
value: -0.0144, | ||
tooltip: | ||
'MSN is not significantly differentially expressed in ACC with a log fold change value of -0.0145 and an adjusted p-value of 0.893.', | ||
}, | ||
quartiles: [-0.0661, -0.0036, 0.0604], | ||
}, | ||
]; |
29 changes: 5 additions & 24 deletions
29
libs/agora/charts/src/lib/box-plot-chart/box-plot-chart.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
<!-- <div class="chart box-plot-chart" (window:resize)="onResize()"> | ||
<div class="chart-inner"> | ||
@if (heading) { | ||
<h4 class="chart-heading">{{ heading }}</h4> | ||
} | ||
<div class="chart-body"> | ||
<div #chartContainer class="chart-container"></div> | ||
</div> | ||
@if (xAxisLabel) { | ||
<div class="chart-x-axis-label">{{ xAxisLabel }}</div> | ||
} | ||
@if (!this._data.length) { | ||
<div class="chart-no-data"> | ||
<div class="chart-no-data-text">No data is currently available.</div> | ||
</div> | ||
} | ||
</div> | ||
</div> --> | ||
|
||
<!-- <div | ||
<div | ||
sageBoxplot | ||
[points]="points" | ||
[summaries]="summaries" | ||
[title]="title" | ||
[xAxisTitle]="xAxisTitle" | ||
[yAxisTitle]="yAxisTitle" | ||
[title]="heading" | ||
[xAxisTitle]="xAxisLabel" | ||
[yAxisTitle]="yAxisLabel" | ||
[yAxisMin]="yAxisMin" | ||
[yAxisMax]="yAxisMax" | ||
[xAxisCategoryToTooltipText]="xAxisCategoryToTooltipText" | ||
[pointTooltipFormatter]="pointTooltipFormatter" | ||
></div> --> | ||
></div> |
40 changes: 40 additions & 0 deletions
40
libs/agora/charts/src/lib/box-plot-chart/box-plot-chart.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { HelperService } from '@sagebionetworks/agora/services'; | ||
import { BoxplotDirective } from '@sagebionetworks/shared/charts-angular'; | ||
import { render, screen } from '@testing-library/angular'; | ||
import { boxPlotChartItemsMock } from './box-plot-chart-data-mock'; | ||
import { BoxPlotComponent } from './box-plot-chart.component'; | ||
|
||
class MockHelperService { | ||
getGCTColumnTooltipText(column: string): string { | ||
return column + '-mock-text'; | ||
} | ||
} | ||
|
||
describe('Component: Chart - Box Plot', () => { | ||
it('should render chart with data', async () => { | ||
await render(BoxPlotComponent, { | ||
componentProperties: { | ||
data: boxPlotChartItemsMock, | ||
}, | ||
imports: [BoxplotDirective], | ||
providers: [{ provide: HelperService, useClass: MockHelperService }], | ||
}); | ||
|
||
// keys are sorted alphabetically | ||
const tooltipTextRegExp = new RegExp( | ||
`${boxPlotChartItemsMock[1].circle.tooltip}.*${boxPlotChartItemsMock[0].circle.tooltip}`, | ||
); | ||
expect(screen.getByLabelText(tooltipTextRegExp)).toBeVisible(); | ||
}); | ||
|
||
it('should render no data placeholder when no data is passed', async () => { | ||
await render(BoxPlotComponent, { | ||
componentProperties: { | ||
data: undefined, | ||
}, | ||
imports: [BoxplotDirective], | ||
providers: [{ provide: HelperService, useClass: MockHelperService }], | ||
}); | ||
expect(screen.getByLabelText('No data is currently available.')).toBeVisible(); | ||
}); | ||
}); |
73 changes: 0 additions & 73 deletions
73
libs/agora/charts/src/lib/box-plot-chart/box-plot-chart.component.spec.ts.off
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
libs/agora/charts/src/lib/box-plot-chart/box-plot-chart.component.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; | ||
import { BoxplotDirective } from '@sagebionetworks/shared/charts-angular'; | ||
import { applicationConfig, moduleMetadata, type Meta, type StoryObj } from '@storybook/angular'; | ||
import { boxPlotChartItemsMock } from './box-plot-chart-data-mock'; | ||
import { BoxPlotComponent } from './box-plot-chart.component'; | ||
|
||
const meta: Meta<BoxPlotComponent> = { | ||
component: BoxPlotComponent, | ||
title: 'Charts/BoxPlot', | ||
decorators: [ | ||
applicationConfig({ | ||
providers: [provideHttpClient(withInterceptorsFromDi())], | ||
}), | ||
moduleMetadata({ | ||
imports: [BoxplotDirective], | ||
}), | ||
], | ||
}; | ||
export default meta; | ||
type Story = StoryObj<BoxPlotComponent>; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
heading: 'AD Diagnosis (males and females)', | ||
data: boxPlotChartItemsMock, | ||
xAxisLabel: 'Brain Region', | ||
yAxisLabel: 'LOG 2 FOLD CHANGE', | ||
yAxisMin: -1, | ||
yAxisMax: 1, | ||
}, | ||
}; | ||
|
||
export const NoData: Story = { | ||
args: { | ||
heading: 'AD Diagnosis (males and females)', | ||
xAxisLabel: 'Brain Region', | ||
yAxisLabel: 'LOG 2 FOLD CHANGE', | ||
yAxisMin: -1, | ||
yAxisMax: 1, | ||
}, | ||
}; |
Oops, something went wrong.