Reputation: 31
Now my project folder named as "App" has four modules: "electron-packager", "electron", "echarts","echarts-gl". now I command "npm start" to run the echarts demo, but index.html has not shown as expected. I guess some function has not worked, such as "echarts.init" and "myChart.setOption", since the prompt is "any" by VSCode . Or should be something wrong with the relationship between these modules?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<!-- import echarts.js -->
<script src="echarts.js"></script>
</head>
<body>
<!-- prepare a Dom for echarts -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// prepare a dom for echarts
var myChart = echarts.init(document.getElementById('main'));
// configure option
var option = {
title: {
text: 'ECharts demo'
},
tooltip: {},
legend: {
data:['a']
},
xAxis: {
data: ["A","B","C","D","E","F"]
},
yAxis: {},
series: [{
name: 'a',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
};
// use option
myChart.setOption(option);
</script>
</body>
</html>
the window is empty, displaying like this,
Upvotes: 0
Views: 260
Reputation: 4440
Probably it's a security issue, try to add into </head>
:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' style-src 'self' 'unsafe-inline';">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self' style-src 'self' 'unsafe-inline';">
Upvotes: 0