Begin creating a graphical page modal immediately upon the user's submission button click

I recently implemented a feature where users can input data to populate a Google graph directly on the same page.

For reference, you can view the page image here: https://ibb.co/fAm7BQ

Below is the HTML code snippet:

<form method="post">
  <label>CUF PERFORMANCE</label> &nbsp&nbsp&nbsp
  <select id="select" name="options">
    <option>Select The Value</option>
    <option id="hourly" value="a">Hourly</option>
    <option id="daily" value="b">Daily</option>
    <option id="monthly" value="c">Monthly</option>
    <option id="yearly" value="d">Yearly</option> 
  </select><br/><br/>

  <label id="from" style="display:none;">Enter starting Date and Time</label>

  <input id="dateInputone" name="dateipone" type="datetime-local" step="600" onblur="validate_time(this.value)" style="display:none;">

  <label id="to" style="display:none;">Enter Ending Date and Time</label>

  <input id="dateInputtwo" name="dateiptwo" type="datetime-local" step="600" style="display:none;">
  <br/><br/>
  <label for="Inverter">Inverter</label>
  <select name="ino">
    <option>Select The Value</option>
      <option value="1">Inverter 1</option>
    <option value="2">Inverter 2 </option>
      <option value="3">Inverter 3</option>
      <option value="4">Inverter 4</option> 
      <option value="5">Inverter 5</option> 
      <option value="6">Inverter 6</option>
  </select><br/><br/>

  <input type="submit" value="submit" onclick="myFunction()">

Here's my script code for integrating Google Charts:

google.charts.load('current', {
  'packages': ['line', 'bar', 'corechart']
});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
  var arr1 = <?php echo json_encode($narray) ?>;
  var dataArray = [];
  for (i = 0; i < arr1.length; i++) {
    var implicitArray = [];
    implicitArray.push(arr1[i].timestamp);
    implicitArray.push(arr1[i].sum);
    implicitArray.push(arr1[i].sum / (6 * 72 * 245));
    dataArray.push(implicitArray);
  }

  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Days');
  data.addColumn('number', "Grid Power Total");
  data.addColumn('number', "CUF");
  data.addRows(dataArray);

  var linematerialOptions = {
    chart: {
      title: 'CUF CALCULATION'
    },
    width: 400,
    height: 400,
    series: {
      // Gives each series an axis name that matches the Y-axis below.
      0: {
        axis: 'CUF'
      },

    },
    axes: {
      // Adds labels to each axis; they don't have to match the axis names.
      y: {
        CUF: {
          label: 'CUF'
        }
      }
    }
  };

  var linechart = new google.charts.Line(document.getElementById('chart_div'));
  linechart.draw(data, linematerialOptions);

  var barmaterialOptions = {
    width: 400,
    height: 400,
    series: {
      0: {
        axis: 'CUF'
      }, 
      1: {
        axis: 'Gridpowertotal'
      } 
    },
    axes: {
      y: {
        CUF: {
          label: 'CUF'
        }, 
        Gridpowertotal: {
          side: 'right',
          label: 'Grid Power Total'
        }
      }
    }
  };
  alert(barmaterialOptions);
  var barchart = new google.visualization.BarChart(document.getElementById('chartdiv'));
  barchart.draw(data, google.charts.Bar.convertOptions(barmaterialOptions));
}

If you'd like to see how the user input triggers immediate changes in the displayed graph, check out this link: https://ibb.co/cbytkk

Answer №1

  <!--custom modal table -->
    <div id="myModal" class="modal fade in">
     <div class="modal-dialog">
      <div class="modal-content">
       <div class="modal-header">
       <a class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span></a>
       <h4 class="modal-title">CUF Graph</h4>
       </div>

      <div class="modal-body">                
       <table class="columns">
        <tr>
         <td><div id="chart_div" style="border: 1px solid #ccc"></div></td>
         <td><div id="chartdiv" style="border: 1px solid #ccc"></div></td>
        </tr>
       </table>
      </div>

     <div class="modal-footer">
      <div class="btn-group">
      <button id="change-chart"  class="btn btn-danger">Bar Chart</button>
      </div>
     </div>
    </div>
   </div>
  </div>

Only the code snippet displaying the graph table within a custom modal has been showcased.

For more information, please visit the following link:

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

The system detected a missing Required MultipartFile parameter in the post request

Can anyone explain to me why I am encountering the error mentioned above? I am unable to figure out the reason. Below is my code, please review it and suggest a solution for fixing this error. The objective is to upload multiple files to a specific locatio ...

My attempts at creating a column in Bootstrap using push and pull are not successful

