-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chart.js/HTMLCanvasElement compatibility #100
Comments
Ah yes. the context would need a canvas property that implements the HTMLCanvasElement interface. However, that's a giant interface (because it inherits Element). Do you know what subset of the interface that ChartJS actually uses? Probably width and height, I assume. Anything else? |
Checking out their last stable release it looks like they use from both Element and HTMLCanvasElement:
Also getRootNode and getBoundingClientRect, but I'm not pretty sure the function where they're used would be called in this context at all, I'd have to check. So, as I see, basically width and height related stuff and the base64 stuff that might be realizable via the png stream that is already implemented |
It sounds like a fairly easy fix then. Would you like to try implementing it and then I can code review? |
Sure thing, I'll try to assemble a simple implementation and see what happens |
I see context.rect() method is not implemented yet, but I'd need it for chartjs. Do you have an idea of an implementation? |
for now you could delegate to drawRect or fillRect |
Probably a transform issue. what's your implementation of 'rect' now? |
I'm just calling fillrect:
I probably mixed up the parameters order or now that I'm thinking I might need to apply some colour or something like that |
oh yeah, the parameters are wrong. However, that might not be enough to fix it. It could be that fill() is being called as part of a beginPath() / close() sequence and it's using the wrong transform. |
I'm not entirely familiar with the implementation of the library as I'm still reading through it, but if I'm not wrong, couldn't you implement the rect() function by simply calling moveTo() on the first corner, and then calling lineTo() for each edge? |
I just fixed this. Could you test the latest version: 0.2.5 |
Hi:
I have a little express server where I create some chart.js charts using node-canvas implementation of the canvas API. The thing is, Cairo is a real pain and has a long-standing bug where custom fonts just break in Windows Azure machines... which is what I use.
I tried to switch to this library but with little success. ChartJs contructor takes the following parameters:
My try was to just pass the context that I can create via:
but this didn't work since this particular context does not implement CanvasRenderingContext2D.canvas property which is required for chartjs.
What I had done with node-canvas is this:
It works, since that library actually exposes a CanvasRenderingContext2D.canvas (here) class that implements HTMLCanvasElement methods.
Is there a way to work this out? Maybe it's as easy as just providing a HTMLCanvasElement implementation with already existing methods, and I wouldn't mind patching it myself if this library is kind of compatible already.
Thanks in advance😊😊
The text was updated successfully, but these errors were encountered: