Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda