How to fix chart in ColdFusion 11? - coldfusion

Like many other people who switched from CF9 to CF11, I'm having issues with charts too. My chart worked perfectly fine in CF9. After we did an update to CF11, a few things just disappeared or do not fit in the chart.
In my case I have two elements to fix. One is TITLE. The problem is that my title has frame for some reason and if I have more than one row with the text, that cannot fit in the title. Second is XAXISTITLE does not show up on the screen at all. Here is my code that I used in CF9 to build my chart:
<cfchart format="#ffPrint#" xaxistitle="#desc#" yaxistitle="#yTitle#" style="ChartStyle.xml"
chartheight="700" chartwidth="#graphWidth#" title="#title#" showlegend="#theLegend#" >
I played with my code and tried to remove some parts to see how that will effect CF11 and I found if I remove STYLE, my xaxistitle showed up, but still with wrong values. Also I could not find the way how to resize my TITLE box.
For example my title looked like this in CF9:
Washington DC
4th Conference
Date: 07/01/2015 - 07/08/2015
Time: 08am - 4pm
all these info are stored in #title# variable.
xaxistitle has just simple name that was on the bottom of the graph column. Something like JOHN COOK and that text was with the angle, wasn't just horizontal. This is the code that I used for that:
<cfoutput query="getRecords" group="Year">
<cfchartseries type="bar" itemcolumn="#Year#" valuecolumn="count" seriescolor="#listGetAt(Colors,colorId)#" >
<cfset colorId++>
<cfoutput>
<cfchartdata item="#description#" value="#count#">
</cfoutput>
</cfchartseries>
</cfoutput>
If anyone can help with this problem please let me know. Thank you.

Related

How to stack time charts vertically

I'm new to chartjs and couldn't find any example on this...
Is there a way to stack these charts vertically (same x-axis) with one long y-axis instead of 3 scales/y-axes ?
From this:
To something like this : (just an example)
here an example:
https://jsfiddle.net/Developer2011/ogjewLuz/34/
Thanks
Soo I did some research about it and there is a lot of people with this problem.
The solution that I'm giving to you will have some problems interacting with the final user but if it's just for display maybe this is what you want.
Right here is the example where you can ofcourse add your own format and specifications:
https://jsfiddle.net/4th6rbcw/3/

Google Visualization Datatable: DateFormatter is not working

