<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; horizontalAlternateFill</title>
	<atom:link href="http://blog.flexexamples.com/tag/horizontalalternatefill/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Alternating background row colors in a Flex LineSeries chart</title>
		<link>http://blog.flexexamples.com/2007/11/15/alternating-background-row-colors-in-a-flex-lineseries-chart/</link>
		<comments>http://blog.flexexamples.com/2007/11/15/alternating-background-row-colors-in-a-flex-lineseries-chart/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 02:58:20 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[GridLines]]></category>
		<category><![CDATA[LineChart]]></category>
		<category><![CDATA[SolidColor]]></category>
		<category><![CDATA[backgroundElements]]></category>
		<category><![CDATA[horizontalAlternateFill]]></category>
		<category><![CDATA[horizontalFill]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/11/15/alternating-background-row-colors-in-a-flex-lineseries-chart/</guid>
		<description><![CDATA[<p>The following example shows how you can alternate background row colors in a LineSeries chart in Flex by setting the horizontalAlternateFill style in the GridLines object, as seen in the following snippet:</p> &#60;mx:LineChart showDataTips=&#34;true&#34; dataProvider=&#34;{dp}&#34;&#62; &#60;mx:backgroundElements&#62; &#60;mx:GridLines&#62; &#60;mx:horizontalAlternateFill&#62; &#60;mx:SolidColor color=&#34;haloSilver&#34; alpha=&#34;0.25&#34; /&#62; &#60;/mx:horizontalAlternateFill&#62; &#60;/mx:GridLines&#62; &#60;/mx:backgroundElements&#62; &#60;/mx:LineChart&#62; <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/GridLines_horizontalAlternateFill_test/main.mxml">View [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can alternate background row colors in a LineSeries chart in Flex by setting the <code>horizontalAlternateFill</code> style in the GridLines object, as seen in the following snippet:</p>
<pre class="code">
&lt;mx:LineChart showDataTips=&quot;true&quot; dataProvider=&quot;{dp}&quot;&gt;

    &lt;mx:backgroundElements&gt;
        &lt;mx:GridLines&gt;
            <span style="color:red;">&lt;mx:horizontalAlternateFill&gt;
                &lt;mx:SolidColor color=&quot;haloSilver&quot; alpha=&quot;0.25&quot; /&gt;
            &lt;/mx:horizontalAlternateFill&gt;</span>
        &lt;/mx:GridLines&gt;
    &lt;/mx:backgroundElements&gt;

&lt;/mx:LineChart&gt;
</pre>
<p>Full code after the jump.</p>
<p><span id="more-303"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/GridLines_horizontalAlternateFill_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/11/15/alternating-background-row-colors-in-a-flex-lineseries-chart/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:XMLListCollection id="dp"&gt;
        &lt;mx:source&gt;
            &lt;mx:XMLList&gt;
                &lt;quote date="8/27/2007" open="40.38" close="40.81" /&gt;
                &lt;quote date="8/24/2007" open="40.5" close="40.41" /&gt;
                &lt;quote date="8/23/2007" open="40.82" close="40.6" /&gt;
                &lt;quote date="8/22/2007" open="40.4" close="40.77" /&gt;
                &lt;quote date="8/21/2007" open="40.41" close="40.13" /&gt;
                &lt;quote date="8/20/2007" open="40.55" close="40.74" /&gt;
                &lt;quote date="8/17/2007" open="40.18" close="40.32" /&gt;
                &lt;quote date="8/16/2007" open="39.83" close="39.96" /&gt;
                &lt;quote date="8/15/2007" open="40.22" close="40.18" /&gt;
                &lt;quote date="8/14/2007" open="41.01" close="40.41" /&gt;
                &lt;quote date="8/13/2007" open="41" close="40.83" /&gt;
                &lt;quote date="8/10/2007" open="41.3" close="41.06" /&gt;
                &lt;quote date="8/9/2007" open="39.9" close="40.75" /&gt;
                &lt;quote date="8/8/2007" open="39.61" close="40.23" /&gt;
                &lt;quote date="8/7/2007" open="39.08" close="39.42" /&gt;
                &lt;quote date="8/6/2007" open="38.71" close="39.38" /&gt;
                &lt;quote date="8/3/2007" open="39.47" close="38.75" /&gt;
                &lt;quote date="8/2/2007" open="39.4" close="39.52" /&gt;
                &lt;quote date="8/1/2007" open="40.29" close="39.58" /&gt;
            &lt;/mx:XMLList&gt;
        &lt;/mx:source&gt;
    &lt;/mx:XMLListCollection&gt;

    &lt;mx:LineChart id="lineChart"
            showDataTips="true"
            dataProvider="{dp}"
            width="100%"
            height="100%"&gt;

        &lt;mx:backgroundElements&gt;
            &lt;mx:GridLines&gt;
                &lt;mx:horizontalAlternateFill&gt;
                    &lt;mx:SolidColor color="haloSilver" alpha="0.25" /&gt;
                &lt;/mx:horizontalAlternateFill&gt;
            &lt;/mx:GridLines&gt;
        &lt;/mx:backgroundElements&gt;

        &lt;!-- vertical axis --&gt;
        &lt;mx:verticalAxis&gt;
            &lt;mx:LinearAxis baseAtZero="false" title="Price" /&gt;
        &lt;/mx:verticalAxis&gt;

        &lt;!-- horizontal axis --&gt;
        &lt;mx:horizontalAxis&gt;
            &lt;mx:CategoryAxis id="ca" categoryField="@date" title="Date" /&gt;
        &lt;/mx:horizontalAxis&gt;

        &lt;!-- horizontal axis renderer --&gt;
        &lt;mx:horizontalAxisRenderers&gt;
            &lt;mx:AxisRenderer axis="{ca}" canDropLabels="true" /&gt;
        &lt;/mx:horizontalAxisRenderers&gt;

        &lt;!-- series --&gt;
        &lt;mx:series&gt;
            &lt;mx:LineSeries yField="@open" form="curve" displayName="Open" /&gt;
        &lt;/mx:series&gt;
    &lt;/mx:LineChart&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/GridLines_horizontalAlternateFill_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/GridLines_horizontalAlternateFill_test/bin/main.html" width="100%" height="500"></iframe></p>
<p>You can also change the <code>horizontalAlternateFill</code> style using CSS, as seen in the following snippet.</p>
<pre class="code">
&lt;mx:Style&gt;
    GridLines {
        horizontalAlternateFill: haloSilver;
    }
&lt;/mx:Style&gt;
</pre>
<p>Note that when using CSS, you set the <code>horizontalAlternateFill</code> style to a color name, not a SolidColor object.</p>
<p>If you want to change the <code>horizontalAlternateFill</code> style using ActionScript, you can use one of the following snippets:</p>
<pre class="code">
myGridLines.setStyle("horizontalAlternateFill", "haloSilver");
</pre>
<pre class="code">
import mx.graphics.SolidColor;
...
var solidColor:SolidColor = new SolidColor(0xFF0000, 0.2);
myGridLines.setStyle("horizontalAlternateFill", solidColor);
</pre>
<p>Note that you must pass a numeric value to the SolidColor constructor (or the SolidColor instance&#8217;s <code>color</code> property). If you want to use a named color (such as &#8220;red&#8221;, or &#8220;haloSilver&#8221;), you can use the static <code>StyleManager.getColorName()</code> method, as seen in the following snippet:</p>
<pre class="code">
import mx.graphics.SolidColor;
import mx.styles.StyleManager;
...
var colorAsNumber:uint = StyleManager.getColorName("haloBlue");
var solidColor:SolidColor = new SolidColor(colorAsNumber, 0.1);
myGridLines.setStyle("horizontalAlternateFill", solidColor);
</pre>
<p>You can also alternate row colors using the horizontalFill style, or use both the <code>horizontalFill</code> and <code>horizontalAlternateFill</code> styles to set the fill colors for both odd and even rows, as seen in the following snippet:</p>
<pre class="code">
&lt;mx:backgroundElements&gt;
    &lt;mx:GridLines direction=&quot;both&quot;&gt;
        <span style="color:red;">&lt;mx:horizontalFill&gt;
            &lt;mx:SolidColor color=&quot;haloBlue&quot; /&gt;
        &lt;/mx:horizontalFill&gt;
        &lt;mx:horizontalAlternateFill&gt;
            &lt;mx:SolidColor color=&quot;haloSilver&quot; /&gt;
        &lt;/mx:horizontalAlternateFill&gt;</span>
    &lt;/mx:GridLines&gt;
&lt;/mx:backgroundElements&gt;
</pre>
<p>The following example shows how you can alternate the row colors for even and odd numbered rows by setting both the <code>horizontalFill</code> and <code>horizontalAlternateFill</code> styles using MXML:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/GridLines_horizontalFill_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/11/15/alternating-background-row-colors-in-a-flex-lineseries-chart/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:XMLListCollection id="dp"&gt;
        &lt;mx:source&gt;
            &lt;mx:XMLList&gt;
                &lt;quote date="8/27/2007" open="40.38" close="40.81" /&gt;
                &lt;quote date="8/24/2007" open="40.5" close="40.41" /&gt;
                &lt;quote date="8/23/2007" open="40.82" close="40.6" /&gt;
                &lt;quote date="8/22/2007" open="40.4" close="40.77" /&gt;
                &lt;quote date="8/21/2007" open="40.41" close="40.13" /&gt;
                &lt;quote date="8/20/2007" open="40.55" close="40.74" /&gt;
                &lt;quote date="8/17/2007" open="40.18" close="40.32" /&gt;
                &lt;quote date="8/16/2007" open="39.83" close="39.96" /&gt;
                &lt;quote date="8/15/2007" open="40.22" close="40.18" /&gt;
                &lt;quote date="8/14/2007" open="41.01" close="40.41" /&gt;
                &lt;quote date="8/13/2007" open="41" close="40.83" /&gt;
                &lt;quote date="8/10/2007" open="41.3" close="41.06" /&gt;
                &lt;quote date="8/9/2007" open="39.9" close="40.75" /&gt;
                &lt;quote date="8/8/2007" open="39.61" close="40.23" /&gt;
                &lt;quote date="8/7/2007" open="39.08" close="39.42" /&gt;
                &lt;quote date="8/6/2007" open="38.71" close="39.38" /&gt;
                &lt;quote date="8/3/2007" open="39.47" close="38.75" /&gt;
                &lt;quote date="8/2/2007" open="39.4" close="39.52" /&gt;
                &lt;quote date="8/1/2007" open="40.29" close="39.58" /&gt;
            &lt;/mx:XMLList&gt;
        &lt;/mx:source&gt;
    &lt;/mx:XMLListCollection&gt;

    &lt;mx:LineChart id="lineChart"
            showDataTips="true"
            dataProvider="{dp}"
            width="100%"
            height="100%"&gt;

        &lt;mx:backgroundElements&gt;
            &lt;mx:GridLines direction="both"&gt;
                &lt;mx:horizontalFill&gt;
                    &lt;mx:SolidColor color="haloBlue" alpha="0.6" /&gt;
                &lt;/mx:horizontalFill&gt;
                &lt;mx:horizontalAlternateFill&gt;
                    &lt;mx:SolidColor color="haloSilver" alpha="0.6" /&gt;
                &lt;/mx:horizontalAlternateFill&gt;
            &lt;/mx:GridLines&gt;
        &lt;/mx:backgroundElements&gt;

        &lt;!-- vertical axis --&gt;
        &lt;mx:verticalAxis&gt;
            &lt;mx:LinearAxis baseAtZero="false" title="Price" /&gt;
        &lt;/mx:verticalAxis&gt;

        &lt;!-- horizontal axis --&gt;
        &lt;mx:horizontalAxis&gt;
            &lt;mx:CategoryAxis id="ca" categoryField="@date" title="Date" /&gt;
        &lt;/mx:horizontalAxis&gt;

        &lt;!-- horizontal axis renderer --&gt;
        &lt;mx:horizontalAxisRenderers&gt;
            &lt;mx:AxisRenderer axis="{ca}" canDropLabels="true" /&gt;
        &lt;/mx:horizontalAxisRenderers&gt;

        &lt;!-- series --&gt;
        &lt;mx:series&gt;
            &lt;mx:LineSeries yField="@open" form="curve" displayName="Open" /&gt;
        &lt;/mx:series&gt;
    &lt;/mx:LineChart&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/GridLines_horizontalFill_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/GridLines_horizontalFill_test/bin/main.html" width="100%" height="500"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Alternating background row colors in a Flex LineSeries chart on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/11/15/alternating-background-row-colors-in-a-flex-lineseries-chart/',contentID: 'post-303',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'backgroundElements,horizontalAlternateFill,horizontalFill',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/11/15/alternating-background-row-colors-in-a-flex-lineseries-chart/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

