文章目录

  • Highcharts 写 venn图 鼠标悬浮效果以及点击事件
  • 具体方法
    • 下面具体代码如下:
    • 单独的html文件写highcharts

Highcharts 写 venn图 鼠标悬浮效果以及点击事件

效果图如下:

参考highcharts官网venn

具体方法

安装包依赖:npm install highcharts

//组件中引入
import Highcharts from 'highcharts';
// import exportingInit from 'highcharts/modules/exporting';
// exportingInit(Highcharts)
// import stockInit from 'highcharts/modules/stock'
// stockInit(Highcharts)
// 这里的venn.js放到mian.js中去引用
// import venn from 'highcharts/modules/venn'
// venn(HighCharts);

只在上面引入会报错

在main.js中引入venn.js(解决报错)

// 引入hightcharts
import Highchart from "highcharts/highcharts";
// 引入hightcharts中的venn模块(否则韦恩图出不来)
import venn from 'highcharts/modules/venn'
venn(Highchart);

下面具体代码如下:

html代码:这里两个图

      <div id="container"></div><div id="container2"></div>
 Highcharts.chart('container2', {series: [{type: 'venn',name: 'Highcharts Venn',data: [{sets: ['Good'],value: 2}, {sets: ['Fast'],value: 2}, {sets: ['Cheap'],value: 2}, {sets: ['Good', 'Fast'],value: 1,name: 'More expensive'}, {sets: ['Good', 'Cheap'],value: 1,name: 'Will take time to deliver'}, {sets: ['Fast', 'Cheap'],value: 1,name: 'Not the best quality'}, {sets: ['Fast', 'Cheap', 'Good'],value: 1,name: 'They\'re dreaming'}]}],title: {text: 'The Unattainable Triangle'}});var datas = [{sets: ['A'],value: 3,other: '123sfdfzsdfsdf3',}, {sets: ['B'],value: 2,other: '1233',}, {sets: ['C'],value: 4,}, {sets: ['d'],value: 4,}, {sets: ['A', 'B'],value: 1,name: 'A∩B',}, {sets: ['d', 'B'],value: 1,name: 'd∩B',// other:'666',}, {sets: ['A', 'C'],value: 1,name: 'A∩C',}, {sets: ['B', 'C'],value: 1,name: 'B∩C',}, {sets: ['A', 'B', 'C'],value: 1,name: 'A∩B∩C',}];Highcharts.chart('container', {series: [{type: 'venn',data: datas,cursor: 'pointer',showInLegend: false,dataLabels: {enabled: true,align: 'center',style: {color: "black",fontSize: "14px",fontWeight: "bold", //nomaltextOutline: "0px 0px contrast",fontFamily: 'Microsoft YaHei',}},events: {//单击事件click: function (e) {console.log(e.point.name + ":" + e.point.value);alert('点我干啥?就不告诉你:' + e.point.name + ":" + e.point.value)// location.href = "http://www.baidu.com";},}}],title: {text: '韦恩图(Veen)'},subtitle: {text: 'Highcharts Venn',align: 'center',style: {}},tooltip: {backgroundColor: 'rgba(82,82,82,0.8)',borderColor: '#525252',         // 边框颜色borderRadius: 10,             // 边框圆角borderWidth: 0,               // 边框宽度shadow: false,                 // 是否显示阴影animation: true,               // 是否启用动画效果headerFormat: '',pointFormat: `<span style="color:{point.color};font-size:14px;font-family:Microsoft YaHei">\u25CF{point.name}</span><br/><br/><span style="color:white;font-size:14px;font-family:Microsoft YaHei">数量: {point.value}</span><br/><span style="color:white;font-size:14px;font-family:Microsoft YaHei">其他:{point.other}</span><br/>`// +'占比: <b style="font-size: 14px,color:#eee">{point.percentage:.2f}%</b><br/>'}});

单独的html文件写highcharts

<!DOCTYPE html>
<html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv="x-ua-compatible" content="ie=edge"><title></title><!-- 注意引种js,以及顺序 --><script src="js/highcharts.js"></script><script src="js/oldie.js"></script><script src="js/venn.js"></script><script src="js/grid-light.js"></script><script src="js/drilldown.js"></script></head><body><div id="container"></div><script>var datas = [{sets: ['A'],value: 3,other: '123sfdfzsdfsdf3',}, {sets: ['B'],value: 2,other: '1233',}, {sets: ['C'],value: 4,}, {sets: ['d'],value: 4,}, {sets: ['A', 'B'],value: 1,name: 'A∩B',}, {sets: ['d', 'B'],value: 1,name: 'd∩B',}, {sets: ['A', 'C'],value: 1,name: 'A∩C',}, {sets: ['B', 'C'],value: 1,name: 'B∩C',}, {sets: ['A', 'B', 'C'],value: 1,name: 'A∩B∩C',}];Highcharts.chart('container', {series: [{type: 'venn',data: datas,cursor: 'pointer',showInLegend: false,dataLabels: {enabled: true,align: 'center',style: {color: "black",fontSize: "14px",fontWeight: "bold", //nomaltextOutline: "0px 0px contrast",fontFamily: 'Microsoft YaHei',}},events: {//单击事件click: function (e) {console.log(e.point.name + ":" + e.point.value);//链接到新页面//window.open('http://www.baidu.com','_self','width=200,height=100');// location.href = "http://www.baidu.com";},}}],title: {text: '韦恩图(Veen)'},subtitle: {text: '数据来源:个人编造',align: 'center',style: {}},tooltip: {backgroundColor: 'rgba(82,82,82,0.8)',borderColor: '#525252',         // 边框颜色borderRadius: 10,             // 边框圆角borderWidth: 0,               // 边框宽度shadow: false,                 // 是否显示阴影animation: true,               // 是否启用动画效果headerFormat: '',pointFormat: `<span style="color:{point.color};font-size:14px;font-family:Microsoft YaHei">\u25CF{point.name}<br/></span><span style="color:white;font-size:14px;font-family:Microsoft YaHei">数量: {point.value}<br/></span><br/><span style="color:white;font-size:14px;font-family:Microsoft YaHei">其他:{point.other}</span><br/>`// +'占比: <b style="font-size: 14px,color:#eee">{point.percentage:.2f}%</b><br/>'}});</script></body></html>

Highcharts 写 venn图 (韦恩图),以及解决项目中venn的报错相关推荐

  1. Eclipse和MyEclipse使用技巧--解决MyEclipse中的js报错的小方法

    今天,下了个模版,但是导进去的时候发现js会报错.看了下其他都没有错误.而有一个js报错误,请原谅我有点红色强迫症,不能留一点红色 . 错误如下: Syntax error on token &quo ...

  2. 解决 vscode中pylint抽风报错问题

    解决 vscode中pylint抽风报错问题 问题原因 主要是pylint再vs中的配置不太对,找不到相关的库,就算一个project中的文件也找不到 如何配置? 链接: 原文链接. 首先点击 文件- ...

  3. 解决maven项目中-Dmaven.multiModuleProjectDirectory报错问题

    maven项目中,在run as  执行maven命令的时候,报错: -Dmaven.multiModuleProjectDirectory system property is not set. C ...

  4. 解决pycharm中画图工具报错无法显示问题

    当我把我的pycharm和anaconda重装了过后,重新配置环境,发现了以前使用import matplotlib.pyplot as plt,画图工具,画不出来,并且还发生了上图的报错,查阅资料发 ...

  5. vue项目中的一些报错解决方法

    1.mixed spaces and tabs no-mixed-spaces-and-tabs 禁止使用空格和tab混合缩进:大多数代码约定要求使用空格或 tab 进行缩进.因此,一行代码同时混有 ...

  6. 【解决python中使用pillow报错】PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问

    项目场景 import os from PIL import Image img = Image.open('test.png') w, h = img.size if w > h:os.rem ...

  7. 一步解决word中ctrl-v粘贴报错问题

    问题:运行时错误'53':文件未找到:MathPage.WLL 这里只针对MathType引起的加载项冲突原因. 首先关闭word 打开MathType所在文件夹 右击MathType图标->点 ...

  8. 解决项目莫名奇妙的报错问题

    1.将项目clean一下: 2.重新build path配置一下jar包: 3.重新配置source下的内容 4.重新配置一下Libraries下的jar包: 5.如果jre报错重新配置方式如下: 6 ...

  9. Web项目:解决eclipse中jsp文件报错javax.servlet.http.HttpServlet 提示 was not found on the Java Build Path的错误

    具体错误如图示如下: 具体结局方案如下: 1.右击web工程(你的项目名字)->属性或Build Path->Java Build Path->Libraries-> Add ...

最新文章

  1. 腾讯:将收购Riot Games多数股权
  2. ABAP performance学习笔记
  3. ios使用支付宝进行支付,注意事项 集成支付宝钱包支付iOS SDK的方法与经验。...
  4. rstudio运行python_RStudio 1.2发布,改进对Python chunks,R脚本等的测试和支持
  5. 解决MacOS升级后出现xcrun: error: invalid active developer path, missing xcrun的问题
  6. 移动滚动条显示或隐藏元素事件
  7. 国庆蓝牙耳机最强选购攻略,2020不容错过的精品蓝牙耳机
  8. 如何编写大数据分析师简历
  9. java镜像劫持_解析映像劫持技术第1/3页
  10. 深入理解GBDT回归算法
  11. 重心解模糊化matlab,谁能给我个用重心法的MATLAB模糊推理程序
  12. 一种基于A* 算法的动态多路径规划算法
  13. 怎么做ssl证书配置?
  14. python和scre_python学习日志10
  15. 乱花渐欲迷人眼:浅谈关于分布式存储的五大 “谎言”
  16. 机器人门禁控制盒怎么接线方法_门禁系统接线方法
  17. 2009-2010年中国十大平面设计公司排名
  18. 加入美人联盟,一起创造App增长新生态
  19. 电脑输入英文字母间距太大
  20. 台湾屏东大学校徽设计被指抄袭 校方:征选过程严谨

热门文章

  1. 安卓4.4和6.0系统wifi开关设置
  2. Dual Illumination Estimation for Robust Exposure Correction阅读札记
  3. 前端之jQuery框架/全面教程/一小时速成/常用点整合 【附代码、前端必备之一】
  4. PostgreSQL服务端监听设置
  5. 超实用!轻松几步修复灰蒙蒙的情侣合照!
  6. linux从源码编译cairo,如何在windows下编译cairo
  7. 微信分享给朋友 图片显示正常,但是分享到朋友圈图片黑色【显示不出来】
  8. android蓝牙浅析
  9. svn的客户端从安装到运行
  10. C++排雷:19.过滤英文和中文标点符号,string与wstring之间的转换