Tree map package

Hi there. Is the tree map source code available?

I guess we can share some parts of it with sunburst diagram. At least the hierarchy selection UI.

Hi Nikolay, the tree map source code is currently implemented in Dart so it’s not exactly open-sourced, however, if there is interest I can share the code with you. For your reference, here is the selection method that we use for most of the viewers. We are going to create similar utility method(s) in our JS API as well. By the way, JS API is actually open-sourced and we accept pull requests :slight_smile:

/// Selects or deselects [rows] in the [rowMask], based on the modifier keys from the [mouseEvent] :
/// (nothing): selects rows exclusively
/// (Shift): adds rows to selection
/// (Shift+Ctrl): removes rows from selection
/// (Ctrl): toggles selection
void selectRows(BitSet rowMask, Iterable<int> rows, MouseEvent mouseEvent) {
  if ((mouseEvent.ctrlKey || mouseEvent.metaKey) && !mouseEvent.shiftKey)  // toggle
    rowMask.setIndexes(rows, value: rowMask.anyIndex(rows, value: false), clear: false);
        value: !(mouseEvent.ctrlKey || mouseEvent.metaKey),
        clear: !(mouseEvent.ctrlKey || mouseEvent.metaKey) && !mouseEvent.shiftKey);
1 Like

That’s really helpful. I’ll give it a shot tomorrow.

BitSet.setIndexes() method is not currently exposed in JS (since Dart’s Iterables are different from JS ones), but it’s trivial to implement it right in JS. By the way, I hope you have found our JS API documentation:

Well, I would contribute the JS API happily, but there are some problems with the knowledge of the Dart part of datagrok API and inability to create grok_* functions.

Right, but in that particular case setIndexes() method could be written completely in JavaScript - it would simply iterate over the passed indexes and call set(index, flag) for each index. Admittedly, it won’t be fast - we’ll provide an optimized version in the next release.

1 Like