一、词云

实现如下效果:

 首先引入echarts-wordcloud.js文件

请求数据:

$.ajax({
    url: domainName + '/api/data-visualization/analysis/statistic/wordCloud',
    type: 'post',
    data: {
        beginDate: beginDate,
        endDate: currentDate,
        keywords: '',
    },
    success(res) {
        if (res.code === 200) {
            console.log(res);
            initWordCloud(res.data)
        }
    },
    error(err) {
        console.log(err);
    }
})

返回的数据:

 配置项:

 // 提示信息
        tooltip: {
            show: true,
            backgroundColor: 'rgba(0,0,0,0.5)',
            borderWidth: 0,
            textStyle: {
                color: '#fff',
                fontSize: 14
            },
            trigger: 'item',
            formatter: (params) => {
                let { name, value } = params.data
                return `${params.marker} ${name}:${value}`
            }
        },
        series: [{
            type: 'wordCloud',
            shape: 'circle',
            /*  字体最下 12 最大 60 */
            // 设置文字大小范围
            sizeRange: [12, 60],
            /*  旋转范围 */
            rotationRange: [-90, 90],
            /*  旋转角度  */
            rotationStep: 45,
            // 修改文字(画布)之间的间距
            gridSize: 5,
            /* 不运行画到外侧 */
            drawOutOfBound: false,
            // If perform layout animation.
            // NOTE disable it will lead to UI blocking when there is lots of words.
            layoutAnimation: true,
            textStyle: {
                color: '#1EFFAA',
            },
            data: wordCloudData.map(i => ({
                name: i.x,
                value: i.value
            }))
        }]
    });

二、地图

效果:

 要有地图的json文件

请求数据:

配置项:

const initMap = mapData => {
    $.getJSON('../lib/china.json', data => {
        echarts.registerMap('China', data);
        map.setOption({
            series: [{
                type: 'map',
                mapType: 'China', //  与注册时的名字保持统一   echarts.registerMap('China', geoJson);
                itemStyle: {
                    areaColor: '#1E71FF',
                    borderColor: '#1950CC',
                    borderWidth: 1.5,
                },
                emphasis: {
                    itemStyle: {
                        areaColor: '#00C3F5',
                    },
                },
                select: {
                    label: {
                        show: false
                    },
                    itemStyle: {
                        areaColor: '#1E71FF',
                    },
                },
                zoom: 1.2,
                data: mapData,
            }],
        });
    })
}

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