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

0 favourites
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • 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.

  • GraphBars.capx

  • Hey 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.

  • try this one..

    gRAPHbAR2.capx

  • Now that's what I'm talking about! Wow, thanks a lot 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?

  • just use instance variable...

    gRAPHbAR3.capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!

  • 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?

  • Bump...

  • Bump

    ..don't worry guannstar ... I did not forget, just a different time zone

    so first...

    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

    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..

    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

    so you can do something like this

    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..

  • Lol, I have to admit... I kind of thought you did forget; but OMG, thank you so much! You have been such a great help. I understand how you created the twelve month buttons now. I can't say it enough man, thanks again. You're the best!

    P.S. I checked out you're artwork. It's very interesting... dark yes, but very interesting! I personally like "Hiding Inside Myself" and "Desperation". They remind me of Dali pieces.

  • Hey I followed your instructions and set it up and my app. I did it correctly, but there's still one slight problem. For some reason, when I set it all up, the bar and number above it keep floating away from the clamped spot on the chart. Can you tell me? Why is this happening?

  • from what I can see from the picture..you probably did not put bar origin image point on bottom..

    If I'm wrong, please upload simple capx...

  • Hey korbaach, yeah, you were right about the image point. I fixed the bar clamp problem, but there are still few little things I need to fix.

    For instance:

    1. the text linked to the bar is still offset (it keeps floating a bit to the right)

    2. when I slide my page/layout (I use a slide function in my app) to get to the chart, the year text in the list keeps shrinking.

    (Before Sliding)

    (After Sliding)

    [sidenote:] Also, I was wondering, how can I put a space area between each bar, rather than having them pressed up right against each other?

  • 1. the text linked to the bar is still offset (it keeps floating a bit to the right)

    the same problem as with bar sprite..click on text object and set

    [quote:rsarlnc9]2. when I slide my page/layout (I use a slide function in my app) to get to the chart, the year text in the list keeps shrinking.

    try this..click on list object..set

    [quote:rsarlnc9] Also, I was wondering, how can I put a space area between each bar...

    in example i use bar sprite (h=250px;w=22px)...so in code

    if you replace 22 with 30..you'll have a 8px space between each bar...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)