FitBit: Masking only the size Text - fitbit

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?

Related

How can I strike text with custom thickness XSL:FO

I strike text with text-decoration="line-through", but I find out the thickness is not suitable.
<fo:inline text-decoration="line-through">
...
</fo:inline>
I tried to use but I can't find a way to overlay the text. Is there any way to adjust the thickness of the strike? Or a way to use fo:leader to do the same thing?
There is no property in XSL 1.1 for specifying the width of the text-decoration line. (FWIW, AH Formatter has an extension property for it: https://www.antennahouse.com/product/ahf66/ahf-ext.html#axf.text-line-width.)
Using fo:leader could be problematic because you might have trouble getting the width exactly right.
You might be able to do something with an fo:inline-container with a top or bottom border and playing tricks with the baseline shifts of the fo:inline-container and of the text in an fo:block within the fo:inline-container such that the fo:inline-container is lowered/raised to make the strike-through and the text is raised/lowered to be back on the original baseline.
You should be able to just set the padding-bottom to negative 1/2 the font-height coupled with a bottom-border. Like this if say the font-size is 24pt.
<fo:block>Testing line-through
<fo:inline text-decoration="line-through">
I have regular line-through
</fo:inline>
</fo:block>
<fo:block space-before="48pt">Testing line-through
<fo:inline border-bottom="5px solid black" padding-bottom="-12pt">
I have custom line-through
</fo:inline>
</fo:block>
This in RenderX results in:
Unfortunately nothing tried in FOP will work as it apparently does not respect any margin or padding settings on fo:inline.

How do i change the color of a text element?

Below code is not working, whats the correct way to change the text color?
<xsl:text color="green">Sold</xsl:text>
<xsl:text color="green">Sold</xsl:text>
There is no attribute like color in xslt. You must provide format and input where you want to color your text.

XSL-FO : Block element wrong height

Im trying to surround and image with 2 vertical gray bar using XSL-FO. I created a vertical separator with 180*1 dimension, and i'm able to render it correctly in my XSL.
Problem is, the <fo:block> element is taking too much height, and i cant seem to find a workaround, see image below ( the red is the background of the <fo:block> element, while the thin grey line is my separator. I've had good result by wrapping the whole <fo-block> into a <fo:block-container> but the separator isnt centered, and i wasnt able to center it.
This is my code
<fo:block height='1px' background-color='#DE122D'>
<fo:external-graphic height='1px' content-width="scale-down-to-fit" src="url('images/verticalSeparator.png')" />
</fo:block>
I put a background color in order to be able to see how much height it was taking.
Ultimately i'm trying to achieve the 2nd screenshot, there might be other way to do this ( perhaps something with border ? ) and i'm willing to try them. Simply notice that the 2 vertical bars are longer than the image, and that the content must be centered !
I might not understand your question, but based on the code posted you imply the rule is the issue and make too much space. If the rule is your issue, possibly you want to use an alternative structure than an image. For this you could use a leader and set the length to what you want and have no issues centering it. The following code:
<fo:block text-align="center">Text Before</fo:block>
<fo:block text-align="center" font-size="1px" line-height="0"><fo:leader color="silver" leader-length="2in" leader-pattern="rule"/></fo:block>
<fo:block text-align="center">Text Between</fo:block>
<fo:block text-align="center" font-size="1px" line-height="0"><fo:leader color="silver" leader-length="2in" leader-pattern="rule"/></fo:block>
<fo:block text-align="center">Text After</fo:block>
Produces this output -- you can see no issues in spacing:

XSL fit single image and label to a page

I have an xsl document where I need to have a series of pages that each contain a single image caption and then a single image below it.
I do not know the exact image sizes ahead of time, but I want the caption to appear at the top of the page and then constrain the image to be no larger than the remainder of the height of the page or the width of the page (scaled uniformly if needed).
I have tried
<fo:block>
<fo:block>Image Caption Here</fo:block>
<fo:block>
<fo:external-graphic content-width="scale-down-to-fit" width="100%" content-height="scale-down-to-fit" height="100%" scaling="uniform">
</fo:block>
</fo:block>
And many combinations of widths/content-widths/heights/content-heights on the blocks and external graphic to no avail. Most often I get the image overflowing off the page either vertically or horizontally.
It is likely that it is necessary to add the attributes max-height and max-width to 100%.
<fo:external-graphic content-width="scale-down-to-fit" width="100%" content-height="scale-down-to-fit" height="100%" scaling="uniform" max-width="100%" max-height="100%">

cfchart ignores my scalefrom value

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.