[英]Making Google Visualization API to return the rendered visualization from https://charts.googleapis.com/* instead of http://charts.apis.google.com/*
The issue I am trying to solve is serving line charts prepared by Google visualization API on secure websites. 我要解决的问题是在安全网站上投放由Google可视化API编写的折线图。 I have read a couple of forums & blog posts but haven't come up with a workable solution.
我已经阅读了几个论坛和博客文章,但还没有提出可行的解决方案。
One solution mentioned here is to get the image through server-side code, save it locally & then serve it. 这里提到的一种解决方案是通过服务器端代码获取图像,将其保存在本地然后提供服务。 But the problem for me is how to generate the image URLs on the fly?
但是对我来说,问题是如何动态生成图像URL? I currently use visualization API to just feed my data to "google.visualization.ImageSparkLine" constructor & it does the rest.
我目前使用可视化API只是将我的数据馈送到“ google.visualization.ImageSparkLine”构造函数,其余的工作都会完成。
Anyways after looking at the response generated by this method I get that an image is returned with a url pattern http://chart.apis.google.com/chart , which is the main cause of the problem on sites served via SSL. 无论如何,查看此方法生成的响应后,我得到的是返回的图像带有url模式http://chart.apis.google.com/chart ,这是通过SSL服务的网站上出现问题的主要原因。 These causes warning to show up in FF, IE, Chrome.
这些导致警告显示在FF,IE,Chrome中。
Now I figured that if I just replaced the "http://chart.apis.google.com" WITH "https://chart.googleapis.com" everything works fine. 现在我发现,如果我只是将“ http://chart.apis.google.com”替换为“ https://chart.googleapis.com”,则一切正常。
So any help for either 1. converting the image URL before it is fetched by the browser or 2. Getting secure response to begin with; 因此,对于以下任何帮助:1.在浏览器获取之前转换图像URL,或者2.首先获得安全响应; will be great.
会很棒。
I finally got this resolved by constructing the Chart Images URLs. 我终于通过构建Chart Images URL解决了这个问题。
Now before making a call to google visualization API for generating the visualization, the JavaScript code checks if the location.protocol has "https" or not. 现在,在调用Google可视化API生成可视化之前,JavaScript代码会检查location.protocol是否具有“ https”。 If it does have https than it does,
如果它的https比它的多,
Tested on FF3.6, Chrome, IE8 (w & w/o compatibility mode) without generating security warning messages or popups. 在FF3.6,Chrome,IE8(无兼容模式)上进行了测试,没有生成安全警告消息或弹出窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.