News for hackers. Stuff that matters.
Re:A Beginner’s Guide to Chart.js by augstein on Sunday October 06, 2019 @07:31AM (#21171353)
Chart.js still uses the HTML Canvas element, so charts generated with it look blurred when printed or zoomed in.

Nowadays I prefer Apexcharts.js, which renders to SVG.

https://github.com/apexcharts/apexcharts.js (MIT License)

Re:A Beginner’s Guide to Chart.js by benmccann on Sunday October 06, 2019 @11:07AM (#21172495)
I think most chart libraries use SVG. There are trade-offs between the two approaches and both have their advantages. One of the places that canvas really shines is performance. In the past I've found Chart.js and some of the faster SVG libraries to be about on par with each other, but the upcoming Chart.js 2.9.0 release has had a couple major performance improvements that I think will make it significantly faster than probably any SVG library. It's an area we'll continue to work on since it's one of the main reasons to choose a canvas implementation over an SVG implementation.

I think the other advantage SVG has can be is if you want to do some advanced interactivity. That can sometimes be easier in SVG.

Re:A Beginner’s Guide to Chart.js by cseelus on Sunday October 06, 2019 @11:31AM (#21172633)
Thank you for your work on Chart.js. I used it exclusively for a couple of years and still think its great.
Re:A Beginner’s Guide to Chart.js by tmd83 on Sunday October 06, 2019 @01:51PM (#21173591)
So Chart.js doesn't have a way to generate sharp images for print and such purposes?
Re:A Beginner’s Guide to Chart.js by etimberg on Sunday October 06, 2019 @03:38PM (#21174498)
For printing, it should be sharp unless you are have specific print CSS. There's a bunch of discussion in https://github.com/chartjs/Chart.js/issues/1350
Re:A Beginner’s Guide to Chart.js by ldad on Sunday October 06, 2019 @02:12PM (#21173740)
There's an option that'll increase the resolution...

options: { devicePixelRatio: 2 }

Re:A Beginner’s Guide to Chart.js by Spiritus on Sunday October 06, 2019 @09:08AM (#21171790)
Interesting. Do you know how Apexcharts.js performs with real-time graphs? We're currently using Chart.js via react-chartjs-2 and while it works, it's consuming quite a bit of CPU.
Re:A Beginner’s Guide to Chart.js by benmccann on Sunday October 06, 2019 @10:49AM (#21172373)
There have been two major changes in Chart.js that will dramatically improve performance in the upcoming 2.9.0 release. We're also adding a section to the documentation about options you can set to improve performance over the defaults. We're hoping to release soon, but there are a couple pending PRs we'd like to review first

Also, if you're interested in realtime charts, here's a related plugin I've seen: https://github.com/nagix/chartjs-plugin-streaming

Re:A Beginner’s Guide to Chart.js by leeoniya on Sunday October 06, 2019 @12:56PM (#21173209)
i'm working on a micro timeseries plotter that easily handles 150k+ datapoints. it uses canvas but accounts properly for display pixel density, so is as sharp as SVG.

here is how it performs vs Chart.js:

https://github.com/leeoniya/uPlot#performance

i will add Apex charts to the bench list in a day or so

i think the only practical way to get acceptable perf with SVG is to simplify the paths via something like https://mourner.github.io/simplify-js/

Re:A Beginner’s Guide to Chart.js by etimberg on Sunday October 06, 2019 @01:39PM (#21173529)
If you change the `scales.xAxes[0].ticks.source config option to `'auto'` you can drop ~1s off the render the time. It's still not great, but it is an improvement. I'll take a look through the profile I generated and see if there are any obvious improvements in Chart.js.

Thanks for creating this :)

Re:A Beginner’s Guide to Chart.js by leeoniya on Sunday October 06, 2019 @01:56PM (#21173622)
sweet, i'll add this.

is this mentioned anywhere in the docs? seems non-obvious.

Re:A Beginner’s Guide to Chart.js by etimberg on Sunday October 06, 2019 @02:07PM (#21173710)
The option is documented at https://www.chartjs.org/docs/latest/axes/cartesian/time.html... but the performance implications aren't. I'll work on adding something there.
Re:A Beginner’s Guide to Chart.js by olavgg on Monday October 07, 2019 @03:34AM (#21178354)
Very impressive work! Funny thing though, I recently implemented a zoomable line chart with D3.js, and I also use double click to reset the zoom :)
Re:A Beginner’s Guide to Chart.js by antman on Sunday October 06, 2019 @01:29PM (#21173453)
That really looks fast! Does it work in.live mode also?
Re:A Beginner’s Guide to Chart.js by leeoniya on Sunday October 06, 2019 @01:57PM (#21173633)
it will. i'm still fiddling with the final api design to make sure it can accomodate the planned features in a logical manner without hacks.
Re:A Beginner’s Guide to Chart.js by GordonS on Sunday October 06, 2019 @09:46AM (#21171978)
Wow, this looks really good! I was looking at different chart libraries recently, don't know how I didn't find Apexcharts, but wish I had!
Re:A Beginner’s Guide to Chart.js by IshKebab on Sunday October 06, 2019 @11:23AM (#21172591)
SVG is way slower than canvas though. Not that chartjs is fast.