Is there a way to select the parent div without knowing its name or class id?
I have a graph that I made in the d3 javascript library. Its size depends on the size of the window:
var GUIWidth = window.innerWidth;
var GUIHeight = window.innerHeight;
This works great, but what if I want to put this graph on a different page, but make it smaller? I don't want to go into here and customize it, I want the container to be resized and use that width and height.
But in my case, I don't know the ID of the container (because another person is developing the UI).
How do I get the id (and width and height desired) of the parent div that stores my graph.
Here's some sample code:
var svg = d3.select("#interface") //this is my graphs container
.append("div")
.attr("id", "svgContainer")
.attr("width", GUIWidth)
.attr("height", GUIHeight);
Here interface
is the container for my plots, but I want to do something like this to get the width and height:
var GUIWidth = $(parentOf('#interface')).innerWidth();
var GUIHeight = $(parentOf('#interface')).innerHeight();
Is it possible?
I would also like to stick with javascript / jquery for this, since I'm using variables GUIWidth
and GUIHeight
elsewhere in my code to determine the size of other divs :)
Thankyou
source to share