Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions generative/frontend/jwebmp/agcharts-enterprise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ What this covers
- Troubleshooting and diagnostics

Quick links
- **[NEW] Release Notes v2.0.0** — ./RELEASE_NOTES_v2.0.0.md
- Plugin overview and integration — ./agcharts-enterprise-integration.rules.md
- Grid ↔ Charts Data Binding — ./grid-data-binding.rules.md
- Page Configurator — ./page-configurator.rules.md
- Licensing & Activation — ./licensing-and-activation.rules.md
- Java Usage Guide (Java-only) — ./java-usage-guide.rules.md
Expand Down
255 changes: 255 additions & 0 deletions generative/frontend/jwebmp/agcharts-enterprise/RELEASE_NOTES_v2.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
# AG Grid Enterprise + AG Charts Enterprise v2.0.0 Release Notes

## Overview
Version 2.0.0 introduces **Grid-to-Charts Data Binding** — a comprehensive framework for synchronizing AG Grid data with AG Charts Enterprise, enabling coordinated dashboards with cross-filtering and selection sync.

## New Features

### Grid ↔ Charts Data Binding
- **Unified Data Model**: Single data source powers both grid and charts with automatic synchronization.
- **Cross-Filtering**: Chart interactions filter grid rows; grid filters update charts in real-time.
- **Selection Sync**: Grid row selection highlights corresponding chart data points and vice versa.
- **Custom Data Bridges**: Implement `IChartDataBridge<T>` for domain-specific data transformations and coordination logic.
- **Registry Pattern**: Centralized `ChartRegistry` manages chart instances, relationships, and event lifecycle.

### Core Components (New)

#### `IChartDataBridge<T>`
Abstraction layer for bidirectional data synchronization:
- Generic over row data type (POJO, Map, custom types)
- Methods: `getGridRowData()`, `onGridDataChanged()`, `onGridSelectionChanged()`, `onChartInteraction()`
- Field mapping support for grid column → chart property projection
- Listener pattern for chart interaction events

#### `ChartConfiguration`
Metadata container for chart-grid relationships:
- 58 fluent properties for complete chart customization
- Chart ID, type, title, themes
- Data bridge and grid references
- Field mapping configuration
- Feature flags: enableCrossFiltering, enableSelectionSync
- Theme overrides and custom options

#### `ChartRegistry`
Singleton registry for lifecycle and relationship management:
- Thread-safe with ConcurrentHashMap
- Manages chart registration, data bridges, and grid-chart linking
- Event listener support for chart lifecycle
- Retrieve linked charts by grid ID

### AgGridEnterprise Helper Methods
Five new fluent methods for simplified chart integration:

1. **`linkCharts(String... chartIds)`** — Link pre-registered charts by ID
2. **`registerAndLinkChart(ChartConfiguration config)`** — Create and link atomically
3. **`enableChartCrossFiltering()`** — Activate bidirectional filtering
4. **`enableChartSelectionSync()`** — Enable selection highlighting
5. **`getChartRegistry()`** — Static accessor to ChartRegistry singleton

All methods follow CRTP pattern: return `(J) this` for method chaining.

## Integration Patterns

### Basic Linking
```java
grid.registerAndLinkChart(new ChartConfiguration("chart1", "bar")
.setTitle("Sales by Region")
.setFieldMapping(Map.of("region", "x", "sales", "y")));
```

### Cross-Filtering
```java
grid.registerAndLinkChart(new ChartConfiguration("chart1", "line")
.setTitle("Sales Trend")
.setEnableCrossFiltering(true)
.setFieldMapping(Map.of("month", "x", "amount", "y")))
.enableChartCrossFiltering();
```

### Selection Sync
```java
grid.enableCharts()
.registerAndLinkChart(new ChartConfiguration("chart1", "pie")
.setTitle("Market Share")
.setEnableCrossFiltering(true)
.setEnableSelectionSync(true)
.setFieldMapping(Map.of("competitor", "label", "share", "value")))
.enableChartSelectionSync();
```