I'm trying to show 12 hours format on Google Chart timeline.
This is the example from Google with arrayToDataTable method. It is working fine and this is the result I really want in 12hrs format with am & pm.
Code Pen link 1: http://codepen.io/Thein/pen/mAOrow
This is how I populated dataTable using google.visualization.DataTable().
Additionally, I formatted -
var formatter_12h = new google.visualization.DateFormat({ pattern: "d/MM/yy h:m:s aa" });
formatter_12h.format(dataTable, 1);
formatter_12h.format(dataTable, 2);
It always comes up with 24 hours format in tooltip.
Code Pen link 2: http://codepen.io/Thein/pen/KgNvJA
I tried to play with Culture value in in web.config as follow but it is still showing 24h format.
<globalization enableClientBasedCulture="false" uiCulture="en-AU" culture="en-AU" />
EDIT: It seems that Snippet 2 code is working with 12 hours format on
Apahache server and It is showing 24 hours format on IIS server.
Thanks to WhiteHat and his solution. I have fixed the Timeline chart as follow:
Code Pen link 3: http://codepen.io/Thein/pen/LRbdKv
HhAxis is quite messy though. It is so much cleaner in Code Pen link 1(http://codepen.io/Thein/pen/mAOrow). Please post your answer if you can get the result exactly like Code Pen link 1 with dataTable, I will accept your answer.

SpreadsheetFormatRow abruptly stops working

I've seen this post, but there does look to be a resolution. Anyway, I'm using ColdFusion 10 to generate an Excel spreadsheet. However, when I use SpreadsheetFormatRow() and pass in the rows to be formatted, it only does about 3 and then abruptly stops. Here is an example...
ColdFusion Code
<cfscript>
rowCount = 1;
headingRows = 4;
// Create instance of new Spreadsheet
excelSheet = SpreadsheetNew("ReportName",false);
// HEADING (IMAGE) ROW FORMAT
formatHeadingRow = StructNew();
formatHeadingRow.fgcolor="blue";
// Add rows to fill the header area (must add as many as we are spanning with the above image)
for (x=0;x<headingRows;x++) {
SpreadsheetAddRow(excelSheet,"TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST,TEST");
SpreadsheetFormatRow(excelSheet,formatHeadingRow,rowCount);
rowCount++;
}
</cfscript>
<!--- stream it to the browser --->
<cfheader name="Content-Disposition" value="inline; filename=reportName.xls">
<cfcontent type="application/vnd.ms-excel" variable="#SpreadSheetReadBinary(excelSheet)#">
and here is a screenshot of the resulting Excel sheet
Why is the formatting stopping after X number of rows and cells?
If I switch to using XML format with
excelSheet = SpreadsheetNew("ReportName",true);
it works properly. However I'm using a custom palette for my colors so I don't think switching to XLSX format is going to work for me. When I try and then call
palette = excelSheet.getWorkbook().getCustomPalette();
I get an error stating that getCustomPalette() method is undefined.
coldfusion.runtime.java.MethodSelectionException: The getcustompalette method was not found
Can anyone help me figure this out? Thank you!!!
Or even better since it works with the XML format, can anyone show example of how to use a custom palette with the XLSX (xml format)
This is an issue I have seen often when dealing with xls files from CF; they seem to stop applying styles after a certain number of cells. I've been able to work around it by outputting to xlsx instead. (I was able to replicate and "fix" your issue by doing so.)
excelSheet = SpreadsheetNew("ReportName",true);
...
<cfheader name="Content-Disposition" value="inline; filename=reportName.xlsx">
<cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
variable="#SpreadSheetReadBinary(excelSheet)#">
Since you are applying the exact same format to all rows, only do it once, not on each row. Using SpreadsheetFormatCellRange after the loop should resolve the issue:
SpreadsheetFormatCellRange(excelSheet
, formatHeadingRow
, startRow
, startCol
, endRow
, endCol );
I suspect the problem somehow relates back to Excel's maximum style limits. Since CF is a black box, it is difficult to know how many styles it actually creates or exactly how they are applied. However, in my experience it is very easy to exceed the style limits without even knowing it. Especially when using the older .xls file format, whose limits are much lower. That is why I suggested using the newer .xlsx format instead.
getCustomPalette() method is undefined.
Correct. It does not exist in XSSF. Is there some reason you need a custom palette instead of just defining your own colors, as mentioned in your other thread?

CFSpreadsheet borders for Merged Cells

I searched around for this for awhile, so forgive me if there is an answer already. I am having trouble applying borders to merged cells using CFSpreadsheet. Below is some example code.
<cfscript>
newSS = SpreadsheetNew('Testing'); //Create Spreadsheet
SpreadsheetMergeCells(newSS,1,1,1,9);
SpreadsheetAddRow(newSS,'Underline this Header');
SpreadSheetFormatCell(newSS,{bold=true,alignment='center',bottomborder='thin'},1,1);
Spreadsheetwrite(newSS,expandpath('myTest.xls'),true); //Write File
</cfscript>
What I would expect is the top cell to be underlined all the way across. What I get is the top cell only underlined through column "A" and not underlined after. Is there anyway around this or is this just a limitation of CFSpreadsheet??
Thanks!
According to the POI FAQ's, ie underlying library CF uses to generate spreadsheets, this is currently not supported (emphasis mine):
12. How do I add a border around a merged cell?
Add blank cells around where the cells normally would have been and
set the borders individually for each cell. We will probably enhance
HSSF in the future to make this process easier.
Probably the best you can do for now is to use SpreadsheetFormatCellRange instead of SpreadSheetFormatCell:
SpreadsheetFormatCellRange ( newSS
, {bold=true,alignment='center',bottomborder='thin'}
, 1,1,1,9 );

ScaleMin not working with cf chart in cf 9

I am creating a line graph chart in CF 9.
My cfchart code is below:
<cfchart showborder="yes"
chartheight="500" chartwidth="1000"
yaxistitle="% Correct" xaxistitle="Month"
sortXAxis="yes"
xAxistype="Scale"
showxgridlines="yes"
scaleFrom="1"
scaleTo="110"
showLegend="yes"
tipStyle="mouseOver"
title="Data Entry Audit %">
</cfchart>
Along the X-axis will display the Month Numbers, but it is counting by 2s, instead of 1,2,3,4,5,6 etc.. It is diplaying 0,2,4,6,8. There is data for month of January, so "1", but the 1 does not show up along the x-axis. I tried adding Scalemin=1 and ScaleMax=12, but it seems this is not supported with CF 9. Any help is much appreciated.
Thanks!
How many months are you displaying along the x-axis? Webcharts3D (the underlying charting tool) does a lot of automatic adjustments to ensure the best fit of chart elements. If Webcharts3D is skipping labels, then it may have decided there are too many to reasonably fit on along the axis. So it opts to display every other label instead.
I do not think cfchart has an attribute for overriding those particular settings on the x-axis. However, you can use the webcharts3d utility to customize/override the default settings. Specifically, play around with the xAxis settings in the "basic" tab (type, scale min/max, etcetera).