superset icon indicating copy to clipboard operation
superset copied to clipboard

Download Slice or Dashboard As SVG, problem reusing feature from past commit

Open nam147 opened this issue 9 years ago • 6 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stacktraces and included it here as text if any
  • [X] I have reproduced the issue with at least the latest released version of superset
  • [X] I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.20.4

Expected results

By deploying the branch export-by-svg ( referenced by @SalehHindi from this post: #2995

or by:

  • installing the d3-save-svg and font-awesome with npm
  • making changes in the file ExploreActionButtons.jsx, as seen here

I could then see a export/Download SVG button when i create a slice with D3JS

Actual results

As Admin, I can't find the button anywhere maybe i'm just not looking in the right place ?

pleasehelp

Steps to reproduce

By cloning the branch export-as-svg installing and launching superset

or by:

  • installing the d3-save-svg and font-awesome with npm
  • making changes in the file ExploreActionButtons.jsx, as seen here

If this feature can't be implemented like this, could you tell me why ? Thank you. Your help would be greatly appreciated.

nam147 avatar Oct 31 '17 10:10 nam147

Hello, Following up on this issue, I have tried to create the button 'export as svg' to the component Controls.jsx in: superset/static/assets/javascripts/dashboard/components/

Here is the Button that i added in the ButtonGroup:

       <Button
            onClick={() => my-svg-crowbar()}
        >
            <i className="fa fa-download" />
        </Button>

The Function my-svg-crowbar is exported from the svg-crowbar.js script from NYTimes github page. It's the same code, but it returns 1 in the last line so that i'm sure that it doesnt return null when i pass it to the arrow function, don't know if it matters

I expected there to be 1 more button in the dashboard screen, on the right, next to the save, message, edit, refresh ... buttons

Could just tell me what i have to add to complete the code ?

I really need your help, thanks for your time

nam147 avatar Nov 06 '17 14:11 nam147

Hi, I'd be down to help. Give me a few days to fully respond because I have a major deadline this week at my job. I'd be down to try to wrap up the backend work.

I think when I initially tried this I had trouble getting the SVGs to render properly. So I think like half of visualizations render fully but some of the visualizations render only partially. That, plus I had trouble testing this with the mailer function that's in the codebase but I assume that function is working fine. I think if I can figure out why not all the SVGs from the example visualizations are rendering properly it won't be too hard to finish up the rest of the backend work so you can make a button and export the SVGs : )

Keep in mind my original commit didn't go into master and its not 100% done so if you're spending time finishing it, try pausing on it until the end of the weekend. Sorry for the delayed response and thank you so much for trying to help me finish this @nam147 👍

SalehHindi avatar Nov 07 '17 01:11 SalehHindi

Thanks for the response! good luck at your job :+1:

nam147 avatar Nov 07 '17 09:11 nam147

@SalehHindi So i've been trying to load the package html2canvas in the Controls.jsx

I imported the html2canvasExport from the html2canvas.js script that i got here

put it in a app folder in static/assets/dashboard/components, and did

var H2C = require('./app/html2canvas.js');
//we will then use html2canvasExport, which is Exported from html2canvas.js

[... JSX code ...]

        <Button
          onClick={() => {
            H2C.html2canvasExport(document.body).then(function(canvas) {
              document.body.appendChild(canvas);
            });
          }}
        >
          <i className="fa fa-download" />
        </Button>

/*
Also tried this function :
          H2C.html2canvasExport( document.body,{
          onrendered: function(canvas) {
          window.open(canvas.toDataURL());
*/

The error I get in the console is that H2C.html2canvasExport is not a function, so it seems that i'm not importing the function correctly, also tried with import {...} and import ...

Do you think it's a bad approach ?

Thanks for your help if you have some time to look at this

nam147 avatar Nov 12 '17 00:11 nam147

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

stale[bot] avatar Apr 11 '19 07:04 stale[bot]

any updates on this @SalehHindi? (exporting a whole dashboard)

klazaj avatar Feb 11 '20 16:02 klazaj