Chart.js: Horizonal Scroll Chart

Created on 5 Jul 2016  路  14Comments  路  Source: chartjs/Chart.js

When i change width of web(like width of mobile), chart.js show chart very small. I want my chart "horizonal scroll". Like this : link here.

support

Most helpful comment

@bimal1331 @vbspam @jwds I found a solution for a fixed Y axis by using the onComplete and onProgress animation options to draw the Y axis as it scrolls, and also to clear the previous one so there is no overlapping/blurring. I also needed to scale it to match the device's DPR (which Chart.js already handles, hence the problem I was having in my previous post).

See - https://jsfiddle.net/EmmaLouise/eb1aqpx8/3/

All 14 comments

@MrKen99 the best way to do this would be to put the canvas in a fixed size div. Then, have that div inside a container that allows scrolling.

Yep, I got it. Thank you , etimberg.

@etimberg I'm also building a scrolling chart inside a div, but as soon as the user scroll, the yaxis isn't display anymore. How to keep this axis visible ?

  1. Create a canvas beside the chart to redraw the axis. Then how to get the coordinate (y) of the ticks?
  2. Add the labels value to the xGridlines. How to do it ?

Im using ChartJs v1.x with angular chartJS (wrapper for ChartJS)

capture d ecran 2016-12-06 a 11 28 16
capture d ecran 2016-12-06 a 11 28 31

@jibaxx Unfortunately version 1 is no longer supported, and this could be a problem with the angular wrapper. Please consider upgrading to version 2 and seeing if you can fix the problem then.

I use ChartJS 2 and fixed Y-axis is not supported there also. @jibaxx Did you find anything that worked for you? Only thing I can think of to display another Y-axis that is outside the chart and thus won't scroll with the chart, but you'll have to calculate the values yourself.

You might want to check out the zoom/pan plugin.

@bimal1331 , Did you find any solution for your issue? I am using v2.7.2
zoom/pan plugin is not an option for me. I want scrolling with Y-axis outside constant.

I would be also interested. The 'chartjs-plugin-zoom' mentioned as possible workaround does not work.
Does anyone successfully deployed chartjs with large datasets (those requiring horizontal scrolling) ?

Has anybody managed to resolve having a fixed Y-axis while the chart scrolls horizontally?

I have tried this approach with 2.7.2 - https://jsfiddle.net/EmmaLouise/vcbg0jdn/1/ - but unfortunately this breaks on higher DPI settings (still trying to figure out a good workaround for scaling it up with the DPI). I find it hard to believe that the only way to have a fixed axis involves having an animation workaround but that has been all I could find in my research online for 2.x.x versions.

@bimal1331 @vbspam @jwds I found a solution for a fixed Y axis by using the onComplete and onProgress animation options to draw the Y axis as it scrolls, and also to clear the previous one so there is no overlapping/blurring. I also needed to scale it to match the device's DPR (which Chart.js already handles, hence the problem I was having in my previous post).

See - https://jsfiddle.net/EmmaLouise/eb1aqpx8/3/

@EmmaLouS Thanks for the solution, it works great! Although I tried to make it dynamic, but it's not working really well. The chart is updating, but stays in it's wrapper as it wouldn't be scrollable. But the scrollbar is there and I can scroll it, but there is white background. Do you guys have an idea what am I missing?

@izsoandras share your example! I am trying to get @EmmaLouS working with the y-axis on the right.

But it still can't be scrolled and reponsive together. When you change window size, the chart not fit screen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JewelsJLF picture JewelsJLF  路  3Comments

benmccann picture benmccann  路  3Comments

HeinPauwelyn picture HeinPauwelyn  路  3Comments

bytesnz picture bytesnz  路  3Comments

joebirkin picture joebirkin  路  3Comments