When using Stacked area in Highcharts, my data series gracefully transition between visibility and opacity

Here's a question I have regarding a stacked area graph visualization.

Take a look at this image: https://i.sstatic.net/Rk9tg.png

What I'm aiming for is to have "test1" end directly at 2024, instead of gradually fading out towards 2028. Similarly, for "test2" and "test3", I want them to start directly at 2028 without any fade-in effect from 2024.

If anyone knows if achieving this is possible, I would greatly appreciate your insights. I've checked the API reference but didn't find any relevant information.

VIEW DEMO ON JSFIDDLE along with the code snippet:

$(function () {
        var yAxisLabels = [0, 20000, 40000, 60000, 80000, 100000, 120000];
    var xCategories = ['2016', '2020', '2024', '2028', '2032', '2036', '2040'];

    $('#container').highcharts({
        chart: {
            type: 'area'            
        },
        xAxis: {            
            tickmarkPlacement: 'on',
            title: {
                enabled: false
            },
            labels: {
                formatter: function() {
                    return xCategories[this.value];
                }
            },
            startOnTick: false,
            endOnTick: false,
            minPadding: 0,
            maxPadding: 0,
        },
        yAxis: {
                startOnTick: true,
            title: {
                enabled: false
            },
            tickPositioner: function() {
                return yAxisLabels;
            },
            labels: {
            formatter: function() {
                return "€ " + this.value;
                }
                }
        },
        tooltip: {
            shared: true,
            valueSuffix: ' millions'
        },
        plotOptions: {
            area: {
                stacking: 'normal',
                lineColor: '#666666',
                lineWidth: 1
            },
            series: {
                fillOpacity: 1
            }
        },
        series: [{
            name: 'test1',
            data: [113864, 113864, 113864, 0, 0, 0, 0],
            color: 'rgba(0,0,0,1)'
        }, {
            name: 'test2',
            data: [0, 0, 0, 87905, 87905, 87905, 87905]            
        }, {
            name: 'test3',
            data: [0, 0, 0, 14211, 14211, 14211, 14211]
        }]
    });
});

Answer №1

The shape appears odd because the area1 value is zero but it is positioned at the top of the stacked areas. By placing the area1 data last in the array, it will be filled last and appear at the bottom, resulting in a better visual layout:

series: [{
    name: 'test2',
    data: [0, 0, 0, 87905, 87905, 87905, 87905]
}, {
    name: 'test3',
    data: [0, 0, 0, 14211, 14211, 14211, 14211]
},{
    name: 'test1',
    data: [113864, 113864, 113864, 0, 0, 0, 0],
    color: 'rgba(0,0,0,1)'
}]

Check out the updated fiddle here

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

What are the best ways to ensure a website is responsive in a vertical

When designing a responsive webpage, I encountered an issue with the body element not properly expanding the content vertically. Despite enlarging the web content horizontally, the body failed to adjust its height accordingly, resulting in unwanted black a ...

Apply styling on hover with an additional class

I am attempting to apply a border to an input element when its pseudo class :hover is activated, while also adding the same border to the button next to it. I have read that using the selector class:hover + class should achieve this effect. However, in my ...

Rotating the Orientation of Cellphone Images

Currently facing an issue where the images I am attempting to display on a basic html page appear rotated to the left, likely due to being taken by a cellphone. These images are stored on my computer. I have tried using the css property image-orientation: ...

Learn the steps to use jQuery remove() method specifically for targeting a single item

Recently, I started using jQuery for the first time and I'm trying to understand how to use the remove() function to delete only one item with a specific class, instead of removing all items with that class. In my code, it looks like this: jQuery: $ ...

Is there any difference between keeping JavaScript at the bottom of the page versus including it in the <head> tag inside document.ready?

Would it make a difference if I place my JavaScript code at the bottom of the page versus inside <head> within document.ready? I'm torn between these two approaches, referenced here: http://api.jquery.com/ready/ and http://developer.yahoo.com/p ...

