cfchart horizontal bar labels crowded - coldfusion

I have created a simple chart in coldfusion 10. For some reason the labels on Y-axis are too crowded. Granted they are long texts (not more than 100 characters though), they should still appear on single lines instead of wrapping. Here is the screen-shot:
<cfchart chartheight="1000" chartwidth="1000" showxgridlines="no" showygridlines="no" showborder="no" fontbold="no" fontitalic="no" show3d="no" rotated="no" sortxaxis="no" showlegend="no" showmarkers="no" format="jpg" xaxistitle="Issues">
<cfchartseries type="horizontalbar" serieslabel="Survey Count" >
<cfchartdata item="lwkencfkenklnr lknevfvfv ghthrtg y;l;lm;'m jkbjed lknl klnelvkn lknlknrweknn" value="10">
<cfchartdata item="lewfll; ;lmrtgbjweb vkn wkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfewflfojewmlrm" value="20">
<cfchartdata item="efklnwkln lknkleng lwkencfkenefe klnr lknevlknl klnelvkn lknlknrweknn ewe" value="40">
<cfchartdata item="lkenglk klkn kjbghdchg lwk ewefrewf ncfkenklnr lknevlknl klnelvkn lknlknrweknn" value="10">
<cfchartdata item="lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="60">
<cfchartdata item="lwkencfkenklnr lkneffvlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="80">
<cfchartdata item="lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="50">
<cfchartdata item="lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="5">
<cfchartdata item="lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="100">
<cfchartdata item="lwkencfke btgnklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="20">
<cfchartdata item="lwkencfkenklnr lknevlvvrgr knl klnelvkn lknlknrweknn wcwfojewmlrm" value="10">
<cfchartdata item="lwkencfkenklnr lkneffvfg vlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="50">
<cfchartdata item="lwkffdfdf encfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="60">
<cfchartdata item="lwkenc hy jujuyjj fkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="10">
<cfchartdata item="lwkencrfrf fkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="80">
<cfchartdata item="lwkencfrfrf h thtt yyuyu kenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="25">
<cfchartdata item="lwkencefef ferrgrg fkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="38">
<cfchartdata item="lwken hthththcfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="2">
<cfchartdata item="jjkjkkjbjk lwkencfkeefefnklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="120">
<cfchartdata item=";l;m;';' frfegtgrt tgt kencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="12">
<cfchartdata item="knklnknk lknlkne lknklnewf lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="55">
<cfchartdata item="el;mvlml ;lmlmll ';,;lwkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="88">
<cfchartdata item="lwkg;lm;l ';,;' nkneknfv encfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="6">
<cfchartdata item="knklnekgn klnqd legegwkeeg ncfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="10">
<cfchartdata item="lwgerg;,e;' ';,hytlhmwjkbfh kjkencfkenklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="25">
<cfchartdata item="lwkencfkenfwekfnwkln knklnklnd l;ml;fklnr lknevlknl klnelvkn lknlknrweknn wcwfojewmlrm" value="150">
</cfchartseries>
Thanks.

CF10 uses multiple charting engines: ZingChart for format="html" and WebCharts3D for all other formats ie "flash|jpg|png".
As mentioned, using ZingCharts directly would offer more control. However, to answer your question your current chart is generated with WebCharts3D. You can modify the chart's behavior by using a custom style. To disable wrapping use isMultiline="false". (See also the charting utility in {cfroot\charting\webcharts.bat}).
<cfsavecontent variable="customStyle"><?xml version="1.0" encoding="UTF-8"?>
<frameChart>
<xAxis>
<labelStyle isMultiline="false" isHideOverlapped="false" orientation="Horizontal"/>
</xAxis>
</frameChart>
</cfsavecontent>
<cfchart style="#customStyle#"
chartheight="1000"
chartwidth="1000" ....>
</cfchart>

Related

ColdFusion cfselect bind not working

