cfchart ignores my scalefrom value - coldfusion

I have the following codes in my page.
The style variable holds the custom style.
<cfchart chartheight="450" chartwidth="550" gridlines="9" yaxistitle="Score" scalefrom="20" scaleto="100" style="#style#" format="png" >
<cfchartseries query="variables.chart_query" type="scatter" seriescolor="##000000" itemcolumn="MyItem" valuecolumn="MyScore"/>
</cfchart>
Before I begin, please see chart_good.jpg. This is how I want my report to come up. On the x-axis, there will always be three items as long as at least one of them has values. If an item does not have any values (i.e. 2010), there would not be a marker in the chart.
The problem occurs only when only one item has value. Please see chart_bad.jpg. As you can see, 2008 and 2010 do not have any values; y-axis is now scaled from 0 to 100. I have tried setting one of the items (ex. 2008) a value of 0 or something off the chart; it would scale according to this off-the-chart value and the 2009 value. In short, I have to have at least two items with values between 20 and 100 in order for cfchart to scale from 20 to 100.
My question is, how can I correct the issue so that cfchart would ALWAYS scale from 20 to 100? I am running CF9.

What is inside your style variable?
I would suggest not using scaleFrom="" and scaleTo="" in the cfchart tag as they can be buggy sometimes. I believe that Coldfusion's cfchart tag attempts to scale the chart automatically to what it deems the best fit. Instead I would build the chart's minimum and maximum scales inside a frameChart tag.
Example of a style variable to build a chart
<cfsavecontent variable="style">
<?xml version="1.0" encoding="UTF-8"?>
<frameChart is3D="false" font="Arial-11-bold">
<frame xDepth="0" yDepth="0" outline="black" lightColor="#CCCCCC" darkColor="#CCCCCC"
wallColor="#CCCCCC" frameSize="5" dashSize="3" gridColor="#333333">
<background type="HorizontalGradient" maxColor="#828EB0"/>
</frame>
<!--- THE BREAD AND BUTTER
NOTE: if you use variables for the scaleMin and scaleMax
make sure to surround them with a cfoutput tag
--->
<yAxis scaleMin="20" scaleMax="100">
<!--- --------------------- --->
<labelFormat style="Currency" pattern="#,##0"/>
<parseFormat pattern="#,##0"/>
<titleStyle></titleStyle>
</yAxis>
<legend allowSpan="true" isVisible="false" placement="Bottom" valign="Bottom" foreground="black"
isMultiline="true">
<decoration style="None"/>
</legend>
<elements outline="black" shapeSize="40"/>
<popup background="#748BA6" foreground="white"/>
<paint palette="Modern" paint="Plain" isVertical="true"/>
<insets right="5"/>
</frameChart>
</cfsavecontent>
Then all you have to do is load the variable into the style attribute like you already mentioned.
<cfchart format="png" chartWidth="550" chartHeight="175" style="#style#">
Also a great resource to use, is the Webcharts program that will be in your C:/coldfusion/charting/ directory. Just open webcharts.bat, create your custom chart, copy the xml code into your style variable, and voila!
Make sure to remove the scaleTo= and scaleFrom= from your cfchart tag if you decide to go this route.

Related

FitBit: Masking only the size Text

Please bear with me if my terminology is not correct. Very new to this.
I'm creating a mask of a text element
<svg>
<mask id="TextMask">
<text id="TextMask"
class="Text-Mask"
x="10" y="193">Some Text to Mask</text>
</mask>
The Class Text-Mask just contains font/anchor/font size.
I then want to apply a gradient coloring to this text and only this text. I have created a gradientRect element to apply to the text.
<svg mask="#TextMask" width="100%" height="100%">
<gradientRect width="100%" height="100%"
gradient-type="linear"
gradient-x1="0" gradient-y1="50"
gradient-x2="0" gradient-y2="100%-50"
gradient-color1="red"
gradient-color2="yellow" />
</svg>
</svg>
Now this works fine, but it isn't the effect I was hoping for.
From my understanding when I created this gradientRect element, I'm creating it over the background of the entire screen.
What I want is for the entire gradientRect to only cover the area that the text takes up. (Ex. The very top of the text is red and then it becomes gradient to the bottom of the text to yellow). As of right now how I currently have it, the text is in an orange/yellow area of the gradientRect.
I'm not sure how I can accomplish this with the gradient-y1 y2.
Am I able to get the size (and position) of the text (regardless if the font size changes or place the text somewhere else on the screen) and apply this easily, or will I have to brute force it and hard code it to fit around only the text area?

limit x axis for cfchart

