首页 前端知识 echarts --- 词云图

echarts --- 词云图

2024-09-06 00:09:40 前端知识 前端哥 47 77 我要收藏

上周做数据统计的大屏展示,其中涉及到词云图。

词云图:由词标签/维度和词大小/度量组成。

angular cli8  +  echarts4   (这是之前的项目了)。

只安装echarts,中已经不可以直接用 type: 'wordCloud' 去绘制词云图了,需要额外安装echarts-wordcloud   这里选择适合自己的版本安装就可以了。

需要引用:

import * as echarts from 'echarts';

import "echarts-wordcloud/src/wordCloud.js";

options的配置项可以按文档和自己本身的需求进行设置。

这边直接贴上我自己的代码。

let option =  {
          series: [{
            type: 'wordCloud',
            sizeRange: [15, 80],
            rotationRange: [0, 0],
            rotationStep: 45,
            gridSize: 8,
            shape: 'pentagon',
            width: '100%',
            height: '100%',
              textStyle: {
                normal: {
                    color: function () {
                        return 'rgb(' + [
                            Math.round(Math.random() * 256),
                            Math.round(Math.random() * 256),
                            Math.round(Math.random() * 256)
                        ].join(',') + ')';
                    },
                    fontFamily: 'sans-serif',
                    fontWeight: 'normal'
                },
                emphasis: {
                    shadowBlur: 10,
                    shadowColor: '#333'
                }
            },
            data: this.wordcloudData
          }]
 }

效果图:

 

转载请注明出处或者链接地址:https://www.qianduange.cn//article/17798.html
标签
评论
发布的文章

关于HTML的知识

2024-09-18 23:09:36

js简单实现轮播图效果

2024-09-18 23:09:36

CSS3美化网页元素

2024-09-18 23:09:27

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!