Hacker News new | past | comments | ask | show | jobs | submit | nnnnnick's comments login

Yep, you can call .toBase64Image() on your chart instance to return a png image encoded as a base 64 data url.


Sounds ace, let me know if there's anything I can do to help!


SVG is a good solution too, but it can really suffer performance-wise, especially on mobile, tablet and when animating svg node positions.


Canvas is bitmap-based, while SVG is vector. If you need to print the chart SVG is going to look a lot better. Also, if you pinch-zoom the chart, SVG is going to look better. Canvas doesn't support animation -- you have to code it yourself. SVG performance is quite good unless you have thousands of elements, which a chart isn't going to have.


> Canvas doesn't support animation -- you have to code it yourself.

What do you mean?


The obvious. That canvas is just a set of pixels with colors (a bitmap image). To get animation, you have to explicitly change them every X milliseconds.

Whereas SVG has actual objects, that you can apply items like animateTransform, animateMotion etc to them directly, in a declarative style.


Ok, thanks. I didn't know that. I thought you had to clear/redraw the SVG for animation as well.


Have you done any benchmarking of canvas vs svg charts?


I did a while back for my university dissertation, I'll have to see if I can dig it out.

IIRC: canvas tends to outperform svg when dealing with a lot of individual objects, due to them being individual dom nodes in svg. However svg will outperform canvas drawing fewer nodes, on a larger canvas, due to canvas being bitmap based.


Cheers, sorry it took so long!


New site is responsive for mobile, so you should be seeing the new version!

This new release allows for custom chart types, using the same core API, so hopefully we'll see some community led new chart type extensions soon!


Thanks! I'll see if I can give it a shot, I just went back after grabbing my laptop and noticed the section on writing new chart types. Maybe I can figure it out. I have a project in mind I could use this for.


I'd misunderstood some of the issues I wrote about earlier in regard to the library. It is now back online for good, licensed under MIT. Sorry for all this kerfuffle.


I don't intend to be rude or anything, but how can you misunderstand your employer asking you to remove the library? They either did or they didn't?


Didn't use any particular software or tools as such, but used Google prettify (https://code.google.com/p/google-code-prettify/) for coloured syntax highlighting.

Wrote the content in plain HTML, and used jQuery to build the nav on left hand side from the headings on the page.


Great job, some of the best docs I've seen in a while.


Very nicely done :)


I found quite a few existing SVG based graphing libraries based off d3 or Raphael, and wanted to create something a bit more lightweight - canvas sacrifices interactivity for raw speed.

I wanted Chart.js to be dependency free, which has led to a footprint of only ~4.4kb when minified and gzipped, d3 is a lot more complex, and has a gzipped size of about 10x that.

It'll have to be up to you whether canvas is the right solution in your use case over SVG!


Just updated and closed this with an MIT license added to the docs and readme on Github.


Just updated the online docs and readme on Github with an MIT license, so feel free to use!


Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: