Author Topic: Shape Script and Tag Values  (Read 3793 times)

JDavies1000

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Shape Script and Tag Values
« on: July 31, 2014, 07:24:46 pm »
Hi,

I want to create a shape script that has a number of inner rectangles that aim to look like bar charts.

----------------- 100%
------------        50%
---                   20%

It's easy to draw them. What I would like to be able to do it have the values driven from a tag value so that changing the tag value will alter the size of the bar.

I can read the value as "#TAGS:BAR1#" but when I use that as a variable to change the size of the bar the shape vanishes (possibly due to the type being non-numeric??).

Any idea how I can do this? Pint for the best answer.

Cheers,
Jez

ZuluTen

  • EA User
  • **
  • Posts: 56
  • Karma: +0/-0
    • View Profile
Re: Shape Script and Tag Values
« Reply #1 on: July 31, 2014, 08:15:06 pm »
The following is crude in the sense that it tests for one of three values, but the principles are sound - you should be able to replace the repeated 'test and move to' with a set of instructions which use your scaled variable to determine the amount of movement. I don't think that there is a Shape Script method which will support infinitely variable values.

Code: [Select]
decoration mycolouredshape

{
      
noshadow=true;
      
if(HasTag("Confidence","High"))

      {
      startpath();
      moveto(0,0);
      lineto(0,200);
      lineto(200,200);
      lineto(200,0);
      lineto(0,0);
      endpath();
      setfillcolor(0,255,0);
      }

else if(HasTag("Confidence","Medium"))
      {
      startpath();
      moveto(0,0);
      lineto(0,100);
      lineto(100,100);
      lineto(100,0);
      lineto(0,0);
      endpath();
      setfillcolor(255,220,0);
      }

else if(HasTag("Confidence","Low"))
      {
      startpath();
      moveto(0,0);
      lineto(0,50);
      lineto(50,50);
      lineto(50,0);
      lineto(0,0);
      endpath();
      setfillcolor(255,0,0);
      }

else
      {
      setfillcolor(200,200,200);
      }

fillpath();      
}
« Last Edit: July 31, 2014, 08:20:26 pm by ZuluTen »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Shape Script and Tag Values
« Reply #2 on: July 31, 2014, 08:29:09 pm »
It should be a bit easier when using sub-shapes but that's just a marginal difference. IIRC there's a sample script in the help which looks a bit like a bar graph.

q.
« Last Edit: July 31, 2014, 08:30:13 pm by qwerty »

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Shape Script and Tag Values
« Reply #3 on: August 01, 2014, 08:50:05 am »
What version of EA are you using? In EA 11 there is a Charting facility that should do what you want and a lot more besides.
Best Regards, Roy