Building Vertical Tabs with external JS for loading custom visuals

I am trying to figure out how to display the visuals I created in an alternate page within my Vertical tabs. The tabs are already styled, and I have omitted the CSS due to its length. The HTML file I am working with is test.html, and the visuals are in the alternate file App.js. Despite testing to confirm that the visuals work, nothing shows up when I click on the tab. It's as if clicking a button with no action attached. No changes occur on the screen.

How can I integrate the visuals into the tabs to make them visible?

Code snippet of test.html Page(CSS link excluded for brevity):

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  </head>
  <body ng-App="App">
    <div id="container" style="padding-top: 20px" ng-controller="AppController">
    <div id="tab">
       <button class="tablink" onclick="show1()">Visual 1</button>
    </div>

    <div id="visual1" ng-show"display1">
       <script type="text/javascript" src="App.js"></script>
       <div id="testdash">
         <div id="filter1"></div>
         <div id="chart1"></div>
       </div>
    </div>
</body>
</html>

App.js file:

var app = angular.module('App',);
 app.controller('AppController', function($scope, $http, $ace) {
       $scope.show1 = function() {
        if ($scope.display1 == false) {
            getCurrVis1();
            $scope.display1 = true;   }
        else {
            $scope.display1 = false;  }     
        }

    function getCurrVis1() { 
            var req = { method: 'POST',
                        url: "test.tsv" 
            }
            $http(req).success(function(js) {
                var data = js;
                drawChart1(data); 
            })
    }

    function drawChart1(data) {
        //creates data table
        var table = new google.visualization.DataTable();
        var data = data;
        console.log(data);
        var dataRows = data.split("\n");
        var headers = dataRows[0].split('\t');
        table.addColumn('string', headers[0]); 
        table.addColumn('number', headers[1]);
        table.addColumn('string', headers[2]);
        var rs = [];

        for (var x=1; x<(dataRows.length); x++) {
            var cols = dataRows[x].split('\t');
            var row = [];
            row.push(cols[0]);           
            row.push(parseInt(cols[1]));
            row.push(cols[2]);
            rs.push(row);
        }

        table.addRows(rs);

        // Create a dashboard to bind a filter to the chart
        var dashboard = new google.visualization.Dashboard(document.getElementById('testdash'));

        var filter1 = new google.visualization.ControlWrapper({
            'controlType': 'CategoryFilter',
            'containerId': 'filter1',
            'options': {
                'filterColumnIndex': 0,
                'ui': { 
                    'label': 'Filter:',
                    'selectedValuesLayout': 'belowStacked',
                    'allowTyping': false,
                    'allowMultiple':true,}
            }
        });

        //Sets chart, and chart options
        var chart = new google.visualization.ChartWrapper({
                    'chartType': 'PieChart',
                    'containerId': 'chart1',
                    'options': { 'left': '25%',
                        'height': '80%',
                        'width': '80%' ,
                        'width':800,
                        'height':600,
                        'pieSliceText': 'value'},
                    'view': { 'columns': [0,1]}
        });

        dashboard.bind(filter1, chart);
        dashboard.draw(table);

    }
 }

Answer №1

Success! Made a small tweak to the HTML page and now everything is running smoothly! Below is the updated code snippet:

<html>
<body>   
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
</head>
<div class="tab">
<button class="tablinks" onclick="functionname(event, 'DIVID') ng-click="show1()">TabName</button>
</div>

<div id="DIVID" class="tabcontent">
<h3>Content1</h3>
    <div id="panel1" ng-show="display5">   <!-- div id for panels and down...-->
        <script type="text/javascript" src="App.js"></script>
            <div id = "test.js">
                <div id = "filter1"></div>
                <div id = "chart1" align = "center"></div>
            </div>
    </div>
</div>


<script>

function functionname(value1, value2) {
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(value2).style.display = "block";
    value1.currentTarget.className += " active";
}
</script>

</body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error: Unable to cast value "undefined" to an ObjectId for the "_id" field in the "User" model

Whenever a user logs into their account, I am trying to retrieve their data on the login screen. The login functionality itself works perfectly, but unfortunately, the user data is not displaying. I have tried troubleshooting this issue by making changes i ...

Creating numerous hash codes from a single data flow using Crypto in Node.js

Currently, I am developing a Node.js application where the readable stream from a child process' output is being piped into a writable stream from a Crypto module to generate four hash values (md5, sha1, sha256, and sha512). However, the challenge ari ...

Components in React are unable to be accessed

I'm a complete beginner when it comes to React and I'm facing issues with organizing my components into separate files. The error message I encounter is: ERROR in ./src/App.js 5:0-34 Module not found: Error: You attempted to import /components/ ...

Having trouble accessing the height of a div within an Iframe

Here is the issue I am facing: I need my iFrame to adjust its size based on a div within it, but every attempt to retrieve the size of this div results in 0. var childiFrame = document.getElementById("myDiv"); console.log(childiFra ...

Styling a nested scrollbar using JQuery

I am looking to customize two scrollbars using a jquery plugin or JS library. Here is the HTML code: <div id="container"> <div class="fixedHeightContainer"> <div class="fixedHeightContent"> Lorem ipsum dolor sit amet, con ...

Is it possible for :hover to function with td elements in jQuery?

I created an HTML Table that includes a hidden infobox within one of the td elements. <style type="text/css"> .infobox{ display: none; background-color: #FFDB8F; font-size: 11px; } td { border: 1px solid; ...

Retrieving information from an API and presenting it as a name with a link to the website

I am attempting to retrieve information from an API and present it in the format Name + clickable website link. Although I have managed to display the data, the link appears as text instead of a hyperlink. Here is my Ajax script: $(function() { ...

Ionic 2: Unveiling the Flipclock Component

Can anyone provide guidance on integrating the Flipclock 24-hours feature into my Ionic 2 application? I'm unsure about the compatibility of the JavaScript library with Ionic 2 in typescript. I have searched for information on using Flipclock in Ionic ...

Issue with Material UI button not properly redirecting to specified path

Having an issue with a button that should redirect to a specific component with props on click. <Button variant="contained" color="primary" className={classes.button} endIcon={<SendIcon/>} onClick={() => { <Redirect ...

Issue encountered with AJAX multiple image uploader

I'm attempting to create an PHP and JavaScript (jQuery using $.ajax) image uploader. HTML: <form method="post" action="php/inc.upload.php" id="upload-form" enctype="multipart/form-data"> <input type="file" id="file-input" name="file[]" a ...

What changes can I make to my method in order to utilize async/await?

Within my React application, I have implemented a post request to the server using axios: onSubmit = async (results) => { try { const response = await axios.post("http://localhost:8080/simulate/", results); this.setState({results: ...

The issue of req.file being undefined when using Multer in Node.js with Express Router

I have been working on incorporating File Upload capability utilizing multer and Express Router. I set up an endpoint /batch_upload using router.use in the following manner: api.js router.use( "/batch_upload", upload.single("emp_csv_data"), userCo ...

Downloading a PDF file received from a Django view using JavaScript and jQuery

I have a celery task that creates PDF files on the click of a button. When the button is clicked, the JavaScript side will keep checking until the task is done, and when it is, it will download the file. Some recursion should do the trick: $(".getPdf").o ...

Can Node.js fetch a PHP file using AJAX?

The Challenge: Greetings, I am facing an issue with my website that features a game created using node.js, gulp, and socket.io. The problem arises when I attempt to call a php file from node.js. While the file returns a success message (echo in the file) ...

Absolute positioned content causing unexpected spacing on top of relative positioned content

I've been experimenting with a fantastic technique by Chris Coyier for implementing full page video backgrounds with content scrolling over the video. However, I've encountered an issue where there's an unexpected gap to the right in Windows ...

changing size when hovered over with the mouse is not consistent between entering and exiting

Hi there, I'm currently utilizing the transform: scale(); property on a website and could use some assistance with a particular issue I haven't been able to find an answer for online. Here is the code snippet I'm working with: HTML: <d ...

Error: When attempting to send a message in a different channel, an undefined property 'send' is encountered causing a TypeError

I'm utterly stumped as to why I keep encountering this issue, so perhaps someone here can shed some light on it. The error message reads: TypeError: Cannot read property 'send' of undefined Here is the snippet of code in question: client.o ...

Troubleshooting issue with JavaScript sorting function failing to arrange elements in ascending

I'm having trouble sorting numbers in ascending order using JavaScript. Here's the code snippet: <h2>JavaScript Array Sort</h2> <p>Click the button to sort the array in ascending order.</p> <button onclick="myFunctio ...

What are the differences between using a single ng-app and multiple ng-apps in

I am currently developing a web application that is powered by Spring for the backend, from controllers to database integration. At this point, I manage page navigation using get methods in Spring MVC controllers to access different pages. My plan now is ...

How to Retrieve the Name of the Active Element from an Unordered List (<ul>) in ReactJS and Display it in the

I have a project where I am creating a long navbar specifically for mobile devices, and I am structuring it in an accordion style. Initially, the view will show the currently active link name. When the user clicks on this active link name, it expands below ...