ChartJS-在折线图中将滚动添加到水平图例 [英] ChartJS - adding scroll to horizontal legend in Line chart

查看:222
本文介绍了ChartJS-在折线图中将滚动添加到水平图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ChartJs创建项目,并且正在从服务器中获取实时数据。每秒,我添加额外的数据点。一段时间后,图表上的点太多了,以至于您看不到任何东西。我想知道,是否有一种方法可以滚动x变量,并且始终在两点之间设置距离?众所周知,点之间的距离正在缩小,从而使图形不可读。

I am creating project with ChartJs, and I am fetching real time data from the server. Each second, I add extra data point. After some time, there is just too many points on the graph, to the point that you cannot see anything. I would like to know, if there is a way to scroll through the x-variables, and always have set distance between the points? As of know, the distance between points is shrinking, making the graph not readable.

谢谢!

推荐答案


I想知道,是否有办法滚动
x变量,

I would like to know, if there is a way to scroll through the x-variables,

您可以使用 .removeData()以删除(当前)第一组点。这样一来,在图表上只能看到相同数量的(最新)点。

You can use .removeData( ) to remove the (current) first set of points. This would keep only the same number of (latest) points visible on the graph.


...并且两点之间的距离总是固定的

...and always have set distance between the points?

除非您删除点保持一定的距离,而增加点会导致图形宽度增加-通常这不是您想要的要做。

Unless you remove points maintain a set distance while adding points would cause the graph width to increase - which is usually not what you want to do.

这篇关于ChartJS-在折线图中将滚动添加到水平图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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