Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Tables & Charts

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 21st, 2016, 10:33 AM
Ryan_B Ryan_B is offline
Regular Contributor
 
Join Date: Mar 2015
Location: Kansas City, MO
Posts: 70
Default Additional Chart Frame formatting (specifically the x axis labels)

How much control do you have with the formatting of the x and y axis labels on a bar chart?

I have built a bar chart using the following:
Code:
var str = '';

str += '<row type="header">';
str += '<cell><cell>Jan'+"$"+Field("JanTotal")+'<cell>Feb'+"$"+Field("FebTotal")+'<cell>Mar'+"$"+Field("MarTotal")+'<cell>Apr'+"$"+Field("AprTotal")+'<cell>May'+"$"+Field("MayTotal")+
       '<cell>June'+"$"+Field("JunTotal")+'<cell>July'+"$"+Field("JulTotal")+'<cell>Aug'+"$"+Field("AugTotal")+'<cell>Sep'+"$"+Field("SepTotal")+'<cell>Oct'+"$"+Field("OctTotal")+
       '<cell>Nov'+"$"+Field("NovTotal")+'<cell>Dec'+"$"+Field("DecTotal");

str += '<row>';
str += '<cell><cell>'+Field("JanTotal")+'<cell>'+Field("FebTotal")+'<cell>'+Field("MarTotal")+'<cell>'+Field("AprTotal")+'<cell>'+Field("MayTotal")+'<cell>'+Field("JunTotal")+'<cell>'+
       Field("JulTotal")+'<cell>'+Field("AugTotal")+'<cell>'+Field("SepTotal")+'<cell>'+Field("OctTotal")+'<cell>'+Field("NovTotal")+'<cell>'+Field("DecTotal");

return str;
Which returns this:
original.JPG

As you can see, the category (x) axis labels are not displaying in any sort of consistent format. What I'd like to display is the month with the amount spent beneath it.

I have tried the following, to no avail:
Code:
'<cell><cell>Jan<br>'+"$"+Field("JanTotal")
Code:
'<cell><cell>Jan<br/>'+"$"+Field("JanTotal")
Code:
'<cell><cell>Jan<p>'+"$"+Field("JanTotal")
Code:
'<cell><cell>Jan'+'<p>'+"$"+Field("JanTotal")
Code:
'<cell><cell>Jan\n'+"$"+Field("JanTotal")
When validating the rule in the editor, it would appear that my desired results will be returned, however that is not the case.
validation.JPG

