Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: JDavies1000 on July 31, 2014, 07:24:46 pm

Title: Shape Script and Tag Values
Post by: JDavies1000 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
Title: Re: Shape Script and Tag Values
Post by: ZuluTen 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();      
}
Title: Re: Shape Script and Tag Values
Post by: qwerty 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.
Title: Re: Shape Script and Tag Values
Post by: RoyC 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.