new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Chart.js · all subjects

plugins/tooltip

4 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Tooltip position modes: average, nearest, and custom

Tooltip position can be set via chart.options.plugins.tooltip.position. The built-in modes are 'average' and 'nearest'. Custom position modes can also be defined by assigning a function to components.Tooltip.positioners with a custom name.

Create custom tooltip positioner

Custom tooltip positioners are created by assigning a function to components.Tooltip.positioners[name]. The function receives an items array and should return either false (when nothing is found) or an object with properties x, y, xAlign, and yAlign. The function has access to this.chart for accessing chart properties like chartArea.

Custom tooltip positioner example: position at bottom

Example of creating a custom 'bottom' tooltip positioner: components.Tooltip.positioners.bottom = function(items) { const pos = components.Tooltip.positioners.average(items); if (pos === false) { return false; } const chart = this.chart; return { x: pos.x, y: chart.chartArea.bottom, xAlign: 'center', yAlign: 'bottom', }; };

Tooltip positioner return value structure

A tooltip positioner function must return either false (when nothing is found) or an object with four properties: x (number, horizontal position), y (number, vertical position), xAlign (string, horizontal alignment such as 'center'), and yAlign (string, vertical alignment such as 'bottom').

Give your agent this brain