According to page 29 in the TagsRefGuide, (I realize this is for a table, but I would think it'd be the same concept for charts) the <br> should work.
Their example:
documentation.JPG
The results:
documentationResults.JPG


Does anybody have any ideas on what to try next?
__________________
Ryan Boever
FusionPro VDP Designer 9.3.36
Adobe Acrobat XI 11.0.07
Windows 10
Reply With Quote
  #2  
Old December 21st, 2016, 11:36 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,367
Default Re: Additional Chart Frame formatting (specifically the x axis labels)

This seems to work for me if I put a space between the month name and the dollar sign. If that doesn't work for you, can you post the template?
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old December 21st, 2016, 11:39 AM
Ryan_B Ryan_B is offline
Regular Contributor
 
Join Date: Mar 2015
Location: Kansas City, MO
Posts: 70
Default Re: Additional Chart Frame formatting (specifically the x axis labels)

Which one did you use? <br>? \n?
__________________
Ryan Boever
FusionPro VDP Designer 9.3.36
Adobe Acrobat XI 11.0.07
Windows 10
Reply With Quote
  #4  
Old December 21st, 2016, 11:43 AM
Ryan_B Ryan_B is offline
Regular Contributor
 
Join Date: Mar 2015
Location: Kansas City, MO
Posts: 70
Default Re: Additional Chart Frame formatting (specifically the x axis labels)

Or did you mean an actual space like:
Code:
'<cell><cell>Jan'+"$"+" "+Field("JanTotal")
__________________
Ryan Boever
FusionPro VDP Designer 9.3.36
Adobe Acrobat XI 11.0.07
Windows 10
Reply With Quote
  #5  
Old December 21st, 2016, 11:49 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,367
Default Re: Additional Chart Frame formatting (specifically the x axis labels)

Quote:
Originally Posted by Ryan_B View Post
Or did you mean an actual space like:
Code:
'<cell><cell>Jan'+"$"+" "+Field("JanTotal")
Yes, I mean an actual space, BEFORE the dollar sign:
Code:
'<cell><cell>Jan'+" $"+Field("JanTotal")
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #6  
Old December 21st, 2016, 12:28 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,367
Default Re: Additional Chart Frame formatting (specifically the x axis labels)

Or you could just do this:
Code:
var headerRow = [], dataRow = [];
for (var m = 1; m <= 12; m++)
{
    var month = Left(MONTH_NAMES["English"][m-1], 3);
    row.push(month + " $" + Field(month + "Total"));
    dataRow.push(Field(month + "Total"));
}

return '<row type=header>\n<cell>\n<cell>' + headerRow.join("\n<cell>") +
        '\n\n<row>\n<cell>\n<cell>' + dataRow.join("\n<cell>");
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #7  
Old December 21st, 2016, 02:00 PM
Ryan_B Ryan_B is offline
Regular Contributor
 
Join Date: Mar 2015
Location: Kansas City, MO
Posts: 70
Default Re: Additional Chart Frame formatting (specifically the x axis labels)

Hey Dan

I've zipped up and attached the template and a handful of records from the data file for you to take a look at. When you open and preview the template, pg 5 ("TE") is where the bar chart in question is. You will see that the first two records still do not format properly. Records three and four are formatted properly, but only because the monthly amount spent is long enough to force it to the next line. The name of the rule that builds the chart is simply called Bar Chart.

My original plan for displaying the monthly dollar amount spent is on pg 4 ("PLCC"). Changing the field "Type" in the data file to "PLCC" will display why that won't work for me. If a customer spends $1000 or more, the y axis label grows, thus pushing the x axis labels to the right, and making my text frames overlap the labels. You can see what I'm talking about on record #2.

FP_Forum.zip
__________________
Ryan Boever
FusionPro VDP Designer 9.3.36
Adobe Acrobat XI 11.0.07
Windows 10
Reply With Quote
  #8  
Old December 22nd, 2016, 02:18 PM
Ryan_B Ryan_B is offline
Regular Contributor
 
Join Date: Mar 2015
Location: Kansas City, MO
Posts: 70
Default Re: Additional Chart Frame formatting (specifically the x axis labels)

Hey Dan.

Any luck with this?
__________________
Ryan Boever
FusionPro VDP Designer 9.3.36
Adobe Acrobat XI 11.0.07
Windows 10
Reply With Quote
  #9  
Old December 22nd, 2016, 02:41 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,367
Default Re: Additional Chart Frame formatting (specifically the x axis labels)

Okay, thanks for attaching the job. I see what's going on. Almost all text attributes, such as tags and entities, are ignored when putting down the chart axis labels. So things like <br> tags get stripped out, and multiple spaces, even &nbsp; entities, get collapsed.

I did come up with a way to get the output you want. Basically, we need to insert some kind of invisible character (but not a regular space) to "pad out" the space between the month name and the amount, to force the amount to always be wrapped onto the next line. I tried several characters, and finally settled on a Unicode full-width filler character, 0xFFA0.

So, what we need to do is iterate through all of the values, find the longest one, and pad out all of them to the same length, with that invisible character. This is what I came up with:
Code:
var values = [];
for (var m = 1; m <= 12; m++)
{
    var month = Left(MONTH_NAMES["English"][m-1], 3);
    values.push(Field(month + "Total"));
}

var longest = values.sort(function (a, b) { return b.length - a.length; })[0];
var longlength = longest.length + 1; // add one for the dollar sign
var pad = new Array(longlength).join(' ');

var headerRow = [], dataRow = [];
for (var m = 1; m <= 12; m++)
{
    var month = Left(MONTH_NAMES["English"][m-1], 3);
    headerRow.push(month + " " + Right(pad + "$" + Field(month + "Total"), longlength).replace(/\s/g, Chr(0xFFA0)));
    dataRow.push(Field(month + "Total"));
}

return '<row type=header>\n<cell>\n<cell>' + headerRow.join("\n<cell>") +
        '\n\n<row>\n<cell>\n<cell>' + dataRow.join("\n<cell>");
Note that you'll need to go into the Chart Properties dialog and switch the font for the Axis Labels to a font that supports that 0xFFA0 Unicode character, so that you don't just get a box for an undefined character in the output. I suggest Arial Unicode MS.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:21 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.