Book a Demo

Author Topic: Creating a data chart using the EA API  (Read 11014 times)

Ian Mitchell

  • EA User
  • **
  • Posts: 507
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Creating a data chart using the EA API
« on: April 28, 2016, 07:54:01 pm »
I'm trying to figure out how to create an EA chart (bar chart etc) using the EA API, and there doesn't seem to be any obvious support for it.
Nor can I even find where in the EA database the definition of the example charts is saved.
Does anyone have any experience of creating charts this way ?
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Creating a data chart using the EA API
« Reply #1 on: April 28, 2016, 11:01:05 pm »
No sorry, I always tell people to use Excel if they want to make charts.
Just like I tell them to use an email client for emailing, a test tool for testing, and a project management tool to do project management.

You of all people should understand that ;D :P 8)

Geert

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Creating a data chart using the EA API
« Reply #2 on: April 29, 2016, 06:52:48 am »
Here is a thought, a chart is just a class with stereotype "Chart" on a diagram with some extra fields. So try creating a class with stereotype "Chart" for starters then look at whats in the various fields and try populating those via the API.
Happy to help
:)

Ian Mitchell

  • EA User
  • **
  • Posts: 507
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Creating a data chart using the EA API
« Reply #3 on: April 29, 2016, 06:31:42 pm »
I know, I'm a crazy optimist for using a modelling tool for creating charts, but there they are, looking all nice and simple in the examples, just waiting to be used. Doing yet another Excel integration is probably going to be the way forward, but honestly, what's the point in having a Charting capability which is UI-accessible only.
@Sparx - any clues where you stash the chart data in the database?
@Qwerty - no clues in "Inside EA" - what was that utility you once showed me for dumping an EAP file to text, so that it can I could do a text-search to find the secret data ?
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Creating a data chart using the EA API
« Reply #4 on: April 29, 2016, 06:35:08 pm »
Ian,

If you have an SQL Server model (even the free version SQL Server Express will do) you can turn on the profiler.
This profiler will record all queries that are executed against the database, making it rather easy to figure out where EA hides certain things.

If I were a betting person I would bet on t_document; probably stored as a zipped, base64 encoded xml string.  8)

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Creating a data chart using the EA API
« Reply #5 on: May 02, 2016, 08:48:59 am »
It's in a tagged value of the chart.

Ian Mitchell

  • EA User
  • **
  • Posts: 507
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Creating a data chart using the EA API
« Reply #6 on: May 05, 2016, 05:31:51 pm »
Thanks Simon!
Could we please have seom documentation about the required format of the XML?
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Creating a data chart using the EA API
« Reply #7 on: May 06, 2016, 08:26:39 am »
There's no documentation, schema etc.

But it's really quite simple, you should be able to see everything needed by looking at a couple of samples.

Code: [Select]
<chart type="piechart">
<source table="t_object" field="t_object.Author">
<package guid="{4FD466F2-C633-42e9-B17D-F3F9D7C5F432}" recursive="1"/>
<package guid="{45C0AC49-8B26-40c7-9681-9105DD2115B8}" recursive="1"/>
</source>
<Search GUID="{27518F8F-E640-495b-8975-DC6505085124}" PkgGUID="-1" Type="0" LnksToObj="0" CustomSearch="0" AddinAndMethodName="">
<!-- Same XML used in search definitions. -->
</Search>
<appearance category="3" gradient="0" showindexinlabels="0" exploded="0" showdatalabels="1" fitinarea="0" labelPosition="0" holesize="40" displaylegend="0" rotationAngle="0" pieAngle="45"/>
</chart>

Code: [Select]
<chart type="2DBarchart">
<source customSQL="select 'A' as Series, 'B' as GroupName, 20 as ChartValue"/>
<appearance subType="0" category="1" gradient="0" showdatalabels="1" labelPosition="0" displayShadow="1" opacity="0" displaylegend="0"/>
</chart>

There are two tagged values associated with line charts.

Code: [Select]
<CloudSchedule frequency="weekly" dayofweek="1"/>

Code: [Select]
<chart type="Linechart">
<source/>
<dataset series="A" sql="...">
<row date="2016-04-17 23:40:49" value="8"/>
<row date="2016-04-24 23:40:41" value="6"/>
</dataset>
<dataset series="B" sql="...">
<row date="2016-04-17 23:40:49" value="3"/>
<row date="2016-04-24 23:40:41" value="5"/>
</dataset>
<appearance gradient="0" showindexinlabels="0" showdatalabels="1" labelPosition="0" subType="0" category="1" lineWidth="1" lineStyle="0" showDataMarkers="0" showDataLabels="0" displayShadow="0" markerSize="7" markerShape="0" labelAngle="-90"/>
</chart>
« Last Edit: May 06, 2016, 08:53:14 am by Simon M »

Ian Mitchell

  • EA User
  • **
  • Posts: 507
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Creating a data chart using the EA API
« Reply #8 on: May 25, 2016, 09:05:53 pm »
"But it's really quite simple.."
Sorry Simon, but you may need to re-calibrate your simple-o-meter.
"Simple" would be an API when I can set all this stuff: your 'simple' approach means yet more time reverse engineering your internal XML, to discover what all the options are, creating my own XML etc etc. So not really usable at all....:-(
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Creating a data chart using the EA API
« Reply #9 on: May 26, 2016, 08:44:50 am »
I guess I have a programmers simple-o-meter.

I didn't define any of the XML formats involved, but I have written code to read, update and create new charts based on looking at examples.

What are you having trouble with?

Ian Mitchell

  • EA User
  • **
  • Posts: 507
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Creating a data chart using the EA API
« Reply #10 on: May 31, 2016, 08:42:41 pm »
Thanks Simon,
 The challenge is just to know what's possible.
If an XML schema was available, for example, then that defines what the XML SHOULD look like - when creating-  , but also all the different possibilities of which it MIGHT look like - when reading data created by the UI.
The alternative is  a kind of 'particle physics' approach, where we have to fire different settings into the UI, see the XML fragments which fly off, then try to piece together a standard model of what happened in between. Not simple.
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

hdjebar

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Creating a data chart using the EA API
« Reply #11 on: March 10, 2022, 03:09:27 am »
In order to create a new Chart Element  within a package pck
$mychart = $pck.Elements.AddNew('myChart','EAUML::Chart')
$tg = $mychart .TaggedValues[0]    ----or via GetByName('ChartProperties')
$tg.Value =<memo>
$tg,Value = '<memo>
$tg,Notes = '<chart type="2DBarchart">
                  <source customSQL="salrequest"/>
                  <appearance subType="0" category="0" gradient="0" showdatalabels="1" labelPosition="0" displayShadow="1" opacity="0" displaylegend="1"/>
               </chart>'
$tg.Update()