感觉好久没有更新博客了,最近一直忙着毕业论文,紧接着就开始搭建数据库,实在抽不出时间写。

正好趁着做数据库,写一写关于Highchart里两个饼图之间的互动。

用到的数据比较大,我也懒得修饰了,涉及到两个pie图的div,分别是 pie_container 和 signature_container

先说明一下画 signature_container  时为了和  pie_container 互动,定义了一个函数,画图的数据利用 ajax 读取:

function signature_pie(cancer_type){
var data_arr = [
{name: "gene", y: 0.4},
{name: "protein", y: 0.2},
{name: "lncRNA", y: 0.1},
{name: "miRNA", y: 0.1},
{name: "mutation", y: 0.1},
{name: "methylation", y: 0.1}
];
var options = {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie',
},
title: {
text: 'signature type statistics',
style:{
fontSize: "20px"
},
y: 10,
x:-5
},
tooltip: {
pointFormat: 'Cohort precentage: <b>{point.percentage:.1f}%</b>'
},
credits: {
enabled: false
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
events: {
click: function(event){
var signature_type = event.point.name;
document.getElementById("choose_signature_type").innerHTML = "<b>" + signature_type + "</b>";
}
},
dataLabels: {
enabled: false,
color: "black",
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
}
}
},
series: [{
names: 'signature stat',
data: data_arr
}]
};
if(cancer_type == "ALL"){
Highcharts.chart('signature_container', options);
} else {
$.ajax({
url: '../data/test.txt',
dataType: 'text',
type: 'GET',
async: false,
success: function(data) {
var lines = data.split('\n');
for(var index = 1; index < (lines.length - 1); index++){
var info = lines[index].split('\t');
if(info[0] == cancer_type){
for(var i = 1; i < (info.length-1); i++){
options.series[0].data[i-1].y = parseFloat(info[i]);
}
Highcharts.chart('signature_container', options);
break;
}
}
}
});
}
}

  

下面是 pie_container 的 options:

var options = {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie',
},
title: {
text: 'cancer type statistics',
style:{
fontSize: "20px"
},
y: 10,
x:-5
},
tooltip: {
pointFormat: 'Type is <b>{point.type}<b><br/>Cohort precentage: <b>{point.percentage:.1f}%</b>'
},
credits: {
enabled: false
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
events: {
click: function(event){
var cancer_type = event.point.name;
document.getElementById("choose_cancer_type").innerHTML = "<b>" + cancer_type + "</b>";
         //利用signature_pie()函数,根据对应数据重新画一个pie图
javascript:signature_pie(cancer_type);
var index = event.point.index;
options.series[0].data[index]['selected'] = 'true';
options.series[0].data[index]['sliced'] = 'true';
Highcharts.chart('pie_container', options);
options.series[0].data[index]['selected'] = '';
options.series[0].data[index]['sliced'] = '';
}
},
dataLabels: {
enabled: false,
color: "black",
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
}
}
},
series: [{
names: 'cancer stat',
data: [
{name: 'ACC', y: 0.00602188825469969, type: 'A'},
{name: 'BLCA', y: 0.0293239775881028, type: 'A'},
{name: 'BRCA', y: 0.0532544378698225, type: 'B'},
{name: 'CESC', y: 0.011520134052469, type: 'B'},
{name: 'CHOL', y: 0.00314185474158245, type: 'B'},
{name: 'COADREAD', y: 0.0395873697439388, type: 'A'},
{name: 'COAD', y: 0.029585798816568, type: 'D'},
{name: 'DLBC', y: 0.00382258993559198, type: 'D'},
{name: 'ESCA', y: 0.0112059485783107, type: 'D'},
{name: 'GBMLGG', y: 0.0756663350264439, type: 'C'},
{name: 'GBM', y: 0.0327800178038435, type: 'C'},
{name: 'HNSC', y: 0.0432005026967587, type: 'A'},
{name: 'KICH', y: 0.00837827931088653, type: 'B'},
{name: 'KIPAN', y: 0.0774990836257004, type: 'D'},
{name: 'KIRC', y: 0.0473896423522019, type: 'C'},
{name: 'KIRP', y: 0.0251348379326596, type: 'A'},
{name: 'LAML', y: 0.0116772267895481, type: 'A'},
{name: 'LGG', y: 0.0444048803476986, type: 'C'},
{name: 'LIHC', y: 0.0315232759072106, type: 'B'},
{name: 'LUAD', y: 0.0424674032570561, type: 'C'},
{name: 'LUSC', y: 0.0116248625438551, type: 'C'},
{name: 'OV', y: 0.043671780907996, type: 'A'},
{name: 'PAAD', y: 0.0190082211865738, type: 'D'},
{name: 'PCPG', y: 0.0109441273498455, type: 'D'},
{name: 'PRAD', y: 0.0450332512960151, type: 'D'},
{name: 'READ', y: 0.0123055977378646, type: 'A'},
{name: 'SARC', y: 0.0142430748285071, type: 'C'},
{name: 'SKCM', y: 0.0388542703042363, type: 'B'},
{name: 'STAD', y: 0.0378069853903754, type: 'A'},
{name: 'STES', y: 0.047494370843588, type: 'D'},
{name: 'TGCT', y: 0.00942556422474734, type: 'C'},
{name: 'THCA', y: 0.0492747551971514, type: 'A'},
{name: 'THYM', y: 0.00774990836257004, type: 'B'},
{name: 'UCEC', y: 0.0151332670052888, type: 'D'},
{name: 'UCS', y: 0.00429386814682934, type: 'A'},
{name: 'UVM', y: 0.00555061004346232, type: 'C'},
]
}]
}

  

