jquery - Charts JS: How to set units? -
how can add units labels when hovered on bars? looked in documentation can't find answer.
http://www.chartjs.org/docs/#bar-chart 
i want add example (mm, °c,) code:
options: { scales: { yaxes: [{ ticks: { beginatzero:false }, scalelabel: { display: true, labelstring: 'temperature' } }] }, title: { display: true, text: 'temperature' }, tooltips:{ enabled: true, mode: 'label' } } }); datasets: [ { label: "temperature", type: "line", backgroundcolor: "transparent", bordercolor: "#c72448", pointbackgroundcolor: "#c72448", pointbordercolor: "#fff", pointhoverbackgroundcolor: "#fff", pointhoverbordercolor: "rgba(179,181,198,1)", data: [19,20,21,24,27,29,30,31,30,28,25,21] }
you can add units tooltips using tooltip callbacks configuration.
for example, here how add "gb" unit tooltip:
const options = { tooltips: { callbacks: { label: (item) => `${item.ylabel} gb`, }, }, }
Comments
Post a Comment