Drawing labels and captions in the treemap element #101
-
I was having a look to the code and now captions and labels are drawing in the controller code instead of in each element. But I see a couple of things which are not clear and then I'm asking if there is a reason for that. updateElements(rects, start, count, mode) {
const me = this;
const reset = mode === 'reset';
const dataset = me.getDataset();
// Why this is invoked?
const firstOpts = me._rect.options = me.resolveDataElementOptions(start, mode);
// Why this is invoked?
const sharedOptions = me.getSharedOptions(firstOpts);
// Why this is invoked?
const includeOptions = me.includeOptions(mode, sharedOptions);
for (let i = start; i < start + count; i++) {
const sq = dataset.data[i];
// Why dont invoke resolveDataElementOptions only here?
const options = sharedOptions || me.resolveDataElementOptions(i, mode);
const sp = options.spacing;
const sp2 = sp * 2;
const properties = {
x: sq.x + sp,
y: sq.y + sp,
width: reset ? 0 : sq.w - sp2,
height: reset ? 0 : sq.h - sp2,
hidden: sp2 > sq.w || sp2 > sq.h,
};
if (includeOptions) { // Why dont include always?
properties.options = options;
}
me.updateElement(rects[i], i, properties, mode);
}
// Why this is invoked?
me.updateSharedOptions(sharedOptions, mode, firstOpts);
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
options are included in each element (in updates after construction) if the options are not shared (= no scriptables used). When the options are shared, only single instance of options exists and that can be animated with just few animations So its an optimization and there is similar or equal optimization in core controllers (line and bar at least) |
Beta Was this translation helpful? Give feedback.
options are included in each element (in updates after construction) if the options are not shared (= no scriptables used). When the options are shared, only single instance of options exists and that can be animated with just few animations
So its an optimization and there is similar or equal optimization in core controllers (line and bar at least)