I have a ColdFusion 11 component which is supposed to populate a cfselect using bind. However, the select is not populated with the values at all. It shows blank. These are 2 select form controls that I want to relate to each other. A select from one should populate the other with values based on the selection made.
<td>
From IJ:
<cfselect name="im"
id="im"
bind="cfc:BTransfer.Get_Alls()"
display="strTName"
value="city_code"
queryposition="below"
bindonload="true">
<option value="">Select ...</option>
</cfselect>
</td>
<td>
To IJ:
<cfselect
name="toij"
id="toij"
bind="cfc:BTransfer.Get_Ts({city_code})"
value="strTCode"
display="strTName"
queryposition="below">
<option value="">Select ...</option>
</cfselect>
</td>
[b]The component.[/b]
<cfcomponent output="false">
<cffunction name="Get_Alls" access="remote" output="false" returntype="Query">
<cfset var qry_getall = "">
<CFQUERY NAME="qry_getall" DATASOURCE="#dsn#" cachedWithin="#CreateTimeSpan(1,0,0,0)#" >
SELECT T_Code AS strTCode,
ltrim(t_name) AS strTName,
city_code
FROM tblLookupTCity
WHERE blnactive = 1
ORDER BY T_name
</CFQUERY>
<cfreturn qry_getall />
</cffunction>
<cffunction name="Get_Ts" access="remote" output="false" returntype="Query">
<cfset var qry_getall = "">
<cfargument name="city_code" type="numeric" required="true" >
<CFQUERY NAME="qry_getall" DATASOURCE="#dsn#" cachedWithin="#CreateTimeSpan(1,0,0,0)#" >
SELECT T_Code AS strTCode,
trim(T_name) AS strTName,
city_code
FROM tblLookupTCity
WHERE CITY_CODE = '#arguments.city_code#'
AND blnactive = 1
ORDER BY T_name
</CFQUERY>
<cfreturn qry_getall />
</cffunction>
</cfcomponent>

CF Save As Dialog box and setting Save Type As

I am using CF 10 and I am trying to create a save as dialog box appear and set the save as type as xls (Excel Extension) so that my report can be easily saved in excel. I was thinking I could maybe do this with
<cfelseif FORM.Format IS "xls">
<cfcontent type="application/vnd.ms-excel">
<cfheader name="Content-Disposition" value="inline; filename=fileName.xls">
but that does not open up the correct dialog box. Does anyone know how this may be accomplished?
This is what should appear:
<cfelseif FORM.Format IS "xls">
<cfcontent type="application/vnd.ms-excel">
<cfheader name="Content-Disposition" value="inline; filename=fileName.xls">
<cfset result = {} />
<cftry>
<cfset date1 = CREATEODBCDATETIME(form.StartDate & '00:00:00')>
<cfset date2 = CREATEODBCDATETIME(form.EndDate & '23:59:59')>
<cfquery datasource="#application.dsn#" name="GetLocationInfo">
SELECT *
FROM cl_checklists
WHERE date >= <cfqueryparam value="#date1#" cfsqltype="cf_sql_timestamp" />
AND date <= <cfqueryparam value="#date2#" cfsqltype="cf_sql_timestamp" />
AND trans_location IN ( <cfqueryparam value="#FORM.location#" cfsqltype="cf_sql_varchar" list="true" /> )
</cfquery>
<cfquery name="allLocCode" dbtype="query">
SELECT DISTINCT trans_location, COUNT(*) AS locationCount FROM GetLocationInfo Where trans_location is not null GROUP BY trans_location ORDER BY trans_location
</cfquery>
<cfset columnSum = ArraySum(allLocCode['locationCount'])>
<cfset checkListPercentage = arrayNew(1)>
<table border="1" id="Checklist_Stats">
<thead>
<th><strong>Location</strong></th>
<th><strong>Percent of Total Checklists</strong></th>
<th><strong>Location Total</strong></th>
</thead>
<tbody>
<cfloop query="allLocCode">
<cfset thisLocationName = trim(allLocCode.trans_location) />
<cfquery name="allLocCodeForLocationQry" dbtype="query">
SELECT trans_location,count(*) AS locCntr FROM GetLocationInfo WHERE trans_location='#thisLocationName#' GROUP BY trans_location ORDER BY trans_location
</cfquery>
<cfoutput query="allLocCodeForLocationQry">
<cfset currentPercentage = (allLocCodeForLocationQry.locCntr / columnSum * 100)>
<cfset arrayAppend(checkListPercentage, currentPercentage)>
<cfset totalPercentage = arraySum(checkListPercentage)>
<tr>
<td><strong>#thisLocationName#</strong></td>
<td>#numberFormat(currentPercentage, '9.99')#%</td>
<td>#allLocCodeForLocationQry.locCntr#</td>
</tr>
</cfoutput>
</cfloop>
<tr>
<cfoutput>
<td><strong>Total</strong></td>
<td>#numberFormat(totalPercentage, '9.99')#%</td>
<td>#columnSum#</td>
</cfoutput>
</tr>
</tbody>
</table>
<cfcatch type="any">
<cfset result.error = CFCATCH.message >
<cfset result.detail = CFCATCH.detail >
</cfcatch>
</cftry>
</cfcontent>
</cfif>
Just add the following cfheader with a XLS-filename after cfcontent:
<cfheader name="Content-Disposition" value="yourfilename.xls">

