Note that there are some explanatory texts on larger screens.

plurals
  1. POhighcharts add plotline label with images
    primarykey
    data
    text
    <p>Using Highchart.js</p> <p>is it possible to add an image to a plotline label? Something as shown below</p> <p><img src="https://i.stack.imgur.com/AOKAB.png" alt="enter image description here"></p> <p>I want to add this (i) image along with a tooltip, but it seems (from <a href="http://api.highcharts.com/highcharts#yAxis.plotLines.label.text" rel="nofollow noreferrer">here</a>) that the limited set of html available for this elements does not support images, divs, or titles. </p> <p>I've figured that it would be easier to add this image and tooltip on a separated div (from graph), find the position of the label and use absolute positioning to add this layer. But I can't add any id or something to this element, so I can't find its position.</p> <p>Has someone had similar issues?</p> <p><strong>My Solution:</strong></p> <p><strong>CSS</strong></p> <pre><code>.infoMedia { position: absolute; z-index : 10000; width: 30px; height: 30px; background: url('../img/information.png') center no-repeat; } </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;div class='infoMedia' style='left:0px;top:0px;'&gt;&lt;/div&gt; </code></pre> <p><strong>javascript</strong></p> <pre><code>function processHintPosition() // every resize, call this function { $('.infoMediaENEM').css('top', 0); $('.infoMedia').css('left', 0); var this_container = $('#container_line_graph'); var this_container_width = $(this_container).width(); var this_container_height = $(this_container).height(); var this_margin_y = 60; var this_margin_x = 15; $('.infoMedia').css('top', $(this_container).offset().top + $(this_container).height() - this_margin_y); // POSITION X var x_val = $(this_container).offset().left + this_container_width - this_margin_x; $('.infoMedia').css('left', x_val) // POSITION Y var this_media = parseFloat(lineGraph.linechart_data.prcMedia); var this_max = 100; var this_val_posy = Math.ceil( ( this_media * (this_container_height - this_margin_y) ) / this_max ); var y_val = (($('.infoMedia').offset().top) - this_val_posy) - ($('.infoMedia').height()/2); $('.infoMedia').css('top', y_val); } </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.
 

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