### Custom Data Bridge
```java
class SalesDataBridge implements IChartDataBridge<SalesRecord> {
@Override
public List<SalesRecord> getGridRowData() {
return salesService.getRecords();
}

@Override
public void onGridDataChanged(List<SalesRecord> newData) {
ChartRegistry.getInstance().updateChartData("salesChart", newData);
}

@Override
public Map<String, String> getFieldMapping() {
return Map.of("region", "x", "sales", "y");
}
}

ChartRegistry.getInstance()
.registerDataBridge("bridge1", new SalesDataBridge())
.registerChart(new ChartConfiguration("salesChart", "bar")
.setTitle("Sales Analysis")
.setDataBridgeId("bridge1"));
```

## Architecture

### Data Flow
```
┌─────────────────┐
│ Grid Data │
│ (Row Model) │
└────────┬────────┘
├─────────────────────────┐
│ │
v v
[ChartRegistry] [ChartRegistry]
│ │
Chart #1 ◄────────► Chart #2
(Bar Chart) Cross- (Line Chart)
Filtering
│ │
└────────────┬────────────┘
[Grid Selection Sync]
Row Highlight
```

### Thread Safety
- `ChartRegistry` uses `ConcurrentHashMap` for thread-safe access
- Safe for multi-threaded grid updates and chart interactions
- Event listeners are notified asynchronously

### Registry Event Lifecycle
1. `onChartRegistered(ChartConfiguration)` — Chart added to registry
2. `onChartUnregistered(String chartId)` — Chart removed from registry
3. `onChartsLinkedToGrid(String gridId, List<String> chartIds)` — Charts associated with grid
4. `onDataBridgeRegistered(String bridgeId, IChartDataBridge)` — Data bridge added
5. `onChartDataUpdated(String chartId, List<Map>)` — Chart data refreshed

## Field Mapping Reference

### Bar / Column Charts
- Grid columns map to: `x` (category), `y` (series values), `color` (optional)
- Example: `region→x, sales→y, quarter→color`

### Line Charts
- Grid columns map to: `x` (x-axis), `y` (series), `strokeColor` (optional)
- Example: `date→x, revenue→y, department→strokeColor`

### Pie / Doughnut Charts
- Grid columns map to: `label` (segment labels), `value` (segment sizes)
- Example: `category→label, percentage→value`

### Scatter Charts
- Grid columns map to: `x` (x-axis), `y` (y-axis), `size` (optional), `color` (optional)
- Example: `height→x, weight→y, age→size`

### Waterfall Charts
- Grid columns map to: `x` (categories), `y` (values), `isIntermediateTotal`, `isTotal`
- Example: `month→x, amount→y, isQuarterEnd→isIntermediateTotal`

## Best Practices

### IDs and References
- Use consistent, descriptive chart IDs: `"sales-regional"`, `"forecast-monthly"`
- Grid IDs auto-generated; access via `getGridId()` (private, but used internally)
- Bridge IDs should indicate data source: `"bridge-sales"`, `"bridge-forecast"`

### Field Mapping
- Define mappings before linking charts
- Validate grid column names against data model
- Use consistent naming: snake_case or camelCase throughout
- Document custom field transformations in `IChartDataBridge`

### Data Bridges
- Implement for custom transformations (filtering, aggregation, calculation)
- Keep synchronous; use async tasks only for heavy computations outside grid
- Store computed data in bridge instance variables if needed
- Test field mapping with sample data before deployment

### Performance
- Large datasets (>10K rows): aggregate on server before charting
- Enable cross-filtering selectively; it has CPU cost on interactions
- Use pagination for grids with charts to reduce rendering overhead
- Profile chart update performance; consider debouncing rapid grid changes

### Error Handling
- Catch `NullPointerException` when accessing unregistered bridge IDs
- Validate field mapping exists before `enableChartCrossFiltering()`
- Log chart interaction errors; don't fail grid updates on chart exceptions
- Fail fast on registration; use try-catch around `registerAndLinkChart()`

