Skip to content

Commit 75b6f3b

Browse files
committed
Enhance the charts.md instructions
1 parent 3d223ff commit 75b6f3b

1 file changed

Lines changed: 135 additions & 61 deletions

File tree

  • skills/igniteui-angular-components/references

skills/igniteui-angular-components/references/charts.md

Lines changed: 135 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ Ignite UI for Angular Charts provides 65+ chart types for data visualization. Ch
99
- `@infragistics/igniteui-angular-charts` — Licensed version with same API (ProGet)
1010

1111
### Main Chart Components
12-
- **`IgxCategoryChartComponent`** — Simplified API for area, bar, column charts; auto-detects best visualization
13-
- **`IgxFinancialChartComponent`** — Stock/candlestick charts with OHLC data, indicators, and volume panes
14-
- **`IgxDataChartComponent`** — Advanced chart with explicit axis, series, and annotation control (>65 types)
15-
- **`IgxPieChartComponent`** — Part-to-whole pie and donut charts
16-
- **`IgxDataPieChartComponent`** — Simplified API version for pie charts
12+
13+
> **IMPORTANT — Not Standalone Components**: Chart components from `igniteui-angular-charts` are **NOT** Angular standalone components (they predate the standalone API). They must always be imported via their **NgModule**. Standalone Angular components (Angular 14+) can still import NgModules directly in their `imports` array — this is fully supported.
14+
15+
| Component | NgModule to import | Description |
16+
|---|---|---|
17+
| `IgxCategoryChartComponent` | `IgxCategoryChartModule` | Simplified API for area, bar, column charts |
18+
| `IgxFinancialChartComponent` | `IgxFinancialChartModule` | Stock/candlestick charts with OHLC data |
19+
| `IgxDataChartComponent` | `IgxDataChartModule` | Advanced: explicit axes, series, >65 chart types |
20+
| `IgxPieChartComponent` | `IgxPieChartModule` | Part-to-whole pie and donut charts |
21+
| `IgxDataPieChartComponent` | `IgxDataPieChartModule` | Simplified API for pie charts |
22+
| `IgxLegendComponent` | `IgxLegendModule` | Shared legend component |
1723

1824
### When to use each:
1925
- **Category Chart** → Use for simple area/bar/column; let framework auto-configure
@@ -27,11 +33,14 @@ Ignite UI for Angular Charts provides 65+ chart types for data visualization. Ch
2733

2834
### Data Binding
2935
```typescript
30-
// All chart components require ItemsSource (array of data objects)
31-
chartComponent.itemsSource = [
36+
// Category Chart uses 'dataSource' to bind data (auto-detects numeric fields)
37+
chartComponent.dataSource = [
3238
{ month: 'Jan', revenue: 5000 },
3339
{ month: 'Feb', revenue: 6500 }
3440
];
41+
42+
// Data Chart uses 'itemsSource' and explicit series configuration
43+
chartComponent.itemsSource = dataArray;
3544
```
3645