Binding 3 cfselects produces error

I have three select boxes: State, District, School. The first two work great if I don't have the school, but the school is actually the important part. Without the school select everything works fine. With the school box I get the error:
Bind failed, element not found: pid
CFC
<cfcomponent>
<cfset THIS.dsn="whatever">
<cffunction name="getDistricts" access="remote" returntype="query">
<cfargument name="state" required="yes" hint="The districts are in this state." />
<cfstoredproc datasource="#THIS.dsn#" procedure="getSchoolAndDistrict" returncode="yes">
<cfprocparam cfsqltype="cf_sql_varchar" dbvarname="#mstate" value="#arguments.state#" type="in">
<cfprocresult resultset="1" name="districts">
</cfstoredproc>
<cfreturn districts>
</cffunction>
<cffunction name="getSchools" access="remote" returntype="query">
<cfargument name="state" required="yes" hint="The districts are in this state." />
<cfargument name="pid" required="yes" hint="The district pid." />
<cfstoredproc datasource="#THIS.dsn#" procedure="getSchoolAndDistrict" returncode="yes">
<cfprocparam cfsqltype="cf_sql_varchar" dbvarname="#mstate" value="#arguments.state#" type="in">
<cfprocparam cfsqltype="cf_sql_varchar" dbvarname="#pid" value="#arguments.pid#" type="in">
<cfprocresult resultset="2" name="schools">
</cfstoredproc>
<cfreturn schools>
</cffunction>
</cfcomponent>
CFM
<cfoutput>
<cfform action="#CGI.PATH_INFO#" name="testdistricts" method="post">
<cfselect name="states" query="states"
queryPosition="below"
display="state" value="state">
<option value="">State</option>
</cfselect>
<cfselect name="districts"
bind="cfc:cfcs.getDistricts.getDistricts({states})"
queryPosition="below"
display="name" value="pid" bindonload="no">
<option value="">District</option></cfselect>
<cfselect name="schools"
bind="cfc:cfcs.getDistricts.getSchools({pid})"
queryPosition="below"
display="name" value="pid" bindonload="no">
<option value="">School</option>
</cfselect>
<br> <br>
<cfinput type="submit" name="submit" value="Submit">
</cfform>
</cfoutput>
Your problem is that the Schools select is bound to the value of the selected option instead of being bound to the district control itself...
<cfform action="#CGI.PATH_INFO#" name="testdistricts" method="post">
<cfselect name="states" query="states"
queryPosition="below"
display="state" value="state">
<option value="">State</option>
</cfselect>
<cfselect name="districts"
bind="cfc:cfcs.getDistricts.getDistricts({states})"
queryPosition="below"
display="name" value="pid" bindonload="no">
<option value="">District</option></cfselect>
<cfselect name="schools"
bind="cfc:cfcs.getDistricts.getSchools({districts})"
queryPosition="below"
display="name" value="pid" bindonload="no">
<option value="">School</option>
</cfselect>
<br> <br>
<cfinput type="submit" name="submit" value="Submit">
</cfform>
This is where your problem is
bind="cfc:cfcs.getDistricts.getSchools({districts})"

