Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7521815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:20:17+00:00 2026-05-30T02:20:17+00:00

I am new to javascripting and jquery. I am drawing charts using flot in

  • 0

I am new to javascripting and jquery. I am drawing charts using flot in which i have 2 Bar graphs…

My first bar graph

<div id="bar1" style="width:600px;height:300px;"></div>
$(function () {

var css_id = "#bar1";
var data = [
    {label: 'foo',color:'red', data: [[1,300], [2,300], [3,300], [4,300], [5,300]]},
    {label: 'bar',color:'blue', data: [[1,800], [2,600], [3,400], [4,200], [5,0]]},
    {label: 'baz',color:'green', data: [[1,100], [2,200], [3,300], [4,400], [5,500]]},
];
var options = {
    series: {stack: 0,
             lines: {show: false, steps: false },
             bars: {show: true, barWidth: 0.4, align: 'center',},},
    xaxis: {ticks: [[1,'One'], [2,'Two'], [3,'Three'], [4,'Four'], [5,'Five']]},
};

$.plot($(css_id), data, options);

});​

My second graph

<div id="bar2" style="width:600px;height:300px;"></div>
var data = [
    {label: 'foo', color:'red', data: [[1,300], [2,300], [3,300], [4,300], [5,300]]},
    {label: 'bar', color:'blue', data: [[1,800], [2,600], [3,400], [4,200], [5,0]]},
    {label: 'baz', color:'yellow', data: [[1,100], [2,200], [3,300], [4,400],   [5,500]]},
    ];

$.plot($("#bar2"), data, {
series: {
    stack: 1,
    bars: {
        show: true,
        barWidth: 0.6,
        fill:1
    }
}
});​

Now i have a click event of a button

$(document).ready(function() {
......
});

Now what should i write on the occurance of the button event such that i dynamically change my bar graphs from <div id="bar1"> to <div id="bar2">

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:20:20+00:00Added an answer on May 30, 2026 at 2:20 am

    If i understand the question correctly you want to hide/show each div on the press of a button …. first hide one of the <div> using style="display:none" and then use the following code to toggle both on click of a button

    $(document).ready(function() {
       $('#idofbutton').click(function() {
          $('#bar1,#bar2').toggle();
       });
    });
    

    Using toggle() on both with hide the currently shown div and show the currently hidden div (hope that makes sense !)

    Docs for toggle()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm completely new on JQuery and not so used to JavaScripting yet. I have
New to javascript/jquery and having a hard time with using this or $(this) to
New to jquery question... Using jQuery, depending on the radio button clicked I would
I have couple of forms on my php page. I am using jQuery (&
(New to ASP.NET here.) I have a user control which should check for a
New to DDD here and have a architecture question which should be a typical
New to SO and javascript. I have been playing with JQuery for a couple
I am new to jQuery and Javascript. I have to create select->option drop down
I am new to javascripting. I am using script in html code and i
New to both Ruby and Rails but I'm book educated by now (which apparently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.