[英]amcharts Export with Meteor + React (JSX)
我正在使用帶有amCharts的Meteor + React(JSX)。 我的圖表呈現了我面臨的問題是導出功能無法正常工作。
我在瀏覽器中收到以下錯誤消息:
fabric.min.js:1 Uncaught SyntaxError: Unexpected token <
jszip.min.js:1 Uncaught SyntaxError: Unexpected token <
FileSaver.min.js:1 Uncaught SyntaxError: Unexpected token <
xlsx.min.js:1 Uncaught SyntaxError: Unexpected token <
在每個文件的第1行上,我看到: <!DOCTYPE html>
我相信問題與流星加載文件的方式有關,但不確定。
在組件的頂部,我有:
import "amcharts3-export";
import React from 'react';
import ReactDOM from 'react-dom';
import AmCharts from 'amcharts3-react';
amCharts配置如下所示:
const config = {
"type": "serial",
"theme": "light",
"categoryField": "year",
"valueAxes": [
{
"id": "ValueAxis-1",
"title": "Payback"
}
],
"animation": false,
"graphs":
[{
"type": "smoothedLine",
"balloonText": "[[title]] of [[year]]:[[value]]",
"bullet": "round",
"id": "AmGraph-1",
"title": "graph 1",
"valueField": "value",
"fillColorsField": "lineColor",
"lineColorField": "lineColor",
"fillAlphas": 0.3,
}],
"dataProvider": this.state.lineItems,
"export": {
"enabled": true,
"libs": {
"autoLoad": false,
"path": "../libs/"
},
"menu": [{
"class": "export-main",
"menu": [ "JPG" ]
}]
}
}
任何建議將不勝感激
因此,我不確定為什么會起作用。 我將導出js文件復制到public / libs文件夾中。 哪些確實消除了錯誤,但不確定為什么以及是否將重復的js捆綁在一起-需要進行調查。 為了使出口組件正常工作,我需要進行以下進口:
import 'amcharts3-export';
import 'amcharts3-export/export.css';
import AmCharts from 'amcharts3-react';
我用以下方式繪制圖表:
render () {
return (
<div id={this.props.tileid} style={{width: '100%', height: this.props.height.toString()+'px'}} >
<AmCharts.React
ref="chartref"
{...this.chart}
dataProvider={this.props.data}
key={this.props.tile._id}
/>
</div>
);
其中this.chart
是我的圖表設置對象。
此圖表obj應該具有:
"export": {
"enabled": true,
"libs": { "path": "/libs/" },
...
}
我也導入了'amcharts3 / amcharts / gauge.js'; 使用其他圖表類型時。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.