bar chart question

For questions about using Classic.

Post » Tue May 27, 2008 5:04 pm

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
B
1
G
4
Posts: 4
Reputation: 1,033

Post » Tue May 27, 2008 5:46 pm

I posted an example in the Uploads forum.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Wed May 28, 2008 3:53 am

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??
B
1
G
4
Posts: 4
Reputation: 1,033

Post » Wed May 28, 2008 9:13 am

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

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.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Wed May 28, 2008 2:45 pm

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.
B
1
G
4
Posts: 4
Reputation: 1,033

Post » Wed May 28, 2008 3:25 pm

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.

[code:1mg7qowh]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.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Wed May 28, 2008 5:17 pm

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.
B
1
G
4
Posts: 4
Reputation: 1,033

Post » Thu May 29, 2008 12:12 am

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.
B
3
S
2
G
4
Posts: 130
Reputation: 1,735

Post » Thu May 29, 2008 3:23 pm

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.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests