Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script / Data Merge to change Polygon Position

New Here ,
Feb 13, 2020 Feb 13, 2020

Hi there, relatively new to InDesign but have been a long time Illustrator and Photoshop user. Currently working on a project that is using Data Merge to generate text content from a CSV (which is all working wonderfully), but additionally, we have a slider that has an arrow that we would like to move horizontally based on a CSV value.

 

I saw this post which uses a script to rotate an object from a CSV and was wondering if/how this could be used to change the position of our triangle?

 

Annotation 2020-02-13 095054.png

TOPICS
Scripting
359
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 13, 2020 Feb 13, 2020

Hi tyturner1782,

this should be possible through data merge alone.

If you can relate an integer number in your CSV file to formatting of text. E.g. you could correlate the number and the width of a character in percentage.

 

Think of an inline anchored object, your position triangle, some white space characters with fixed width in front of it. The position of the anchored object represents the 100% mark. After the anchored triangle comes the text that is provided through data merge, a number in your case.

 

AnchoredMarkerTriangle.PNG

 

Example paragraphs with the 100% mark, the 50% mark and the 10% mark below.

Text in the paragraph is invisible, because I used fill color [None] for formatting.

The yellow bars are just indicators I added.

 

All screenshots done from my German InDesign 2020 on Windows 10:

 

The-100%-Mark.PNG

 

The-50%-Mark.PNG

 

The-10%-Mark.PNG

The paragraph is formatted using GREP styles. The GREPs are looking for numbers at the end of a paragraph with a positive lookahead. If a number is found, all the white space at the beginning of the paragraph is formatted with a character style. That character style will change the width of characters. Say, if number 50 is used, one of the GREP styles discover this and will format all white space at the beginning of the paragraph to 50%.

 

GREP-Styles-Definitions.PNG

 

Below a sample character style, the one for 10% character width:

The-10%-CharacterStyle.PNG

 

 

At first glance you need 99 GREP styles to represent all integer values from 1 to 99. Value 100 is default, so no GREP style is necessary to represent 100. Each GREP style triggers one of 99 character styles where the width of a character is defined in 1% steps.

 

Just a thought…

 

Of course a script can do this more efficiently, scaling the white space characters, after the data merge is done.

And it could scale to more precise values if your numbers in the CSV file require this.

 

Note: the total amount of GREP styles that can be defined with one paragraph style is 100.

 

Regards,
Uwe Laubender

( ACP )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2020 Feb 14, 2020
LATEST

Further to Laubender's suggestion, I have a script that makes the GREP code for a "GREP graph" over at indesignsecrets.com: https://indesignsecrets.com/a-script-for-making-bar-graphs-with-grep.php

I also have a solution to move a graphic on X-Y Coordinates that uses either the above solution or a paid font called FF Chartwell. More on that here: https://colecandoo.com/2013/09/04/another-use-for-ff-chartwell-plotting-x-and-y-coordinates/

And this may assist as well: https://colecandoo.com/2016/06/26/better-infographics-for-data-merge-with-chartwell-bars/

 

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines