Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

260
Visualizações
Echarts: how to get x and y values during mouse events

I have the following chart:

const quotesChart = echarts.init(quotesContainer);
quotesChart.setOption({
  dataset: [
    { source: quotes }
  ],
  xAxis: [
    {
      type: 'category',
    },
  ],
  yAxis: [
    {
      position: 'left',
    }
  ],
  series: [
    {
      name: 'Quotes',
      type: 'line',
      datasetIndex: 0,
    }
  ]
})

quotesChart.getZr().on("mousemove", function(params){
  const pointInPixel = [params.offsetX, params.offsetY];
 
  // how do I get x and y values for current mouse position?

  // I see some examples using convertFromPixel but I don't know how to use these coordinates to get x and y values
  const pointInGrid = quotesChart.convertFromPixel('grid', pointInPixel);
})

The quotes dataset source looks like: [{period: '20/01/2021', value: 15.59}, {period: '21/01/2021', value: 15.99}]

I need to get values from axis x and y (ex: 20/01/2021 and 15.59) but I don't know how, I only have the grid coordinates.

Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It was simpler than I thought, it turns out pointInGrid[0] is the position of the series array, so I did: quotes[pointInGrid[0]] to get the series item I needed.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda