Skip to content
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

Use pablo to download a D3.js chart #97

Open
dang2906 opened this issue Mar 3, 2016 · 5 comments
Open

Use pablo to download a D3.js chart #97

dang2906 opened this issue Mar 3, 2016 · 5 comments

Comments

@dang2906
Copy link

dang2906 commented Mar 3, 2016

Hi,

I have multiple d3 charts and would like to download these as an image file. Is this possible with pablo? if so, how would i go about it correctly?

Many Thanks :)

@dang2906
Copy link
Author

dang2906 commented Mar 3, 2016

When i attempt it like:

function saveChart(placeholderid) { var chart = $('#' + placeholderid); Pablo(chart).download('png', placeholderid+'.png', function(result){ alert(result.error ? "Fail" : "Success"); }) };

i get the console error:

Object doesn't support property or method 'getBBox' from Pablo.js line 1453,25.

This also happens when i try the selection using d3.select

@premasagar
Copy link
Owner

Thanks for your report, @dang2906. I tried to replicate this, but I don't get the error you see.

I am guessing that the most likely cause is the placeholder element you are using is an HTML element and not the root SVG element. Could you confirm?

Otherwise, it suggests that your browser doesn't support the SVG DOM method getBBox. What browser and browser version are you using? Does it pass the tests at http://pablojs.com/tests/ ?

If so, could you supply a minimal script / image that you see this problem with?

One simplification you can make is to avoid using jQuery - I presume that is the $() function. You can directly call Pablo('#my-element') or use any other selector.

@premasagar
Copy link
Owner

Would it be desirable and intuitive that calling Pablo(someHTMLElement).download() should download all SVG root elements within the HTML element?

@leoschet
Copy link

leoschet commented Aug 11, 2016

Using Pablo I was only able to download the SVG when I called Pablo(svgElement).download() I have a div element and embedded the svg element with Pablo(divElement).load('/path/to.svg') but isn't possible to download it calling the download method from Pablo(divElement).

When I try to do it I get the same console error:

Object doesn't support property or method 'getBBox' from Pablo.js line 1453,25.

answering @premasagar 's question, it would be intuitive!

Edit: My browser gets 100% at http://pablojs.com/tests/

@premasagar
Copy link
Owner

Yes, only SVG elements can be downloaded in the current implementation.
Doing this should work though:
Pablo(divElement).load('/path/to.svg', function (image) {image.download()})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants