Chart.js中的可滚动X轴 [英] Scrollable x-axis in Chart.js

查看:475
本文介绍了Chart.js中的可滚动X轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Chart.js库在我的网站上绘制图表,但我打算向图表提供大量数据(> 1000).但是,当我将数据提供给chart.js折线图时,该图不是可滚动的,而是将这些值推在一起使该图不可读.有没有办法使chart.js折线图在x轴上可滚动?

I would like to use Chart.js library for drawing charts on my website, but I intend to feed the chart large amounts of data (>1000). However, when I feed the data to chart.js line chart, the chart is not made scrollable, but the values are pushed together rendering the chart unreadable. Is there a way to make the chart.js line chart scrollable on the x-axis?

推荐答案

我遇到了此问题,并通过使用jquery编辑我的chartjs画布的父div的CSS来解决此问题.这不是一个非常可靠的解决方案,但确实可以使数据可读/可滚动.

I was experiencing this problem and worked around it by using jquery to edit the css of the parent div for my chartjs canvas. This isn't a very robust solution, but is does make the data readable/scrollable.

<div id="parentDiv"><canvas id="myChart" width="15000" height="400"></canvas></div>

<script>
    $("#parentDiv").css("width", "1000px");
    $("#parentDiv").css("overflow", "auto");
</script>

这篇关于Chart.js中的可滚动X轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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