I would like to limit the x-axis of my chart that is created by cfchart. I see the attribute scaleFrom and scaleTo that limit the y-axis, but I see nothing that limits the x-axis.
Also, I saw a similar question here:
ColdFusion Chart x-axis label limits
but neither of the answers were appropriate. ScaleMin and ScaleMax do not exists as far as I can tell and the other answer is more complicated than what I'd like to do.
The scaleMin and scaleMax attributes Saul mentioned are only available when using a custom style. Note, using type "scale" means your xAxis values must be numeric. If you want to use strings, you will probably need to use Ben's approach instead.
Here is a quick example that creates a chart with 24 points on the xAxis. Even though the query only contains the first six (6) points.
<!--- bare bones style --->
<cfsavecontent variable="style">
<?xml version="1.0" encoding="UTF-8"?>
<frameChart is3D="false" isInterpolated="true">
<frame xDepth="3" yDepth="1" />
<xAxis type="Scale" scaleMin="0" scaleMax="24" labelCount="25" isBucketed="false" />
</frameChart>
</cfsavecontent>
<!--- sample query --->
<cfset qry = queryNew("")>
<cfset queryAddColumn(qry, "xValue", listToArray("1,2,3,4,5,6"))>
<cfset queryAddColumn(qry, "yValue", listToArray("30,15,22,14,45,5"))>
<!--- chart code --->
<cfchart format="jpg" style="#style#" width="600">
<cfchartseries type="line"
markerstyle="circle"
query="qry"
itemColumn="xValue"
valueColumn="yValue" />
</cfchart>

Infragistics columnfilter

In my application i have used WebDataGrid Infragistics control. I have total 5 columns(Status,CandidateName,WorkOrderId,VenderName,Rate) in this grid. I needed to apply filter on 2 columns only i.e; Status and CandidateName. I have explicitly write code to set filter only in 2 columns. Below is my code. But, the problem is, Filter is applying on all the 5 columns regardless of setting the filter explicitly.
<ColumnFilters>
<ig:ColumnFilter ColumnKey="Status">
<ConditionWrapper>
<ig:RuleTextNode Rule="Contains" />
</ConditionWrapper>
</ig:ColumnFilter>
<ig:ColumnFilter ColumnKey="CandidateName">
<ConditionWrapper>
<ig:RuleTextNode Rule="Contains" />
</ConditionWrapper>
</ig:ColumnFilter>
</ColumnFilters>
Please any one can tell me how to apply filter only on specific columns defined explicitly.
Thanks in Advance !!!!
You should be able to disable the other columns by setting Enabled=false as follows:
<Behaviors>
<ig:Filtering>
<ColumnSettings>
<ig:ColumnFilteringSetting ColumnKey="WorkOrderId" Enabled="false" />
<ig:ColumnFilteringSetting ColumnKey="VenderName" Enabled="false" />
<ig:ColumnFilteringSetting ColumnKey="Rate" Enabled="false" />
</ColumnSettings>
</ig:Filtering>
</Behaviors>

REGEX to link terms within displayed text

I have an application that I have inherited that dynamically builds HREF links within the displayed text. All seemed to be working well until we recently did a database change and our list of terms to link started to get returned from the query in a different order. This exposed a bug within the existing REGEX where it tries to place an HREF link within a preexisting HREF. Simply forcing a new ordering on the terms list is not an option. A term could be just one word, could be multiple words and even could be words formatted using HTML.
What would I need to adjust within the REGEX so that it ignores terms within the HREF attribute of an A element? Here is an example of what I am referring to:
<cfset Output = "This is some sample text to show the problem when we have term1 term2." />
<cfloop index="w" list="sample;term1 term2;term1" delimiters=";">
<cfset Output = "." & Variables.Output & "." />
<cfset Output = REReplaceNoCase(Variables.Output, "(?![</]#w#>)(\W)(#w#)(\W)", "\1\2\3", "one") />
<cfset Output = Mid(Variables.Output, 2, Len(Variables.Output)-2) />
</cfloop>
<cfoutput>#Variables.Output#</cfoutput>
Change the first (\W) in the regex to ([^=\w>]) and the second to ([^=\w<])
<cfset Output = REReplaceNoCase(Variables.Output, "(?![</]#w#>)([^=\w>])(#w#)([^=\w<])", "\1\2\3", "one") />

CFCHART: reverse Y-axis ordering

I mean that MIN should be on top and MAX on X-axis.
This needed to make chart more intuitive to read and related to object ranking, when 1st place is "better" than 3rd. That's why it'd be better to look this way:
(source: xantea.net) =>
(source: xantea.net)
This can be done using custom XML. I ran the Chart Designer (cfinstall/charting/webcharts.bar (or .sh) and simply worked with the YAxis setting. There is an isReversed setting which does what you want. Consider this code:
<cfset q2 = queryNew("year,employees","integer,integer")>
<!--- generate random sales data --->
<cfloop index="y" from="1994" to="1998">
<cfscript>
queryAddRow(q2);
querySetCell(q2, "year", y);
querySetCell(q2, "employees", randRange(2,8));
</cfscript>
</cfloop>
<cfsavecontent variable="chartxml">
<?xml version="1.0" encoding="UTF-8"?>
<frameChart is3D="false">
<yAxis isReversed="true">
</yAxis>
</frameChart>
</cfsavecontent>
<cfchart chartWidth="400" chartHeight="400" title="Sales" font="arial" style="#chartxml#">
<cfchartseries type="line" query="q2" itemColumn="year" valueColumn="employees" seriesLabel="Employees" />
</cfchart>
The query on top was just used for testing. The XML came from the chart designer. I removed everything but the yAxis stuff that used isReverse. Lastly, note how I specify style in the chart tag.