0

I am working on a project. It is a dashboard based on d3.js.

The following problem occurs:

There is the main site (index.html) that contains the navigation menu. I use various dashboards which are inserted into index.html via "object tag".

I looks like this:

<div id="sales1">   

    <div id="right">

    <object id="dashboard1" style="width:900px; height:600px; type="text/html" data="dashboard.html">
    </object>
    </div>

</div>

Within the dashboard-file (dashboard.html) it is possible to change the datasets (parsed csv) via button:

  <!-- here are the buttons to control the two csv data sets -->
  <button id="d1">Data 1 (should be units FTP 2018)</button>
  <button id="d2">Data 2 (should be units FTP 2019)</button>

<!-- The event listeners for buttons -->  
 <script>
    // here are the event listeners to control the buttons
    d3.select("#d1").on("click", function(d, i) {
      data1();
    });
    d3.select("#d2").on("click", function(d, i) {
      data2();
    });

</script>

Since I want to control this from the navigation menu on the main site (index.html), there must be a way to place buttons and event listeners to the index.html and change datasets within the dashboard from the navigation menu.

So the index.html should look something like this:

Buttons
to change datasets within dashboard.html
  <button id="d1">Data 1 (should be units FTP 2018)</button>
  <button id="d2">Data 2 (should be units FTP 2019)</button>

Event listeners
to change datasets within dashboard-file(dashboard.html, embedded through object tag) 
<script>

?????

</script>

    <div id="sales1">   

        <div id="right">

        <object id="dashboard1" style="width:900px; height:600px; type="text/html" data="dashboard.html">
        </object>
        </div>

    </div>

I uploaded the whole code here:

The main site (index.html): https://codepen.io/robx360/pen/wbpoQM Dashboard (dashboard.html): https://codepen.io/robx360/pen/pmpNWN

In the end, there will be various dashboards. By clicking on data 2019, datasets inside the dashboards switch the dataset to 2019 instead of 2018.

2
  • I don't know if object is suitable for communicating with its external context. In a recent project we wanted to have decoupled navigation and modules; we ended up using iframe inside the navigation page and utilized window messages to bidirectionally interact with the loaded module. Have a look at gist.github.com/pbojinov/8965299 Commented Jun 20, 2019 at 16:40
  • I should be possible: There´s another question asking somethin similar: stackoverflow.com/questions/10665108/… Commented Jun 24, 2019 at 8:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.