By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
rocoderesrocoderes
  • Home
  • HTML & CSS
    • Login and Registration Form
    • Card Design
    • Loader
  • JavaScript
  • Python
  • Internet
  • Landing Pages
  • Tools
    • Google Drive Direct Download Link Generator
    • Word Count
  • Games
    • House Painter
Notification Show More
Latest News
How to set the dropdown value by clicking on a table row
Javascript – How to set the dropdown value by clicking on a table row
JavaScript
Attempting to increase the counter, when the object's tag exist
Javascript – Attempting to increase the counter, when the object’s tag exist
JavaScript
Cycle2 JS center active slide
Javascript – Cycle2 JS center active slide
JavaScript
Can import all THREE.js post processing modules as ES6 modules except OutputPass
Javascript – Can import all THREE.js post processing modules as ES6 modules except OutputPass
JavaScript
How to return closest match for an array in Google Sheets Appscript
Javascript – How to return closest match for an array in Google Sheets Appscript
JavaScript
Aa
Aa
rocoderesrocoderes
Search
  • Home
  • HTML & CSS
    • Login and Registration Form
    • Card Design
    • Loader
  • JavaScript
  • Python
  • Internet
  • Landing Pages
  • Tools
    • Google Drive Direct Download Link Generator
    • Word Count
  • Games
    • House Painter
Follow US
High Quality Design Resources for Free.
rocoderes > JavaScript > Javascript – Updating from/to plotBands values on input from a slider
JavaScript

Javascript – Updating from/to plotBands values on input from a slider

Admin
Last updated: 2023/12/10 at 1:31 PM
Admin
Share
1 Min Read
Updating from/to plotBands values on input from a slider

Problem:

I am trying to update my Highcharts plotBands dynamically with sliders on the page. I want both to and from to be attached to slider values and dynamically updated on the canvas as the user drags the sliders. Is that possible?

Contents
Problem:Solution:

HTML:

<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container"></div>
<!-- <input id="range" type="range" /> -->



<div id="slider">
    <input class="bar" type="range" id="range-input" min="1" max="25" value="1"/>
    <span class="highlight"></span>
    <output id="range-value">1</output>
</div>

JS:


 var rangeInput = document.getElementById("range-input")
 var rangeValue = document.getElementById("range-value")

 rangeInput.oninput = rangeOutput
 
 function rangeOutput() {
   rangeValue.innerText = rangeInput.value
 }
 
 let bla = rangeInput.value;

Highcharts.chart('container', {
    chart: {
        marginTop: 5
    },
    title: {
        text: 'Flats sold per month'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    yAxis: {
plotBands: [{
                from: bla,
                to: 5,
                color: 'yellow'
            }],
        title: {
            text: 'Flats'
        }
        
    },

    series: [{
        data: [1, 3, 5, 2, 3, 9, 6, 7, 3, 5, 4, 3]
    }]
});

Where I get stuck is updating the chart in real time. I can see there are methods to do that if I want to update my data, but I’m not sure how to do that for plotBands.

Solution:

Related

Subscribe to Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Share this Article
Facebook Twitter Email Print
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article Output all documents in a nested collection Javascript – Output all documents in a nested collection
Next Article How to change the input component attribute conforimng to the pinia's data vue3 Javascript – How to change the input component attribute conforimng to the pinia’s data vue3
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

- Advertisement -

You Might Also Like

How to set the dropdown value by clicking on a table row

Javascript – How to set the dropdown value by clicking on a table row

February 11, 2024
Attempting to increase the counter, when the object's tag exist

Javascript – Attempting to increase the counter, when the object’s tag exist

February 11, 2024
Cycle2 JS center active slide

Javascript – Cycle2 JS center active slide

February 10, 2024
Can import all THREE.js post processing modules as ES6 modules except OutputPass

Javascript – Can import all THREE.js post processing modules as ES6 modules except OutputPass

February 10, 2024
rocoderesrocoderes
Follow US

Copyright © 2022 All Right Reserved By Rocoderes

  • Home
  • About us
  • Contact us
  • Disclaimer
Join Us!

Subscribe to our newsletter and never miss our latest news, podcasts etc.

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Lost your password?