@anushr opened this Issue on September 4th 2009

Allow charts to track click events and perform a certain action. The action taken can be:

  1. Javascript - a JS function is invoked
  2. URL - a new URL is loaded into the browser window
    3. Datafile - a new datafile is loaded into the chart

Open Flash Chart does support on-click events (see Open Flash Chart On-click).

I propose adding support for a "special" column (like "label"), say "click_url", which Piwik's widgetize module would recognize and add on-click functionality to the chart. Each data value in that column would either be a JS function, a URL or a [module,action] pair (for datafile).

I think adding interactivity to the charts would be a great feature!
Keywords: chart, graph

@anushr commented on September 15th 2009

Attachment: on-click support in pie charts
Pie.php.patch

@robocoder commented on September 6th 2009 Contributor

Piwik already uses this feature but does not expose it as a general purpose feature to widget authors.

@robocoder commented on September 6th 2009 Contributor

"Datafile" isn't possible with the current version of OFC2.

@robocoder commented on September 6th 2009 Contributor

URL is already supported by the Evolution chart. See Piwik_Visualization_Chart->setAxisXOnClick().

@mattab commented on September 8th 2009 Owner

anush, did you try using Piwik_Visualization_Chart->setAxisXOnClick() ?

Does it work as expected for you? if yes, we could close the ticket.

@anushr commented on September 8th 2009

I did take a look after vipsoft mentioned it. I wasn't having too much luck with it for my development purposes. Then again, my dev environment is in bit of disarray at the moment. Give me another day or two -- I can delve a bit more deeper and definitively say "yay" or "nay".

Thanks for your diligence.

@anushr commented on September 15th 2009

Ok, here are my thoughts...

  1. The evolution chart is clickable, but not extensible. It currently is hardcoded to link back to the CoreHome module only. I think it would be great if we could make this a bit more extensible such that the on-click could be a custom JS call or URL. See: Piwik_ViewDataTable_GenerateGraphData_ChartEvolution->initChartObjectData()
  2. The other two types of charts (pie and vertical bar), although they have the setAxisXOnClick() method, the on-click values do not appear to be used during rendering. I believe the Piwik_Visualization_Chart->customizeChartProperties() method should be updated to take the on-click values into account (see Pie.php.patch).
  3. Even with the on-click values being accounted for in the charts, there is currently no easy way to set the on-click values from the controller (or maybe I just dont know how?). It appears as though there is no way to set the on-click event on a "per-chart" basis -- I can only see a way to set the on-click on a "per-datapoint" basis. I feel it would be useful for the onclick event to derive data from a column on the dataTable itself. So, I think the setAxisXOnClick() (or perhaps a new method) should be able to take a URL pattern or JS function and a column name from which a dynamic value should be derived. e.g:
#!php
// %s is dynamically replaced by the value in the specified column (in this case, "label")
setAxisXOnClickURL('http://example.com?page=%s', 'label'); 
setAxisXOnClickJS('alert(%s)', 'label');
@mattab commented on September 22nd 2009 Owner

1- agreed. Would you be able to provide a patch for this?
2- patch looks good, we can commit, let's wait for 1) and 3)
3- again, agreed with the concept. if you are able to provide a patch for this, it would help getting it done.

@anushr commented on September 24th 2009

sure, i'll try to take a stab at 1 & 3.

@mattab commented on January 8th 2010 Owner

anush, any update?

@mattab commented on July 29th 2010 Owner

no news from dev, wont fix. Please comment if any update.

This Issue was closed on July 29th 2010
Powered by GitHub Issue Mirror