naver / billboard.js

📊 Re-usable, easy interface JavaScript chart library based on D3.js
https://naver.github.io/billboard.js/
MIT License
5.85k stars 355 forks source link

Line graph highlight line instead of matching X group #2791

Open KindarConrath opened 2 years ago

KindarConrath commented 2 years ago

Description

Question/Feature Request I am not sure if it is possible and I'm not finding it, or if it's not an option right now. I want to have a line graph, but when I mouse over a point, it shows all the points on the LINE not all the points on the same X intersection.

Is it currently possible to do this?

Thank you for your time.

netil commented 2 years ago

Hi @KindarConrath, isn't provided as direct option, but you can make adding some customization.

// handler for data point visibility
function showHidePoints(d, element) {
    const {id} = d;

    this.$.circles
        .filter(d => d.id === id)
        .style("opacity", element.style.opacity === "1" ? 0 : 1);
}

bb.generate({
    data: {
        columns: [
            ["data1", 30, 200, 100, 400, 150, 250],
            ["data2", 50, 20, 10, 40, 15, 25]
        ],
        type: "line",
        onover: showHidePoints,
        onout: showHidePoints
    },

Jul-25-2022 23-24-27

checkout the working example

KindarConrath commented 2 years ago

Interesting, I see what you've done. It shows the circles, but the tooltip stays the same, I will see if I can fiddle with the tooltips to make the same thing happen for that.

Thank you for the information.