Click Legend to Hilite Line on Chart

Create fast, sprite powered games with Animation Engine, co-developed with DerBrill Software!

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm
Location: Seattle, USA

Click Legend to Hilite Line on Chart

Post by townsend » Fri Dec 20, 2013 9:03 pm

I'm using a line chart with potentially 10 lines. When the user clicks on a element in the Legend, I want the corresponding line on the Chart to become hilited. In order to do this, I would be changing the line width. But since the Legend Buttons are created dynamically, by Animation Engine, I need to be able to use some code to add an On MouseUp handler to each of the buttons, which to increase the line width.

What's the best way of doing this?

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm
Location: Seattle, USA

Re: Click Legend to Hilite Line on Chart

Post by townsend » Sat Dec 21, 2013 12:46 am

Here an example that illustrates one way this can be done.

Code: Select all

on mouseUp
     put "click me" into temp
     create button temp
     set the loc of it to 200,100
     set the width of it to 60
     set the height of it to 30
     set the script of btn "click me" to "on mouseUp" & cr & "beep" & cr & "end mouseUp"
     set the label of btn "click me" to "I'm New"
end mouseUp

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Click Legend to Hilite Line on Chart

Post by Simon » Sat Dec 21, 2013 2:52 am

Hi townsend,
I wasn't sure when you first asked the question if you knew where the legend icon would be... now I know.
Since they are static why don't you just place transparent buttons on top of them?
Setting scripts is a pain because they are limited when running on a stand alone.

If you hide the buttons when they are not needed then they can't be activated.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Click Legend to Hilite Line on Chart

Post by malte » Sat Dec 21, 2013 9:08 am

You can set a behavior of the button...

Post Reply

Return to “Animation Engine”