3746
### Chart Type Selection
@@ -41,10 +50,25 @@ chartComponent.itemsSource = [
4150
- **Pie Chart**: No chartType needed; inherent pie structure
4251

4352
### Required Properties
44-
- `itemsSource` — Data array (required for all charts)
45-
- `valueMemberPath` — For Category/Financial/Pie charts; which property contains numeric values
46-
- `labelMemberPath` or `legendLabelMemberPath` — Category/label data
47-
- `xAxisLabel` / `yAxisLabel` — Axis title properties
53+
54+
**IgxCategoryChartComponent** (simplest API; auto-detects numeric & string columns):
55+
- `dataSource` — Data array (required)
56+
- `chartType` — Chart type (Area, Bar, Column, Line, etc.)
57+
- Component auto-detects: first string column → X-axis labels, numeric columns → Y-axis data
58+
59+
**IgxDataChartComponent** (advanced; requires explicit configuration):
60+
- `itemsSource` — Data array (required)
61+
- `valueMemberPath` — Which property contains numeric values (for series)
62+
- Requires explicit axis and series components
63+
64+
**IgxFinancialChartComponent** (stock data):
65+
- `dataSource` — Data array with date + OHLC columns
66+
- `openMemberPath`, `highMemberPath`, `lowMemberPath`, `closeMemberPath` — OHLC field names
67+
68+
**IgxPieChartComponent**:
69+
- `dataSource` — Data array
70+
- `labelMemberPath` — Field with category labels
71+
- `valueMemberPath` — Field with numeric values
4872

4973
### Responsive & Sizing
5074
- Charts auto-resize with container
@@ -193,33 +217,30 @@ chartComponent.itemsSource = [
193217

194218
## Common API Members by Chart Type
195219

196-
### IgxCategoryChartComponent (Area, Bar*, Column, Line, etc.)
220+
### IgxCategoryChartComponent (Area, Bar, Column, Line, etc.)
197221
```typescript
198-
chartType: ChartType;
199-
itemsSource: any[];
200-
valueMemberPath: string;
201-
categoryXAxis: boolean;
202-
xAxisTitle: string;
203-
yAxisTitle: string;
204-
xAxisLabelLocation: AxisLabelLocation;
222+
// Required
223+
dataSource: any[]; // Data array (auto-detects numeric fields)
224+
chartType: ChartType; // Area, Bar, Column, Line, Waterfall, etc.
225+
226+
// Common optional inputs
227+
xAxisTitle: string; // X-axis label
228+
yAxisTitle: string; // Y-axis label
229+
xAxisLabelLocation: AxisLabelLocation; // Axis label alignment
205230
yAxisLabelLocation: AxisLabelLocation;
206-
yAxisMinimumValue: number;
207-
yAxisMaximumValue: number;
208-
brushes: string[];
209-
outlines: string[];
210-
markerTypes: MarkerType[];
211-
markerBrushes: string[];
212-
markerOutlines: string[];
213-
showDefaultTooltip: boolean;
214-
toolTipType: ToolTipType;
215-
isHorizontalZoomEnabled: boolean;
216-
isVerticalZoomEnabled: boolean;
217-
crosshairsDisplayMode: CrosshairsDisplayMode;
218-
highlightingMode: HighlightingMode;
231+
yAxisMinimumValue: number; // Y-axis minimum
232+
yAxisMaximumValue: number; // Y-axis maximum
233+
brushes: string[]; // Series colors (fill)
234+
outlines: string[]; // Series colors (outline)
235+
markerTypes: MarkerType[]; // Marker shapes (Circle, Square, etc.)
236+
markerBrushes: string[]; // Marker fill colors
237+
markerOutlines: string[]; // Marker outline colors
238+
toolTipType: ToolTipType; // Tooltip display mode
239+
highlightingMode: HighlightingMode; // Hover highlight behavior
219240
highlightingBehavior: HighlightingBehavior;
220-
trendLineType: TrendLineType;
221-
transitionInMode: TransitionInMode;
222-
transitionDuration: number;
241+
trendLineType: TrendLineType; // Trendline visualization
242+
transitionInMode: TransitionInMode; // Animation on load
243+
transitionInDuration: number; // Animation duration (milliseconds)
223244
```
224245

225246
### IgxFinancialChartComponent (Stock/Candlestick/OHLC)
@@ -272,30 +293,24 @@ highlightingMode: HighlightingMode;
272293

273294
## Import Paths
274295

275-
All charts come from `igniteui-angular-charts` entry point:
296+
> **Chart components are NOT standalone** — always import via their NgModule, never by component class. Standalone Angular components can import NgModules directly in their `imports` array.
297+
298+
### NgModule imports (required for all project types)
276299

277300
```typescript
278-
// Category, Financial, Data Chart components
279-
import {
280-
IgxCategoryChartComponent,
281-
IgxFinancialChartComponent,
282-
IgxDataChartComponent,
283-
// Series components
284-
IgxAreaSeriesComponent,
285-
IgxBarSeriesComponent,
286-
IgxColumnSeriesComponent,
287-
IgxLineSeriesComponent,
288-
// ...
289-
// Axes
290-
IgxCategoryXAxisComponent,
291-
IgxNumericYAxisComponent,
292-
// Annotations
293-
IgxCrosshairLayerComponent,
294-
IgxFinalValueLayerComponent,
295-
IgxCalloutLayerComponent,
296-
// Data Legend
297-
IgxDataLegendComponent,
298-
// Enums
301+
// NgModules — import these into your standalone component's 'imports' array
302+
// or into an NgModule's 'imports' array
303+
import {
304+
IgxCategoryChartModule, // provides IgxCategoryChartComponent
305+
IgxFinancialChartModule, // provides IgxFinancialChartComponent
306+
IgxDataChartModule, // provides IgxDataChartComponent + all series/axes
307+
IgxPieChartModule, // provides IgxPieChartComponent
308+
IgxDataPieChartModule, // provides IgxDataPieChartComponent
309+
IgxLegendModule, // provides IgxLegendComponent
310+
} from 'igniteui-angular-charts';
311+
312+
// Enums and types — these ARE plain TS exports and can be imported directly
313+
import {
299314
ChartType,
300315
FinancialChartType,
301316
MarkerType,
@@ -312,15 +327,74 @@ import {
312327
VolumeType,
313328
AxisMode
314329
} from 'igniteui-angular-charts';
330+
```
331+
332+
### Standalone component example
315333

316-
// Pie charts
334+
```typescript
335+
import { Component } from '@angular/core';
317336
import {
318-
IgxPieChartComponent,
319-
IgxDataPieChartComponent,
320-
IgxLegendComponent
337+
IgxCategoryChartModule,
338+
ChartType
321339
} from 'igniteui-angular-charts';
340+
341+
@Component({
342+
selector: 'app-sales-chart',
343+
imports: [
344+
IgxCategoryChartModule // ✅ Import the NgModule, NOT IgxCategoryChartComponent
345+
],
346+
template: `
347+
<igx-category-chart
348+
[dataSource]="data"
349+
chartType="Column"
350+
xAxisTitle="Month"
351+
yAxisTitle="Revenue ($)"
352+
[transitionInMode]="'FromZero'"
353+
[transitionInDuration]="400">
354+
</igx-category-chart>
355+
`
356+
})
357+
export class SalesChartComponent {
358+
data = [
359+
{ month: 'Jan', revenue: 5000 },
360+
{ month: 'Feb', revenue: 6500 },
361+
{ month: 'Mar', revenue: 7200 }
362+
];
363+
}
322364
```
323365

366+
### Common errors and fixes
367+
368+
**Error 1: NG2011 — component not standalone**
369+
```
370+
// ❌ WRONG: importing component directly
371+
import { IgxCategoryChartComponent } from 'igniteui-angular-charts';
372+
@Component({ imports: [IgxCategoryChartComponent] })
373+
374+
// ✅ CORRECT: import the NgModule instead
375+
import { IgxCategoryChartModule } from 'igniteui-angular-charts';
376+
@Component({ imports: [IgxCategoryChartModule] })
377+
```
378+
379+
**Error 2: NG8002 — can't bind to property (incorrect inputs)**
380+
```
381+
// ❌ WRONG: using IgxDataChartComponent or generic property names
382+
<igx-category-chart
383+
[itemsSource]="data" <!-- Use 'dataSource' instead -->
384+
[valueMemberPath]="'value'" <!-- Auto-detected for Category Chart -->
385+
[showDefaultTooltip]="true" <!-- Not a valid input -->
386+
[transitionDuration]="400"> <!-- Use 'transitionInDuration' -->
387+
388+
// ✅ CORRECT: use Category Chart's actual inputs
389+
<igx-category-chart
390+
[dataSource]="data"
391+
chartType="Column"
392+
[transitionInMode]="'FromZero'"
393+
[transitionInDuration]="400">
394+
```
395+
396+
**Key difference**: IgxCategoryChartComponent **auto-detects** numeric columns and requires minimal configuration. For fine-grained control over field mapping and series types, use `IgxDataChartComponent` instead (but it requires explicit series and axis components).
397+
324398
---
325399

326400
## Styling & Theming

0 commit comments

Comments
 (0)