bar chart question

This forum is currently in read-only mode.
  • I was looking at your new bar chart graphing thing and I realy couldn't figure out how to use it. I.E. How to script it with python and how to set the number of bars and the values exc... My goal is to make a chart with variable bars based on what is in an outside file. I am hopeing it can be done in context. thanks for any help in advance

  • I posted an example in the Uploads forum.

  • I could probily use that without ever figuring out what it does. All I can see is some text and a bar chart and two text manipulators. The odds of me figureing out what that does without an explanation in nil I am afraid. Is there code somewhere??

  • It's 2 events and I explained the data format .

    Essentially it loads a file and then for every item (every '|') it finds, it parses out the relevant data and adds it.

    Substrings are parts of a string which are separated by a character, in this case | and ;.

    Once we split it into strings of |, you then retrieve the text before the first ;, before the second ;, etc.

  • do all bar charts have a data.txt file or was something done to define that... I understand twhat the program is doing I don't understand why it is doing what it is. I could use it as is ... It just seems that part of what is going on is hiding from me or I don't understand what the text control is doing.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This may be helpful:

    http://69.24.73.172/scirra/wiki/index.php?title=Events

    If you insert any object, it won't do much if you don't set up some events to modify it (or python scripting).

    In this case, Bar Chart displays an empty chart when inserted. To make it load data.txt, I created a Start of Layout condition, so when you open this layout data.txt is loaded. You could simply insert the bars using the Insert Bar action with preset data, or data from another source.

    Text Manipulator is another plugin which performs handy operations on strings. In the sub event for Start of Layout I use a loop to add as many bars as there are items in data.txt; the code is admittedly nontrivial especially if you haven't done much string parsing.

    TextManipulator2.GetSubstring(";", 0)[/code:1mg7qowh]
    This expression extracts the text before the first instance of a ';' in a string.
    
    If we take:
    [code:1mg7qowh]10;Item 1;233;11;11[/code:1mg7qowh]
    This will be 10. 
    
    [code:1mg7qowh]TextManipulator2.GetSubstring(";", 1)[/code:1mg7qowh]
    Will return 'Item 1', the name of the bar.
    
    If you have further questions, feel free to ask.
  • That probily helps a bunch (not ready to completly test it though). I like the way that is setup where I can use python to write out a graph and the graphing function is compiled, I would like to see more graph functions... My program will probily have to wait til friday though.. (time is tight).. I plan on posting to http://www.csounds.com when I get a working version.

  • Heh, you answered a question I was about to ask, Rich.

    I was working on doing that very same thing that the text manipulator does using system text events and it was rather hard to work out. (I remember back at the start of high school I could do it easily with QBasic and now I'm having trouble doing it with Construct... am I going forwards or backwards?)

    Well that was definitely helpful. Thanks, Rich.

  • I think there's some things that can be done to make substrings easier.

    Perhaps a 'For each substring'' condition so you can loop a string easily. Substrings are highly useful for custom data storage, it'd be good to get them as simple as possible.

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