Back to Ag Grid

Recent Feature Additions

external/ag-shared/prompts/skills/example/ag-charts/features/recent-features.md

100.0.024.5 KB
Original Source

Recent Feature Additions

Track the latest AG Charts capabilities to ensure gallery examples showcase cutting-edge features.

πŸ†• Recently Added Features (Post b12.2.0)

⚑ Quick Date/Price Measurement Overlay

For base annotation setup, see enterprise.md. This section covers the quick measurement overlay added in Mar 2025.

New Mar 2025 β€’ Apply: 6 minutes β€’ Impact: HIGH ⭐ RECOMMENDED for financial timelines

typescript
annotations: {
    enabled: true,
},
initialState: {
    annotations: [
        {
            type: 'quick-date-price-range',
            start: { x: new Date('2025-01-06'), y: 98 },
            end: { x: new Date('2025-01-15'), y: 112 },
            text: { label: 'January rally' },
            up: {
                statistics: {
                    fillOpacity: 0.3, // Theme handles colors
                },
            },
            down: {
                statistics: {
                    fillOpacity: 0.15,
                },
            },
        },
    ],
},

Highlights: Instant measurement of both price and time deltas with theme-aware styling and directional up/down overrides.

🎯 Highlight Drawing Modes

New Mar 2025 β€’ Apply: 2 minutes β€’ Impact: MEDIUM

typescript
series: [
    {
        type: 'line',
        xKey: 'date',
        yKey: 'close',
        highlight: {
            drawingMode: 'cutout', // or 'overlay' (default)
            highlightedItem: {
                strokeWidth: 3,
            },
        },
    },
];

Use when: You want hover states to punch through dense fills ('cutout') or sit on top ('overlay').

πŸ” Lightweight Data Transactions

New Mar 2025 β€’ Apply: 3 minutes β€’ Impact: MEDIUM

typescript
import type { AgDataTransaction } from 'ag-charts-types';

const newBars = getLatestRows();

const transaction: AgDataTransaction<(typeof newBars)[number]> = {
    append: newBars,
    remove: [{ quarter: '2022 Q1' }],
};

await chart.applyTransaction(transaction);

Why: Append, prepend, or remove data without rebuilding the chartβ€”perfect for live dashboards.

πŸͺ„ Rich Text Formatters Everywhere

New Mar 2025 β€’ Apply: 5 minutes β€’ Impact: HIGH

typescript
formatter: {
    y: ({ value }) => [
        { text: value >= 0 ? '+' : '', fontWeight: 'bold' },
        { text: value.toFixed(1) },
        { text: ' %', opacity: 0.7 },
    ],
},
axes: {
    x: {
        type: 'time',
        position: 'bottom',
        label: {
            formatter: ({ value }) => [
                { text: value.toLocaleString('en-US', { month: 'short' }) },
                { text: ` ${value.getFullYear()}`, opacity: 0.6 },
            ],
        },
    },
};

Scope: Works for axes, labels, navigator mini-chart labels, and chart-level captions.

🧭 Axis Cross Positioning

New Mar 2025 β€’ Apply: 4 minutes β€’ Impact: MEDIUM

typescript
axes: {
    y: {
        type: 'number',
        position: 'left',
        crossAt: {
            value: 0,
            sticky: true, // Keep origin locked to the plotted domain
        },
    },
    x: {
        type: 'time',
        position: 'bottom',
        crossAt: { value: new Date('2025-01-01') },
    },
};

Use for: Center-origin charts, quadrant layouts, and custom axis intersections without manual offsets.

πŸ“Š Series Segmentation

New Jan 2025 β€’ Apply: 8 minutes β€’ Impact: HIGH ⭐ RECOMMENDED

typescript
// Style different segments of a series with different colors/patterns
series: [
    {
        type: 'bar',
        segmentation: {
            enabled: true,
            key: 'y', // Segment by y-axis values
            segments: [
                {
                    start: 0,
                    stop: 50,
                    // Don't set fill/stroke - theme handles segment colors
                },
                {
                    start: 50,
                    stop: 100,
                    // Different theme color automatically applied
                },
                {
                    start: 100,
                    // Extends to domain end
                    // Another theme color automatically applied
                },
            ],
        },
    },
];

