Jump to content

Creating a "score-bar"?


This topic is 6531 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello

I have a database in which i have a number of persons. Each person has a score of how many entries he have made in another database (ex John Doe - 11, Mick - 5).

Now, I would like to make a graphical "score-bar" representing how many entries the persons have made, meaning John Doe's bar is 11 units long, Mick's is 5 units long and so on. - And I need it to get on the web using CDML!

Has anybody got any idea of how I could do this?

I have thought about making a calculation field that puts a number of vertical bars in a text field, corresponding to the persons number of entries, but I cannot figure out how to write this calculation.

So: John Doe: 11 = "|||||||||||" - or something like that

Any ideas?

Link to comment
Share on other sites

Hello Lange,

There are various ways of doing this. An example of a formula you might wish to use is:

Substitute(Right(10^score, score), "0", "|")

Where 'score' is the name of a number field which has the number of entries each person has made in the other database.

Link to comment
Share on other sites

Hey Ray,

I temporarily used this calculation, which I probably hacked from you in some other posts, but then discovered lately that this calc wouldn't work if the "score" was higher than 214.

I have reverted to some other method, not suitable in this case, but do you have any idea how to go around this limitation ?

Link to comment
Share on other sites

Hi Ugo,

Yes, the 64k extended floating point limits of the FMP calc engine in v6 are breached after 214.

If you really need to extend it beyond that there are various ways to go about it, but using the same principle, you can step up the limit in blocks of 214 by capping the variable and appending additional phrases. So for instance, to generate from 0 to 428 pipe characters you could use:

Substitute(Right(10^Min(214, score), Min(214, score)), "0", "|") &

Substitute(Right(10^Min(214, score - 214), Min(214, score - 214)), "0", "|")

It can of course, be extended out a long way in this fashion, but to do so would not necessarily provide the best solution - depending on the context. As I remarked at the preface to my previous post, there are various alternative ways to do what Lange was requesting. wink.gif

Link to comment
Share on other sites

Hi Ray & Ugo

Thanx for your quick responses! The proposed solution from you Ray works like a dream and does what it is supposed to do, but I probably will run into problems with the 214 character-limit. I think some of my records will go as high as 1000. I will try to extend the second proposal from Ray to cover 5 * 214 - that should be enough, I think. I will test and see if it works acceptably.

Chr. Lange

Link to comment
Share on other sites

Hi Lange,

Whew. 1000 huh? That's going to be quite some graph. By my reckoning, using 10 point Times it will run to about 20 inches. You'll have to use very small font sizes or hope that your database will only be viewed by folks with very large monitors.

Notwithstanding that, here is something that might save you some time. The following variation on a theme:

Substitute(Right(10^Int(score / 10), Int(score / 10)), "0", "||||||||||") &

Substitute(Right(10^Mod(score, 10), Mod(score, 10)), "0", "|")

- will generate up to 2,149 pipe characters. That should be enough for your current requirement (and with some headroom to spare). wink.gif

Link to comment
Share on other sites

Hi again

Thanx for the code!

Yeah, I see your point about the long line of characters, but the idea was to give a graphical impression of the people doing a lot of registrations (they get "long bars"). And most of they people will not, I expect exceed, lets say 100, which will be viewable without scrolling - the rest just vanishes to the right.

The table will look like:

John Doe - 37 - ||||||||||||||||||||||||||||||||||||||

Mick - 7 - |||||||

I think it will work ok - thanks again

Chr. Lange

Link to comment
Share on other sites

This topic is 6531 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.