Home forums Using CanvasJS Hover on hidded bar

This topic contains 6 replies, has 2 voices, and was last updated by  Vishwas R 2 months, 1 week ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #22786

    as3script
    Member

    I need the same hover effect on Canvas js bar graph.

    https://jsfiddle.net/alidingling/30763kr7/

    Would it be possible to hide the bars and shows bar only on hover.

    -> initially bars will be hidden
    -> on hover bars, it will display the hovered bar only.

    #22787

    as3script
    Member

    Another issue:

    Blue dots on axisX is not visible. hiding below the line.
    Would like to show the clear dots.

    any solution ?

    Please execute the below code–>

    <!DOCTYPE HTML>
    <html>
    <head>
    <script type=”text/javascript”>
    window.onload = function () {
    var chart = new CanvasJS.Chart(“chartContainer”,
    {
    title: {
    text: “Setting lineDashType for axisX”
    },
    axisX: {
    lineDashType: “dot”,
    lineThickness: 2
    },
    axisY: {
    gridThickness: 0
    },
    data: [
    {
    type: “line”,
    dataPoints: [
    { x: 10, y: 4 },
    { x: 20, y: 3 },
    { x: 30, y: 0 },
    { x: 40, y: 0 },
    { x: 50, y: 0 },
    { x: 60, y: 9 },
    { x: 70, y: 3 },
    { x: 80, y: 4 },
    { x: 90, y: 7 }
    ]
    }
    ]
    });
    chart.render();
    }
    </script>
    <script type=”text/javascript” src=”https://canvasjs.com/assets/script/canvasjs.min.js”></script>
    </head>
    <body>
    <div id=”chartContainer” style=”height: 300px; width: 100%;”></div>
    </body>
    </html>

    #22794

    Vishwas R
    Keymaster

    @as3script,

    I need the same hover effect on Canvas js bar graph.
    https://jsfiddle.net/alidingling/30763kr7/

    You can achieve this either using stripLines as shown in this JSFiddle or crosshair as shown in this JSFiddle.

    -> initially bars will be hidden
    -> on hover bars, it will display the hovered bar only.

    Please take a look at this JSFiddle.


    Vishwas R
    Team CanvasJS

    #22802

    as3script
    Member

    Thanks for your reply. I will look in to this solution.

    Cheers.

    #22856

    as3script
    Member

    @vishwas

    I am integrating with React, and there I dont have

    chart.render()
    instead
    I am using CanvasJSChart component ==> <CanvasJSChart options={options} containerProps={style} />

    So, in this case how can I access options.data ? or axisX to change crosshair thickness ?

    Thanks in advance.

    #22857

    as3script
    Member

    findout ==> using ref :-)

    #22865

    Vishwas R
    Keymaster

    @as3script,

    Glad that you figured out to get access to the chart with the help of ref :) Please take a look at React Gallery for more examples on using React Chart Component.


    Vishwas R
    Team CanvasJS

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.