Replaces: Complex itemStyler logic for value-based coloring, manual data splitting

🎨 Series-Level Stylers

New Jan 2025 β€’ Apply: 6 minutes β€’ Impact: MEDIUM

typescript
// Apply consistent styling to entire series (vs individual items)
series: [
    {
        type: 'line',
        styler: (params) => {
            // Access series-level properties
            const { seriesId, seriesName, highlightState } = params;

            if (highlightState === 'highlighted-series') {
                return {
                    strokeWidth: 3,
                    // Don't hardcode colors - let theme handle it
                };
            }
            return {}; // Use defaults when not highlighted
        },
    },
];

Replaces: Repetitive itemStyler implementations, manual series state management

🏷️ Enhanced Axis Label Stylers

New Jan 2025 β€’ Apply: 5 minutes β€’ Impact: MEDIUM

typescript
axes: {
    y: {
        type: 'number', // Required
        position: 'left',
        label: {
            itemStyler: (params) => {
                const { value, formattedValue } = params;

                // Style specific labels differently
                if (value === 0) {
                    return {
                        fontWeight: 'bold',
                        // Don't set color - theme handles contrast
                    };
                }
                return {};
            },
        },
    },
};

Replaces: Complex label formatter workarounds, custom label rendering

🎯 Pie Callout Line Stylers

New Jan 2025 β€’ Apply: 6 minutes β€’ Impact: MEDIUM

typescript
series: [
    {
        type: 'pie',
        calloutLine: {
            itemStyler: (params) => {
                const { datum, angleKey, value } = params;

                // Emphasize high-value segments
                if (value > 1000000) {
                    return {
                        strokeWidth: 2,
                        length: 30,
                        // Don't set color - theme handles callout colors
                    };
                }
                return {};
            },
        },
    },
];

Replaces: Manual callout line customization, complex label positioning logic

🌊 Range Area Enhancements

New Mar 2025 β€’ Apply: 6 minutes β€’ Impact: HIGH

typescript
series: [
    {
        type: 'range-area',
        xKey: 'date',
        yLowKey: 'low',
        yHighKey: 'high',
        styler: ({ itemType }) => {
            if (itemType === 'high') {
                return { lineDash: [6, 3] };
            }
            return {};
        },
        label: {
            enabled: true,
            formatter: ({ itemType, value }) => `${itemType === 'high' ? 'High' : 'Low'}: ${value.toFixed(0)}`,
        },
        invertedStyle: {
            fillOpacity: 0.35, // Theme picks fill color
        },
        highlight: {
            series: {
                item: {
                    strokeWidth: 2,
                },
            },
        },
    },
];

Takeaway: Use styler, itemType aware label callbacks, and invertedStyle to emphasise band flips without resorting to manual fills.

πŸͺ΅ Range Bar Styling Hooks

New Mar 2025 β€’ Apply: 5 minutes β€’ Impact: MEDIUM

typescript
series: [
    {
        type: 'range-bar',
        xKey: 'task',
        yLowKey: 'start',
        yHighKey: 'finish',
        direction: 'horizontal',
        cornerRadius: 8,
        styler: ({ highlightState }) => (highlightState === 'highlighted-item' ? { strokeWidth: 2 } : {}),
        label: {
            enabled: true,
            placement: 'outside',
            formatter: ({ itemType, value }) => `${itemType === 'high' ? 'Finish' : 'Start'}: ${value}`,
        },
    },
];

Why: Dedicated stylers and label params replace brittle tooltip hacks for Gantt-style visuals.

πŸ“¦ Box Plot Precision Controls

New Mar 2025 β€’ Apply: 6 minutes β€’ Impact: MEDIUM

typescript
series: [
    {
        type: 'box-plot',
        xKey: 'group',
        yNameKey: 'label',
        styler: ({ highlightState }) => (highlightState === 'highlighted-item' ? { strokeWidth: 3 } : {}),
        cap: { strokeWidth: 2 },
        whisker: { strokeWidth: 1 },
        legendItemName: 'Distribution',
    },
];

