# echarts-wordcloud
Unofficial (https://github.com/apache/incubator-echarts) wordcloud extension based on [wordcloud2.js](https://github.com/timdream/wordcloud2.js) for Apache ECharts.
![](./example/word-cloud.png)
## Examples
[Google Trends](https://ecomfe.github.io/echarts-wordcloud/example/wordCloud.html)
[ECharts Option Keywords](https://ecomfe.github.io/echarts-wordcloud/example/optionKeywords.html)
## Install
```html
<script src="echarts.min.js"></script>
<script src="echarts-wordcloud.min.js"></script>
```
Or
```shell
npm install echarts
npm install echarts-wordcloud
```
```js
import * as echarts from 'echarts'
import 'echarts-wordcloud';
```
NOTE:
echarts-wordcloud@2 is for echarts@5
echarts-wordcloud@1 is for echarts@4
## Usage
```js
var chart = echarts.init(document.getElementById('main'));
chart.setOption({
...
series: [{
type: 'wordCloud',
// The shape of the "cloud" to draw. Can be any polar equation represented as a
// callback function, or a keyword present. Available presents are circle (default),
// cardioid (apple or heart shape curve, the most known polar equation), diamond (
// alias of square), triangle-forward, triangle, (alias of triangle-upright, pentagon, and star.
shape: 'circle',
// A silhouette image which the white area will be excluded from drawing texts.
// The shape option will continue to apply as the shape of the cloud to grow.
maskImage: maskImage,
// Folllowing left/top/width/height/right/bottom are used for positioning the word cloud
// Default to be put in the center and has 75% x 80% size.
left: 'center',
top: 'center',
width: '70%',
height: '80%',
right: null,
bottom: null,
// Text size range which the value in data will be mapped to.
// Default to have minimum 12px and maximum 60px size.
sizeRange: [12, 60],
// Text rotation range and step in degree. Text will be rotated randomly in range [-90, 90] by rotationStep 45
rotationRange: [-90, 90],
rotationStep: 45,
// size of the grid in pixels for marking the availability of the canvas
// the larger the grid size, the bigger the gap between words.
gridSize: 8,
// set to true to allow word being draw partly outside of the canvas.
// Allow word bigger than the size of the canvas to be drawn
drawOutOfBound: false,
// If perform layout animation.
// NOTE disable it will lead to UI blocking when there is lots of words.
layoutAnimation: true,
// Global text style
textStyle: {
fontFamily: 'sans-serif',
fontWeight: 'bold',
// Color can be a callback function or a color string
color: function () {
// Random color
return 'rgb(' + [
Math.round(Math.random() * 160),
Math.round(Math.random() * 160),
Math.round(Math.random() * 160)
].join(',') + ')';
}
},
emphasis: {
focus: 'self',
textStyle: {
shadowBlur: 10,
shadowColor: '#333'
}
},
// Data is an array. Each array item must have name and value property.
data: [{
name: 'Farrah Abraham',
value: 366,
// Style of single text
textStyle: {
}
}]
}]
});
```
程序员徐师兄
- 粉丝: 1992
- 资源: 2883
最新资源
- 互助学习小程序的设计与实现+ssm-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于微信小程序的电影交流平台--论文-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 基于微信小程序的高校餐厅食品留样管理系统-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 公交信息在线查询系统+ssm-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于微信小程序的二手物品交易平台ssm-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于微信小程序的快递管理平台的设计与实现ssm-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于微信小程序的考研资料分享系统的设计与实现springboot-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于JAVA的微信食堂线上订餐小程序的设计与实现ssm-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于微信小程序的课堂点名系统springboot-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 婚庆摄影小程序ssm-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于微信的疫情期间学生请假与销假系统的设计与实现ssm-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于java+ssm+mysql的农家乐内部管理系统开题报告.docx
- 基于微信小程序的美容院管理系统-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 基于微信小程序的青少年素质教育培训系统-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 基于微信平台的旅游出行必备商城小程序+ssm-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于微信小程序的汽车销售系统的设计与实现springboot-微信小程序毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