Click Events for (most types of) Bar Charts

Click Events for (most types of) Bar Charts

Postby whtt-eric » Sat Nov 22, 2008 6:36 pm

Hi,

First of all, I want to say that I LOVE this chart library. Combined with this Rails plugin, I was able to quickly and easily produce some really nice looking charts for a RoR project I'm doing for the company I work for, Assembla.com (shameless plug).

The only thing that was missing was clickable bar elements. Since our client needed to have clickable elements in their charts, one of my team and I went in and made some adjustments to the various types of bar charts to allow for click events.

Charts that support the "on-click" property are:
  • Bar
  • Horizontal Bar
  • 3D Bar
  • Glass Bar
  • Outline Bar
  • Sketch Bar

Attached is a zip file containing the modified source files.

I hope this helps some people out.

monk.e.boy, if you end up using this code in a future release, and you include a list of contributors somewhere, I would appreciate it if you could include our information:

Eric Salczynski (Assembla, LLC - eric@wehaventthetime.com)
Duc Duong (Assembla, LLC - duc.assembla@gmail.com)


Thanks,
Eric
Attachments
ofc-bar_charts-source.zip
(18.65 KiB) Downloaded 130 times
whtt-eric
 
Posts: 5
Joined: Tue Nov 18, 2008 10:25 pm

Re: Click Events for (most types of) Bar Charts

Postby monk.e.boy » Sun Nov 23, 2008 11:45 am

Thanks for the code, I will check it out and try to merege it :-)

If I do I'll list you guys on the downloads page? :-)

thanks again :-)
monk.e.boy
Founder & Project Lead
 
Posts: 653
Joined: Thu Sep 04, 2008 10:06 pm

Re: Click Events for (most types of) Bar Charts

Postby hhanna » Tue Nov 25, 2008 7:39 pm

If possible, please include on-click support for stacked bar charts, too.
hhanna
 
Posts: 2
Joined: Mon Nov 24, 2008 5:25 pm

Re: Click Events for (most types of) Bar Charts

Postby filipe » Wed Dec 17, 2008 2:18 pm

hi there,

first of all, thanks for the great library and for this piece of code. it's exactly what I was looking for!

i got a bit confused: there's only .as code in the zip. what about the methods to set the click events on the library? (ex: $bar->set_click())

if you could give a little example on that i'd be very grateful

thanks,

Filipe
filipe
 
Posts: 2
Joined: Mon Dec 15, 2008 6:48 pm

Re: Click Events for (most types of) Bar Charts

Postby whtt-eric » Wed Dec 17, 2008 3:30 pm

Yes you will probably have to add the method to support the new functionality to the PHP library. I was using a Ruby on Rails plugin that needed to be modified as well.

I looked at the "php-ofc-library" and I think all you need to do is to add this method to the bar_base class in ofc_bar_base.php

/* put me in ofc_bar_base.php */
function on_click( $event )
{
$tmp = 'on-click';
$this->$tmp = $event;
}


Let me know if that works for you.


Also, I don't think this patch has been applied to the download yet, so if you haven't already, you will have to apply the patch and re-compile the Flex code.


Eric
whtt-eric
 
Posts: 5
Joined: Tue Nov 18, 2008 10:25 pm

Re: Click Events for (most types of) Bar Charts

Postby kenoxh » Thu Dec 18, 2008 6:54 pm

could you give a example the JSON that recived open-flash-chart.swf ???

thanks
kenoxh
 
Posts: 1
Joined: Thu Dec 18, 2008 6:14 pm

Re: Click Events for (most types of) Bar Charts

Postby dz_ » Thu Dec 18, 2008 11:30 pm

Each "value" needs to be an object with a "top" and an "on-click":

Code: Select all
  {"type":"bar_glass", ...
   "values":[ {"top":7, "on-click":"http://www.google.com"}, ... ] },
dz_
OFC Genius
 
Posts: 591
Joined: Tue Sep 09, 2008 12:56 am

Re: Click Events for (most types of) Bar Charts

Postby whtt-eric » Wed Jan 07, 2009 8:29 pm

I meant to do this earlier, but never got around to it. Sorry, guys.

Here's a zip file containing the re-compiled open-flash-chart.swf with support for bar on-click events. There are some examples of usage in there as well.

Unfortunately, my compiled output was about twice as big as the original. I compiled it using the free Flex SDK with mxmlc from the command line. If anyone has any tips on how to shrink the output, I would appreciate the input.

http://www.wehaventthetime.com/ofc/ofc-bar_charts.zip


Eric
whtt-eric
 
Posts: 5
Joined: Tue Nov 18, 2008 10:25 pm

Re: Click Events for (most types of) Bar Charts

Postby dz_ » Thu Jan 08, 2009 12:04 am

Thanks Eric
Here is a thread that discusses the size of the SWF: http://forums.openflashchart.com/viewtopic.php?f=5&t=284
dz_
OFC Genius
 
Posts: 591
Joined: Tue Sep 09, 2008 12:56 am

Re: Click Events for (most types of) Bar Charts

Postby pullmonkey » Thu Jan 08, 2009 9:13 pm

Nice work Eric, it worked perfectly. A rails example for Bar chart click events can be found here.
pullmonkey
 
Posts: 2
Joined: Tue Sep 23, 2008 3:31 am

Next

Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest