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

Problem Exporting Charts as Image #28713

Open
CharlesNkdl opened this issue May 27, 2024 · 5 comments
Open

Problem Exporting Charts as Image #28713

CharlesNkdl opened this issue May 27, 2024 · 5 comments
Assignees
Labels
viz:charts:export Related to exporting charts

Comments

@CharlesNkdl
Copy link

Bug description

Hi Superset Community,

I have a problem exporting Charts as Image, from multiple Dashboards and instance of Superset.

How to reproduce the bug

  1. Go to a Dashboards with Charts
  2. Click the three dots on the top right of a charts
  3. Download => Download as Image

Screenshots/recordings

Here is the result for my charts :
valeur-moyennes-selon-surface-2024-05-27T14-20-12 529Z

I was wondering if maybe this was related to the fact that the query is quite complicated a lot of filters in the dashboard so i tried to export another charts from the examples datasets.

genders-2024-05-27T14-21-50 342Z

Not quite right too...

Superset version

4.0.1

Python version

3.10

Node version

Not applicable

Browser

Firefox

Additional context

I use Apache Superset 4.0.1 in Local using Windows and a WSL Backend, but this problem was also on my prod. env with Apache Superset 4.0.0 used with Cloudron which handles the deployment.

Even if template processing is ON, i can't download image, with or without Jinja Templating in them.

Here are my superset_config.py flags in local :

SECRET_KEY` = ""

SQLALCHEMY_DATABASE_URI = ''

WTF_CSRF_ENABLED = True (tried with False too...)
WTF_CSRF_EXEMPT_LIST = []
# A CSRF token that expires in 1 year
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365
                                                                                                                
MAPBOX_API_KEY = ''

LANGUAGES = {
        'en': {'flag': 'us', 'name': 'English'},
        'fr': {'flag': 'fr', 'name': 'French'}
}

ENABLE_JAVASCRIPT_CONTROLS = True

APP_NAME = "Superset Local"

WELCOME_MESSAGE = "secret"

PRIMARY_COLOR = "green"

ENABLE_TEMPLATE_PROCESSING = True

CONTENT_SECURITY_POLICY_WARNING = False

TALISMAN_ENABLED = False

DEFAULT_FEATURE_FLAGS = {
        "ENABLE_TEMPLATE_PROCESSING" : True,
}

Here is my python stack trace, minus the get and post request :

Superset.explore_json This API endpoint is deprecated and will be removed in version 4.0.0
2024-05-27 16:34:36,711:WARNING:superset.views.base:Superset.explore_json This API endpoint is deprecated and will be removed in version 4.0.0
2024-05-27 16:34:36,717:DEBUG:parsedatetime:eval - with context - False, False
```


### Checklist

- [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@dosubot dosubot bot added the viz:charts:export Related to exporting charts label May 27, 2024
Copy link

dosubot bot commented May 27, 2024

Hello @CharlesNkdl, I'm here to help you with the issue you're facing. I'm a bot that can assist you with bug resolution, answer your questions, and guide you to become a contributor. Let's work together to get this sorted out.

To resolve the issue of exporting charts as blank images from multiple dashboards in Apache Superset version 4.0.1, you need to ensure that the charts are fully loaded before initiating the export process. The provided code snippet shows the handleBulkChartExport function, which handles the export of charts.

Here is the relevant part of the code:

const handleBulkChartExport = (chartsToExport: Chart[]) => {
    const ids = chartsToExport.map(({ id }) => id);
    handleResourceExport('chart', ids, () => {
      setPreparingExport(false);
    });
    setPreparingExport(true);
  };

To ensure that charts are fully loaded before exporting, you might need to add a check to confirm that the charts are rendered and ready. This can be done by verifying the loading state and ensuring that the charts are not in a loading state before calling the handleBulkChartExport function.

Here is an example of how you might modify the function to include such a check:

const handleBulkChartExport = (chartsToExport: Chart[]) => {
    if (loading) {
      addDangerToast(t('Charts are still loading. Please wait until all charts are fully loaded before exporting.'));
      return;
    }

    const ids = chartsToExport.map(({ id }) => id);
    handleResourceExport('chart', ids, () => {
      setPreparingExport(false);
    });
    setPreparingExport(true);
  };

This modification ensures that the export process is only initiated when the charts are fully loaded, preventing the issue of exporting blank images [1].

Details

About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@visharavana
Copy link
Contributor

@CharlesNkdl Which browser are you using? I am also facing this problem in the Firefox browser, but when I use Chrome, it's working well.

@rusackas
Copy link
Member

Seems to be an issue in Safari too.

@CharlesNkdl
Copy link
Author

@visharavana I'm using Firefox. The solution was so simple i just didn't thought of it, i'm kind of embarassed, thank you ! I tried on Microsoft Edge and it worked

Maybe due to firefox and safari not being chromium-based, compared to Chrome and Edge

@CharlesNkdl CharlesNkdl changed the title Problem Exporting Charts as Diagram Problem Exporting Charts as Image Jun 5, 2024
@stasDomb
Copy link

I still have this type of problem
all-final-acceptance-2024-06-17T13-44-33 596Z

Version 4.0.1 (4.0.0)
I added to Feature Flags:

FEATURE_FLAGS = {
          "DASHBOARD_CROSS_FILTERS": True,
          "DASHBOARD_EDIT_CHART_IN_NEW_TAB": True,
          "DASHBOARD_RBAC": True,
          "EMBEDDED_SUPERSET": True,
          "ENABLE_TEMPLATE_PROCESSING": True,
          "PLAYWRIGHT_REPORTS_AND_THUMBNAILS": True
        }

But it doesn't work. In Safari there are now charts. In Chrome there are a few (as in picture).
Does anybody can help with this ?

xiaoqufengdi added a commit to xiaoqufengdi/superset that referenced this issue Jul 17, 2024
It is wrong not to display a chart if it is not in the browser window display range. When we download the dashboard as a picture, we find that some charts are not displayed

apache#28713
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
viz:charts:export Related to exporting charts
Projects
None yet
Development

No branches or pull requests

5 participants