简体   繁体   English

Flot工具提示整数/自定义

[英]Flot Tooltip Integers / Customization

I made a bar chart with the Flot library, and used the flot-tooltip plugin to create the tooltips. 我使用Flot库制作了条形图,并使用flot-tooltip插件创建了工具提示。 Alas, while all the tooltip values should be integers, they appear as floats. all,虽然所有工具提示值都应为整数,但它们显示为浮点数。 At first I tried to use parseInt on the actual data passed to Flot, but it didn't help. 最初,我尝试在传递给Flot的实际数据上使用parseInt ,但这没有帮助。

Next I tried to use an external function to customize the content of the tooltip, like here: How to set x axis value as tooltip in flot charts textual data 接下来,我尝试使用外部函数来自定义工具提示的内容,例如此处: 如何在浮动图表文本数据中将x轴值设置为工具提示

However, the result was an error: 但是,结果是一个错误:

Uncaught TypeError: content.replace is not a function

And after updating flot-tooltip, it changed to: 更新flot-tooltip后,它更改为:

Uncaught TypeError: a.replace is not a function

I'm using Flot 0.8.3 我正在使用Flot 0.8.3

Did I forget to include some library, or confused the order the scripts should go in? 我是否忘了包含一些库,还是混淆了脚本应遵循的顺序? (that can usually generate such errors). (通常会产生此类错误)。 Is there another way to force the tooltip values to be integers? 还有另一种方法来强制工具提示值是整数吗?

Figured a simple way to do this without an external function: 想出了一种无需外部功能的简单方法:

In the Flot properties, one can add the following: 在Flot属性中,可以添加以下内容:

yaxis: {
            tickDecimals: 0,
        },

This will remove any decimal points from the values. 这将从值中删除所有小数点。

If anyone knows the reasons for the above errors though, an answer would be appreciated anyway! 如果任何人都知道上述错误的原因,那么无论如何,我们将不胜感激!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM