Skip to content

Conversation

@AcarFurkan
Copy link

@AcarFurkan AcarFurkan commented Dec 11, 2025

Problem

SfTreemap doesn't update when data values change if dataCount stays the same.

FR: https://www.syncfusion.com/feedback/47083/provide-dynamic-update-support-for-treemap-datasource-without-changing-the-data

Previous Workaround

The only way to force a rebuild was using a Key:

SfTreemap(
  key: ValueKey(Object.hashAll(data.map((e) => e.hashCode))),
  dataCount: data.length,
  // ...
)

Downsides:
- Forces complete widget rebuild (loses state, animations)
- Not intuitive - key is meant for widget identity, not data changes

Solution

Added optional rebuildToken parameter. When this value changes, the widget rebuilds
even if dataCount is unchanged.

SfTreemap(
  dataCount: data.length,
  rebuildToken: Object.hashAll(data.map((e) => e.hashCode)),
  // ...
)

Or simply use an int counter:

int _rebuildCounter = 0;

// When data changes:
setState(() {
  _rebuildCounter++;
});

SfTreemap(
  dataCount: data.length,
  rebuildToken: _rebuildCounter,
  // ...
)

Advantages:
- Clean, declarative API
- Explicit intent - clearly indicates "rebuild when data changes"
- No breaking changes - parameter is optional with default null

Demo

Before (no update):

before.mov

After (with rebuildToken):

UPDATED.mov

Fixes #1396

Fixes syncfusion#1396

Added optional rebuildToken parameter. When this value changes,
the widget rebuilds even if dataCount is unchanged.
@VijayakumarMariappan VijayakumarMariappan added tree map Treemap component open Open labels Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open Open tree map Treemap component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

realtime update treemap chart when a item change

3 participants