How do I create a bar graph based on textbox inputs?

Get help using Construct 2

Post » Fri Oct 16, 2015 2:16 am

Hello all! How do I create a bar graph (change height of bar) based on the number inputs from a textbox? I want the number 1 to equal 10 pixels. For example, if they input the number 2 into the textbox, the bar on the graph should move up 20 pixels.

capx here: https://dl.dropboxusercontent.com/u/541 ... Graph.capx

Thanks.
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Fri Oct 16, 2015 3:16 am

Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Post » Fri Oct 16, 2015 3:36 am

Hey @korbaach. That's kind of what I'm looking for, but instead of creating a new bar each time you type in a new number in the textbox, I need the new number in the texbox to add on to the first bar.
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Fri Oct 16, 2015 3:50 am

try this one..

gRAPHbAR2.capx
Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Post » Fri Oct 16, 2015 4:08 am

Now that's what I'm talking about! Wow, thanks a lot @korbaach. It's perfect! I have one more question though (sorry... last on, I promise lol). That's just how it's done with one bar. But, with multiple bars; how would the text box know which bar to effect? For example, if one bar on the graph represents 'Jan' and another bar on the graph represents 'Feb', how would the textbox know the current month, so it could effect the correct month/bar on the graph?
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Fri Oct 16, 2015 5:19 am

just use instance variable...

gRAPHbAR3.capx
Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Post » Fri Oct 16, 2015 5:39 am

Wow @korbaach, thanks so much! You're amazing. I'll play around with it and get back to you after I incorporate into my app, just to tell you how it went. Anyways, thanks again. May a thousand blessings be upon you!
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Fri Oct 16, 2015 3:08 pm

Hey @korbaach, I guess I actually do have just two more question for you. How could I make it so that when you input data, the data on the graph only shows up if it's the correct year (2015)?

Also, in the gRAPHbAR3 capx, can you please explain to me exactly how you created the twelve month buttons by using only one object?
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Fri Oct 16, 2015 10:55 pm

Bump...
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Sat Oct 17, 2015 7:53 am

Bump :D
..don't worry @guannstar ... I did not forget, just a different time zone :)

so first...
guannstar wrote: How could I make it so that when you input data, the data on the graph only shows up if it's the correct year (2015)?

..If I correctly understood,you want something like this

Image

gRAPHbAR_4.capx

i use Array(12,11,1)...x(width)=12(months); y(height)=11(years..2010...2020);..z(depth)=1
to store data for each year...


second..
guannstar wrote: can you please explain to me exactly how you created the twelve month buttons by using only one object?


I use button.iid Common features
Image

so you can do something like this
Image
if you click on button with iid=0 you will activate only bar with iid=0..etc..

you'll also notice that I used bar.iid to store values inside array...set value on(bar.iid,row)..
so..frirst if bar is "active" that's meen...array set value on (0,row)..second ..(1,row)...etc..
Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Allardje, R0J0hound, Rudi55, sublimate, Vinterstille and 1 guest