chart.js 中多个图表上的工具提示显示错误的值 [英] Tooltips on multiple charts in chart.js showing the wrong values

查看:13
本文介绍了chart.js 中多个图表上的工具提示显示错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am using latest Chart.bundle.js to create multiple stacked Bar charts on same page. For example, I have 3 charts with 2 datasets. Charts are correct, but tooltips on each of the charts are always the same and showing wrong values. screenshot link. All the values are zero, which is obviously wrong.

Tooltips mode is index, canvas for each chart has different id, dataset variables are all different.

解决方案

My solution was somewhat similar to the @queen-juliet's answer.

I had a shared config variable with the data key being added and updated within a loop. Even though the multiple chart.js objects I had on the page were showing the correct data, the tooltips were shown on one (random) chart only. The solution was to declare and fill the whole config inside my loop instead.

这篇关于chart.js 中多个图表上的工具提示显示错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