Highchart 饼图联动的更多相关文章

  1. 帆软报表(finereport) 饼图联动

    饼图联动:点击饼图1,饼图2和饼图3显示饼图1的关联数据,接着点击饼图2,饼图3显示饼图2的关联数据,点击上方清除级联,饼图则恢复默认展示状态 下面以上图示例效果为例,说明制作过程. 1.为每个饼图准 ...

  2. echarts 地图的背景色和各省颜色配置以及地图饼图联动

    myChart.on(ecConfig.EVENT.MAP_SELECTED, function (param) { var selected = param.selected; var str = ...

  3. Html的Table与Echart的饼图实现联动效果

    功能描述: 单击Table中的某个单元格,Echart的饼图加载相关的数据,鼠标悬停在Echarts饼图中的某一块中,Table显示与Echarts饼图相关的数据. 例:楼宇经济概要显示每一个季度所有 ...

  4. HighChart报表之饼图

    个人认为HighChart做报表还是很不错的,从报表的样式还是性能都是很不错的选择. 1.新建一个html页面,命名为:ReportTest.html <script type="te ...

  5. 进一步封装highchart,打造自己的图表插件:jHighChart.js

    Highcharts 是一个用纯JavaScript编写的一个图表库, 能够很简单便捷的在web网站或是web应用程序添加有交互性的图表.支持的图表类型有曲线图.区域图.柱状图.饼状图.散状点图和综合 ...

  6. 百度推出的echarts,制表折线图柱状图饼图等的超级工具(转)

    一.简介: 1.绘制数据图表,有了它,想要网页上绘制个折线图.柱状图,从此easy. 2.使用这个百度的echarts.js插件,是通过把图片绘制在canvas上在显示在页面上. 官网对echarts ...

  7. highchart.js的使用

    highchart.js是一个很实用的图表插件,涵盖柱状图.曲线图,区域图.3D图.饼图.散列图.混合图等等,功能很强大. 首先去官网下载最新版highchart.js插件,中文网地址:http:// ...

  8. 【highchart】经典问题

    摘要 记录遇到的一些问题和解决方案 时差 数据容量 多表联动 1. 时差 问题描述 highcharts 默认是标准 UTC 时间,而国内默认是东八区时间,所以会有8个小时的时差 解决方法 使用hig ...

  9. Echarts数据可视化series-pie饼图,开发全解+完美注释

    全栈工程师开发手册 (作者:栾鹏) Echarts数据可视化开发代码注释全解 Echarts数据可视化开发参数配置全解 6大公共组件详解(点击进入): title详解. tooltip详解.toolb ...

随机推荐

  1. Grunt 使用(一)基础搭建

    jQuery在使用grunt,bootstrap在使用grunt,百度UEditor在使用grunt,你没有理由不学.不用!废话不多说,直接上干货. 1.安装node.js并检查node -v 和 n ...

  2. Oracle基础操作

    数据库的定义.作用介绍: 什么是数据库? 按照数据结构来组织.存储和管理数据的建立在计算机存储设备上的仓库. 数据库的发展史: 起始于1962年,1968年在IBM出现 数据库在测试过程中的作用: 需 ...

  3. [原]SDL开发教程

    SDL开发库:http://www.libsdl.org/ SDL中文开发教程:http://tjumyk.github.io/sdl-tutorial-cn/index.html SDL英文版开发教 ...

  4. 元素设置float属性后,其后面的元素的位置问题

    分两种情况: .content{ width:350px; height:150px; color:#fff; } .content1,.content2{ background-color: #00 ...

  5. JQuery的异步回调支持 - Promise、Deferred

    1.Deferred对象: 一般在函数内部进行声明,并在运行过程中改变其状态,例如成功或失败,最终返回Promise对象用于状态监听. 主要方法: Deferred.resolve(param...) ...

  6. 【[CQOI2014]数三角形】

    lx让做的题,其实很简单,难度评到紫令人吃惊 首先读进来\(n,m\)先\(++\),之后就是一个格点数为\(n*m\)的矩阵了 我们直接求很那做,补集转化一下,我们容斥来做 首先所有的情况自然是\( ...

  7. CSS布局方面的一些小总结

    1. display属性 display是CSS布局的第一站,它控制一个元素以什么“身份”出现在页面布局当中.它的值有很多个,常用的有block,inline,inline-block,table,n ...

  8. java之静态方法,静态变量

    在自动化测试中,经常会用到静态方法和静态变量.那么什么是静态方法和静态变量呢?以及在什么情况下使用呢?下面来说一说 静态方法和静态变量是使用公共内存空间的,就是说所有对象都可以直接引用,不需要创建对象 ...

  9. 对于dequeueReusableCellWithIdentifier:的理解

      Table Data Source Methods中的一个必要实现的方法tableView: cellForRowAtIndexPath: 中经常会包含一段代码: static NSString  ...

  10. win7下添加库文件出现“file is not regcognized”问题

    最近几天需要画电路图,所以安装了protel se99,安装后在添加库文件的时候出现“file is not regcognized”的问题 百度查了一下,说win7基本上都会出现这个问题. 实际上, ...