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

  • SEARCH
  • Home
  • 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 8682069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:40:21+00:00 2026-06-12T21:40:21+00:00

I am trying to make a application one of the module is displaying a

  • 0

I am trying to make a application one of the module is displaying a multiple canvas at same location. This canvas is used to display graph. I have 2 buttons: pie and bar:

When I click on pie it should display pie chart. and when I click on bar it should display bar graph. I am using following approach:

  1. rendering 2 canvas at same location.

    .wrapper canvas {
        position: absolute;
        top: 0px;
        left: 0px;
        visibility:hidden;
    }
    
  2. In pie button i’m hiding bar chart and display pie. Same goes for bar button.

    $("input[type='radio']").change(function(){
      var  whChart = $('input[name="radio-view"]:checked').val();
      var canpie = document.getElementById('pie4');//$("canvas[name='pie4'][0]");
      var canbar = document.getElementById('pie41');//$("canvas[name='pie4'][0]");
      if(whChart == "Pie"){
          RGraph.Effects.jQuery.Snap(pie4);
          canpie.style.visibility='visible';
          canbar.style.visibility='hidden';
      }
      else if( whChart == "Bar"){
            RGraph.Effects.jQuery.Snap(pie41);
            canpie.style.visibility='hidden';
            canbar.style.visibility='visible';
      }
    });
    

html file

<div class="wrapper" style="text-align:center;">
    <canvas id="pie4" width="450" height="250" style="background:black;  z-index: 1; visibility:visible; ">[No canvas support]</canvas>
    <canvas id="pie41" width="450" height="250" style="background:red;  z-index: 2;">[No canvas support]</canvas>
</div>

But the problem is these 2 canvas are displaying one below another. Not at the same place overlapping.

I have checked other post related to double buffering and also tried other options like making 1st canvas height and width to ‘0’, but it doesn’t seems to work. Could please someone help in this matter. Since I’m very new to this JavaScript.

p.s : Sorry this is my first post. I know there are lot of mistakes and information missing. If you let me know if anything else needed I will provide.

  • 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-06-12T21:40:22+00:00Added an answer on June 12, 2026 at 9:40 pm

    The problem is visibility keeps the space, you want to use display which does not maintain the space.

    var pieState = (whChart == "Pie") ? "block" : "none"; 
    var barState = (whChart == "Bar") ? "block" : "none"; 
    canpie.style.display = pieState;
    canbar.style.display = barState;
    

    Please see this stackoverflow question for an explanation.

    Since you seem to be using jQuery, you could just use jQuery’s show()/hide() or toggle()

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

Sidebar

Related Questions

I have one web application using drupal.Now i am trying to make the same
i trying to make a osx application that just have one window and it
I am trying to make module in-app-billing for my application. There is one thing
I'm trying to make application for tablet with Android 2.3 with this kind of
I am trying to make my java application more standards compliant and one of
I am trying to make an application that will have a set of screens
I have spent the whole day trying to make my application use threads but
I'm trying to make my application support multiple languages. I've made some satellite assemblies
I am trying to make an application in which one component captures the screen
I'm studing Python for one month and I'm trying to make a keygen application

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.