Tips for incorporating animated features into a bar graph using jQuery

How can I create a dynamic animated bar graph using jQuery? I am looking to make the bar slide up from the bottom, incorporating images for both the bar and background. I have already set the positioning in CSS and now need to add animation to make the bar appear. Once the bar is displayed, I also want to show a pop-up image. The animation is functional, but my goal is to have the bar sliding up from the bottom.

    $(document).ready(function() {
    $(window).load(function(){
    $("#graph_bar").animate({
    "height":"toggle"
    },2000,function(){
    $("pop").show();
    });
    });
    });
    #graph_bg{
        position:relative;
    }

    #graph_bar{
    position: absolute;
    top:270px;
    left: 182px;
    display: none;
    }

    #pop{
    position: absolute;
    top:50px;
    left: 50px;
    display: none;
    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img id="graph_bg" alt="graph_bg" src="graph_bg.jpg"/>
<img id="graph_bar" alt="graph_bar" src="graph_bar.jpg"/>
<img id="pop" alt="pop" src="image.jpg"/>

Answer №1

#visual_bg{
    position:relative;
    width:350px;
    height:300px;
    background-color:yellow;
    overflow:hidden;
}

#visual_bar{
    position: absolute;
    top: 350px;
    left: 50px;
    height:300px;
    width:50px;
    background-color:blue;
}

#highlight{
    position: absolute;
    top:50px;
    left: 50px;
    width:50px;
    height:50px;
    background-color:red;
    display: none;
}
<div id="visual_bg">
    <div id="visual_bar"></div>
    <div id="highlight"></div>
</div>
 $("#visual_bar").animate({"top":"50px"}
                          ,2000
                          ,function(){
                            $("#highlight").show();
                           }
                         );

http://jsfiddle.net/zacwolf/cgsdcwp3/1/

As I didn't have access to your images, I substituted background colors instead. You can easily switch them back to background images. The important step was making sure the background container is the parent of the other elements, then using "overflow-hidden" in the background container and positioning the bar outside its visible limits initially. With this setup, you can animate it to the desired "top" position. Also, don't forget to include "#" in your show() function.

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

Create a minimalist Vue table design that enforces a maximum of 2 or 3 columns within

Is there a way to make my v-simple table with v-chips and v-badges align correctly in two or three column peer cell format? Here is the table for reference: Currently, I only have scoped styling applied: <style scoped> .time-slot-x-small { border- ...

Retrieving the selected value from an added dropdown list using jQuery

Could someone please guide me on how to retrieve the selected value from an appended select list using jQuery? Any assistance would be greatly appreciated. Thank you in advance. var wrapper1 = $(".column1"); array1 = ["sample1", "sample2", "sample3"]; ...

extracting both the value and ID attributes from a RadioButtonGroup component in React MaterialUI

I am currently working on extracting the selected value and gameID from a dynamic MaterialUI RadioButtonGroup. Although I have been successful in retrieving the gameID, I am encountering difficulty in obtaining the value: <form onSubmit={this.handl ...

Achieving a similar functionality to Spring Security ACL in a Node.js AWS Lambda serverless environment

I am tackling a javascript challenge that has me stumped. Specifically, I am trying to figure out how to implement fine-grained authorization using an AWS serverless approach. In Spring security ACL, users can be banned from specific tasks at the instanc ...

Tips for personalizing jQuery formBuilder's typUserAttrsIf you want to

In my Rails app, I've added a new feature that involves using a custom form. After considering various plugins, I decided to go with jQuery formBuilder as my top choice. While I am able to customize the values of each "typeUserAttrs," what I really wa ...

Mastering the Art of Integrating API and JSON!

I've developed a bot using botkit and the Zendesk API to retrieve information. There's a function in my bot that prompts the user for a search term, searches for relevant information using the Zendesk API, and displays the result. I'm faci ...

the ever-changing dimensions of a PDF document

I'm attempting to display a PDF using an iframe, but I want the height of the viewer to match the document's height, meaning that all 3 pages should be visible without scrolling. How can I achieve this? Here's a simple example I created on ...

Adjust the element based on hover over the pseudo element

Looking to modify an element based on the hover state of a pseudo-element. Here's what I've tried so far, but it isn't working as expected: nav .logo { display: none; } nav:before{} nav:hover:before .logo { display: block; } I want th ...

Implement the HTML code for utilizing the GET method in an AJAX request

I'm exploring a way to utilize inline HTML directly as the URL for the ajax GET method without fetching data from a separate webpage. Is it feasible? Here is my ajax code: $.ajax({ type: "GET", url: $(elm).attr("href"), ...

How to make a Material UI Dialog Box automatically expand to fit the Dialog Content Area

In my project, I am working on a Dialog component which has a maximum width and a minimum height. Inside the DialogContent, I want to have a Box element that stretches to fill out the remaining space of the DialogContent. The goal is to have a background i ...

Is there a way to save a Morris.js chart as a PDF file

I have successfully created a Morris.js Bar Chart using data from PHP and MySQL. Now, I am looking for a way to export this chart into a PDF format. I have attempted to do so using the FPDF library but I am struggling with the implementation. Can anyone ...

Easily transfer files without the need for a complete page refresh

The Strategy To ensure a seamless user experience, my goal is to upload files without triggering a full page refresh. All uploaded files will be temporarily stored, either in session or cookies, until the user successfully completes all form fields. File ...

The button's background color will vanish if you click anywhere outside the button or on the body of

Struggling with a tabpane created using HTML, CSS, and JavaScript. The problem arises when the background color of the active tab's button disappears upon clicking outside the button or on the body. While switching between tabs, I can change the color ...

Utilizing jQuery to apply CSS styling to the parent element

Here is my current HTML structure: <div class="control-group"> <input value="" id="email" name="email" type="text" placeholder="E-mail"/> <span class="help-inline"></span> </div> This is th ...

Display the array in the Vue view section without using curly braces

I am trying to display the following array in the view section without braces and quotations. Currently, it is showing with exact array containing braces and quotations. Array ["WHATSAPP", "2G", "CLIQ"] Code <v-col cols=& ...

Retrieving data from JavaScript global variables within an HTML document using PhantomJS

Recently, I encountered an interesting piece of HTML code that sparked my curiosity: <html> <body> <script> var foo = { bar: [] }; </script> </body> </html> This led me to wonder how I c ...

Incorporating CSS Styles in EJS

Struggling with connecting my CSS files while using EJS. I've checked out another solution but still can't seem to get it right. Here is the code I used as a reference for my CSS file. EJS <html> <head> <meta charset="utf-8 ...

Troubleshooting a JavaScript error: Script.js throwing 'Uncaught TypeError' at line 5

While working on a small project, I encountered a JavaScript error that reads: script.js:5 Uncaught TypeError: Cannot set properties of null (setting 'onkeyup') at script.js:5:18 Below is the HTML & JavaScript code snippet that triggered thi ...

Error: Headers cannot be set after they have already been sent, resulting in an Unhandled Promise Rejection with rejection id 2

I'm a beginner with Node.js and I've been using express.js. In a section of my code, I'm trying to retrieve data from a form via AJAX and store it in a variable called url. I have access to request.body, but I'm encountering an issue wh ...

Having trouble getting JQuery Ajax POST to work in Codeigniter

Encountering an issue with jQuery AJAX post in CodeIgniter, where clicking the submit button triggers an error. Below is the code snippet: home.js form.on('submit', function(e){ e.preventDefault(); var fields = {}; form.find(' ...