Highcharts气泡填充图

news/2024/10/19 7:34:26/

https://www.hcharts.cn/demo/highcharts/packed-bubble/

如果分类种类有很多,一种的柱状图显示出来界面非常拥挤,此时可以使用气泡图来表示。

首先我们要下载引入,这里参考此文档即可。

https://www.hcharts.cn/docs/install-from-npm/

    drawbar() {let that = this;const sortedData = this.qipaoListData.sort((a, b) => b.count - a.count);const top20Data = sortedData.slice(0, 20);if (this.qipaoListData.length > 20) {const otherData = sortedData.slice(20);const otherCount = otherData.reduce((acc, cur) => acc + cur.count, 0);const otherItem = {text: "其它",count: otherCount};top20Data.push(otherItem);}let chartContent = {coordinate: [],series: [{data: []}]};top20Data.forEach(item => {chartContent.coordinate.push(item.text);chartContent.series[0].data.push(item.count);});const categories = chartContent.coordinate;const values = chartContent.series[0].data;// 定义颜色数组const colors = ["#FF5733","#33FF57","#3357FF","#F1C40F","#8E44AD","#E74C3C","#3498DB","#2ECC71","#9B59B6","#34495E","#1ABC9C","#F39C12","#D35400","#C0392B","#7D3C98","#2980B9","#27AE60","#2C3E50","#E67E22"];// 创建数据数组,包含每个分类的名称、对应的值和颜色const chartData = categories.map((category, index) => ({name: category,value: values[index], // 对应的值z: values[index], // 使用 z 属性来控制气泡大小color: colors[index % colors.length] // 为每个气泡指定颜色}));const myChart = Highcharts.chart(this.$refs.chart1, {chart: {type: "packedbubble",height: "330px",events: {load: function() {this.series.forEach(series => {series.data.forEach(point => {point.update({z: point.value // 使用 value 作为气泡的大小});});});}}},title: {text: null // 设置标题为 null,确保不显示标题},tooltip: {useHTML: true,pointFormat: "{point.name}<br>{point.value}条"},plotOptions: {packedbubble: {minSize: chartData.length === 1 ? "50%" : "70%",maxSize: chartData.length === 1 ? "100%" : "300%",zMin: 0,zMax: 1000,layoutAlgorithm: {splitSeries: false,gravitationalConstant: 0.02,bubblePadding: 10, //气泡间隔overlap: false},dataLabels: {enabled: true,align: "center",className: "circle-p",format: "{point.name}<br>{point.value}条", // 使用 <br> 标签换行filter: {property: "value",operator: ">",value: 0},style: {color: "black",textOutline: "none",fontWeight: "normal",align: "center",fontSize: "12px" // 设置文字大小}}}},series: [{name: "问题类型",data: chartData, // 使用从 chartContent 生成的数据events: {click: function(event) {if (event.point.name) {if (event.point.name == "其它") {that.$message({message: "其它暂不支持反查!",type: "warning",showClose: true});} else {that.condition.wTLX = event.point.name;that.currentListDataX.index = 1;that.condition.pageIndex = 1;that.getTable();that.echartsChange2 = true;}}}}}]});},

这里面是对气泡做了一个限制。只取数组前数量最多的20个。对气泡赋上颜色及一些基础设置供大家参考


http://www.ppmy.cn/news/1521145.html

相关文章

第65期 | GPTSecurity周报

GPTSecurity是一个涵盖了前沿学术研究和实践经验分享的社区&#xff0c;集成了生成预训练Transformer&#xff08;GPT&#xff09;、人工智能生成内容&#xff08;AIGC&#xff09;以及大语言模型&#xff08;LLM&#xff09;等安全领域应用的知识。在这里&#xff0c;您可以找…

Flutter之Linux命令行搭建Android 环境

一、简介 在Linux系统下使用命令行安装Android Studio可以提供更灵活的安装方式&#xff0c;适用于那些熟悉命令行操作的开发者。 二、操作流程 2.1 下载安装包 参考链接 历史版本下载&#xff1a;https://developer.android.com/studio/archive?hlzh-cn 最新版本下载&am…

【TiDB原理与实战详解】3、 集群升级和逻辑备份恢复~学不会? 不存在的!

六、TiDB Cluster 升级 1、打补丁 # tidb 补丁打法 tiup cluster patch 集群名称 /tmp/***.tar.gz -R tidb# tikv 补丁打法 tiup cluster patch 集群名称 /tmp/***.tar.gz -R tikv。。。。2、TiDB Cluster 版本升级 升级分为停机升级和不停机升级&#xff0c;但是不…

mkdir -p

在Unix-like系统中&#xff0c;-p 是 --parents 的缩写。这个选项告诉 mkdir 命令在创建指定目录的同时&#xff0c;如果目录的父目录不存在&#xff0c;也会自动创建这些父目录。 具体来说&#xff0c;当你使用 mkdir -p path/to/directory 时&#xff0c;如果 path/to/direct…

工程管理-Makefile

简介 Linux的 make 程序用来自动化编译大型源码&#xff0c;很多时候&#xff0c;我们在Linux下编译安装软件&#xff0c;只需要 敲一个 make 就可以全自动完成&#xff0c;非常方便。 make 能自动化完成这些工作&#xff0c;是因为项目提供了一个 Makefile 文件&#xff0c;它…

【Redis】缓存(上)

为什么要使用缓存&#xff1f; 在日常开发中&#xff0c;通常使用Redis来做MySQL的缓存。究其原因&#xff0c;首先&#xff0c;根据二八定律&#xff0c;20%的数据可以应对80%的请求&#xff1b;其次&#xff0c;对于MySQL这样的关系型数据库来说&#xff0c;性能普遍都不是很…

AI图像放大工具,图片放大无所不能

AI图像放大工具&#xff0c;如ESRGAN&#xff0c;对于提高由Stable Diffusion生成的AI图像质量至关重要。它们被广泛使用&#xff0c;以至于许多Stable Diffusion的图形用户界面&#xff08;GUI&#xff09;都内置了支持。 在这里&#xff0c;我们将学习什么是图像放大器&…

利用Spring Boot Actuator进行应用性能调优

引言 在现代的微服务架构中&#xff0c;Spring Boot因其便捷性和可扩展性而广受欢迎。Spring Boot Actuator模块更是为开发者提供了无需编写额外代码即可监控和管理应用程序的能力。本文将探讨如何使用Spring Boot Actuator来优化应用性能&#xff0c;包括如何配置、监控以及利…