Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Essai Flot tooltip&lt;/title&gt; &lt;!--[if lte IE 8]&gt;&lt;script language="javascript" type="text/javascript" src="flot/excanvas.min.js"&gt;&lt;/script&gt;&lt;![endif]--&gt; &lt;script type="text/javascript" src="js/jquery-1.5.2.min.js"&gt;&lt;/script&gt; &lt;script src="flot/jquery.flot.min.js" type="text/javascript" language="javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Essai Flot tooltip&lt;/h1&gt; &lt;div id="placeholder" style="width:800px;height:300px"&gt;&lt;/div&gt; &lt;script id="source" language="javascript" type="text/javascript"&gt; $(function () { var data = [ { label: [["Birth Pierre MARTIN (1756)"], ["Marriage Pierre MARTIN (1781)"], ["Death Pierre MARTIN (1812)"]], data: [[1756, 20.0], [1781, 20.0], [1812, 20.0]] }, { label: [["Birth Marie DUPONT (1761)"], ["Marriage Marie DUPONT (1781)"], ["Death Marie DUPONT (1833)"]], data: [[1761, 19.0], [1781, 19.0], [1833, 19.0]] }, { label: [["Birth Charles MARTIN (1782)"], ["Marriage Charles MARTIN (1810)"], ["Death Charles MARTIN (1855)"]], data: [[1782, 18.0], [1810, 18.0], [1855, 18.0]] }, { label: [["Birth Catherine MARTIN (1790)"], ["Marriage Catherine MARTIN (1810)"], ["Death Catherine MARTIN (1868)"]], data: [[1790, 17.0], [1810, 17.0], [1868, 17.0]] }, { label: [["Birth Louis MARTIN (1813)"], ["Death Louis MARTIN (1876)"]], label: "Louis MARTIN (1813-1876)", data: [[1813, 16.0], [1876, 16.0]] } ]; var options = { series: { lines: { show: true, lineWidth: 5}, points: { show: true, radius: 4 } }, legend: { show: false }, xaxis: { min:1745, max:1885, tickDecimals: 0, ticks: [[1750, "1750"], [1760, "1760"], [1770, "1770"], [1780, "1780"], [1790, "1790"], [1800, "1800"], [1810, "1810"], [1820, "1820"], [1830, "1830"], [1840, "1840"], [1850, "1850"], [1860, "1860"], [1870, "1870"], [1880, "1880"]] }, yaxis: { show: true, color:null, min:14, max:22, ticks: [[20, "&lt;strong&gt;Pierre MARTIN&lt;/strong&gt; (1756-1812)"], [19, "&lt;strong&gt;Marie DUPONT&lt;/strong&gt; (1761-1833)"], [18, "&lt;strong&gt;Charles MARTIN&lt;/strong&gt; (1782-1855)"], [17, "&lt;strong&gt;Catherine MARTIN&lt;/strong&gt; (1790-1868)"], [16, "&lt;strong&gt;Louis MARTIN&lt;/strong&gt; (1813-1876)"]] }, selection: { mode: "x" }, grid: { borderWidth: 2, clickable: true, hoverable: true, autoHighlight: true } }; var placeholder = $("#placeholder"); placeholder.bind("plotselected", function (event, ranges) { $("#selection").text(ranges.xaxis.from.toFixed(1) + " to " + ranges.xaxis.to.toFixed(1)); var zoom = $("#zoom").attr("checked"); if (zoom) plot = $.plot(placeholder, data, $.extend(true, {}, options, { xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to } })); }); placeholder.bind("plotunselected", function (event) { $("#selection").text(""); }); var plot = $.plot(placeholder, data, options); $("#clearSelection").click(function () { plot.clearSelection(); }); function showTooltip(x, y, contents) { $('&lt;div id="tooltip"&gt;' + contents + '&lt;/div&gt;').css( { position: 'absolute', display: 'none', top: y + 5, left: x + 5, border: '1px solid #fdd', padding: '2px', 'background-color': '#eef', opacity: 0.80 }).appendTo("body").fadeIn(20); } var previousPoint = null; $("#placeholder").bind("plothover", function (event, pos, item) { $("#x").text(pos.x.toFixed(2)); $("#y").text(pos.y.toFixed(2)); if (item) { if (previousPoint != item.datapoint) { previousPoint = item.datapoint; $("#tooltip").remove(); console.log(item); var x = item.datapoint[0].toFixed(2), y = item.datapoint[1].toFixed(2); showTooltip(item.pageX, item.pageY, item.series.label[item.dataIndex]); } } else { $("#tooltip").remove(); previousPoint = null; } }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Notice that I changed this:</p> <pre><code>showTooltip(item.pageX, item.pageY, item.series.label); </code></pre> <p>For this: </p> <pre><code>showTooltip(item.pageX, item.pageY, item.series.label[item.dataIndex]); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload