Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created June 20, 2012 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/2958242 to your computer and use it in GitHub Desktop.
Save mrchrisadams/2958242 to your computer and use it in GitHub Desktop.
A reformatted gist of the "Potential solution to bar chart values" post for flot
// initially from this code, just reformatted
// https://groups.google.com/forum/?fromgroups#!searchin/flot-graphs/bar$20chart/flot-graphs/T0jFBEGozXU/rHk1sCNc-VgJ
// plotted the graph
var graph = $.plot($(css_id), data, options);
//get x pos of graph
var graphx = $("#coding_graph").offset().left;
//get y pos of graph
var graphy = $("#coding_graph").offset().top;
//set up a variable to use in getting data from array
var h = -1;
$("#coding_graph .tickLabels .xAxis .tickLabel").each(function() {
// increase that so goes 0,1,2,3 etc
h++;
//so y pos of graph to number of decimal places plus y of tick label minus a number to get it to line up
var posy = (((graphy.toFixed(0) * 1)) + ($(this).css('top').replace("px", "") * 1) - 110);
// so x pos of graph to number of decimal places plus x of tick label
// then another function to get the values to fit in the bars (could use bar: width: option here)
var posx = (($(this).css('left').replace("px", "") * 1) + (graphx.toFixed(0) * 1) + (h * 15) + 15);
// normal showTooltip function from the interactive flot example
showTooltip(posx, posy, data[0].data[h][1]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment