在没风的地方找太阳  在你冷的地方做暖阳 人事纷纷  你总太天真  往后的余生  我只要你 往后余生  风雪是你  平淡是你  清贫也是你 荣华是你  心底温柔是你  目光所致  也是你 想带你去看晴空万里  想大声告诉你我为你着迷 往事匆匆  你总会被感动  往后的余生  我只要你 往后余生  冬雪是你  春花是你  夏雨也是你 秋黄是你  四季冷暖是你  目光所致  也是你 往后余生  风雪是你  平淡是你  清贫也是你 荣华是你  心底温柔是你  目光所致  也是你
jQuery火箭图标返回顶部代码 - 站长素材

react 项目使用 echarts-wordcloud(文字云)

一、安装echarts 和 echarts-wordcloud

npm install echarts --save

npm install echarts-wordcloud --save

二、项目中引入echarts 和 echarts-wordcloud

import echarts from 'echarts'

import 'echarts-wordcloud'

三、在生命周期 componentDidMount 中初始化echarts

componentDidMount() {
    this.kpiEcharts = echarts.init(this.kpiRef.current);
    this.kpiEcharts.on('click', (params) => {
        this.props.onCkick(params.data)
    });
    let _this = this
    window.addEventListener("resize",function (){
        _this.kpiEcharts.resize();
    });
    this.setState({
        keyWordsList: this.props.keyWordsList
    })
    this.initChartOption()
}


initChartOption() {
    var maskImage = new Image();//可以根据图片形状生成有形状的词云图
    maskImage.src=require('@/static/img/goToTop.png')
    let option = {
        backgroundColor: '#F7F7F7',
        tooltip: {
            trigger: 'item',
            axisPointer: {
            type: 'none'
            },
            position: "top",
            formatter: function({name, value}) {
            return `${name}:${value.toFixed(2)}`
            }
        },
        series: [{
            name: '搜索指数',
            left: 'center',
            top: 'center',
            width: '100%',
            height: '100%',
            right: null,
            bottom: null,
            type: 'wordCloud',
            size: ['9%', '99%'],
            sizeRange: [20, 100],
            //textRotation: [0, 45, 90, -45],
            rotationRange: [-45, 90],
            //shape: 'circle',
            // gridSize: 10,
            
            // shape: 'triangle',
            maskImage: maskImage,
            textPadding: 0,
            autoSize: {
                enable: true,
                minSize: 6
            },
            textStyle: {
                normal: {
                    color: function() {
                        return 'rgb(' + [
                            Math.round(Math.random() * 160),
                            Math.round(Math.random() * 160),
                            Math.round(Math.random() * 160)
                        ].join(',') + ')';
                    }
                },
                emphasis: {
                    shadowBlur: 10,
                    shadowColor: '#FF6A00'
                }
            },
            data: [
                {
                    name: 'Authentication',
                    value: 10000,
                    textStyle: {
                    normal: {
                        color: 'black'
                    },
                    emphasis: {
                        color: 'red'
                    }
                    }
                },
                {
                    name: 'Streaming of segmented content',
                    value: 6181
                },
                {
                    name: 'Amy Schumer',
                    value: 4386
                },
                {
                    name: 'Jurassic World',
                    value: 4055
                },
                {
                    name: 'Charter Communications',
                    value: 2467
                },
                {
                    name: 'Chick Fil A',
                    value: 2244
                },
                {
                    name: 'Planet Fitness',
                    value: 1898
                },
                {
                    name: 'Pitch Perfect',
                    value: 1484
                },
                {
                    name: 'Express',
                    value: 1112
                },
                {
                    name: 'Home',
                    value: 965
                },
                {
                    name: 'Johnny Depp',
                    value: 847
                },
                {
                    name: 'Lena Dunham',
                    value: 582
                },
                {
                    name: 'Lewis Hamilton',
                    value: 555
                },
                {
                    name: 'KXAN',
                    value: 550
                },
                {
                    name: 'Mary Ellen Mark',
                    value: 462
                },
                {
                    name: 'Farrah Abraham',
                    value: 366
                },
                {
                    name: 'Rita Ora',
                    value: 360
                },
                {
                    name: 'Serena Williams',
                    value: 282
                },
                {
                    name: 'NCAA baseball tournament',
                    value: 273
                },
                {
                    name: 'Point Break',
                    value: 265
                }
            ]
            
        }]
    };
    // this.kpiEcharts.setOption(option, true);
    let _this = this
    maskImage.onload = function() {
        _this.kpiEcharts.setOption(option, true);
    };
}

 四、效果如下

 

posted @ 2020-11-06 11:40  艺术诗人  阅读(4456)  评论(0编辑  收藏  举报