Home forums Using CanvasJS Whole canvas as a hyperlink

Tagged: 

This topic contains 5 replies, has 4 voices, and was last updated by  Sanjoy 6 months, 4 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #9479

    xDanbo
    Member

    Hello.

    How can I make the whole chart canvas to be linked to another page? I tried to add the “a” tag to the chart canvas container, but it allows clicking and transferring to another page only when you click on the tooltip. What I need is to be able to click in any place of the chart and go to a certain page.

    #9491

    ashishraaj
    Participant

    Use onclick to make whole canvas to be linked to another page/ url as shown below,
    <div id="chartContainer" onclick="redirect()"></div>
    then add a function “redirect” to your javascript code, which will contain a link to another page/ url

    function redirect()
    {
        window.location = "http://canvasjs.com/" ;// loads webpage in the current tab
        // window.open = "http://canvasjs.com/" ;// loads webpage in the new tab
    }
    #9494

    xDanbo
    Member

    Thank you.

    #9509

    xDanbo
    Member

    Hmm, it appeared to be working only on desktop browsers. On mobile devices you have to tap at least 10 times to trigger the ‘onclick’ event. Do you know what the problem is?

    #10087

    vinay
    Member

    Hi, please help me how to create hyperlink to each sub chart of the canvas??

    #10486

    Sanjoy
    Moderator

    vinay,

    You can href the chart-container div. Here is an example.

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

You must be logged in to reply to this topic.