Benefit: Fine-tune caps/whiskers and share legend entries across grouped series.

πŸ“ˆ Histogram Themeable Options

New Mar 2025 β€’ Apply: 4 minutes β€’ Impact: MEDIUM

typescript
theme: {
    overrides: {
        histogram: {
            series: {
                areaPlot: true,
                binCount: 20,
                aggregation: 'sum',
            },
        },
    },
},

Use: Move bin configuration into theme.overrides so multiple histogram instances stay in sync.

🧭 Radar Series Stylers

New Mar 2025 β€’ Apply: 5 minutes β€’ Impact: MEDIUM

typescript
series: [
    {
        type: 'radar-line',
        angleKey: 'metric',
        radiusKey: 'score',
        styler: ({ highlightState }) => (highlightState === 'highlighted-item' ? { strokeWidth: 4 } : {}),
        highlight: {
            series: {
                item: { strokeWidth: 3 },
            },
        },
    },
];

Outcome: Polar charts now share the same styler/highlight APIs as cartesian seriesβ€”leverage them for interactive dashboards.

🏷️ Legend Item Grouping

New Mar 2025 β€’ Apply: 3 minutes β€’ Impact: MEDIUM

typescript
series: [
    {
        type: 'range-area',
        legendItemName: 'Projected Range',
    },
    {
        type: 'line',
        legendItemName: 'Projected Range', // Shares toggle with range area
        showInLegend: true,
    },
];

chart.addEventListener('legendItemClick', ({ itemId, enabled }) => {
    console.log('Legend toggled', itemId, enabled);
});

Goal: Synchronise multiple series under one legend toggle and react to legend events using the new name.

πŸŒ‰ Sankey Layout Controls

New Mar 2025 β€’ Apply: 6 minutes β€’ Impact: HIGH

typescript
series: [
    {
        type: 'sankey',
        sort: 'descending', // 'data', 'ascending', 'descending', 'auto'
        node: {
            spacing: 24,
            minSpacing: 12,
            alignment: 'center',
            verticalAlignment: 'center',
            label: {
                placement: 'right',
                edgePlacement: 'outside',
            },
        },
    },
];

Result: Control spacing, alignment, sorting, and label placement without custom layers.

πŸ’Ή Custom Financial Range Buttons

New Mar 2025 β€’ Apply: 4 minutes β€’ Impact: HIGH

typescript
const chart = AgCharts.createFinancialChart({
    // ...base options
    ranges: {
        buttons: [
            '1W',
            '1M',
            { type: 'fixed', count: 90, label: '90D' },
            { type: 'callback', label: 'YTD', callback: ({ setRange }) => setRange('yearToDate') },
        ],
    },
});

Best for: Tailoring toolbars to analyst workflows (earnings windows, YTD, custom presets).

πŸ”„ Zoom Data Change Strategy

For base zoom setup, see enterprise.md. This section covers the data-change strategy added in Nov 2024.

New Nov 2024 β€’ Apply: 3 minutes β€’ Impact: MEDIUM

typescript
zoom: {
    enabled: true,
    onDataChange: {
        strategy: 'preserveDomain', // 'reset' | 'preserveDomain' | 'preserveRatios'
    },
}

Strategy Options:

  • 'reset': Reset zoom to show all data when data changes
  • 'preserveDomain' (default): Keep current zoom domain when data changes
  • 'preserveRatios': Adjust zoom to fit new data range while maintaining zoom level

Use for: Live data updates where you want to control how zoom behaves when new data arrives.

🌳 Hierarchy Highlight States

New Nov 2024 β€’ Apply: 5 minutes β€’ Impact: MEDIUM

typescript
series: [
    {
        type: 'treemap',
        sizeKey: 'value',
        labelKey: 'name',
        styler: (params) => {
            const { highlightState } = params;

            // Differentiate between directly hovered items and branch items
            if (highlightState === 'highlighted-item') {
                return { strokeWidth: 3 }; // Directly hovered
            }
            if (highlightState === 'highlighted-branch') {
                return { strokeWidth: 2, opacity: 0.8 }; // Same branch
            }
            if (highlightState === 'unhighlighted-branch') {
                return { opacity: 0.3 }; // Different branch
            }
            return {};
        },
    },
];