My Versatile Code for Different Screen Sizes <div class="col-xs-6 col-lg-2"> <div>A</div> </div> <div class="col-xs-12 col-lg-8 "> <div>B</div> </div> <div class="col-xs-6 col-lg-2"> <di ...

jQuery's visibility check function is not functioning properly

I am developing a web application for managing orders and finance in a restaurant. To enhance the functionality of my application, I require more screens to operate with. To facilitate this, I have implemented a small function to toggle between visibility: ...

Strategies for breaking down and streamlining Drag-And-Drop code into more manageable sections

Upon experimenting with react-beautiful-dnd, I developed a prototype drag & drop functional component. However, I find the code quite lengthy (around 250 lines) and believe it could be structured better. You can view this example on this sandbox. I am see ...

The functionality of the String prototype is operational in web browsers, but it encounters issues

Version: 8.1.0 The prototype I am working with is as follows: String.prototype.toSlug = function () { return (<string>this) .trim() .toLowerCase() .replace(/\s+/g, '-') .replace(/[^\w\-]+/g, '') ...

Optimal methods for creating large files using jQuery or Java

I am currently working on a web application using jQuery and Java, and one of my tasks involves generating a report from database records. This report should be downloadable in csv, xls, and txt formats. The number of records in the file can vary, sometime ...

Input text into search box to transfer value to URL without using the equal (=) symbol

Currently, my website allows users to search by entering a value in the URL after /search/. For instance, searching for "hello" can be done by visiting www.mywebsite.com/search/hello. Now, I am looking to implement a simple search box that functions simil ...

HTML with an intricate and dynamic table layout

I am attempting to design a dynamic table that looks like the one shown in this image: https://i.stack.imgur.com/0Bmur.png The challenges I face in creating this HTML table are as follows: It needs to be dynamic as it will display data from a database T ...

the navigate feature is not redirecting to the intended page as expected

I am currently working on a React application and facing an issue with configuring the navigation. The problem lies in the code of the Navbar component, where upon clicking the logout button, the authentication context should be cleared and the user should ...

The window.open function is returning a null value after attempting to open the specified

Is there a way to prevent users from opening more than one IFrame window for my application? I have included the following code: <html> <head> <title>Testing Window Opening Limitation</title> <meta http-equiv="Content-Type" cont ...

flexible navigation bar with Bootstrap

I'm currently using Yamm with Bootstrap, but I'm encountering an issue where I need to make it flexible so that each list item will have the same spacing as the others. Additionally, I want to be able to add new list items in the future without d ...

The <nav> and <section> elements are not appearing on the page

Website: CSS: Hello there! I am experiencing an issue where the nav and section elements are not displaying on my website. They seem to only show the height and background-color attributes. Interestingly, they appear correctly on my old Firefox version ( ...

Online support chat powered by jQuery AJAX

Does anyone know of a script that offers free online customer support using AJAX, JQUERY, and PHP? I'm looking for something that allows each person to have their own chat window... Thanks! ...

Accessing local storage in HTML 5 using Selenium

I have been working with Selenium web driver in C# and I encountered a weird issue. When I use a JavaScript method to write to local storage, it works perfectly fine (I can see the values when inspecting the HTML page), but when I try to read from the loca ...

Having trouble executing a fetch request in Next.js

I am struggling to perform a fetch request using getStaticProps in Next.js. Despite following the documentation provided on their website, I am unable to console log the props successfully. My background is mainly in React, so I tried to adapt my approac ...

Is there a reason why this MD Bootstrap Snippet isn't functioning properly?

When zooming out to 25% or beyond, I noticed that the toolbar unexpectedly pops open and refuses to close. How can I prevent this from happening? I asked this question yesterday but unfortunately received only downvotes :( Appreciate any help provided ...

Adjust the size of the browser window using JS/Jquery when accessing a website

I created my first website a few months ago, but unfortunately it is not responsive. The website was designed for 1280x1024px screens, so it does not adjust properly on larger or smaller screens. While I am not concerned about the display on smaller screen ...

What is the best way to create a mobile menu transition that moves in a "reverse" direction?

I have been working on animating a mobile menu where the three stripes transform into an 'X' when clicked and revert back to three stripes when closed. The transition to an 'X' is working perfectly, but when closing the menu, it jumps b ...

The RequiredFieldValidator in my textbox is triggered, however, it fails to prevent the postback when I include JavaScript in the

I have a required field validator that is functioning correctly when it's on its own and stops the post back. However, when I add JavaScript to enable the "next" button upon checking a checkbox, the required field validator will trigger when clicking ...

Tips for customizing a dropdown menu where the first item is not the label and may include an input field

How can I create a dropdown box that includes a label of "select so and so..." and when the user clicks on it, a list of options is displayed with the first option being blank instead of showing the label name? Is it possible to include an input box insi ...