gpt4 book ai didi

css - 导出时的 Highcharts css 样式

转载 作者:太空宇宙 更新时间:2023-11-04 09:07:54 26 4
gpt4 key购买 nike

我有以下数字图表。见图片: enter image description here

但是当使用 Highchart 的 hamburguer CSS 菜单导出为 PDF 或 JPG 或 PNG 时,我得到这样的图表:见图片: enter image description here

如您所见,CSS 样式、字体和大小未保留。我们怎样才能留住他们? TIA 为您提供帮助。

最佳答案

您可以在您的帖子请求中将您的 CSS 样式传递给导出服务器。

var options = {
chart: {},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
]
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
type: 'column'
}]
}

var chart = Highcharts.chart('container', options);

var data = {
options: JSON.stringify(options),
resources: {
// You can add your CSS styles here
css: ".highcharts-background { fill: #efefef; stroke: #a4edba; stroke-width: 2px}"
},
filename: 'test.png',
type: 'image/png',
async: true
}

var exportUrl = 'https://export.highcharts.com/';
$.post(exportUrl, data, function(data) {
var imageUrl = exportUrl + data;
var urlCreator = window.URL || window.webkitURL;
document.querySelector("#image").src = imageUrl;
fetch(imageUrl).then(response => response.blob()).then(data => {console.log(data)});
})

实例:https://jsfiddle.net/nfbcq865/

关于css - 导出时的 Highcharts css 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42340707/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com