4 Replies Latest reply on Oct 27, 2009 9:42 AM by enriquevw

    Styles for graphs and charts?




      I am trying to find out if there is a way to save a graph style, as you would do a paragraph style. This is mainly due to the fact that I need to create about 250 charts in illustrator, and I would really appreciate if I could automate some of the graph or chart creation process, as where I could define a style and then just apply it, meaning the colors, position, size, and font.


      What do you guys think? How would you approach it?


      I'm even having a hard time making the graphs look the way I want them to.


      Thanks in advance for any input you can give me.


        • 1. Re: Styles for graphs and charts?
          JETalmage Level 6

          A Graph is a special kind of Group. If you create a Graphic Style from it, the Style will just contain Appearances applied to the Group.


          So it will be more practical to think in terms of creating one Graph, styled the way you want it, and then automating the changing of its data, saving a file each time you change the data.


          That raises questions for you to either answer or consider:


          You say that you have 250 Graphs to build. Are all the charts going to be the same type (bar, pie, etc.)?

          Where is the data? Does it already exist, or will you have to key it in somewhere anyway? If you are going to have to key it, there is not much to automate; you might as well key it into the Graph Data table anyway. If it already exists, what kind of file is it? Does it exist as separate data files for each Graph?


          You can import tab-delimited text into Illustrator's Data dialog. But the step of actually importing the data is not accessible to Actions. You can merely record the step of opening the dialog.


          A Graph in Illustrator can be bound as a dynamic object. Its data can be captured as DataSets. You can then record an Action to batch process the swapping of the DataSets on one Graph that is styled the way you want, and save each iteration as a separate file. Unfortunately, the Varialbles Palette requires your messing around with XML; it cannot import ordinary tab-delimited text as DataSets or as a Variable Library. And it's particularly picky about the way the XML is formatted; you won't be able to simply create your data in Excel, export as XML, and then import as DataSets. See online Help for Variables.


          A Javascript can be written to create DataSets from ordinary tab-delimited text. (I wrote such a script for other purposes, but it does not involve Graphs.) But again, that begs the question of whether the data already exists for the 250 Graphs or if you are going to have to create it anyway.



          • 2. Re: Styles for graphs and charts?
            enriquevw Level 1

            Hello JET,


            I knew you would come through with a deep and rich answer.


            Let me give you some more info. The charts will all have the same ammount of rows and columns (lucky me), the data is already collected and its stored in excel files. So I will most likely go the Variables way, I was messing around with that based on the insight you gave me, but I haven't made it work yet.


            So where can I learn the right way to convert my excel data to XML that Variables will accept, and also about your script, could it be adapted to create the Data Sets for the graphs? And if so, is it available for download or  purchase?


            Everything else about the automation seems pretty clear, I could batch proccess and select IN from data sources, and apply the pertinent actions for save or export.


            You have been immensely helpful, and I would appreciate it if you continue to point me in the right direction.


            PS: I am attaching a sample of a graphic how it should look, taken from an earlier version of the book, which were all made by hand . These graphics and the pertinent titles will then be imported and flowed in InDesign for a book, which I have already tried doing with Data Merge, and so far it works beautifully.


            Best regards,



            • 3. Re: Styles for graphs and charts?
              JETalmage Level 6



              So where can I learn the right way to convert my excel data to XML that Variables will accept, and also about your script, could it be adapted to create the Data Sets for the graphs? And if so, is it available for download or  purchase?

              I'm afraid I don't really know how to massage an XML file into what Illustrator wants. I've done a little reading about XML, but it bores me to death, seems quite cumbersome, and I've yet to have any real need for it. So far, every time I thought I might need it, I've worked the solution more directly in FileMaker.


              If I remember correctly, in my dinking around with XML, I found that FileMaker could export XML that InDesign could deal with unaltered; but not Illustrator.


              Especially given that all your Graphs require the same number and arrangements of values, though, I would think an ordinary manual find/replace routine in a text editor should do in your case:


              1. Use the first set of values from one of your Excel files to build the first graph.
              2. Bind the Graph as a Variable. Capture its DataSet.
              3. Edit the Data from the second spreadsheet in the Graph Data Dialog. Capture its DataSet.
              4. Now you have a Variable Graph, with two DataSets. Export the DataSets as a Variables Library.
              5. Open the Variables Library in a text editor. You can see how the two DataSets are structured and tagged. That should be fairly easy to use as a guide for a few Find/Replace routines in Word or some other text editor Copy/Paste the data from the various spreadsheets. Then use Find/Replace to semi-automate the addition of the XML tags. When done, Copy all that and paste it into place in the Variables Library you exported. Reimport the edited Library into AI.


              All things considered, though, that's probably as much work as simply right-clicking the Graph, select Data from the cursor menu, Click the Import Data button in the Data Dialog, and selecting the next spreadsheet in the folder. Export as PDF. Repeat. If you decided to do that, you could at least have a couple of Actions to invoke the DataDialog, and to Save A Copy as PDF. That would at least reduce those operations to a single click each.


              Although I haven't time to try it right now, I do suspect it would be a fairly simple scripting task to adapt my VFTROU script to generate DataSets for a Graph.


              Finally, though: Your graph sample doesn't appear to be graphics intensive at all. Why not just make the graphs in Excel and export to PDFs that you can place in InDesign? I'm wondering why you feel you need Illustrator involved in this at all.



              1 person found this helpful
              • 4. Re: Styles for graphs and charts?
                enriquevw Level 1



                In the end you make a good point. The graphs I need are not graphics intensive at all and they need not to be.

                I went poking around in XML, and Excel, but it's very cumbersome as you said, Excel simply makes a really messy XML which is not worth cleaning up. I also tried importing a tab delimited file into MySQL to export a clean XML, but even importing text data to MySQL is complicated, the export of the xml is very pure, though.

                So in the end, I tried opening my Excel in Numbers and I actually liked how it stripped the effects, and then I just copy-pasted that to Illustrator or InDesign. It'd be interesting to write an AppleScript (if I knew AppleScript of course) to take all the Excel files open them in numbers and just export as PDF, then that could be easily imported to InDesign in one sitting through Data Merge.

                What do you think?


                Thanks for your time.