1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| var data = [[22,25],[23,1],[0,24],[1,16],[2,8],[3,11],[4,11],[5,9],[6,5],[7,8],[8,16],[9,6],[10,22],[11,9],[12,6],[13,4],[14,11],[15,13],[16,10],[17,6],[18,8],[19,4],[20,1],[21,3]];
var dataset = [{data: data,color: '#409628',label:'Chromosomes',bars: {show: true, align:'center', barWidth:0.6}} ];
var ticks = [[22,"X"],[23,"Y"],[0,"1"],[1,"2"],[2,"3"],[3,"4"],[4,"5"],[5,"6"],[6,"7"],[7,"8"],[8,"9"],[9,"10"],[10,"11"],[11,"12"],[12,"13"],[13,"14"],[14,"15"],[15,"16"],[16,"17"],[17,"18"],[18,"19"],[19,"20"],[20,"21"],[21,"22"]];
var options = {xaxis: { ticks:ticks},
grid: {hoverable: true}
};
$.plot($("#Chromosome_all"), dataset, options);
$("#Chromosome_all").bind("plothover", Chromosome_all_hover);
$("#Chromosome_all").parent().children(":first").append(" (237)");
function Chromosome_all_hover (event, pos, obj){
// Handles the hover label generation and fade.
if (!obj) {
// Although obj seems to be NULL also half of the time while hovering the pie, this if() is only activated when you're moving outside of the pie.
$("#Chromosome_all_hover").fadeOut(1000);
return;
}
//creer une var contenant la valeur des donnees
theone = obj.series.data[obj.dataIndex][1];
//calculer le pourcentage
percent =parseFloat(theone).percent;
//mettre le tout dans ma variable message qui sera affiche
sMessage = theone + "/237 (" + percent + " %)";
$("#Chromosome_all_hover").stop(true, true); // Completes possible fading animation immediately and empties queue.
$("#Chromosome_all_hover").show(); // Shows the div, that may have been hidden.
$("#Chromosome_all_hover").html("<B>" + obj.series.xaxis.ticks[obj.dataIndex].label +": " + sMessage + "</B>");
}; |
Partager