-
Notifications
You must be signed in to change notification settings - Fork 5
feat(skills): adding complete data chart example #143
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4e690d9
feat(*): adding complete data chart example
645d953
Update skills/igniteui-react-components/reference/CHARTS-GRIDS.md
kdinev eb296d7
fix(skills): removing Reveal SDK from igniteui-react skills
kdinev 103fe44
Merge branch 'charts-grids-skill' of https://github.com/IgniteUI/igni…
kdinev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ IgrCategoryChartModule.register(); | |||||||
| | Component | Module Import | Registration | | ||||||||
| |---|---|---| | ||||||||
| | `IgrCategoryChart` | `IgrCategoryChartModule` | `IgrCategoryChartModule.register()` | | ||||||||
| | `IgrDataChart` | `IgrDataChartCoreModule` + category/annotation modules (see [Complete Data Chart Example](#complete-data-chart-example)) | Multiple `.register()` calls required | | ||||||||
| | `IgrPieChart` | `IgrPieChartModule` | `IgrPieChartModule.register()` | | ||||||||
| | `IgrFinancialChart` | `IgrFinancialChartModule` | `IgrFinancialChartModule.register()` | | ||||||||
| | `IgrRadialGauge` | `IgrRadialGaugeModule` | `IgrRadialGaugeModule.register()` | | ||||||||
|
|
@@ -90,6 +91,222 @@ export default function DashboardView() { | |||||||
| } | ||||||||
| ``` | ||||||||
|
|
||||||||
| ## Complete Data Chart Example | ||||||||
|
|
||||||||
| > **⚠️ IMPORTANT:** `IgrDataChart` requires registering **multiple modules** depending on the series type used. For bar charts, register the modules shown below. If you miss any module, the chart or axis types will silently fail to render. | ||||||||
|
|
||||||||
| ### Module Registration for Bar Charts | ||||||||
|
|
||||||||
| ```tsx | ||||||||
| import { | ||||||||
| IgrLegendModule, | ||||||||
| IgrDataChartCoreModule, | ||||||||
| IgrDataChartCategoryCoreModule, | ||||||||
| IgrDataChartCategoryModule, | ||||||||
| IgrDataChartInteractivityModule, | ||||||||
| IgrDataChartVerticalCategoryModule, | ||||||||
| IgrDataChartAnnotationModule, | ||||||||
| } from 'igniteui-react-charts'; | ||||||||
|
|
||||||||
| // Register all required modules once at module level (outside any component) | ||||||||
| IgrLegendModule.register(); | ||||||||
| IgrDataChartCoreModule.register(); | ||||||||
| IgrDataChartCategoryCoreModule.register(); | ||||||||
| IgrDataChartCategoryModule.register(); | ||||||||
| IgrDataChartInteractivityModule.register(); | ||||||||
| IgrDataChartVerticalCategoryModule.register(); | ||||||||
| IgrDataChartAnnotationModule.register(); | ||||||||
| ``` | ||||||||
|
|
||||||||
| | Module | Purpose | | ||||||||
| |---|---| | ||||||||
| | `IgrDataChartCoreModule` | Core chart infrastructure | | ||||||||
| | `IgrDataChartCategoryCoreModule` | Base for category series | | ||||||||
| | `IgrDataChartCategoryModule` | Column, Line, Area, Spline etc. | | ||||||||
| | `IgrDataChartVerticalCategoryModule` | **Bar series** (horizontal bars) | | ||||||||
| | `IgrDataChartInteractivityModule` | Mouse hover, selection | | ||||||||
| | `IgrDataChartAnnotationModule` | Tooltip layers, callout layers | | ||||||||
| | `IgrLegendModule` | `IgrLegend` component | | ||||||||
|
|
||||||||
| ### Axis Choice for Bar Charts | ||||||||
|
|
||||||||
| | Chart Orientation | Category Axis | Value Axis | | ||||||||
| |---|---|---| | ||||||||
| | Bar (horizontal) | `IgrCategoryYAxis` | `IgrNumericXAxis` | | ||||||||
| | Column (vertical) | `IgrCategoryXAxis` | `IgrNumericYAxis` | | ||||||||
|
|
||||||||
| > **Bar charts are horizontal** — categories go on the Y-axis and numeric values on the X-axis. This is the opposite of column charts. | ||||||||
|
|
||||||||
| ### Complete Bar Chart Component (Multiple Series) | ||||||||
|
|
||||||||
| ```tsx | ||||||||
| import { useRef } from 'react'; | ||||||||
| import { | ||||||||
| IgrLegendModule, | ||||||||
| IgrDataChartCoreModule, | ||||||||
| IgrDataChartCategoryCoreModule, | ||||||||
| IgrDataChartCategoryModule, | ||||||||
| IgrDataChartInteractivityModule, | ||||||||
| IgrDataChartVerticalCategoryModule, | ||||||||
| IgrDataChartAnnotationModule, | ||||||||
| IgrLegend, | ||||||||
| IgrDataChart, | ||||||||
| IgrCategoryYAxis, | ||||||||
| IgrNumericXAxis, | ||||||||
| IgrCategoryHighlightLayer, | ||||||||
| IgrBarSeries, | ||||||||
| IgrDataToolTipLayer, | ||||||||
| } from 'igniteui-react-charts'; | ||||||||
| import styles from './bar-chart-view.module.css'; | ||||||||
|
|
||||||||
| // Register all required modules once at module level | ||||||||
| IgrLegendModule.register(); | ||||||||
| IgrDataChartCoreModule.register(); | ||||||||
| IgrDataChartCategoryCoreModule.register(); | ||||||||
| IgrDataChartCategoryModule.register(); | ||||||||
| IgrDataChartInteractivityModule.register(); | ||||||||
| IgrDataChartVerticalCategoryModule.register(); | ||||||||
| IgrDataChartAnnotationModule.register(); | ||||||||
|
|
||||||||
| interface MovieFranchise { | ||||||||
| franchise: string; | ||||||||
| totalRevenue: number; // total box office in billions USD | ||||||||
| highestGrossing: number; // highest single film in billions USD | ||||||||
| } | ||||||||
|
|
||||||||
| const movieData: MovieFranchise[] = [ | ||||||||
| { franchise: 'Marvel Universe', totalRevenue: 22.55, highestGrossing: 2.80 }, | ||||||||
| { franchise: 'Star Wars', totalRevenue: 10.32, highestGrossing: 2.07 }, | ||||||||
| { franchise: 'Harry Potter', totalRevenue: 9.19, highestGrossing: 1.34 }, | ||||||||
| { franchise: 'Avengers', totalRevenue: 7.76, highestGrossing: 2.80 }, | ||||||||
| { franchise: 'Spider Man', totalRevenue: 7.22, highestGrossing: 1.28 }, | ||||||||
| { franchise: 'James Bond', totalRevenue: 7.12, highestGrossing: 1.11 }, | ||||||||
| ]; | ||||||||
|
|
||||||||
| export default function BarChartView() { | ||||||||
| const legendRef = useRef<IgrLegend>(null); | ||||||||
|
|
||||||||
| return ( | ||||||||
| <div className={styles['chart-wrapper']}> | ||||||||
| <h3 className={styles['legend-title']}>Highest Grossing Movie Franchises</h3> | ||||||||
|
|
||||||||
| {/* Legend must be rendered before the chart so the ref is populated */} | ||||||||
| <IgrLegend ref={legendRef} orientation="Horizontal" /> | ||||||||
|
|
||||||||
| <div className={styles['chart-container']}> | ||||||||
| <IgrDataChart legend={legendRef.current ?? undefined}> | ||||||||
| {/* | ||||||||
| * IgrCategoryYAxis — category axis for horizontal bar charts. | ||||||||
| * - label: field name that supplies the axis labels. | ||||||||
| * - dataSource: the data array (required on the axis for bar charts). | ||||||||
| * - isInverted: renders top-to-bottom instead of bottom-to-top. | ||||||||
| * - gap / overlap: control bar spacing (gap) and multi-series overlap. | ||||||||
| */} | ||||||||
| <IgrCategoryYAxis | ||||||||
| name="yAxis" | ||||||||
| label="franchise" | ||||||||
| dataSource={movieData} | ||||||||
| isInverted={true} | ||||||||
| gap={0.5} | ||||||||
| overlap={-0.1} | ||||||||
| useEnhancedIntervalManagement={true} | ||||||||
| enhancedIntervalPreferMoreCategoryLabels={true} | ||||||||
| /> | ||||||||
|
|
||||||||
| {/* IgrNumericXAxis — value axis; start at 0 per bar chart best practices */} | ||||||||
| <IgrNumericXAxis | ||||||||
| name="xAxis" | ||||||||
| title="Billions of U.S. Dollars" | ||||||||
|
||||||||
| title="Billions of U.S. Dollars" | |
| title="Billions of U.S. Dollars" | |
| minimumValue={0} |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
legend={legendRef.current ?? undefined}pattern won’t reliably wire up the legend:legendRef.currentisnullduring render and refs don’t trigger a re-render when they’re populated, so the chart will likely keeplegendasundefined. Use a callback ref / state setter to trigger a re-render, or setchartRef.current.legendin auseEffectafter mount (and update the nearby comment that rendering order is sufficient).