【发布时间】:2017-08-11 07:32:06
【问题描述】:
我想用 .Net Core 项目在后面渲染地图文件
所以,目的是在 Javascript 中间件上执行 Highmaps 库,并将 svg 文件导出到“node-export-server”。
我有一个从客户端接收一些数据的 API。我想用 Highmap 库生成 SVG 地图文件,然后发送到另一个 API,该 API 将包含一个中间件来执行节点模块或 PNG/JPG/... 导出。
将 svg 文件传递给“node-export-server”模块的方法是什么? 我阅读了相关文档,但我没有找到方法...... (https://github.com/highcharts/node-export-server/blob/master/README.md)
我想通过这个示例传递我的 SVG 文件。
//Include the exporter module
const exporter = require('highcharts-export-server');
//Export settings
var exportSettings = {
type: 'png',
options: {
title: {
text: 'My Chart'
},
xAxis: {
categories: ["Jan", "Feb", "Mar", "Apr", "Mar", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
},
series: [
{
type: 'line',
data: [1, 3, 2, 4]
},
{
type: 'line',
data: [5, 3, 4, 2]
}
]
}
};
//Set up a pool of PhantomJS workers
exporter.initPool();
//Perform an export
/*
Export settings corresponds to the available CLI arguments described
above.
*/
exporter.export(exportSettings, function (err, res) {
//The export result is now in res.
//If the output is not PDF or SVG, it will be base64 encoded (res.data).
//If the output is a PDF or SVG, it will contain a filename (res.filename).
//Kill the pool when we're done with it, and exit the application
exporter.killPool();
process.exit(1);
});
【问题讨论】:
-
什么意思?您可以将 JSON 或 SVG 文件设置为
--infile参数。另外,为什么要导出为 SVG 文件并将其传递给 node-export-server?您可以改为以 JSON 形式传递图表选项。示例:highcharts-export-server --infile chart.json --outfile chart.png. -
是的,但我不想使用 CLI 命令。我编辑了我的问题,现在可能更清楚了..
-
只是为了理解这个问题:您想从 highchart-export-server 生成 svg,然后将该 svg 传递给另一个 api ?
标签: node.js highcharts .net-core highmaps