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

95
Vistas
how to access highstock properties in this example

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Highstock Example</title>
        <style type="text/css">
#container {
    height: 400px;
    min-width: 310px;
}

        </style>
    </head>
    <body>

<script src="../../code/highstock.js"></script>
<script src="../../code/modules/data.js"></script>
<script src="../../code/modules/exporting.js"></script>
<div id="container"></div>
        <script type="text/javascript">
Highcharts.getJSON('https://demo-live-data.highcharts.com/aapl-ohlc.json', function (data) {
    // create the chart
    Highcharts.stockChart('container', {
        rangeSelector: {
            selected: 2
        },
        title: {
            text: 'AAPL Stock Price'
        },
        series: [{
            type: 'ohlc',
            name: 'AAPL Stock Price',
            data: data,
            dataGrouping: {
                units: [[
                    'week', // unit name
                    [1] // allowed multiples
                ], [
                    'month',
                    [1, 2, 3, 4, 6]
                ]]
            }
        }]
    });
});

        </script>
    </body>
</html>

Hi, this is my first post on stack so plz correct if wrong. I wish to know how do I access the properties of highstock chart in the above example. eg. if i want to set the 'selected' property of 'rangeselector' externally through code how to do it. Any help will be highly appreciated.

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can:

  1. Store a chart in a variable:

  const chart = Highcharts.stockChart('container', {...});

  chart.rangeSelector.buttons[0].element.dispatchEvent(new Event('click'));
  1. Use load event:

  Highcharts.stockChart('container', {
    chart: {
      events: {
        load: function() {
          this.rangeSelector.buttons[0].element.dispatchEvent(new Event('click'));
        }
      }
    },
    ...
  });
  1. Use a callback function:

  Highcharts.stockChart('container', {
    ...
  }, function(chart) {
    chart.rangeSelector.buttons[0].element.dispatchEvent(new Event('click'));

Live demo: http://jsfiddle.net/BlackLabel/3L7uvm4n/

API Reference:

https://api.highcharts.com/class-reference/Highcharts#.chart

https://api.highcharts.com/highcharts/chart.events.load

about 4 years ago · Juan Pablo Isaza Denunciar
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