LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 2 Dec 2008 10:02:53 -0600
Reply-To:     "Peck, Jon" <peck@spss.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         "Peck, Jon" <peck@spss.com>
Subject:      Re: Programmatic manipulation of charts?
Comments: To: ViAnn Beadle <vab88011@gmail.com>
In-Reply-To:  A<000c01c95492$cb69b270$623d1750$@com>
Content-Type: text/plain; charset="us-ascii"

To elaborate a bit further, it is possible to manipulate the labels programmatically, but it will take more than two lines of code.

The chart is represented internally as an XML specification, and there are apis in the Python SpssClient module, GetXML and SetXML that allow you to read and change it. The schema is installed with SPSS. So you could write a program to read and parse the XML and manipulate the labels. If you do File>Export Chart XML from the Chart Editor, you can see what it looks like.

Then, for example, you could programmatically remove labels for categories below some threshold value, remove fractional values to use less space, reduce point sizes, or make other changes that might help the layout.

Python has excellent support for manipulating XML - see the ElementTree module if you are interested.

You might find it easier to prepare an XML template using the new VizDesigner product, which gives greater control over details of the charts, and then use that template within SPSS Statistics to generate your charts. You can read about VizDesigner at http://www.spss.com/vizdesigner/

HTH, Jon Peck

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of ViAnn Beadle Sent: Tuesday, December 02, 2008 8:29 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: [SPSSX-L] Programmatic manipulation of charts?

AFAIK, there is no automatic fitting algorithm for label position. GPL does allow you to lump really small counts together into a general other category. The label() function in GPL provides labels for almost anything you want and can be named multiple times on the ELEMENT statement. But you'll still have the overlapping problem. The internal representation of the chart is XML (called vizML). You can export the vizML from the chart editor and play with it outside of the context of the chart editor. The GGRAPH command can be used to test rendering within SPSS. SPSS "might" still license an integrated graphics package based upon the graphics engine used within SPSS. It is a java based development environment that is used for direct chart generation and manipulation from data marts and is completely independent. Talk to SPSS support for more info.

-----Original Message----- From: Simon Palmer [mailto:Simon.Palmer@strategicdata.com.au] Sent: Tuesday, December 02, 2008 12:18 AM To: ViAnn Beadle Cc: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: Programmatic manipulation of charts?

Hi ViAnn,

> Both templates and GPL provide "some" control over labels but you'd > have to > be more specific as to what you want.

It's data labels in particular that are problematic. I have to generate a large number of (horrible!) pie charts that need to have data labels in or near their segments. I have tried templating but it seems for charts with several little-endorsed values I have to compromise between not showing all the labels or having them obscure each other. Templating doesn't seem apply to label padding either, but that is a minor concern. I can't see anything in GPL that lets me do anything with data labels, let alone algorithmically specify co- ordinates that can be set dynamically. On the other hand it looks like there has been a substantial amount of thought behind the GPL so it wouldn't surprise me if it was just a lack of understanding on my part.

What I thought might be possible was post-processing of the chart object, presumably with python scripting. My rough plan was to write a script that turned on the labels for the pie chart then looped through a process of checking to see if each data label object overlapped any other one, and if so keep moving it until it didn't. But it looks like the only way to manipulate a chart after it has been produced is via the Chart Editor.

Thanks for your help, Simon

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


Back to: Top of message | Previous page | Main SPSSX-L page