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

add chart export png #6973

Closed
wants to merge 4 commits into from
Closed

add chart export png #6973

wants to merge 4 commits into from

Conversation

wushenchao
Copy link
Contributor

add chart export png
#6737

@kristw kristw added the enhancement:request Enhancement request submitted by anyone from the community label Mar 4, 2019
@@ -78,6 +80,12 @@ class SliceHeaderControls extends React.PureComponent {
this.props.exportCSV(this.props.slice.slice_id);
}

exportPNG() {
const title = this.props.slice.slice_name;
const index = $('input[value="' + title + '"]').parents('.chart-header').next('.dashboard-chart').index('.dashboard-chart');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use jquery $

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I am a react white

@@ -0,0 +1,7261 @@
/*!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add as dependency in package.json instead of copying code into this repo.


const propTypes = {
actions: PropTypes.object.isRequired,
canDownload: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]).isRequired,
chartStatus: PropTypes.string,
latestQueryFormData: PropTypes.object,
queryResponse: PropTypes.object,
slice: propTypes.slice
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is referring to itself.
Please check prop-types reference on how to define a proper prop type.

@kristw
Copy link
Contributor

kristw commented Mar 4, 2019

Could you add an example of the exported png? Does it look exactly like taking a screenshot?

@wushenchao
Copy link
Contributor Author

Could you add an example of the exported png? Does it look exactly like taking a screenshot?

That's true,it taking a screenshot.

@kristw
Copy link
Contributor

kristw commented Mar 5, 2019

Also, if I remember correctly, this approach will not work if the chart uses canvas inside.
There are also open issues about missing pieces and css when capturing reported in the html2canvas repo.
Please attach some screenshots generate from this approach vs. screenshot manually taken before I can give more reviews.

const w = parseInt(window.getComputedStyle(_canvas).width);
const h = parseInt(window.getComputedStyle(_canvas).height);

const canvas = document.createElement('canvas');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the values which arepresent inside scroll are not screenshot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, there is an error in my submission

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am trying to take scrollheight for it but nothing is useful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are one mistakes above and it will be ok after modification

屏幕快照 2019-03-15 下午5 47 49

@wushenchao wushenchao closed this Mar 15, 2019
@Benji81
Copy link
Contributor

Benji81 commented Mar 18, 2019

Hi @wushenchao , do you plan to reopen it? This is a great feature.

@wushenchao
Copy link
Contributor Author

Hi @wushenchao , do you plan to reopen it? This is a great feature.

屏幕快照 2019-03-19 上午9 33 02

Here, I don't know how to do use react, if you have a good idea, please let me know, thank you

etr2460 pushed a commit that referenced this pull request May 17, 2020
…9819)

* feat(frontend): add ability to export dashboard and chart as image (#6973)

* refactor: migrate download image as to typescript

* feature(frontend): download as image updates

add toast message if error occurs.
make generate file stem an internal method.

* refactor(frontend): move default background color to a const

* feat(frontend): wrap download image toast in translate function
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
…pache#9819)

* feat(frontend): add ability to export dashboard and chart as image (apache#6973)

* refactor: migrate download image as to typescript

* feature(frontend): download as image updates

add toast message if error occurs.
make generate file stem an internal method.

* refactor(frontend): move default background color to a const

* feat(frontend): wrap download image toast in translate function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement:request Enhancement request submitted by anyone from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants