Skip to content

Commit 901fa3a

Browse files
committed
docs: update pipeline dashboard comparison chart examples and tests
1 parent b7163da commit 901fa3a

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

examples/app-crm/src/dashboards/pipeline.dashboard.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import type { Dashboard } from '@objectstack/spec/ui';
1313
* labelled "vs last quarter".
1414
* - **Avg Deal Size YoY** — metric with `compareTo: 'previousYear'` to
1515
* compare against the same window one year prior.
16-
* - **Pipeline Trend (90d)** — line chart with a sliding
17-
* `compareTo: { offset: '90d' }` overlay, rendered as a dashed muted
18-
* series on top of the current 90-day trend.
19-
* - **Opportunities by Stage** / **Pipeline by Industry** — bar / pie
20-
* examples without `compareTo` (pie / donut / funnel ignore overlays
21-
* even if set).
16+
* - **Pipeline Trend (12 months)** — line chart with
17+
* `categoryGranularity: 'month'` bucketing and a `compareTo: 'previousYear'`
18+
* overlay, rendered as a dashed muted series on top of the current
19+
* 12-month trend.
20+
* - **Opportunities by Stage** — bar chart with
21+
* `compareTo: 'previousPeriod'` to overlay the prior quarter.
22+
* - **Pipeline by Industry** — pie chart without `compareTo`
23+
* (pie / donut / funnel ignore overlays even if set).
2224
*/
2325
export const PipelineDashboard: Dashboard = {
2426
name: 'pipeline_dashboard',

examples/app-crm/test/smoke.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,24 @@ describe('Pipeline dashboard', () => {
6060
expect(w.filter.close_date.$lte).toBe('{current_year_end}');
6161
});
6262

63-
it('uses a sliding `{ offset }` compareTo on the trend chart', () => {
63+
it('uses a YoY `previousYear` compareTo on the trend chart', () => {
6464
const w: any = byId.get('pipeline_trend_90d');
65-
expect(w.compareTo).toEqual({ offset: '90d' });
65+
expect(w.compareTo).toBe('previousYear');
6666
expect(w.type).toBe('line');
67+
expect(w.categoryGranularity).toBe('month');
6768
});
6869

69-
it('omits compareTo on widgets that do not need it (pie, plain bar, total)', () => {
70+
it('omits compareTo on widgets that do not need it (pie, total)', () => {
7071
expect((byId.get('total_pipeline') as any).compareTo).toBeUndefined();
71-
expect((byId.get('opportunities_by_stage') as any).compareTo).toBeUndefined();
7272
expect((byId.get('pipeline_by_industry') as any).compareTo).toBeUndefined();
7373
});
7474

75+
it('uses `compareTo: previousPeriod` on the Opportunities by Stage bar chart', () => {
76+
const w: any = byId.get('opportunities_by_stage');
77+
expect(w.compareTo).toBe('previousPeriod');
78+
expect(w.type).toBe('bar');
79+
});
80+
7581
it('widgets bind to the opportunity object', () => {
7682
for (const w of PipelineDashboard.widgets) {
7783
expect((w as any).object).toBe('crm_opportunity');

0 commit comments

Comments
 (0)