Sliding content with the grace of a visual journey

I'm currently working on a content slider that is very similar to this one. My goal is to make it rotate automatically, but I've been struggling to get it to work. I've attempted various methods, including triggering a click event on the lin ...

Searching for a table row that corresponds to the content of a cell using Python and Selenium

If you need to retrieve the row element from an HTML table where the text in a specific cell matches the string 'Mathematik & Informatik'. Here is the structure of the HTML: <table class="views-table cols-4"> <thead> ...

Showing the value of a JavaScript variable within an HTML input field

Here is an interesting HTML structure that includes a list and input field: <li> <span>19</span> </li> <li> <span>20</span> </li> ...

What is the method for obtaining the current date when altering the system date to a previous time?

To ensure that my datepicker always displays the current date and does not allow selection of past dates, I need to update the date if the system date is in the past. If I change the system date to a past date, I don't want the datepicker to reflect t ...

avoid inserting into a specific field with a specific name

I am trying to add a picture next to a specific name, but I am facing issues as there is no option for inserting it. This is how my table looks: https://i.sstatic.net/RRaTb.png How can I insert a picture in front of a particular name? The content of my ...

interactive switch using font awesome icons and jquery

Initially, I assumed this would be an easy task, but I've encountered some difficulties in making it function smoothly. Although I am able to toggle once using .show and .hide, I am unable to toggle back. Any assistance would be greatly appreciated. ...

The functionality of CSS scroll snap does not seem to be compatible with the CSS Grid

When utilizing CSS scroll snap with Flexbox, the snapping functionality works adequately: * { box-sizing: border-box; margin: 0; padding: 0; } .slider { font-family: sans-serif; scroll-snap-type: mandatory; scroll-snap-points-y: repeat(100vw ...

Developing web applications using Express.js and Jade involves connecting CSS stylesheets

I'm currently in the process of developing a web application using Express.js along with some Bootstrap templates. I utilized jade2html for conversion, and while the page loads successfully, it lacks any styling. The following code snippet is what I ...

JavaScript - Continue attempting to execute the first function until successful execution is achieved

Currently, I am working on enhancing a JavaScript code for a browser extension. The original function is functioning properly without any issues. However, I am trying to extend the functionality by incorporating additional code. I want to modify my functi ...

A function that listens for the onmouseover event and updates the image source of an HTML img element

I have created a function that positions my objects based on the array they are assigned to. For example, if they are in players[0], they will be placed in one position, and if they are in players[1], they will be placed elsewhere. The X and Y values are ...

Building a Laravel 4 application with dynamic cascade dropdowns using Jquery ajax

Trying to update a select box based on the value selected in another select box using Laravel 4. Having some logic issues :S My Javascript Code: $('#cat').change(function(){ category_id = $(this).val(); $('#secondcat').empty() ...

Obtain the image and store it in the designated storage location

I need help with a web page that features a profile viewing section. I have an empty image placeholder and when clicked, it prompts the user to browse for an image. However, I am struggling with saving the selected image into storage. Below is my code snip ...

I am having trouble getting IF statements within an onchange function to properly execute when using Javascript

My goal is to use JavaScript to trigger a function whenever a select dropdown menu undergoes a change. This is the HTML structure: <select id="select" onchange="characterchange()"> <option value="spidey">Spider-Man <option value="panth ...

Is there a way to retrieve the value of an HTML variable using Selenium?

Seeking assistance in determining the progress value of a video using Selenium. I understand that I need to utilize JavaScript executor, but have been unsuccessful in finding a solution so far. The element in question is: <div aria-label="scrub bar" a ...

Is there a way to stop the horizontal scroll bar from appearing when a div exceeds the width of my content?

I have come across similar questions, but the answers don't quite fit my scenario. I am dealing with a content width of 940px and I want to use an 'easel' as a background for my slideshow. The easel image extends about 400px beyond the conte ...