Closed jduncanRadBlue closed 3 months ago
Hi
Sorry I have never used this functionality myself before. Can't really help you much here. Having said that, you still can ask the same question at https://github.com/leeoniya/uPlot/issues Hopefully there are more people that can help you with it!
Thanks @leeoniya I have been looking at that and trying to figure out how to access the cursor and location, data in the vue component.
@skalinichev How do I access the data in the chart based on cursor location? I have the @create on the component saving a ref to the chart but the cursor.idxs are always null. Any ideas?
See this code from uPlot:
u.over.addEventListener('click', e => {
const [xIdx, yIdx] = u.cursor.idxs;
const xVal = u.data[0][xIdx];
const yVal = u.data[1][yIdx];
const xPos = u.valToPos(xVal, 'x');
const yPos = u.valToPos(yVal, 'y');
let popup = document.createElement("div");
popup.classList.add("popup");
popup.textContent = yVal;
popup.style.left = xPos + "px";
popup.style.top = yPos + "px";
u.over.appendChild(popup);
});
}
Here is my code and screen shot of the chart.value being logged to the console. the cursor.idxs is an array of 6 null values
<UplotVue ref="timelineContainer" :options="options" :data="plotData" @click="handleMenuAction" :key="graphKey" @create="onCreate"/>
function handleMenuAction(){
console.log(chart.value)
}
I have a simple graph with data plotted. When a user right clicks on data, I display a context menu with a few options, one of them being a simple "Get Info" option where I'd like to display a dialog containing more detailed data.
I'm having a hard time getting to the data within the graph. So far I have tried using the uplot cursor.idxs to get the location of the click from this example: https://jsfiddle.net/w07t8q4g/
but I'm getting errors:
I am not sure how to accomplish this. Can anyone help? Thanks so much!