Developing a Highchart Graph using JavaScript

I am trying to develop a high chart graph.

Check out my code on FIDDLE LINK.

I have two values, a and b, for the x-axis and y-axis. The issue arises when the difference between a and b is minimal, such as when both are equal (-9). In such cases, the graph does not appear.

$(function () {
    var a, b, x, j;
    a = -9;
    b = -9;

    if (a > b) {
        x = a;
        j = b
    } else {
        x = b;
        j = a
    }


    alert("X is " + x);
    alert("Y is" + j);



    $('#container').highcharts({
        chart: {
            type: 'bar',
            backgroundColor: null
        },
        credits: {
            enabled: false
        },
        tooltip: {
            enabled: false,
        },

        title: {
            text: ''
        },
        xAxis: {
            categories: ["", "", ""],
           
        },
        yAxis: {
            min: j - (j * 5 / 100),
            max: x + (x * 5 / 100),

           
            endOnTick: true,
            tickPixelInterval: 340,
            maxPadding: 0.25,
            title: {
                text: ''
            },
            labels: {

                formatter: function () {
                    if (j - (j * 5 / 100) > 1000000) {
                        return Highcharts.numberFormat((this.value) / 1000000, 0, '', ',') + 'M';
                    } else if (j - (j * 5 / 100) > 1000) {
                        return Highcharts.numberFormat((this.value) / 1000, 0, '', ',') + 'K';
                    } else {

                        return Highcharts.numberFormat((this.value), 0, '', ',');


                    }
                },
                x: 6
            }
        },
        legend: {
            backgroundColor: '#FFFFFF',
            reversed: true
        },
        plotOptions: {
            series: {
                stacking: 'normal'
            }
        },
        series: [{
            name: ' ',
            data: [a]
        },

        {
            name: ' ',
            data: [0, b]
        }, ]
    });
});

Answer №1

Check out a functional demo

To improve it, simply eliminate:

min: j-(j*5/100),
max: x+(x*5/100)

within the yAxis: { --- some options --- }

Experiment by setting one value as positive and the other as negative for both a and b.

I trust this will be beneficial.

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

Unable to generate webpage source code

Having some trouble with my Next.js project as I'm using getStaticProps and getStaticPath to build a page, but unfortunately, the HTML is not being generated in the page source. This issue is causing problems with SEO, and I haven't implemented r ...

Mastering the Art of jQuery: Easily Choosing and Concealing a Div Element

I'm currently facing challenges in removing a div upon successful AJAX completion. The issue I'm encountering is that the word "Added" appears twice after success, indicating that I am not properly selecting the two divs containing it. Any sugges ...

The Google Maps application is experiencing an issue with rendering maps

Here is my code without the google map key. I am not receiving any errors, but the map is not showing up. What could I be missing? To test it out yourself, you will need to add your own map key which you can obtain from here. <!DOCTYPE html> <h ...

A single image with dual clickable areas managed by an interactive image map

Is there a way to attach two href links to one image using CSS? I want it to function like an old school image map, but purely with CSS. Is this something that can be done? The current HTML code looks like the example below. However, I need the image to h ...

React is unable to assign a class field beyond the scope of axios

class App extends React.Component { app: Application; ... componentDidMound() { axios.get(…).then(res => { this.app.currentUser = res.data.data; // setting value inside lambda function. console.log(this.app.currentUser); // ...

Ways to eliminate duplicate names within an object that contains multiple arrays

I have a set of data with different arrays and I need to remove any duplicate names that are being displayed. How can I accomplish this? Example of duplicate names The data is currently being output like this View all data The dsUserId values are repea ...

Tips on when to display the "Email Confirmation" input text box only after updating the old email

Oh no!! Yes, that's exactly what I desire! I've been facing obstacles in trying to understand how to display the "Email Confirm" input text-box ONLY when the old email has been updated. Can someone point out where I might have gone wrong? :( ...

What's the process for setting a value in selectize.js using Angular programmatically?

Currently, I am implementing the AngularJS directive to utilize selectize.js from this source: https://github.com/kbanman/selectize-ng In my scenario, I have two dropdowns and my goal is to dynamically populate one of them called selectizeVat based on the ...

When utilizing :id with Vue, HTML attributes become hidden from view

I am facing an issue where I need to make HTML elements visible, but they appear invisible upon rendering. Below is my HTML code: <div class="created-links-wrapper" v-for="item in createdUrls" :key="item._id"> <d ...

Leveraging the outcome of JSON within PHP variables

I would like to completely rewrite my question. My goal is to update the display of five variables without having to reload the entire page. I have a PHP file called check_conf_update.php which executes a query, retrieves data, and converts it into JSON ...

What could be the reason for Spawn() not being invoked?

After working with node.js and express for some time, I have encountered a persistent bug in my code. In my service file, there is a resolved Promise where I call spawn(), but for some reason, the spawn code never gets executed (or if it does, ls.on(' ...

Retrieve the date from the event

Incorporating fullcalendar v2.0.2, I am currently developing a copy/paste system for events. By right-clicking, I am able to copy the event with the help of a small menu. Upon right-clicking on the calendar during a week view, I am tasked with calculating ...

Incorporate a line break between the day and month on your JQuery datepicker

Is it possible to insert a line break or some other element between the day and month in the input field when using JQuery datepicker? Here is the current code I have: jQuery('#checkin').datepicker({ showAnim: "drop", dateFormat ...

Troubleshooting the issue with a styled subcomponent in React using Styled Components

Recently, I've delved into React and have been experimenting with creating a Modal component using styled components. My goal is to achieve a similar effect to Framer Motion's motion.div, but utilizing styled components instead. Currently, I hav ...

Elegant switch in jQuery

I am trying to use jQuery to create an animated toggle button. The toggle function is working correctly, but I am having trouble adjusting the speed and smoothness of the animation. After researching different methods and attempting to modify the values i ...

Send properties to the makeStyles function and apply them in the CSS shorthand property of Material UI

When working with a button component, I pass props to customize its appearance: const StoreButton = ({ storeColor }) => { const borderBottom = `solid 3px ${storeColor}`; const classes = useStyles({ borderBottom }); return ( <Button varian ...

Is there a way to showcase English and CJK text vertically with CSS?

This particular issue was first discussed 14 years ago on Stack Overflow, but a definitive solution still remains elusive. My goal is to have both CJK and Latin characters displayed vertically, with their bottoms facing the right side. While writing-mode ...

Ways to obtain parameter from URL in Express without diving into the request object

const express = require('express'); const app = express(); app.use('/', anyroute); // in anyroute file router.route('/:id').get(controlFunction) controlFunction(req, res, res)=> { // Here we can get the "id" fr ...

Sequelize cannot locate the specified column in the database

click here for image description I encountered an issue where a column was not recognized after migrating with sequelize-cli. Even though all the columns are defined in the migration file, this error keeps appearing. Additionally, when trying to create a ...

Transferring variables from the $(document).ready(function(){}) to the $(window).load(function(){} allows for seamless and

Just think about if I successfully create percent_pass at the time of document.ready, how can I transfer that variable to window.load? $(document).ready(function() { jQuery(function() { var ques_count = $('.question-body').length; va ...