使用Highchart.jshighcharts add plotline label with images
是否可以将图像添加到情节标签?东西如下图所示
我想用一个工具提示一起加入这个(我)的图像,但似乎(从here),其可用于该元素的组有限的HTML不支持图像,申报单或标题。
我已经想到,将图像和工具提示添加到独立的div(从图表)中,找到标签的位置并使用绝对定位添加此图层会更容易。但是我不能给这个元素添加任何id或者什么,所以我找不到它的位置。
有人有类似的问题?
我的解决方案:
CSS
.infoMedia {
position: absolute;
z-index : 10000;
width: 30px;
height: 30px;
background: url('../img/information.png') center no-repeat;
}
HTML
<div class='infoMedia' style='left:0px;top:0px;'></div>
的JavaScript
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);
}
你能可能告诉我你如何添加一个标签,你的情节主线?谢谢! – AustinT
当用户滚动或更新位置时,我最终将独立于图形的图标与绝对定位一起放置在逻辑上。 – jose
你是如何计算图像位置的?你能在这里发布你的最终解决方案吗? – Guian