import {
NgbGridChartComponent,
NgbGridChartConfig,
NgbDataMetricDef,
} from '@angular-bootstrap/ngbootstrap';
@Component({
imports: [NgbGridChartComponent],
template: `
<ngb-grid-chart [config]="config"></ngb-grid-chart>
`,
})
export class ProductSalesChartOverview {
readonly metrics: NgbDataMetricDef<ProductRow>[] = [
{ key: 'q1Sales', label: 'Q1 Sales', accessor: (row) => row.q1Sales, color: '#4F7DF3' },
{ key: 'q2Sales', label: 'Q2 Sales', accessor: (row) => row.q2Sales, color: '#F1645D' },
{ key: 'q3Sales', label: 'Q3 Sales', accessor: (row) => row.q3Sales, color: '#60C56E' },
{ key: 'q4Sales', label: 'Q4 Sales', accessor: (row) => row.q4Sales, color: '#F3B13E' },
];
readonly config: NgbGridChartConfig<ProductRow> = {
mode: 'row-selection',
rows: this.products,
dimension: { key: 'product', label: 'Product', accessor: (row) => row.product },
subDimension: { key: 'category', label: 'Category', accessor: (row) => row.category },
metrics: this.metrics,
rowSelectionMetrics: this.metrics,
selectedRowIds: [1, 3, 4],
chartType: 'bar',
chartTitle: 'Quarterly Sales by Product',
};
}