Available States:

  • 'highlighted-item': The directly hovered node
  • 'highlighted-branch': Nodes sharing the same root branch as the hovered item
  • 'unhighlighted-branch': Nodes in different branches
  • 'unhighlighted-item': Other items not in the hovered branch
  • 'none': Default state

Use for: Treemap and sunburst charts where you want to highlight related nodes in the same hierarchy branch.

πŸ“Š Series Axis Binding

New Nov 2024 β€’ Apply: 4 minutes β€’ Impact: MEDIUM

typescript
series: [
    {
        type: 'bar',
        xKey: 'category',
        yKey: 'volume',
        xKeyAxis: 'category', // Default: 'x'
        yKeyAxis: 'volume', // Bind to volume axis
    },
    {
        type: 'line',
        xKey: 'category',
        yKey: 'price',
        xKeyAxis: 'category', // Same x-axis
        yKeyAxis: 'price', // Bind to price axis
    },
],
axes: {
    category: { type: 'category', position: 'bottom' },
    price: { type: 'number', position: 'left' },
    volume: { type: 'number', position: 'right' }, // Secondary axis
}

Use for: Multi-axis charts where different series need to be bound to different axes, or polar charts with multiple angle/radius axes.

πŸ†• Recently Added Features (Past 6 Months)

πŸ”§ Global Font Theme Settings

New Dec 2024 β€’ Apply: 3 minutes β€’ Impact: Low ❌ GENERALLY AVOID

typescript
// ⚠️ ONLY use if you MUST override ALL fonts globally
// ❌ PREFER letting theme handle fonts automatically
theme: {
    params: {
        // ❌ AVOID setting fontSize - breaks theme consistency
        // ❌ AVOID setting fontWeight - unnecessary
        foregroundColor: '#333333',  // Only if absolutely needed
    }
}

Note: Theme defaults are almost always better than manual font overrides

🎯 Enhanced Marker Styling

New Dec 2024 β€’ Apply: 4 minutes β€’ Impact: Medium

typescript
series: [
    {
        marker: {
            lineDash: [4, 2], // Dashed marker borders
            lineDashOffset: 2,
            // Don't set stroke - use theme colors
            strokeWidth: 2,
        },
        // Use the newer highlight options instead of deprecated highlightStyle
        highlight: {
            highlightedItem: {
                // Don't hardcode colors
                strokeWidth: 3,
            },
        },
    },
];

Replaces: Simple solid marker borders, custom marker implementations

πŸ“Š Zoom Aspect Ratio Control

For base zoom setup, see enterprise.md. This section covers the aspect-ratio control added in Dec 2024.

Enterprise β€’ New Dec 2024 β€’ Apply: 6 minutes β€’ Impact: Medium

typescript
zoom: {
    enabled: true,
    enableSelecting: true,
    keepAspectRatio: true, // Maintain chart proportions during zoom selection
}

Replaces: Manual aspect ratio calculations in zoom implementations

πŸ” Enhanced Series Visibility Events

New Dec 2024 β€’ Apply: 5 minutes β€’ Impact: Low

typescript
listeners: {
    seriesVisibilityChange: (event) => {
        const { itemId, legendItemName, visible } = event;
        console.log(`${legendItemName} (${itemId}) is now ${visible ? 'visible' : 'hidden'}`);
    },
}

Replaces: Manual series state tracking and visibility detection

⚑ Field Dot Notation Control

New Nov 2024 β€’ Apply: 2 minutes β€’ Impact: Medium

typescript
data: getData(),
suppressFieldDotNotation: true, // Improves performance for complex nested data

Replaces: Manual data flattening and performance optimization workarounds

πŸ“… Previously Added Features (6-12 Months)

πŸ”„ Donut Series Inner Labels

New Aug 2024 β€’ Apply: 8 minutes β€’ Impact: High

