| 可以使用以下代码来导入echarts-wordcloud.js和echarts.js插件,并加载CSV的数据生成云图: |
| |
复制
| DOCTYPE html> |
| |
| |
| <meta charset="utf-8"> |
| <title>Wordcloud Example</title> |
| |
| < src="https://cdn.jsdelivr.net/npm/echarts/dist/ech.min.js"> |
| |
| <script src="https://cdn.jsdelivr.net/echarts-wordcloud/dist/echartscloud.min.js"></script> |
| |
| > |
| <div id="wordcloud" ="width:="" 600px;="" height:="" px;"=""></div> |
| |
| <script type="/javascript"> |
| var myChart = echarts.init(document.getElementById('word')); |
| |
| var data = [ |
| {name: "apple", value: 100}, |
| {name: "banana", value: 50 {name: "orange", value: 80} |
| // Add more data from your CSV file here |
| ]; |
| |
| var option = { |
| series: [{ |
| type: 'wordCloud', |
| grid: { |
| top: '10%', |
| bottom: '10%', |
| left:10%', |
| right: '10%' |
| }, |
| size: ['70%', '70%'], |
| textRotation: [0, 45,90, -45], |
| shape: 'circle', |
| drawOutOfBound: false, |
| textStyle: { |
| normal: { |
| fontFamily:sans-serif', |
| fontWeight: 'bold', |
| color: function () { |
| return 'rgb(' [ |
| Math.round(Math.random() *160), |
| Math.round(Math.random() * 160), |
| Math.round(Math.random() * 160) |
| ].join(',') ')'; |
| } |
| } |
| }, |
| data: data |
| }] |
| }; |
| |
| myChart.setOption(option); |
| </script> |
| |
复制
请注意,此示例中的数据是硬编码在代码中的,如果需要从CSV文件中导入数据,需要使用JavaScript中的File API来读取CSV文件并解析数据后再进行展示。