任何人都可以帮我弄清楚为什么高图表导出(下载png)功能无法在移动浏览器中运行?我在移动浏览器中尝试了它的演示http://www.highcharts.com/demo并且它工作正常。请帮助我。< / p>
编辑以下是来自export.js的代码,负责文件下载 -
f.post(a.url, {
filename: a.filename || "chart",
type: a.type,
width: a.width || 0,
scale: a.scale || 2,
svg: e
},
谢谢。
答案 0 :(得分:1)
我是通过技巧做到的,可能对你也有用,所以我下载export.js并将其修改为 -
exportChart: function(t, e) {
var n = this.getSVGForExport(t, e),
t = u(this.options.exporting, t),
o = {
filename: t.filename,
type: t.type,
width: t.width || 0,
scale: t.scale || 2,
svg: n,
async: !0
};
$.post(t.url, o, function(e) {
var n = t.url + e,
o = document.URL,
i = "chartUrl",
r = n,
a = new RegExp("([?&])" + i + "=.*?(&|$)", "i"),
s = -1 !== o.indexOf("?") ? "&" : "?";
o.match(a) ? currentUrl = o.replace(a, "$1" + i + "=" + r + "$2") : currentUrl = o + s + i + "=" + r, window.open(currentUrl, "_self")
})
},
在android方面,我有以下代码 -
f (url != null) { //url = current web url
String arr[] = url.split("=");
if (arr != null && arr.length == 2) {
String newUrl = arr[1];
if (newUrl != null && !newUrl.equals("")) {
String fileName = newUrl.substring(newUrl.lastIndexOf('/') + 1, newUrl.length());
Toast.makeText(context, "Start Downloading...", Toast.LENGTH_LONG).show();
Log.i(getClass().getName(), "newUrl : " + newUrl);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(newUrl));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
}
}}