Tips for adjusting column spacing in HighCharts

Looking for some advice on how to make a chart container scrollable and properly space the labels and bars within a parent container with fixed width and height. The goal is to ensure all labels are visible and bars are well spaced. Any suggestions or tips on achieving this would be greatly appreciated. You can view the example on this jsfiddle link

I have already tried enabling scroll using

 scrollbar: {
             enabled: true
            }

But unfortunately, this hasn't provided much help so far.

Answer №1

To achieve the desired effect, simply apply the CSS property overflow: scroll to the parent div.

<div style="width:500px;height:600px; overflow: scroll;">
    <div id="recoranks" style="width: 400%; height: 100%; margin: 0 auto"></div>
</div>

See an example here: jsfiddle.net/z5wqgkm9/2

Answer №2

The underlying issue here is that highcharts relies on the container width to display the chart, which means it will adjust to fit the parent container's dimensions.

If you want to increase the chart's width or height while keeping it contained within a box with scrolls, you can utilize the float property to position the element independently from its parent.

Here's what you need to do:

Firstly, add another div container above the main div

<div style="width:500px;height:600px">

Secondly, assign a CSS class like .main-container to the top container and .inner-container to the inner div.

Your HTML structure should resemble the following:

<div class="main-container">
  <div class="inner-container">
    <div id="recoranks" style="min-width: 100%; height: 100%; margin: 0 auto">  </div>
  </div>
</div>

Next, add the following CSS classes:

.main-container {
  width:500px;
  height:600px;
  overflow-x:scroll;
  overflow-y:hidden;
}

.inner-container {
  width:700px;
  height:580px;
  float:left
}

With these adjustments, the setup is complete.

To summarize our approach, we placed the chart div inside a restricted-size container with scrolls. This outer container specifies the desired dimensions for the chart container. The overflow properties control scrolling behavior, allowing horizontal scrolling as per your requirements. You have the flexibility to adjust these settings based on your needs.

The inner chart div is set to float, preventing it from expanding to match the parent's width. Its specified width and height dictate the final dimensions of the rendered chart.

For a demonstration using your code with the proposed solution, visit: http://codepen.io/Nasir_T/pen/QGbxRw

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

Sending JSON data to PHP using AJAX request

Currently attempting to send textbox values to a database via JSON and .getJSON. I am currently testing whether the JSON is successfully posting to the page, as I have confirmed that the UPDATE query is functioning correctly... The following code is not a ...

Ensure advertisements are easily accessible and not visible to screen-reading tools

I oversee the management of numerous ads on a website. My goal is to enhance their accessibility, and though I have been doing research, there seems to be limited information available on how to achieve this effectively. While I continue my investigation, ...

Attempting to extract information from a webpage that contains multiple data tables, but encountering an issue where only the first table is successfully scraped

For my current project, I am attempting to extract data from basketball players' profiles on Basketball-Reference. Each player page on B-R contains several tables of valuable information that I need to access. However, when trying to extract the table ...

The layout option is not specified within the ejs-mate package

error boilerplate I am baffled as to why the layout is not being defined. I have installed ejs-mate and ejs, yet it still gives this error. <% layout('layouts/boilerplate') %> <h1>All campgrounds </h1> <div> <a ...

Tips on updating content at a specific time without the need to refresh the page

I'm working on a digital signage script that needs to be time scheduled. I was able to accomplish this using JavaScript and refreshing the page every 15 minutes. However, my question is, how can I track the time and update the content at specific hour ...

Customize Bootstrap 4 borders within a row

I am currently facing an issue with my code, where there is a border at the bottom of every row. Click here to view the code Unfortunately, I have noticed that the border at the bottom of each row does not extend across the full width. This occurs even wh ...

PHP SimpleXML: What is the best way to parse an HTML document?

As I attempt to use simplexml_load_string to load an HTML file as XML, numerous errors and warnings related to the HTML content arise leading to a failed process. Is there a method to effectively load an html file using SimpleXML? The HTML document in que ...

Using Angular 4 to retrieve a dynamic array from Firebase

I have a dilemma while creating reviews for the products in my shop. I am facing an issue with the button and click event that is supposed to save the review on the database. Later, when I try to read those reviews and calculate the rating for the product, ...

What causes the scrollbar to move while I am dragging the div downward on the page?

$('#aaa').draggable(); * { margin: 0; padding: 0; } #aaa { width: 800px; height: 800px; position: absolute; background: red; } .wrap { height: 2000px; position: relative; ; } <div class="wrap"> < ...

Is there a way for ResponsiveSlides to fade the pager without causing any disruption to the content below, all

I have been working with the Responsive Slides jQuery plugin and made some custom modifications. Everything is going smoothly, but I am facing an issue with getting the pager and next/prev controls to fade in when hovering over the container. Although I s ...

Tips for displaying a modal to a user only once

I've developed a Flask application that enables multiple users to register and log in. To achieve this, I have incorporated sessions into my code. When new users land on the initial page, they are greeted with a modal introducing them to the platform. ...

Animating a Canvas to Follow Mouse Coordinates

I am looking for a way to animate a circle moving towards specific coordinates, similar to the game . I have attempted using the jquery animate() function, but it is too slow due to the constant updating of the target coordinates. Is there a faster metho ...

How to change elements within an HTML string using jQuery

I am facing an issue where I have an HTML string (not DOM) that needs to be manipulated using jQuery. However, the code I am trying does not seem to work as expected: var html = '<div><h4><a class="preview-target" href="content.html"&g ...

Blending images together can obscure surrounding elements

Is there a way to make two images crossfade on hover without hiding the text underneath? I need the text to show below the image, not behind it. Any suggestions on how to solve this issue? #center { text-align: center; } #under { text-align: cente ...

Ways to incorporate design elements for transitioning focus between different elements

When focusing on an element, I am using spatialNavigation with the following code: in index.html <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfb5acf2acafbeabb6beb3f2b1bea9b6 ...

how can you make keyframe animation pause at the last stage?

Here is an example of utilizing CSS animations: .show-left-menu { -webkit-animation-name: leftSidebarAni; -webkit-animation-duration: .25s; -webkit-animation-timing-function: ease-out; -webkit-animation-iteration-count: 1; } @-webkit-keyframes l ...

Tips for minimizing the padding/space between dynamically generated div elements using html and css

Currently, I have 4 dropdown menus where I can choose various options related to health procedures: Area, specialty, group, and subgroup. Whenever I select a subgroup, it dynamically displays the procedures on the page. However, the issue I am facing is th ...

Issue with custom author meta not being returned by Wordpress AJAX

Currently, I am attempting to fetch custom author meta data using AJAX when a user clicks on the author's name. The issue I'm facing is that my AJAX call is not returning any response. I have verified that the variable being sent contains the c ...

Why won't my dropdown menu work properly with JavaScript on certain pages?

Being new to javascript, I encountered an issue with a function that I recently modified. When a user selects "Yes" from a dropdown menu, it should generate 3 text boxes within a specific div area. Below is the code for my form dropdown: <select name= ...

Using .change(); in JavaScript code with jQuery does not trigger a function

Here we have a generic code example for a jQuery function: $(document).ready(function() { if (something) { // This does something } else if (something else) { // This does something else } else { // And this does somethin ...