Skip to content
Closed
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
15 changes: 11 additions & 4 deletions grouped-categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
return JSON.parse(JSON.stringify(thing));
}

function Category(obj, parent) {
function Category(obj, parent, tooltipOptions) {
this.userOptions = deepClone(obj);
this.name = obj.name || obj;
this.parent = parent;
this.tooltipOptions = tooltipOptions;

return this;
}
Expand All @@ -58,6 +59,10 @@
cat = cat.parent;
}

if (this.tooltipOptions.reverseTitle) {
parts = parts.reverse();
}

return parts.join(', ');
};

Expand All @@ -74,8 +79,8 @@
}

// Adds category leaf to array
function addLeaf(out, cat, parent) {
out.unshift(new Category(cat, parent));
function addLeaf(out, cat, parent, tooltipOptions) {
out.unshift(new Category(cat, parent, tooltipOptions));

while (parent) {
parent.leaves = parent.leaves ? (parent.leaves + 1) : 1;
Expand All @@ -100,7 +105,7 @@
}
buildTree(cat.categories, out, options, cat, depth + 1);
} else {
addLeaf(out, cat, parent);
addLeaf(out, cat, parent, options.userSuppliedTooltipOptions);
}
}
options.depth = mathMax(options.depth, depth);
Expand Down Expand Up @@ -165,6 +170,8 @@
userAttr = labelOptions.groupedOptions,
css = labelOptions.style;

stats.userSuppliedTooltipOptions = this.chart.options.tooltip || {};

// build categories tree
buildTree(categories, reverseTree, stats);

Expand Down