dosubot[bot] commented on issue #29775:
URL: https://github.com/apache/superset/issues/29775#issuecomment-2258232745

   <!-- Answer -->
   To address your issues with Superset 4.0.2:
   
   1. **Including All Plots in Email**:
      To ensure all plots from a dashboard are included in the email, you need 
to modify the email template to iterate over all the charts in the dashboard 
and include them in the email content. Here is a sample code snippet to achieve 
this:
   
      ```python
      from superset import db
      from superset.models.dashboard import Dashboard
   
      def get_dashboard_charts(dashboard_slug):
          dashboard = 
db.session.query(Dashboard).filter_by(slug=dashboard_slug).first()
          if not dashboard:
              return []
   
          charts = []
          for component in dashboard.position_json['CHARTS']:
              chart_id = component['meta']['chartId']
              chart_name = component['meta']['sliceName']
              charts.append((chart_id, chart_name))
          
          return charts
   
      def generate_email_content(dashboard_slug):
          charts = get_dashboard_charts(dashboard_slug)
          email_content = "<h1>Dashboard Charts</h1>"
          for chart_id, chart_name in charts:
              email_content += f"<h2>{chart_name}</h2>"
              email_content += f'<img 
src="http://your-superset-url/superset/slice/{chart_id}/thumbnail"; 
alt="{chart_name}"/>'
          
          return email_content
   
      # Example usage
      dashboard_slug = "tabbed_dash"
      email_content = generate_email_content(dashboard_slug)
      print(email_content)
      ```
   
      Replace `"http://your-superset-url"` with your actual Superset URL. This 
will generate an email content with all the charts from the specified dashboard 
<sup>[[1]](https://github.com/apache/superset/blob/master/superset/examples/tabbed_dashboard.py)</sup>.
   
   2. **Controlling Width and Height of Table Chart Cells**:
      You can adjust the chart dimensions directly in the dashboard's JSON 
configuration. Here is an example:
   
      ```json
      {
          "CHART-06Kg-rUggO": {
              "children": [],
              "id": "CHART-06Kg-rUggO",
              "meta": {
                  "chartId": 617,
                  "height": 42,  // Adjust the height here
                  "sliceName": "Number of Girls",
                  "width": 4     // Adjust the width here
              },
              "parents": [
                  "ROOT_ID",
                  "TABS-lV0r00f4H1",
                  "TAB-NF3dlrWGS",
                  "ROW-kHj58UJg5N",
                  "COLUMN-_o23occSTg",
                  "TABS-CslNeIC6x8",
                  "TAB-SDz1jDqYZ2",
                  "ROW-DnYkJgKQE"
              ],
              "type": "CHART"
          },
          // Other chart configurations...
      }
      ```
   
      Adjust the `height` and `width` values as needed 
<sup>[[1]](https://github.com/apache/superset/blob/master/superset/examples/tabbed_dashboard.py)</sup>.
   
   3. **Sharing Selected Plots via Email**:
      Currently, Superset does not support sharing multiple selected plots as a 
single email attachment directly. You might need to manually create a custom 
email template that includes the selected plots.
   
   4. **Sharing Dashboards as Text via Email**:
      Superset allows for text-based sharing through the `context_markdown` 
field in report schedules. You can use this field to include text-based content 
in your email reports. Here is an example:
   
      ```py
      show_columns = [
          "id",
          "active",
          "chart.id",
          "chart.slice_name",
          "chart.viz_type",
          "context_markdown",
          "creation_method",
          "crontab",
          "custom_width",
          "dashboard.dashboard_title",
          "dashboard.id",
          "database.database_name",
          "database.id",
          "description",
          "extra",
          "force_screenshot",
          "grace_period",
          "last_eval_dttm",
          "last_state",
          "last_value",
          "last_value_row_json",
          "log_retention",
          "name",
          "owners.first_name",
          "owners.id",
          "owners.last_name",
          "recipients.id",
          "recipients.recipient_config_json",
          "recipients.type",
          "report_format",
          "sql",
          "timezone",
          "type",
          "validator_config_json",
          "validator_type",
          "working_timeout",
          "email_subject",
      ]
      ```
   
      The `context_markdown` field allows for text-based sharing within the 
report schedules 
<sup>[[2]](https://github.com/apache/superset/blob/master/superset/reports/api.py)</sup>.
   
   These solutions should help you address the issues you're facing with 
Superset 4.0.2.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to