## Migration from v1.x

- **No breaking changes**: Existing grid and chart code continues to work unchanged
- **Additive only**: New chart binding APIs are optional; use when needed
- **Backward compatible**: Community plugin still works; enterprise features enhance it
- **Opt-in**: Chart linking requires explicit `registerAndLinkChart()` or `linkCharts()` calls

## Documentation

- **User Guide**: `docs/ChartGridIntegration-Guide.md` — 650+ lines with examples and best practices
- **Rules Reference**: `./grid-data-binding.rules.md` — 450+ lines with patterns and API details
- **Integration Guide**: `./agcharts-enterprise-integration.rules.md` — Quick start and configuration
- **Troubleshooting**: `./troubleshooting.rules.md` — 7 chart-grid scenarios with diagnosis/solution
- **Java Usage**: `./java-usage-guide.rules.md` — Java API reference and patterns

## Technical Details

### Compilation
- **Java Version**: 25 (module-path compilation)
- **Dependencies**: AG Grid 34.2.0, AG Charts 12.2.0, MapStruct (entity mapping)
- **Build Status**: ✅ SUCCESS (`mvn clean compile`)
- **Package**: ✅ `aggrid-enterprise-2.0.0-SNAPSHOT.jar` created

### Module System
- Explicit module exports in `module-info.java`
- ServiceLoader discovery for `IPageConfigurator`
- Raw type suppression for service providers as needed

### Licensing
- Requires AG Grid Enterprise license (already required)
- Requires AG Charts Enterprise license (new in v2.0.0)
- Initialize licenses per `./licensing-and-activation.rules.md`

## Support & Feedback

- Report issues via GitHub Issues (link to repo)
- Request features via GitHub Discussions (link to repo)
- See `./troubleshooting.rules.md` for common issues
- Review `docs/ChartGridIntegration-Guide.md` for detailed examples

## Changelog

### v2.0.0 (Current)
- **NEW**: Grid-to-charts data binding framework
- **NEW**: IChartDataBridge interface for custom data coordination
- **NEW**: ChartConfiguration class with 58 fluent properties
- **NEW**: ChartRegistry singleton with event listeners
- **NEW**: 5 helper methods on AgGridEnterprise for simplified linking
- **NEW**: Cross-filtering support (grid ↔ charts)
- **NEW**: Selection sync support (grid ↔ charts)
- **NEW**: Comprehensive grid-data-binding.rules.md documentation
- **NEW**: Troubleshooting guide for chart-grid integration
- **IMPROVED**: agcharts-enterprise-integration.rules.md with grid binding examples
- **VERIFIED**: Full backward compatibility with v1.x code

---

**Release Date**: [Current Date]
**Version**: 2.0.0-SNAPSHOT
**Artifact**: `com.jwebmp.plugins:aggrid-enterprise:2.0.0-SNAPSHOT`
Original file line number Diff line number Diff line change
@@ -1,38 +1,87 @@
# AgCharts Enterprise Integration — Rules

Overview
## Overview
- This module extends the community AgCharts plugin to activate AG Charts Enterprise features in JWebMP applications.
- It mirrors the model used by WebAwesomePro extending WebAwesome and FullCalendarPro extending FullCalendar.
- **New in v2.0.0**: Integrated grid-to-charts data binding for synchronized dashboards with cross-filtering and selection sync.

Usage patterns
## Usage patterns

### Basic Usage
- Add Maven dependency: com.jwebmp.plugins:agcharts-enterprise:${version} (version via BOM recommended).
- Keep community plugin dependency present: com.jwebmp.plugins:agcharts.
- Use charts as normal through JWebMP; enterprise features become available on the client when the Page Configurator includes the TypeScript dependency for `ag-charts-enterprise`.
- Reference architecture & sequence diagrams in `docs/architecture/` via `docs/PROMPT_REFERENCE.md` before generating code; they define the required containers and build flow.