typescript
// Replace manual center text with native inner labels
innerLabels: [
    {
        text: 'Total Sales',
        // ❌ Don't set fontSize/fontWeight - theme handles it
        // Don't set color - theme handles contrast
    },
    {
        text: '$1.2M',
        // ❌ Don't set fontSize/fontWeight - theme handles it
        // Don't set color - theme handles contrast
    },
];

Replaces: Manual HTML overlays or canvas text drawing

🎯 Enhanced Legend Positioning Strategy

New Jul 2024 β€’ Apply: 5 minutes β€’ Impact: VERY HIGH ⭐

typescript
// DECISION GUIDE FOR LEGEND POSITIONING:

// For MULTI-SERIES charts (consider floating with verification):
legend: {
    position: 'bottom', // Safe default
    // OR if space permits and verified:
    position: 'top-right',
    border: {
        enabled: true, // ALWAYS add border for floating
        strokeWidth: 1,
    },
    cornerRadius: 8,
    padding: 12,
}

Replaces: Complex CSS positioning and manual legend placement

🎨 Advanced Grid Line Styling

New Jun 2024 β€’ Apply: 6 minutes β€’ Impact: HIGH ⭐ RECOMMENDED

typescript
// Professional alternating bands - STRONGLY consider using this!
gridLine: {
    style: [
        {
            // Primary grid lines
            strokeWidth: 1,
            lineDash: [3, 3],
            // Don't set stroke - theme handles grid colors
        },
        {
            // Alternating background bands for visual clarity
            strokeWidth: 0, // No line, just fill
            // Don't set fill - theme provides appropriate band colors
        },
    ],
}

Replaces: Manual background bands and custom grid implementations

πŸ“ Spacing vs Padding Standardization

New May 2024 β€’ Apply: 3 minutes β€’ Impact: Medium

typescript
// Context-specific usage of spacing and padding
legend: {
    spacing: 16, // Between legend and chart
    padding: 12, // Internal legend padding
}

Replaces: Inconsistent padding properties across components

πŸ”§ Enhanced Tooltip Positioning

New Apr 2024 β€’ Apply: 8 minutes β€’ Impact: High

typescript
tooltip: {
    position: {
        anchorTo: 'pointer', // 'node', 'cursor', 'pointer'
        placement: ['top', 'bottom'], // Fallback order
        xOffset: 10,
        yOffset: -10,
        constraints: 'never-flip', // 'flip-on-overflow'
    },
    wrapping: 'hyphenate', // 'normal', 'break-word', 'anywhere'
}

Replaces: Manual tooltip positioning calculations and HTML-based tooltips

🎭 Pattern & Gradient Enhancements

New Mar 2024 β€’ Apply: 10 minutes β€’ Impact: Medium

typescript
fill: {
    type: 'pattern',
    pattern: 'forward-slanted-lines', // New stock patterns
    // Don't set fill/backgroundFill - theme handles pattern colors
    scale: 1.5,
    rotation: 45,
}

Replaces: Custom SVG pattern definitions and manual pattern creation

πŸ“Š Crosshair Label Enhancements

For base crosshair setup, see enterprise.md. This section covers label enhancements added in Feb 2024.

Enterprise β€’ New Feb 2024 β€’ Apply: 7 minutes β€’ Impact: Medium

typescript
crosshair: {
    label: {
        enabled: true,
        xOffset: 5,
        yOffset: -5,
        renderer: (params) => ({
            text: `${params.value}`,
            // Don't set color/backgroundColor - theme handles crosshair styling
            opacity: 0.9,
        }),
    },
}

Replaces: Manual crosshair label positioning and custom hover indicators

πŸ“œ Historic Feature Additions (1-2 Years)

🎬 Series Load Animations

New May 2023 β€’ Apply: 5 minutes β€’ Impact: High

typescript
animation: {
    enabled: true,
    duration: 1200, // Animation duration in milliseconds
}
// Works across all series types with different entrance effects

Replaces: Static chart loading and manual animation implementations

πŸ“ Axis Title Formatting

New May 2023 β€’ Apply: 8 minutes β€’ Impact: Medium

typescript
axes: {
    y: {
        type: 'number', // Required
        position: 'left',
        title: {
            formatter: (params) => {
                const { defaultValue, boundSeries, domain } = params;
                return `${defaultValue} (${boundSeries.length} series)`;
            },
        },
    },
};

