2017-08-11 103 views
8

我想呈现的地图文件中使用.NET的核心项目Highcharts出口图表exportSettings与SVG文件

所以后面,目的是为了在一个Javascript中间件执行Highmaps库,以及SVG文件导出到“节点导出服务器”。

我有一个从客户端接收一些数据的API。我想用Highmap库生成SVG映射文件,然后发送到另一个包含中间件的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); 
}); 
+0

你是什么意思?您可以将JSON或SVG文件设置为'--infile'参数。另外,为什么要导出到SVG文件并将其传递到节点导出服务器?您可以使用JSON形式传递图表选项。例如:'highcharts-export-server --infile chart.json --outfile chart.png'。 –

+0

是的,但我不想使用CLI命令。我编辑了我的问题,现在可能更清楚了.. – Coemgen

+0

只是为了理解这个问题:您想从highchart-export-server生成svg,然后将该svg传递给另一个api? –

回答

1

嗯,这可能不是完全完整的答案,但它可以引导你在正确的方向: 在https://github.com/aspnet/JavaScriptServices它提供了一种方式来传递代码的NodeJS(即使它是关于服务器端看看渲染,原理相似)。然后,您可以通过CLI将参数传递给nodejs,方法相同。

+0

谢谢,但我已经做过之前发布我的问题。 我正在研究解决方案,现在我接近了 – Coemgen