Minimal example
### Grid-Charts Integration (v2.0.0+)
- Link AG Grid data to AG Charts Enterprise for coordinated dashboards.
- Enable cross-filtering: chart selections filter grid rows; grid filters update charts.
- Enable selection sync: grid row selection highlights chart data points.
- Use `IChartDataBridge` for custom data transformations and event coordination.
- Manage charts via centralized `ChartRegistry` for lifecycle and relationship tracking.
- See `grid-data-binding.rules.md` for detailed patterns and API reference.

## Minimal example

### Charts Only
- Server-side (Java/JWebMP): continue to construct charts as with the community plugin; no API change required for basic usage.
- Ensure the Page Configurator from this module is on the classpath (auto-discovery via Java ServiceLoader and JWebMP conventions).

Quick start checklist
### Grid + Charts (v2.0.0+)
```java
// Create grid with data
AgGridEnterprise<AgGridEnterprise<?>> grid = new AgGridEnterprise<>("salesGrid")
.setRowData(loadSalesData())
.enableCharts()

// Register and link a chart
.registerAndLinkChart(new ChartConfiguration("regionChart", "pie")
.setTitle("Sales by Region")
.setFieldMapping(Map.of(
"region", "label",
"sales", "value",
"regionId", "id"
))
.setEnableCrossFiltering(true))

// Enable coordination features
.enableChartCrossFiltering();
```

## Quick start checklist

1. Import the JWebMP BOM plus `com.jwebmp.plugins:agcharts` and this module.
2. Confirm ServiceLoader discovery: `META-INF/services/com.jwebmp.core.services.IPageConfigurator` includes `AgChartsEnterprisePageConfigurator`.
3. Annotate charts via CRTP fluent APIs (see ./java-usage-guide.rules.md and ./usage-examples.rules.md for patterns).
4. Run a build (`mvn clean package`); verify generated Angular `package.json` lists `ag-charts-enterprise` and `ag-charts-angular`.
5. Provide AG Charts Enterprise license initialization per ./licensing-and-activation.rules.md if required by your deployment.
3. **For Grid+Charts**: Use `AgGridEnterprise.registerAndLinkChart()` or `ChartRegistry.getInstance().registerChart()` to establish chart-grid relationships.
4. Annotate charts via CRTP fluent APIs (see ./java-usage-guide.rules.md and ./usage-examples.rules.md for patterns).
5. Run a build (`mvn clean package`); verify generated Angular `package.json` lists `ag-charts-enterprise` and `ag-charts-angular`.
6. Provide AG Charts Enterprise license initialization per ./licensing-and-activation.rules.md if required by your deployment.

Configuration
- TypeScript dependency: `ag-charts-enterprise` is pulled in by the Page Configurator using @TsDependency.
## Configuration

### TypeScript dependency
- `ag-charts-enterprise` is pulled in by the Page Configurator using @TsDependency.
- Angular peer dependencies: community plugin typically includes `ag-charts-community` and `ag-charts-angular`; this enterprise plugin complements them.

Performance/constraints
### Grid-Charts Coordination (v2.0.0+)
- Register charts via `ChartRegistry` or `grid.registerAndLinkChart()`.
- Define field mappings to sync grid columns with chart properties.
- Enable cross-filtering and selection sync on `ChartConfiguration` or via grid helper methods.
- Optionally implement custom `IChartDataBridge` for complex data flows.

## Performance/constraints

- Do not bundle or edit generated TS; rely on the build to include dependencies.
- Enterprise features may increase bundle size; tree-shake when possible.
- Licensing is required per AG Charts Enterprise terms; see licensing-and-activation.rules.md.
- **For large datasets**: Implement server-side aggregation before charting to avoid performance degradation.

## See also

See also
- Page Configurator — ./page-configurator.rules.md
- Grid-Data Binding — ./grid-data-binding.rules.md (new in v2.0.0)
- Licensing — ./licensing-and-activation.rules.md
- Usage examples — ./usage-examples.rules.md
- Troubleshooting — ./troubleshooting.rules.md
- Angular index — ../../../language/angular/README.md

Loading
Loading