* @private
(options)
| 598 | * @private |
| 599 | */ |
| 600 | _createItems(options) { |
| 601 | const active = this._active; |
| 602 | const data = this.chart.data; |
| 603 | const labelColors = []; |
| 604 | const labelPointStyles = []; |
| 605 | const labelTextColors = []; |
| 606 | let tooltipItems = []; |
| 607 | let i, len; |
| 608 | |
| 609 | for (i = 0, len = active.length; i < len; ++i) { |
| 610 | tooltipItems.push(createTooltipItem(this.chart, active[i])); |
| 611 | } |
| 612 | |
| 613 | // If the user provided a filter function, use it to modify the tooltip items |
| 614 | if (options.filter) { |
| 615 | tooltipItems = tooltipItems.filter((element, index, array) => options.filter(element, index, array, data)); |
| 616 | } |
| 617 | |
| 618 | // If the user provided a sorting function, use it to modify the tooltip items |
| 619 | if (options.itemSort) { |
| 620 | tooltipItems = tooltipItems.sort((a, b) => options.itemSort(a, b, data)); |
| 621 | } |
| 622 | |
| 623 | // Determine colors for boxes |
| 624 | each(tooltipItems, (context) => { |
| 625 | const scoped = overrideCallbacks(options.callbacks, context); |
| 626 | labelColors.push(invokeCallbackWithFallback(scoped, 'labelColor', this, context)); |
| 627 | labelPointStyles.push(invokeCallbackWithFallback(scoped, 'labelPointStyle', this, context)); |
| 628 | labelTextColors.push(invokeCallbackWithFallback(scoped, 'labelTextColor', this, context)); |
| 629 | }); |
| 630 | |
| 631 | this.labelColors = labelColors; |
| 632 | this.labelPointStyles = labelPointStyles; |
| 633 | this.labelTextColors = labelTextColors; |
| 634 | this.dataPoints = tooltipItems; |
| 635 | return tooltipItems; |
| 636 | } |
| 637 | |
| 638 | update(changed, replay) { |
| 639 | const options = this.options.setContext(this.getContext()); |
no test coverage detected