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

256
Views
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 answers
Answer question

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 Report
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!