Copy link to clipboard
Copied
I created this slider chart in Illustrator. Used column designs to get the desired style and add the label automatically. Is there an easy find/replace or a script that will allow me to change all whole numbers to be decimals. I want 64 to be consistent with the others and read as 64.0
I have tons of these charts and takes a long time to manually make the adjustment and then have to do it again when/if the data changes and resets.
thanks!
I added a code snippet for this in another thread by OP, hopefully that will work
-Manan
Copy link to clipboard
Copied
Edit: Sorry. I didn't read that this was for a graph. What I wrote won't work.
Copy link to clipboard
Copied
Some of my labels are in text boxes. My stacked bar charts have text boxes but my slider chart has free text not bound in a box so that when the number automatically pulls in from the data it wont get cut off. the text though is attached to the chart, the text is not separate from my chart
Copy link to clipboard
Copied
I was able to use your script after all. I just saved a copy of my working file, ungrouped all of the charts and ran the script! Works great and I was able to adjust it to add a percentage symbol to all of the data labels. Thank you for you help!
var myDoc = app.activeDocument;
var frames = myDoc.textFrames;
for (var i = 0; i < frames.length; i++) {
var text = frames[i].contents;
if (!isNaN(text) && text.search(/\./) == -1) {
frames[i].contents += ".0";
}
if (!isNaN(text)) {
frames[i].contents += "%";
}
}
I tried adding a condition for the text to be a specific paragraph style but it wasn't working. If you have thoughts on how to adjust to get the number to be conditional on a paragraph style... this is what i was using.
var myStyle = myDoc.paragraphStyles.getByName("data_bars_right");
for (var i = 0; i < frames.length; i++) {
var text = frames[i].contents;
if (!isNaN(text) && myStyle){ frames[i].contents += "%";}}
Copy link to clipboard
Copied
I can't check at present, but I don't think a paragraphStyle will work the way you intend.
Off the top of my head, you could try adding % specifically to numbers with decimal points.
if (!isNaN(text) && text.search(/\./) != -1) {
frames[i].contents += "%";
}
Copy link to clipboard
Copied
I added a code snippet for this in another thread by OP, hopefully that will work
-Manan