Jump to content

Onclick Event for Column Chart Series - Open Report


Recommended Posts

I'm trying to add some custom functionality to the Caspio column chart. I want to add a click event to the columns, so that the user can click on a column and have a report pop up.

It seems like it should be pretty simple. If the user clicks on the column, open a new window with this URL. However.... it seems that the columns are clicking themselves on load? Or even at all times?

The script below will immediately go to www.######.caspio.com/'my_url'. First, I'm not sure why it isn't going straight to the URL, it seems to be adding it as a path instead. Second, I don't know why it automatically goes to that site on load, instead of waiting for the click event.

Then, I tried adding a setTimeout function to it, cause I thought well maybe it just clicks on start for some weird reason. Well, after the timeout, it opens all windows at the same time (all still going to the weird url too as a path). Not sure what is going on. This seems like it should be possible.

  setTimeout(function(){
    document.querySelector('[class*=highcharts-color-0]').onclick=window.open('www.capitalglassonline.com');
    document.querySelector('[class*=highcharts-color-1]').onclick=window.open('www.yahoo.com');
    document.querySelector('[class*=highcharts-color-2]').onclick=window.open('www.google.com');
    document.querySelector('[class*=highcharts-color-3]').onclick=window.open('www.capitalglassonline.com');
    document.querySelector('[class*=highcharts-color-4]').onclick=window.open('www.capitalglassonline.com');
    document.querySelector('[class*=highcharts-color-5]').onclick=window.open('www.capitalglassonline.com');
  }, 3000);

I've also tried without setTimeout and in a DataPageReady listener as well, with no luck.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...