The addition of plot bands in highcharts can cause the plot lines to vanish

Whenever I try to use plotbands between two points on the x-axis and draw a line between those two points using pointLines, the line never appears. Strangely, if the same process is done on the yAxis, everything works perfectly fine. Here is my code:

  $(function () {
    var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container'
    },
    xAxis: {        
        plotBands: [{ // marking the weekend
            color: 'rgba(68, 170, 213, 0.2)',
            from: Date.UTC(2010, 0, 2),
            to: Date.UTC(2010, 0, 4)
        }],
        plotLines:[{
         value: Date.UTC(2010, 0, 3),
                  color: 'green',
                  dashStyle: 'shortdash',
                  width: 2,
        }],
        plotLines:[{
         value: Date.UTC(2010, 0, 6),
                  color: 'green',
                  dashStyle: 'shortdash',
                  width: 2,
        }],
        tickInterval: 24 * 3600 * 1000, // one day
        type: 'datetime'
    },
    yAxis:{
        plotLines:[{
            value : 200,
            color: 'green',
                  dashStyle: 'shortdash',
                  width: 2,
        }] ,
         plotBands: [{ // marking the weekend
            color: 'rgba(68, 170, 213, 0.2)',
            from: 150,
            to: 250,
        }],  
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4 , 255.7],
        pointStart: Date.UTC(2010, 0, 1),
        pointInterval: 24 * 3600 * 1000
       }]
   });
 });​

I've also created a jsFiddle demo for this here

Answer №1

It seems like the issue you're facing is related to setting multiple plotLines using an array. Here's an example code snippet that demonstrates how to do this:

plotLines:[{
    value: Date.UTC(2010, 0, 3),
    color: 'green',
    dashStyle: 'shortdash',
    width: 2,
}, {
   value: Date.UTC(2010, 0, 6),
   color: 'green',
   dashStyle: 'shortdash',
   width: 2,
}]

If you want to add more than one plot line, you can refer to LINK1.
To edit the z-index of plotLines, check out LINK2.

Answer №2

Implement zIndex for organizing plotlines and plotbands...

            plotLines: [{
                width: 3,
                color: "#808080"
            },{
                value: "200",
                width: 4,
                color: "#FF0000",
        zIndex: 4}],

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

Which specific HTML element triggers the initiation of ajax in Jquery?

I have a situation where various HTML elements trigger ajax requests when clicked. My goal is to determine which specific element was clicked inside the ajaxComplete event. Although I attempted to use event.target, it only returns the entire document inst ...

Tips for managing this JavaScript JSON array

Here is an example of a JSON array: var data = { name: 'Mike', level: 1, children: [ { name: 'Susan', level: 2, }, { name: 'Jake', level: 2 }, { name: 'Roy', level: 2 }, ...

How to programmatically unselect an ng-checkbox in AngularJS when it is removed from an array

Utilizing checkboxes to gather values and store them in an array for dataset filtering purposes. The objectives are as follows: Show child filters when parent category is selected. Unselect all children if parent is unselected (otherwise they will ...

Troubleshooting encoding problems with Google Cloud's Speech-to-Text API using Node.js

I'm currently working on a project that involves capturing audio from a user's microphone and sending it to a server for translation using Google's Speech-to-Text API. I am utilizing navigator.mediaDevices.getUserMedia() to access the audio, ...

How can you refresh the information shown in a separate component from the search input with a live search bar?

Currently, I am working on integrating a live search functionality into my Next.js application. While I have successfully managed to capture input changes, I am facing difficulties in filtering the results based on the user input. Here is a snippet of the ...

Using AngularJS to auto-populate additional fields after selecting an option from the typeahead autocomplete feature

Just starting with AngularJS and finally figured out how to implement Auto-complete in Angularjs. Now, when a user selects a value from the auto-complete, I want other fields to be populated based on that selection. For example, upon loading the screen, d ...

Tips for guaranteeing that functions within .then() are finished before moving on

Here is an example of using $.when().then(). $.when(setLineDetails(reportId, reportLine)).then(function(data) { console.log("Completed setting line details"); setHeaderDetails(reportId); }).then(function(data) { cons ...

Combining two request.get functions into a single one

Is there a way to combine these two functions into one? I have two APIs: /page1 and /page2. My goal is to merge the two arrays into one because the GitHub API only displays 100 objects per page. request.get({ url: 'https://api.github.com/users/an ...

I am getting a HTTP 405 error indicating that the method is not allowed, and it appears to

In my Javascript program, I requested this URL using the library epson-2.6.0.js, which is the Epson SDK for JavaScript specifically designed for thermal printers. My target device is a TM U220 connected via ethernet. GET XHR http://192.168.199.15:8008/soc ...

Executing an Ajax request to a document containing <script> elements

Recently, I developed a sample page that effectively mimics table layout pages but without relying on the traditional mobile-unfriendly table features. The structure of the page is as follows: <html> ... <body> <div type="page" ...

What are some techniques for applying masking to various elements beyond just input fields within React?

I am currently developing an admin dashboard using NextJS and MaterialUI (mui), and I am facing a challenge with masking certain values, such as phone numbers, that are retrieved from the backend without any masking applied. While I have successfully impl ...

Animating path "d" with ReactJS and SVG upon clicking in FireFox

Visit this CodePen for more: https://codepen.io/sadpandas/pen/xxbpKvz const [currentScreen, setCurrentScreen] = React.useState(0); return ( <React.Fragment> <div> <svg className="theSvg" width="156" height="6 ...

Process called gulp useref eliminates certain files from the pipeline

Is there a way to exclude the gulp.src file from output? I am aiming to bundle only JavaScript and output .js files, not HTML. The following blocks in base.html are utilized for bundling JavaScript with gulp-useref: <!-- build:js app.core.js --> &l ...

Personalize Tooltip on Highchart Area Chart

I am currently in the process of customizing the tooltip for my area chart using Highchart. Within this area chart, I have plotted 3 series. My goal is to display the tooltip at a fixed location on the chart's top center. When hovering over any point ...

Develop a customized modal using jQuery library

I have implemented a jQuery function that replaces specific words with links, however, I am looking to create a modal popup using only jQuery. Is there a way to achieve this? Below is the code snippet: $(".wpb_wrapper, p").html(function(i, html) { re ...

What is the best way to save the properties of elements in an array of objects within another array?

I have obtained attributes from objects within an array that I need to store in another array. Here is the data I am working with: My goal is to extract the `displays` name attribute and save it in the `opt[]` array, which would result in something like t ...

What is the method for showcasing a single Observable from an Array of Observables in Angular?

I am facing a challenge with displaying questions from an Observable-Array one by one. Currently, I can only display all the questions at once using *ngFor in my HTML. Here is my component code snippet: import { Component, OnInit } from '@angula ...

Click on the sort icon in React JS to change its state

I need to update the sort icon in my table header when a user sorts a column. Here is the current implementation of my sorting function: var headerColumns = []; var IconType = 'triangle'; var IconSort = 'top'; var onToggleO ...

Vue: utilizing shared methods in a JavaScript file

Currently, I am building a multipage website using Vue and I find myself needing the same methods for different views quite often. I came across a suggestion to use a shared .js file to achieve this. It works perfectly when my "test method" downloadModel i ...

Instructions on utilizing the transpiled "main.js" file using gulp

As a novice in Angularjs 1.0, I encountered issues with my script and decided to use gulp to compile ec6 to ec5 by implementing the code provided below. The compilation process generated the file main.js. However, I am unsure about how to connect it when l ...