* @private
(options)
| 636 | * @private |
| 637 | */ |
| 638 | _createItems(options) { |
| 639 | const active = this._active; |
| 640 | const data = this.chart.data; |
| 641 | const labelColors = []; |
| 642 | const labelPointStyles = []; |
| 643 | const labelTextColors = []; |
| 644 | let tooltipItems = []; |
| 645 | let i, len; |
| 646 | |
| 647 | for (i = 0, len = active.length; i < len; ++i) { |
| 648 | tooltipItems.push(createTooltipItem(this.chart, active[i])); |
| 649 | } |
| 650 | |
| 651 | // If the user provided a filter function, use it to modify the tooltip items |
| 652 | if (options.filter) { |
| 653 | tooltipItems = tooltipItems.filter((element, index, array) => options.filter(element, index, array, data)); |
| 654 | } |
| 655 | |
| 656 | // If the user provided a sorting function, use it to modify the tooltip items |
| 657 | if (options.itemSort) { |
| 658 | tooltipItems = tooltipItems.sort((a, b) => options.itemSort(a, b, data)); |
| 659 | } |
| 660 | |
| 661 | // Determine colors for boxes |
| 662 | each(tooltipItems, (context) => { |
| 663 | const scoped = overrideCallbacks(options.callbacks, context); |
| 664 | labelColors.push(invokeCallbackWithFallback(scoped, 'labelColor', this, context)); |
| 665 | labelPointStyles.push(invokeCallbackWithFallback(scoped, 'labelPointStyle', this, context)); |
| 666 | labelTextColors.push(invokeCallbackWithFallback(scoped, 'labelTextColor', this, context)); |
| 667 | }); |
| 668 | |
| 669 | this.labelColors = labelColors; |
| 670 | this.labelPointStyles = labelPointStyles; |
| 671 | this.labelTextColors = labelTextColors; |
| 672 | this.dataPoints = tooltipItems; |
| 673 | return tooltipItems; |
| 674 | } |
| 675 | |
| 676 | update(changed, replay) { |
| 677 | const options = this.options.setContext(this.getContext()); |
no test coverage detected