Creating Visio 2010 data driven diagrams programmatically

Started by tu, November 21, 2010, 07:00:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tu

Hi,

This might be a very basic question for this forum, but I am kind of lost and want to find out if it is possible to create visio 2010 data driven diagrams programmatically in C#/Vb .net. The underlying data source can be excel files or a database. Can anyone please point me to a good reference. Thanks!


aledlund

Check David Parker's book "Visualizion Information with ms visio 2007". Also some examples over here
http://visguy.com/vgforum/index.php?topic=836.0
al

tu

Thanks for pointing me to the references Al. I had a follow up question though - My data is dynamic and based on that I need to add/remove shapes from the diagram along with displaying shape data on all shapes. I have to then publish this on sharepoint visio services. I can generate visio files through .net code and link them to data sources but I am not sure how to dynamically add or remove items from a visio drawing based on a change in the underlying data source.

Thanks,
Umer

aledlund

Umer,
That can depend on what you are trying to diagram and how static is the information. As an example one of the more common requests has to do with the OrgChart wizard in Visio. Where organization structures are relatively static (we don't normally reorganize manufacturing and marketing that often) the people assigned to these structures may change. This leads us to the case of a static picture with dynamic data and only occasionally adding personnel. The same can be said about network rack diagrams. After their initial installation the drawings remain fairly static, with some dependencies on how dynamic the physical environment is. As an example in the rack environment I may change out a server for a different one and the only real change to diagram is the asset data associated to the slot in the frame.
With my drawings, I never update (since my environment doesn't work well with static drawings), I always create new via automation. The documents are considered disposable. The main reason for this was in the beginning a decision has to be made as to where the data archive will be; if in the drawing then you have to perform an updata, if external it's (IMO) just as easy to create new as to perform update (and you save yourself the step of having to validate that the drawing your updating is at the correct revision level). Another piece of the puzzle is that once a drawing has been created they have a life of their own (it is extremely difficult to track who has a copy and how to get rid of old ones).
As a final note. I've forwarded two preliminary articles to Chris on data linking to drawings (specifically dealing with the employee/organization drawings) and will probably put up another vb.net dc_rack project dealing with drawing the racks in about six weeks.
al

tu

Thanks Al - I appreciate your help.

So what I have understood from your reply is to create visio diagrams using automation (and link them to data too if required) based on one snapshot of data. When the underlying data changes or on a periodic basis, you can create new diagrams and dispose of the old ones. The scenario I was referring to is not just for updates which you rightly pointed out can be simply managed by changing the data associated to that slot/org chart level. Taking the server racks example, if we were to display server racks for 100 data centers and for each data center there is a probability of adding or removing 2 servers per month (this might not be a practical example for a real world scenario), it means we need to have n visio diagrams (where n= no. of data centers) generated and published by automation and after every month, we run a batch job to remove the old ones and publish new diagrams on a fresh snapshot of data. In my scenario, I am dealing with displaying inventory health status for an enterprise on multiple locations and although the basic use case is to be able to display the current health status of each inventory item on all locations ( a bit of drill down by hyperlinking - from Geographical locations to actual inventory items) but there is also a need to be able to depict new inventory items on the diagrams - not necessarily as soon as they are added but they are expected to be there eventually. I am thinking of going with the approach of running a batch job on a periodical basis to generate a set of diagrams based on the current data snapshot and then publishing the new versions after disposing off the old diagrams. I am, however, a bit concerned about the number of files which need to be generated as supposedly each location will have at least one file ( if there isn't another drill down involving categories for inventories and then displaying the actual inventory instances which takes the number to n*m  (n = no. of locations, m = no. of categories).

Another approach I was thinking about was to handle the drill downs in aspx pages. When a user clicks on a certain location, the request goes back to the server for another aspx page which generates a visio diagram based on the current snapshot and displays it. This saves the generation of all files at once and has the advantage of not being stale in terms of data ( always generating a diagram from the current data snapshot) but it will generate a file per request and unless there is a smart caching mechanism going on - the diagrams will just be disposed as temp files.

Any thoughts/comments


aledlund

First the questions. Obviously in a large enterprise (I assisted one with over 1000 retail locations) document management at a site level can be a real challange. That's why one of my guiding principles has always been to only create them as needed, and then with automation based upon a central data repository that can be shared. This only works when there are very strong change management process's in the enterprise (you might check out the assetGen product). The second issue with this is everytime I have created a report (admittedly a globalization) somebody has wanted it changed in some way, so I have tried to keep myself out of the report writing business by choosing repositories that had report creation tools that users could use.

By focusing on WinForms development and using the drawing controls my intent was to have a set of libraries that might be called from a code behind web application (write it once so that it could be used on a client workstation, or built on a server). When I finish adding the visRackDraw project to the collection I will add a Prism based dataentry module (I already have added a silverlight data entry project to the collection).

Among the batch jobs you should consider (beyond drawing updates if you go that way) are topology analysis used as a component of data validation, stencil/master shapes analysis to ensure your basic drawings are consistent and map to whatever mechanism you use for inventory/assets.

These are the videos associated with the dc_rack project

http://www.youtube.com/view_play_list?p=BAFAAC68D36484CA

visRackLocations (and the associated codeplex project) is for site selection and drilldown.
visRackLinkAttr and visRackCompAttr demonstrate object drilldown.

hth,
al