Replaces: Static axis titles and manual title generation logic

πŸ“ Axis Label Rotation

New Apr 2023 β€’ Apply: 4 minutes β€’ Impact: Low

typescript
axes: {
    x: {
        type: 'category', // Required
        position: 'bottom',
        label: {
            // ❌ Don't set fontSize - theme handles it
            rotation: 0, // Keep horizontal when possible (if needed)
            // ❌ Don't set fontFamily - breaks consistency
            // Don't set color - theme handles label colors
        },
    },
};

Note: Only use rotation if labels truly overlap, otherwise leave default

πŸ“Š Series Area Padding

New Feb 2023 β€’ Apply: 3 minutes β€’ Impact: Medium

typescript
seriesAreaPadding: {
    top: 20,
    right: 20,
    bottom: 20,
    left: 20,
}
// Provides breathing room around the chart data area

Replaces: Manual margin calculations and CSS-based spacing

🎯 Node Click Range Enhancement

New Feb 2023 β€’ Apply: 6 minutes β€’ Impact: Medium

typescript
series: [
    {
        nodeClickRange: 'nearest', // 'exact', 'nearest'
        nodeClickRangeParams: {
            distance: 15, // Pixel tolerance for clicks
        },
    },
];

Replaces: Complex hit-testing logic and manual click area calculations

πŸ–±οΈ Node Double Click Handlers

New Mar 2023 β€’ Apply: 7 minutes β€’ Impact: Low

typescript
series: [
    {
        listeners: {
            nodeDoubleClick: (event) => {
                console.log('Double clicked:', event.datum);
                // Custom double-click behavior
            },
        },
    },
];

Replaces: Manual double-click detection and timing logic

πŸ” Feature Discovery Process

Quarterly Updates (Every 3 months)

  1. Analyze Recent Commits:
bash
# In repository root, analyze recent ag-charts-types changes
git log --format="%h %ad %s" --date=short --since="3 months ago" -- "packages/ag-charts-types/" | head -30

# Look for feature additions in community package
git log --format="%h %ad %s" --date=short --since="3 months ago" -- "packages/ag-charts-community/" | grep -E "(add|Add|new|New)" | head -20
  1. Feature Discovery:

    • Examine new TypeScript interfaces in packages/ag-charts-types/src/
    • Focus on options that enhance visual appeal
    • Check for new series types, styling options, or interaction features
    • Identify Enterprise vs Community feature classification
  2. Validation Requirements:

    • API Contract Compliance: Verify against TypeScript interfaces
    • API Entrypoint Accuracy: Ensure correct usage
    • Enterprise Licensing: Clearly mark features requiring commercial license
    • Working Code: Test examples work as documented

πŸ“ Maintenance Notes

When Adding New Features

Use this format:

markdown
### 🎯 Feature Name

_New MMM YYYY β€’ Apply: X minutes β€’ Impact: High/Medium/Low_ _(Enterprise if applicable)_

\`\`\`typescript
// Clear, working example
const chart = AgCharts.create({
// Feature-specific properties
});
\`\`\`

_Replaces: What manual implementations this native feature can replace_

Section Organization

  1. Recently Added (0-6 months): Latest cutting-edge features
  2. Previously Added (6-12 months): Established recent features
  3. Historic (1-2 years): Well-established foundational features

Review Checklist

  • API Accuracy: Validated against packages/ag-charts-types/src/
  • Correct Entrypoints: Proper API calls specified
  • Enterprise Classification: Clear licensing requirements
  • Implementation Times: Realistic estimates
  • Impact Ratings: Based on visual enhancement
  • Replacement Value: Clear description of what this replaces

🎯 Priority Implementation

When updating examples, prioritize:

  1. High Impact + Low Effort features first
  2. Visual improvements over functional additions
  3. Theme-compatible features (no hardcoded colors)
  4. Enterprise features when they add significant value
  5. Recent additions to showcase latest capabilities

Remember: The goal is to demonstrate AG Charts' latest capabilities while maintaining clean, professional examples.