【问题标题】:Highcharts export chart exportSettings with svg fileHighcharts 使用 svg 文件导出图表 exportSettings
【发布时间】: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


【解决方案1】:

这可能不是完整的答案,但它可能会引导您朝着正确的方向前进: 看看https://github.com/aspnet/JavaScriptServices,它提供了一种将代码传递给nodejs的方法(尽管它是关于服务器端渲染的,但原理是相似的)。然后,您可以通过 CLI 将参数传递给 nodejs。

【讨论】:

  • 谢谢,但在发布我的问题之前我已经做过了。我正在研究解决方案,现在离我更近了
猜你喜欢
  • 1970-01-01
  • 2013-09-28
  • 2019-07-12
  • 1970-01-01
  • 2015-06-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多