MCPcopy Create free account
hub / github.com/chartjs/Chart.js / _convertTicksToLabels

Method _convertTicksToLabels

src/core/core.scale.js:780–799  ·  view source on GitHub ↗

* @param {Tick[]} ticks * @private

(ticks)

Source from the content-addressed store, hash-verified

778 * @private
779 */
780 _convertTicksToLabels(ticks) {
781 this.beforeTickToLabelConversion();
782
783 this.generateTickLabels(ticks);
784
785 // Ticks should be skipped when callback returns null or undef, so lets remove those.
786 // The kept ticks move down in a single pass: a splice for each removed tick is
787 // quadratic when the callback skips most of a large number of ticks.
788 let i, ilen, tick;
789 let count = 0;
790 for (i = 0, ilen = ticks.length; i < ilen; i++) {
791 tick = ticks[i];
792 if (!isNullOrUndef(tick.label)) {
793 ticks[count++] = tick;
794 }
795 }
796 ticks.length = count;
797
798 this.afterTickToLabelConversion();
799 }
800
801 /**
802 * @return {{ first: object, last: object, widest: object, highest: object, widths: Array, heights: array }}

Callers 1

updateMethod · 0.95

Calls 4

generateTickLabelsMethod · 0.95
isNullOrUndefFunction · 0.85

Tested by

no test coverage detected