Adobe ColdFusion, CFGrid is not populating after get login an navigate the page,

I tried to bind a CFGrid in ColdFusion through a CFC function which works correctly, but after login when I tried to surf to the page the CFGrid does not get populated with any records.
Here is my grid.cfm code:
<cfform name="GridForm">
<cfgrid format="html" name="UserGrid" pagesize="10" selectmode="row" bind="cfc:Consumer.getUserinfo({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
<cfgridcolumn name="FirstName" width="300" header="FirstName" />
<cfgridcolumn name="LastName" width="180" header="LastName" />
<cfgridcolumn name="UserName" width="120" header="UserName" />
<cfgridcolumn name="Age" width="60" header="Age" />
</cfgrid>
<br/>
</cfform>
And here is my cfc function:
<cfcomponent output="false">
<cffunction name="getUserInfo" access="remote" returntype="struct" >
<cfargument name="page" required="true" />
<cfargument name="pageSize" required="true" />
<cfargument name="gridsortcolumn" required="true" />
<cfargument name="gridsortdirection" required="true" />
<cfif arguments.gridsortcolumn eq "">
<cfset arguments.gridsortcolumn = "FirstName" />
<cfset arguments.gridsortdirection = "asc" />
</cfif>
<cfquery name="GetUser" datasource="MyDatabase" >
select *
from UserInfo
order by #arguments.gridsortcolumn# #arguments.gridsortdirection#
</cfquery>
<cfreturn queryconvertforgrid(GetUser, page, pagesize) />
</cffunction>
</cfcomponent>
Why doesn't this grid get populated after the login?
I recommend using the developer tools / javascript console in Chrome. Turn on log XMLHTTPRequests. Then, next time you reload your app, the console will show you all of the ajax calls your app is making and if they succeed or fail.
If you have a failing request you can right click on it and open it in a new tab to see the error details just like you would normally trouble shoot a problem.

cfchart data to display drive details indivisually

<html>
<head>
</head>
<body>
<cfhttp method="Get"
url="http://localhost:90/myweb/xmlwork/xmlfile.cfm">
<cfoutput>
#cfhttp.filecontent#
</cfoutput>
<br>
<br><br><br>
<!---<cffile action="read" file="http://localhost:90/myweb/xmlfile.cfm" variable="myxml">--->
<cfset mydoc = XmlParse(cfhttp.filecontent)>
<cfset dd = mydoc.StorageList.XmlChildren>
<cfset size = ArrayLen(dd)>
<cfoutput>
Number of Drive = #size#
<br>
</cfoutput>
<br>
<cfset myquery = QueryNew("DriveName,TotalSpace,FreeSpace") >
<cfset temp = QueryAddRow(myquery, #size#)>
<cfloop index="i" from = "1" to = #size#>
<cfset temp = QuerySetCell(myquery, "DriveName",
#mydoc.StorageList.DriveDetails[i].DriveName.XmlText#, #i#)>
<cfset temp = QuerySetCell(myquery, "TotalSpace",
#mydoc.StorageList.DriveDetails[i].TotalSpace.XmlText#, #i#)>
<cfset temp = QuerySetCell(myquery, "FreeSpace",
#mydoc.StorageList.DriveDetails[i].FreeSpace.XmlText#, #i#)>
</cfloop>
Contents of the: <br>
<cfdump var=#myquery#>
<br><cfloop index="i" from = "1" to = #size#>
<cfchart format="flash" show3d="true" chartwidth="300" chartheight="300" >
<cfchartseries type="pie">
<cfloop query="myquery">
<cfchartdata item="#TotalSpace#" value="#FreeSpace#">
</cfloop>
</cfchartseries>
</cfchart>
</cfloop>
<!---<cfloop index="i" from = "1" to = #size#>
<cfchart>
<cfchartseries
type="pie"
query="myquery"
valueColumn="TotalSpace"
itemColumn="FreePace"/>
</cfchart>
</cfloop>--->
</body>
</html>
i have this code for chart display,but it showing in one chart i want to display this in indivisual chart
Instead of constructing a query and using it to display in your chartseries, use a chartseries with cfchartdata to add the appropriate data to the chart.