Pivot Table Cells Not Rendering Html
Bug Description
The Pivot Table chart in Superset does not render HTML tags within its data cells. While HTML in row and column headers is rendered correctly, HTML content in the data cells is escaped and displayed as literal text. This limitation restricts the ability to embed links or apply custom styling directly within the data portion of the pivot table when the underlying data source contains HTML.
How to Reproduce the Bug
To reproduce the bug, follow these steps:
- Create or import a Pivot Table chart where the dataset provides HTML content for one or more cells.
- Configure the chart to use these HTML-containing fields.
- Observe the rendering of the data cells in the pivot table. The attached chart export (
.json
file) can be imported into Superset to directly observe the issue.
Expected Results
The HTML tags within the data cells should be rendered by the browser. For example:
Capital of <strong style="color:blue;">France</strong>
should display as: Capital of France (with "France" in blue and bold).The <a href="https://en.wikipedia.org/wiki/New_York_City" target="_blank">Big Apple</a>
should display as: The Big Apple (with "Big Apple" as a clickable link).
Actual Results
The HTML tags within the data cells are displayed as literal text. For example:
- You see:
Capital of <strong style="color:blue;">France</strong>
- You see:
The <a href="https://en.wikipedia.org/wiki/New_York_City" target="_blank">Big Apple</a>
Screenshot
Additional Context
The issue is observed in the latest version of Superset (master / latest-dev) with the following environment configurations:
- Python version: 3.10
- Node version: 18 or greater
- Browser: Chrome
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.
Possible Causes and Solutions
The issue might be caused by the way Superset handles HTML content in pivot table data cells. Here are some possible causes and solutions:
- Cause: Superset's HTML rendering engine is not configured to render HTML tags within data cells.
- Solution: Check the Superset configuration files to see if there are any settings that control HTML rendering. Update the configuration files accordingly.
- Cause: The data source is not providing the HTML content correctly.
- Solution: Verify the data source and ensure that it is providing the HTML content correctly. If the issue persists, try to reproduce the issue with a different data source.
Workarounds
Until the issue is resolved, here are some workarounds that can be used:
- Use a different chart type: If possible, use a different chart type that does not require HTML rendering within data cells.
- Use a custom solution: Develop a custom solution that uses JavaScript to render the HTML content within the data cells.
Conclusion
Q: What is the issue with Pivot Table cells not rendering HTML?
A: The issue is that the Pivot Table chart in Superset does not render HTML tags within its data cells. While HTML in row and column headers is rendered correctly, HTML content in the data cells is escaped and displayed as literal text.
Q: Why is this a problem?
A: This limitation restricts the ability to embed links or apply custom styling directly within the data portion of the pivot table when the underlying data source contains HTML. This can make it difficult to present data in a clear and concise manner.
Q: How can I reproduce the issue?
A: To reproduce the issue, follow these steps:
- Create or import a Pivot Table chart where the dataset provides HTML content for one or more cells.
- Configure the chart to use these HTML-containing fields.
- Observe the rendering of the data cells in the pivot table. The attached chart export (
.json
file) can be imported into Superset to directly observe the issue.
Q: What are the expected results?
A: The HTML tags within the data cells should be rendered by the browser. For example:
Capital of <strong style="color:blue;">France</strong>
should display as: Capital of France (with "France" in blue and bold).The <a href="https://en.wikipedia.org/wiki/New_York_City" target="_blank">Big Apple</a>
should display as: The Big Apple (with "Big Apple" as a clickable link).
Q: What are the actual results?
A: The HTML tags within the data cells are displayed as literal text. For example:
- You see:
Capital of <strong style="color:blue;">France</strong>
- You see:
The <a href="https://en.wikipedia.org/wiki/New_York_City" target="_blank">Big Apple</a>
Q: What are the possible causes of this issue?
A: The issue might be caused by the way Superset handles HTML content in pivot table data cells. Here are some possible causes:
- Cause: Superset's HTML rendering engine is not configured to render HTML tags within data cells.
- Cause: The data source is not providing the HTML content correctly.
Q: What are the possible solutions to this issue?
A: Here are some possible solutions:
- Solution: Check the Superset configuration files to see if there are any settings that control HTML rendering. Update the configuration files accordingly.
- Solution: Verify the data source and ensure that it is providing the HTML content correctly. If the issue persists, try to reproduce the issue with a different data source.
Q: Are there any workarounds for this issue?
A: Yes, here are some workarounds that can be used:
- Workaround: Use a different chart type that does not require HTML rendering within data cells.
- Workaround: Develop a custom solution that uses JavaScript to render the HTML content within the data cells.
Q: How can I report this issue?
A: If you are experiencing this issue, please report it to the Superset community by creating a new issue on the Superset GitHub page. Provide much detail as possible, including the steps to reproduce the issue and any relevant configuration files.
Q: How can I stay up-to-date with the latest developments on this issue?
A: To stay up-to-date with the latest developments on this issue, follow the Superset GitHub page and the Superset community forums. You can also subscribe to the Superset newsletter to receive updates on new features and bug fixes.