简体   繁体   English

如何更改 apache superset 图表的背景颜色?

[英]how to change apache superset's chart's background color?

Per How to Change Apache Superset Template from the Superset User Interface? Per 如何从 Superset 用户界面更改 Apache Superset 模板? , I was able to change the CSS template for Superset dashboard. ,我能够更改 Superset 仪表板的 CSS 模板。 But the charts inside the dashboard are not affected.但仪表板内的图表不受影响。 eg most of the charts have white colored background(eg Piechart) and some people dislike it.例如,大多数图表有白色背景(例如 Piechart),有些人不喜欢它。 How to change the chart background color?如何更改图表背景颜色? I mean change it for all charts or for one chart.我的意思是为所有图表或一张图表更改它。 我想在 Apache Superset 中更改的背景

Disclaimer: This should work, but is a bit hacky and could have long-term support implications:免责声明:这应该可行,但有点麻烦,可能会产生长期支持影响:

I've been fiddling with a "dark mode" dashboard just to kick the tires on this.我一直在摆弄“黑暗模式”仪表板,只是为了解决这个问题。 Here's a screenshot just for fun:这是一个截图,仅供娱乐:

超集暗模式示例

So... what did I do?所以……我做了什么?

  1. Click "Edit Dashboard" in the top right of your screenshot单击屏幕截图右上角的“编辑仪表板”
  2. When in edit mode, the top right menu has an option to "Edit CSS"在编辑模式下,右上角的菜单有一个“编辑 CSS”选项
  3. Use your browser's inspector to hack away!使用浏览器的检查器来破解! That said, here are a couple of key ingredients:也就是说,这里有几个关键要素:
    • .dashboard-component{ background: whatever} - sets the main background of each viz card, but you'll still see many components still have white backgrounds within these wrappers. .dashboard-component{ background: whatever} - 设置每个.dashboard-component{ background: whatever}卡片的主要背景,但您仍然会看到许多组件在这些包装器中仍然具有白色背景。
    • .slice_container svg{ background-color: transparent !important; } .slice_container svg{ background-color: transparent !important; } - this overrides the white background of the components I ran into (including Pie charts!). .slice_container svg{ background-color: transparent !important; } -这将覆盖我跑进成分的白色背景(包括饼图!)。

If viz components use SVG you can get pretty clever with inspecting/overriding various bits.如果可视化组件使用 SVG,您可以非常聪明地检查/覆盖各种位。 A couple of gotchas with the above:上面的几个问题:

  1. If a viz component contains multiple SVG elements, this may have side effects.如果一个可视化组件包含多个 SVG 元素,这可能会产生副作用。
  2. If a viz uses canvas instead of svg you will run into more trouble如果可视化使用canvas而不是svg您会遇到更多麻烦

In the worst case scenario, you may need to check out the superset-ui-plugins repo and make tweaks.在最坏的情况下,您可能需要查看superset-ui-plugins库并进行调整。 This dev process isn't super straightforward, but some of us are working to improve that.这个开发过程并不是非常简单,但我们中的一些人正在努力改进它。

对我来说最简单的解决方案是使用深色阅读器扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM