0

I am calling my bubbleChart via chart.js API and trying to access x,y values of points but I get this very strange behavior

console.log(bubbleChart._metasets[1].data)
console.log(bubbleChart._metasets[1].data[0])

enter image description here

when I access object.x or object.y I get those 350.017 and 537.199 for every point even in console it shows x,y with correct values. What is going on?

of course I tried also this, but same result

bubbleChart.getDatasetMeta(1).data[0]

here is the fiddle which show strange behavior console.log shows always same data for different endpoints but if you put in console bubbleChart._metasets it shows correct x,y values

https://jsfiddle.net/vxb792pe/

Mi Ro
  • 740
  • 1
  • 6
  • 31
  • [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) – charlietfl Jan 09 '22 at 21:39
  • there is no error, it just returns different value what is shown in screenshot....x,y doesnt match with x,y it should return – Mi Ro Jan 09 '22 at 21:57
  • 1
    Hard for anyone to help without a [mre] that demonstrates the issue – charlietfl Jan 09 '22 at 21:58
  • ok I created a fiddle for this...it behaves differently than in browser but also wrong – Mi Ro Jan 09 '22 at 22:15

1 Answers1

0

actually I found a workaround

var xAxis = bubbleChart.scales['x'];
var yAxis = bubbleChart.scales['y'];

pointx = xAxis.getPixelForValue(bubbleChart.data.datasets[i].data[0].x)
pointy = yAxis.getPixelForValue(bubbleChart.data.datasets[i].data[0].y)
Mi Ro
  • 740
  • 1
  • 6
  • 31