Here's a solution I quickly put together using jQuery. It can easily be modified to use Vanilla Javascript, but for the sake of writing it quickly I've resorted to a framework.
It basically consists of a <div>
that is relatively positioned, with anchors as plots that are absolutely positioned. This allows us to use coordinates to position the plots anywhere we like within the relative <div>
.
You can create a few icons that will represent different plots on the graph and assign those to the anchor elements.
To make things nice and easy I've used a JSON object to store each plot so you can use it from a 3rd party source.
// change this to fit your needs
var plots = [
{"width":30,"height":30, "top": 150, "left": 100, "content": "Lorem"},
{"width":20,"height":20, "top": 100, "left": 20, "content": "Ipsum"},
{"width":50,"height":50, "top": 20, "left": 20, "content": "Dolor"}
];
// store our 2 divs in variables
var $content = $("#content");
var $map= $("#map");
// Iterate through each plot
$.each(plots, function() {
// store 'this' in a variable (mainly because we need to use it inside hover)
var plot = this;
// create a new anchor and set CSS properties to JSON values
var $plot = $("<a />")
.css({
'width': plot.width,
'height': plot.height,
'top': plot.top,
'left': plot.left
})
.hover(function() {
// replace content of target div
$content.html(plot.content);
});
// Add the plot to the placeholder
$map.append($plot);
});
I hope I've written it in an easy-to-understand way :)
Note that all of the above can be achieved using just HTML/CSS, just inspect the source to see what exactly gets created.
Here's a demo