Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Underline an area of a bar graph with plotly JS

I would like to specify a selected area between two values and underline the area selected but I don't know how doing this with a graphical bar. I'm looking for on the entire web but I didn't find anything. I've also tried to make this graph as a histogram, but the graph isn't correct...

My JS code

jQuery(function() {
    var stats = new Stats();
    displayGraph();
    
    function displayGraph() {
        var dataForPlotly = [];
        dataForPlotly = {
            y: [4.5,5,13,20,12.5,7,1.6,0.66,0.25],
            x: [30,50,65,75,90,110,135,165,220],
            width: [20,20,10,10,20,20,30,30,80],
            type:'bar',
            marker:{
                color: ['rgba(0,0,0,1)', 'rgba(222,45,38,0.8)', 'rgba(204,197,204,1)', 'rgba(243,204,204,1)', 'rgba(111,204,204,1)', 'rgba(189,204,204,1)', 'rgba(222,45,38,0.8)', 'rgba(204,197,204,1)', 'rgba(243,204,204,1)', 'rgba(111,204,204,1)']
            },
            fill: 'tozeroy',
        };

        var layout = {
            showlegend: false,
            autosize: false,
            width: 600,
            height: 600,
            bargap: 0,
        };
        var datas = [dataForPlotly];
        Plotly.newPlot('graph', datas, layout, {staticPlot: true} );
    }
}

My HTML code :

<div class="container">
    <div class="row">
        <div class="col-sm-8">
            <div id="graph"></div>
        </div>
    </div>
</div>

Here is the graph that i should obtein (In yellow a random area that i selected) :

The graph

The graph that I obtain in histogram mode:

enter image description here

and in bar mode :

enter image description here

Here is the values to make the graph :

enter image description here

Any help is welcome. Thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!