将谷歌可视化图表发送到电子邮件
我们可以将 Google 可视化图表发送到电子邮件客户端吗? 我尝试在发送电子邮件时复制粘贴 JavaScript 代码,但它已被 Gmail 即时删除。
谢谢和问候。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我们可以将 Google 可视化图表发送到电子邮件客户端吗? 我尝试在发送电子邮件时复制粘贴 JavaScript 代码,但它已被 Gmail 即时删除。
谢谢和问候。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
免责声明:我是 Image-Charts 创始人。
6年后! Google Image-Charts 自 2012 年起已被弃用,作为一名独立黑客,我不想每次启动新的 SaaS 时都从头开始重写图像生成后端,以便能够通过电子邮件发送图表......
这就是为什么我'已经构建了图像图表
Disclaimer: I'm Image-Charts founder.
6 years later! Google Image-Charts is deprecated since 2012, and as an indiehacker, I don't want to rewrite from scratch an image generation backend each time I started a new SaaS to just be able to send charts in email...
That's why I've built Image-charts ???? and added gif animation on top of it ????(chart animations in emails are awesome!!), no more server-side chart rendering pain, no scaling issues, it's blazing fast, 1 URL = 1 image chart.
我也遇到了这个问题。为了通过电子邮件发送图表,您需要将其呈现为图像,因为电子邮件客户端会剥离 Javascript。
如果您使用的是 Google 图表,则必须运行 Javascript,然后使用 导出它getImageURI。要自动执行此操作,您需要一个无头渲染器,例如 puppeteer。
问题的解决方案是开源的。我将图表渲染封装在库和 Web 服务器中:https://github.com/typpo/quickchart。该 Web 服务处理渲染细节,您所做的就是使用您的数据调用 API。
例如,在查询参数中定义图表:
https://quickchart.io/chart?width=500&height=300&c={type:'bar',data:{labels:['一月','二月','三月','四月','五月'],数据集:[{label:'狗',data:[50,60,70,180,190]},{label:'猫',data:[100,200,300,400,500]}] }}
上述 URL 呈现此图像:
希望这会有所帮助!
I ran into this problem as well. In order to send a chart in email, you need to render it as an image because email clients strip Javascript.
If you're using Google Charts, you'll have to run the Javascript and then export it using getImageURI. To automate this, you need a headless renderer like puppeteer.
The solution to the problem is open source. I wrapped chart rendering in a library and web server: https://github.com/typpo/quickchart. This web service handles the rendering details, all you do is call the API with your data.
For example, define your chart in the query parameters:
https://quickchart.io/chart?width=500&height=300&c={type:'bar',data:{labels:['January','February','March','April','May'],datasets:[{label:'Dogs',data:[50,60,70,180,190]},{label:'Cats',data:[100,200,300,400,500]}]}}
The above URL renders this image:
Hope this helps!
Google 图表可以通过两种方式发布:
作为图像。编辑图表->发布图表->格式:图像。生成图像链接。该图像链接可以在任何 html 页面中使用,也可以
作为交互式图表。编辑图表->发布图表->格式:交互式图表。在这种情况下,必须插入 JavaScript 代码。这只能在 html 页面中发布。无法将其附加到电子邮件正文中,因为大多数电子邮件服务器/客户端不处理 javascript 代码 (AFAIK)。
Google charts could be published in 2 ways:
as an Image. Edit Chart-> Publish Chart-> Format : image. An image link is generated. This image link could be either used in any html page or could be embedded in any email.
as an Interactive Chart. Edit Chart-> Publish Chart-> Format : Interactive Chart. In this case javascript code has to be inserted. This could only be published in html pages. This could not be attached in email body as most email servers/clients do not process javascript code (AFAIK).
3.5 年后...:)
我在 Ramen 的团队最近将一些内部功能拆分成一个独立的产品,该产品就是这样做的:https:// ChartURL.com
您可以使用“加密 URL”方案即时生成图表,也可以向我们发送大量数据并返回可解析为图像的短 URL。
它构建在 C3js.org 之上,因此您可以生成大量的灵活性。
这些 URL 可用于网络应用程序和应用程序。移动应用程序,但最初的目的是电子邮件图表,所以我希望这会有所帮助!
3.5 years later... :)
My team at Ramen recently spun out some internal functionality into a standalone product that does just this: https://ChartURL.com
You can generate charts on the fly using an "Encrypted URL" scheme, or you can send us huge amounts of data and return a Short URL that'll resolve to an image.
It was built on top of C3js.org so there's a ton of flexibility in what you can generate.
These URLs can be used in web apps & mobile apps, but the original intent was email charts so I hope this helps!
电子邮件客户端中很少有 JS 支持。所以你必须使用图像图表。但您可以将图表包含在 svg 版本的链接中。
There is very little JS support in email clients. so you will have to use an image chart. But you could wrap the chart in a link to the svg version.
Google Charts 没有一个 API,您只需构建一个 URL,它就会返回一个图像 - 不需要 Javascript?确实曾经如此。如果您可以使用它,那么:
a)只需将 URL 放入电子邮件中,然后让用户的电子邮件客户端获取它
b)使用 CURL 获取图像并附加到电子邮件中。
Doesn't Google Charts have an API where you can just build a URL and it returns an image - no Javascript needed? It certainly used to. If you can use that, then:
a) Just put the URL in the email and let the users email client get it
b) Fetch the image with CURL and attach to the email.