<?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>Visifire &#187; Tutorials and Samples</title>
	<atom:link href="http://www.visifire.com/blog/category/tutorials-and-samples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.visifire.com/blog</link>
	<description>Fire up your imagination</description>
	<lastBuildDate>Tue, 27 Jul 2010 14:33:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Windows Phone 7 Charts</title>
		<link>http://www.visifire.com/blog/2010/07/19/windows-phone-7-charts/</link>
		<comments>http://www.visifire.com/blog/2010/07/19/windows-phone-7-charts/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 16:20:28 +0000</pubDate>
		<dc:creator>Chirag</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[Tutorials and Samples]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=1338</guid>
		<description><![CDATA[Hi, You folks know that Windows Phone 7 Charts are possible with Visifire. Due to some breaking changes in the latest Beta release of Windows Phone Developer Tools users had issues using Visifire. We have decided to ship separate binaries for WP7 users. All that changes is that one has to provide reference to SLWpVisifire.Charts.dll [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>You folks know that <a href="http://www.visifire.com/blog/2010/04/20/charts-for-silverlight-4/">Windows Phone 7 Charts are possible with Visifire</a>. Due to some breaking changes in the latest Beta release of Windows Phone Developer Tools users had <a href="http://www.dynamicslight.com/2010/06/fuel-my-car-windows-phone-7-app/">issues</a> using Visifire. We have decided to ship separate binaries for WP7 users. All that changes is that one has to provide reference to SLWpVisifire.Charts.dll instead of regular Visifire for Silverlight binaries. Listed below are few links to get you started quickly with Windows Phone 7 Charts:</p>
<ul>
<li><a href="http://visifire.com/documentation/Visifire_Documentation/Core_Concepts/Working_with_Code/Setting_up_WP7_Project_Environment.htm">Setting up environment for Windows Phone 7 development</a></li>
<li><a href="http://visifire.com/documentation/Visifire_Documentation/Quick_Start/WP7/Your_First_Windows_Phone_Chart.htm">Creating your first Windows Phone 7 Chart</a></li>
</ul>
<p><div id="silverlightControlHost"><object data="data:application/x-silverlight," type="application/x-silverlight-2" width="650" height="400"><param name="source" value="http://www.visifire.com/blog/wp-content/post_xaps/Visifire4Wp7.xap"/><param name="background" value="white" /><a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a></object><iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe></div><br /></p>
<p><a href="http://visifire.com/download_silverlight_charts.php">Download  the latest version of Visifire here</a>. We are very excited about this release &amp; would love to have your feedback.</p>
<p>Cheers<br />
Team Visifire</p>
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2010/07/19/windows-phone-7-charts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight/WPF Spline Chart</title>
		<link>http://www.visifire.com/blog/2010/07/09/silverlightwpf-spline-chart/</link>
		<comments>http://www.visifire.com/blog/2010/07/09/silverlightwpf-spline-chart/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 15:52:27 +0000</pubDate>
		<dc:creator>Chirag</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tutorials and Samples]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=1306</guid>
		<description><![CDATA[Hi, With this release Visifire introduces Spline Chart. A Spline Chart is similar to a Line Chart except that it draws a fitted curve through the data points. The spline interpolation and smoothing is for improved presentation of data. It allows one to take a limited set of known data points and approximate transitional values. [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>With this release Visifire introduces Spline Chart. A Spline Chart is similar to a Line Chart except that it draws a fitted curve through the data points. The spline interpolation and smoothing is for improved presentation of data. It allows one to take a limited set of known data points and approximate transitional values.</p>
<p>Demoed below is Messi&#8217;s path to glory!</p>
<p><div id="silverlightControlHost"><object data="data:application/x-silverlight," type="application/x-silverlight-2" width="680" height="250"><param name="source" value="http://www.visifire.com/blog/wp-content/post_xaps/GoalsScoredByMessiForBarcelonaClub.xap"/><param name="background" value="white" /><a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a></object><iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe></div><br /></p>
<ul>
<li><a href="http://www.visifire.com/documentation/Visifire_Documentation/Chart_Types/Spline_Chart.htm">Visit documentation on how to create a Spline Chart</a>.</li>
<li><a href="http://www.visifire.com/silverlight_spline_charts_gallery.php">Visit Gallery for more Spline Chart samples</a>.</li>
<li><a href="http://visifire.com/download_silverlight_charts.php">Download the latest version of Visifire here</a>.</li>
</ul>
<p>Cheers,<br />
Team Visifire</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">[silverlight:<a href="../wp-content/post_xaps/GoalsScoredByMessiForBarcelonaClub.xap,">http://www.visifire.com/blog/wp-content/post_xaps/GoalsScoredByMessiForBarcelonaClub.xap,</a> 680,250]</div>
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2010/07/09/silverlightwpf-spline-chart/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverlight/WPF Radar Chart</title>
		<link>http://www.visifire.com/blog/2010/07/09/silverlightwpf-radar-chart/</link>
		<comments>http://www.visifire.com/blog/2010/07/09/silverlightwpf-radar-chart/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 15:52:07 +0000</pubDate>
		<dc:creator>Chirag</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tutorials and Samples]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=1308</guid>
		<description><![CDATA[Hi, With this release Visifire introduces Radar Chart. A Radar Chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes starting from the same point. Radar Chart is also known as Web, Spider or Star Chart. Shown below is the [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>With this release Visifire introduces Radar Chart. A Radar Chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes starting from the same point. Radar Chart is also known as Web, Spider or Star Chart.</p>
<p>Shown below is the goals scored by top countries in FIFA World Cups 2006 &amp; 2010 (till date).</p>
<p><div id="silverlightControlHost"><object data="data:application/x-silverlight," type="application/x-silverlight-2" width="700" height="305"><param name="source" value="http://www.visifire.com/blog/wp-content/post_xaps/TopGoals2006-2010.xap"/><param name="background" value="white" /><a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a></object><iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe></div><br /></p>
<ul>
<li><a href="http://www.visifire.com/documentation/Visifire_Documentation/Chart_Types/Radar_Chart.htm">Visit documentation on how to create a Radar Chart</a>.</li>
<li><a href="http://www.visifire.com/silverlight_radar_charts_gallery.php">Visit Gallery for more Radar Chart samples</a>.</li>
<li><a href="http://visifire.com/download_silverlight_charts.php">Download the latest version of Visifire here</a>.</li>
</ul>
<p>Cheers,<br />
Team Visifire</p>
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2010/07/09/silverlightwpf-radar-chart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Realtime Update Using DataBinding</title>
		<link>http://www.visifire.com/blog/2010/07/02/realtime-update-using-databinding/</link>
		<comments>http://www.visifire.com/blog/2010/07/02/realtime-update-using-databinding/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 11:37:58 +0000</pubDate>
		<dc:creator>somnath</dc:creator>
				<category><![CDATA[Tutorials and Samples]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=1226</guid>
		<description><![CDATA[DataBinding provides a simple way to manipulate and interact with data. DataBinding does the clear separation between UI implementation and business logic layer. The data can be imported from any data source like database, file etc. The UI element can be any framework element like DataGrid, Chart etc to visualize the data. Connection between UI [...]]]></description>
			<content:encoded><![CDATA[<p>DataBinding provides a simple way to manipulate and interact with data. DataBinding does the clear separation between UI implementation and business logic layer. The data can be imported from any data source like database, file etc. The UI element can be any framework element like DataGrid, Chart etc to visualize the data. Connection between UI and data object results in flow of data between them. When DataBinding is done, if the data changes then UI element which is bound to the data object also changes. In the case of two ways binding, changes made to UI element will cause data object to change.</p>
<p>In this post I will discuss about &#8220;How DataBinding takes place at real-time&#8221;. I prefer updating the chart at real-time without manipulating the Visifire chart elements directly. I will be doing multiple operations like add, delete, update with a collection and it’s good to see the changes reflecting in the chart at real-time.</p>
<div><div id="silverlightControlHost"><object data="data:application/x-silverlight," type="application/x-silverlight-2" width="700" height="264"><param name="source" value="http://www.visifire.com/blog/wp-content/post_xaps/Realtime-Update-Using-DataBinding.xap"/><param name="background" value="white" /><a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a></object><iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe></div><br /></div>
<div style="text-align: justify;">The figure shown below explains the conceptual representation of DataBinding between Visifire Chart and an ObservableCollection. DataRow is a class which holds Data for a DataPoint. A DataRow defines one or more number of properties to be mapped with DataPoints according to the data-mapping-rules defined at Series level. DataRows is a collection of one or more DataRow. Every record present in the DataRows collection represents a DataPoint.</div>
<div><img class="size-full wp-image-1234 alignnone" title="Silverlight-Visifire-Chart-Realtime-Update-Using-DataBinding" src="http://www.visifire.com/blog/wp-content/uploads/2010/06/Silverlight-Visifire-Chart-Realtime-Update-Using-DataBinding.jpg" alt="Visifire-Chart-Realtime-Update-Using-DataBinding.xap" width="699" height="717" /></div>
<div>DataMapping rules which are to be specified in DataSeries are  shown below:</div>
<pre>&lt;vc:DataSeries RenderAs="Column" LabelEnabled="True" Margin="-1,0,1,0"&gt;
    &lt;vc:DataSeries.DataMappings&gt;
        &lt;vc:DataMapping MemberName="AxisXLabel" Path="AxisXLabel"&gt;&lt;/vc:DataMapping&gt;
        &lt;vc:DataMapping MemberName="YValue" Path="YValue"&gt;
    &lt;/vc:DataSeries.DataMappings&gt;
 &lt;/vc:DataSeries&gt;
</pre>
<div>
<p>In  this example we are going to use dataRows as DataSource. Here  DataSource property of the DataSeries has been set from managed code.</p>
<pre>MyChart.Series[0].DataSource  = dataRows;</pre>
<p>Please note that I  have used a DataGrid to dispaly  the data present in dataRows in a tabular format. So I have bound dataRows  collection with the DataGrid also. As DataGrid is bound with the  collection, one can update the data present in collection just by  editing the DataGrid cells. We can even directly perform Add, Remove  operations with dataRows collection which will reflect in Chart as well  as DataGrid.</p>
<p>DataRow is the class which has two properties named   <strong>AxisXLabel</strong> and <strong>YValue</strong>. This class contains business logic  which is required to interact with values of dataRows. You may  wonder how does it know when the property value changes? The answer to  this question lies in the interface called <strong>INotifyPropertyChanged</strong> which is in <strong>System.ComponentModel </strong>namespace. The DataRow class  implements <strong>INotifyPropertyChanged </strong>which notifies when the business  object changes. So, whenever the value changes in the DataSource, corresponding property will trigger <strong>PropertyChanged</strong> event.</p>
</div>
<pre style="height: 200px; overflow: auto; font-size: 12px; background-color: #f3f3f3; border-width: 1px; border-color: #808080;">using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace VisifireDataBinding
{ 

  public class DataRow : INotifyPropertyChanged
  {
    /// &lt;summary&gt;
    /// Selected property is used to know whether the DataRow is selected  or not
    /// &lt;/summary&gt;
    public Boolean Selected
    {
       get
       {
          return _select;
       }
       set
       {
         _select = value;

        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs("Select"));
        }
    }

    /// &lt;summary&gt;
    /// AxisXLabel property
    /// &lt;/summary&gt;
    public String AxisXLabel
    {
        get
        {
            return _axisXLabel;
        }
        set
        {
           _axisXLabel = value;

           if (PropertyChanged != null)
               PropertyChanged(this, new PropertyChangedEventArgs("AxisXLabel"));
         }
     }

     /// &lt;summary&gt;
     /// YValue property
     /// &lt;/summary&gt;
     public Double YValue
     {
         get
         {
             return _yValue;
         }
         set
         {
            _yValue = value;

            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs("YValue"));
         }
      }

      #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

      #endregion

      Double _yValue;
      String _axisXLabel;
      Boolean _select;
   }
}
</pre>
<p>You can find additional information about <strong>InotificationPropertyChanged</strong> <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx" target="_blank">here</a>.</p>
<p>As a result, chart is displayed with chart contents as shown below.</p>
<p><img class="size-full wp-image-1291 alignnone" src="http://www.visifire.com/blog/wp-content/uploads/2010/06/visifire-chart11.jpg" alt="" width="388" height="227" /></p>
<p><strong>DataBinding makes it easy to display &#8220;live&#8221; data.</strong></p>
<p>Changes  made in the DataSource also causes changes in the chart without  requiring any coding on your part! Now manipulate the values in  DataGrid which may include addition, removal, update of DataPoint  properties.</p>
<p>The DataGrid after adding properties for one or more  DataPoint will look like below.</p>
<p><img class="alignnone" src="http://www.visifire.com/blog/wp-content/uploads/2010/06/visifire-chart2.jpg" alt="" width="214" height="232" /></p>
<p>The Output changes!</p>
<p><img class="size-full wp-image-1292 alignnone" src="http://www.visifire.com/blog/wp-content/uploads/2010/06/visifire-chart31.jpg" alt="" width="388" height="227" /></p>
<p>Above image shows the chart  with newly added AxisXLabel and YValue at real-time. Notice  as I change values in DataGrid, the chart gets updated automatically.</p>
<p>You  can download the source code of the sample demo application <a href="http://www.visifire.com/downloads/samples/managed/visifire-chart-realtime-update-using-databinding.zip">here</a>.</p>
<p>Cheers,<br />
Team Visifire</p>
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2010/07/02/realtime-update-using-databinding/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Visifire Now Supports DataBinding</title>
		<link>http://www.visifire.com/blog/2010/02/16/visifire-now-supports-databinding/</link>
		<comments>http://www.visifire.com/blog/2010/02/16/visifire-now-supports-databinding/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 12:11:11 +0000</pubDate>
		<dc:creator>Sunil</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[Tutorials and Samples]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=829</guid>
		<description><![CDATA[Today we are releasing the much awaited DataBinding feature in Visifire 3.0.3 beta 3. Now you can Bind any DataSource at the Series level so that the Chart gets generated automatically and reflects any change. Below is a demonstration of DataBinding. You can change the Values in DataGrid and the Chart gets updated automatically. Here [...]]]></description>
			<content:encoded><![CDATA[<p>Today we are releasing the much awaited DataBinding feature in Visifire 3.0.3 beta 3. Now you can Bind any DataSource at the Series level so that the Chart gets generated automatically and reflects any change. Below is a demonstration of DataBinding. You can change the Values in DataGrid and the Chart gets updated automatically.</p>
<p><div id="silverlightControlHost"><object data="data:application/x-silverlight," type="application/x-silverlight-2" width="635" height="320"><param name="source" value="http://www.visifire.com/blog/wp-content/post_xaps/VisifireDataBinding.xap"/><param name="background" value="white" /><a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a></object><iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe></div><br /></p>
<p><a href="http://visifire.com/downloads/samples/managed/VisifireDataBinding.zip">Here</a> is the source code for the above sample. Also you can visit Visifire documentation <a href="http://www.visifire.com/documentation/Visifire_Documentation/Core_Concepts/Working_with_DataBinding/DataBinding_Overview.htm">here</a> for more info.</p>
<p>You can download Visifire 3.0.3 beta 3 from our <a href="http://www.visifire.com/download_silverlight_charts.php">download page</a>.</p>
<p>Cheers,<br />
Team Visifire</p>
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2010/02/16/visifire-now-supports-databinding/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Exporting Visifire Silverlight Chart as Image</title>
		<link>http://www.visifire.com/blog/2009/11/12/exporting-visifire-silverlight-chart-as-image/</link>
		<comments>http://www.visifire.com/blog/2009/11/12/exporting-visifire-silverlight-chart-as-image/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 15:11:00 +0000</pubDate>
		<dc:creator>Chirag</dc:creator>
				<category><![CDATA[Tutorials and Samples]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=546</guid>
		<description><![CDATA[Exporting Silverlight charts to images has been the most coveted feature. In this tutorial, I am going to show you to export Visifire Silverlight chart as image from managed code. So before we start lets check out the live example below. Project Setup Create a “Silverlight Application” project. Download the latest Visifire binaries from here. [...]]]></description>
			<content:encoded><![CDATA[<p>Exporting Silverlight charts to images has been the most coveted feature. In this tutorial, I am going to show you to export Visifire Silverlight chart as image from managed code. So before we start lets check out the live example below.</p>
<p><div id="silverlightControlHost"><object data="data:application/x-silverlight," type="application/x-silverlight-2" width="500" height="330"><param name="source" value="http://www.visifire.com/blog/wp-content/post_xaps/SLSave2Image.xap"/><param name="background" value="white" /><a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a></object><iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe></div><br /></p>
<h3><strong>Project Setup</strong></h3>
<p>Create a “Silverlight Application” project. Download the latest Visifire binaries from <a href="http://www.visifire.com/download_silverlight_charts.php">here</a>. Extract the Zip file and add reference for the file named “SLVisifire.Charts.dll”. In this sample, I am going to use WriteableBitmap class in order to extract the pixel wise color information of the chart rendered inside Silverlight content. We will take help of JpegEncoder provided by a third party library called FJ.Core to encode the raster information to file stream.</p>
<p>Please download FJ.Core library from <a href="http://code.google.com/p/fjcore/">here</a> and add the FJ.Core.dll as reference to the project.</p>
<p><img src="http://www.visifire.com/blog/wp-content/post_images/ExportingVisifireSilverlightChartsAsImage/solutionexplorer.JPG" alt="" /></p>
<p>Below are the steps that we are going to follow.</p>
<ol>
<li>Construct the Chart XAML inside MainPage.xaml.</li>
<li>Exporting Chart as image.</li>
</ol>
<h3><strong>Constructing Chart XAML</strong></h3>
<p>Open MainPage.xaml page, add a Chart and a button inside it as shown below:</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">&lt;UserControl x:Class=<span style="color: #006080">"SLSave2Image.MainPage"</span>
    xmlns=<span style="color: #006080">"http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span>
    xmlns:x=<span style="color: #006080">"http://schemas.microsoft.com/winfx/2006/xaml"</span>
    xmlns:d=<span style="color: #006080">"http://schemas.microsoft.com/expression/blend/2008"</span>
    xmlns:mc=<span style="color: #006080">"http://schemas.openxmlformats.org/markup-compatibility/2006"</span>
    xmlns:vc=<span style="color: #006080">"clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts"</span>
    mc:Ignorable=<span style="color: #006080">"d"</span> Width=<span style="color: #006080">"500"</span> Height=<span style="color: #006080">"480"</span>&gt;
    &lt;Grid x:Name=<span style="color: #006080">"LayoutRoot"</span>&gt;
        &lt;StackPanel&gt;
            &lt;vc:Chart Name=<span style="color: #006080">"MyChart"</span> Width=<span style="color: #006080">"500"</span> Height=<span style="color: #006080">"300"</span> Theme=<span style="color: #006080">"Theme1"</span>&gt;

                &lt;vc:Chart.Titles&gt;
                    &lt;vc:Title Text=<span style="color: #006080">"Visifire Chart"</span>/&gt;
                &lt;/vc:Chart.Titles&gt;

                &lt;vc:Chart.Series&gt;
                    &lt;vc:DataSeries RenderAs=<span style="color: #006080">"Column"</span> LabelEnabled=<span style="color: #006080">"True"</span>&gt;
                        &lt;vc:DataSeries.DataPoints&gt;
                            &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Jan"</span> YValue=<span style="color: #006080">"35"</span>/&gt;
                            &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Feb"</span> YValue=<span style="color: #006080">"32"</span>/&gt;
                            &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Mar"</span> YValue=<span style="color: #006080">"27"</span>/&gt;
                            &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Apr"</span> YValue=<span style="color: #006080">"17"</span>/&gt;
                            &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"May"</span> YValue=<span style="color: #006080">"16"</span>/&gt;
                        &lt;/vc:DataSeries.DataPoints&gt;
                    &lt;/vc:DataSeries&gt;
                &lt;/vc:Chart.Series&gt;
            &lt;/vc:Chart&gt;
            &lt;Button Name=<span style="color: #006080">"ButtonSave"</span> Height=<span style="color: #006080">"25"</span> Width=<span style="color: #006080">"160"</span> Content=<span style="color: #006080">"Save Chart"</span> &gt;&lt;/Button&gt;
        &lt;/StackPanel&gt;
    &lt;/Grid&gt;
&lt;/UserControl&gt;</pre>
</div>
<h3><strong><strong>Exporting Chart as image<br />
</strong></strong></h3>
<p>Now open MainPage.xaml.cs page and add the following namespaces.</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"><span style="color: #0000ff">using</span> FluxJpeg.Core;
<span style="color: #0000ff">using</span> FluxJpeg.Core.Encoder;
<span style="color: #0000ff">using</span> System.Windows.Media.Imaging;
<span style="color: #0000ff">using</span> System.IO;
<span style="color: #0000ff">using</span> Visifire.Charts;</pre>
</div>
<p>Now attach an event handler for Click event of Button inside the Page constructor.</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"><span style="color: #0000ff">public</span> MainPage()
{
    InitializeComponent();

    ButtonSave.Click += <span style="color: #0000ff">new</span> RoutedEventHandler(ButtonSave_Click);
}

<span style="color: #0000ff">void</span> ButtonSave_Click(<span style="color: #0000ff">object</span> sender, RoutedEventArgs e)
{
    SaveToImage(MyChart);
}</pre>
</div>
<p>Inside the ButtonSave event handler declare a function called SaveToImage() which will accept Chart as parameter as shown above.</p>
<p>Now inside the function definition, create a WriteableBitmap out of a Chart and collect the raster information from it. Then encode the raster information to file stream using JpegEncoder present in FJ.Core library as shown below. Finally save the file stream as image into hard drive.</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"><span style="color: #008000">/// &lt;summary&gt;</span>
<span style="color: #008000">/// Save Visifire chart as Image</span>
<span style="color: #008000">/// &lt;/summary&gt;</span>
<span style="color: #008000">/// &lt;param name="Chart"&gt;Visifire.Charts.Chart&lt;/param&gt;</span>
<span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> SaveToImage(Chart chart)
{
    <span style="color: #0000ff">try</span>
    {
        WriteableBitmap bitmap = <span style="color: #0000ff">new</span> WriteableBitmap(chart, <span style="color: #0000ff">null</span>);

        <span style="color: #0000ff">if</span> (bitmap != <span style="color: #0000ff">null</span>)
        {
            SaveFileDialog saveDlg = <span style="color: #0000ff">new</span> SaveFileDialog();
            saveDlg.Filter = <span style="color: #006080">"JPEG Files (*.jpeg)|*.jpeg"</span>;
            saveDlg.DefaultExt = <span style="color: #006080">".jpeg"</span>;

            <span style="color: #0000ff">if</span> ((<span style="color: #0000ff">bool</span>)saveDlg.ShowDialog())
            {
                <span style="color: #0000ff">using</span> (Stream fs = saveDlg.OpenFile())
                {
                    MemoryStream stream = GetImageStream(bitmap);

                    <span style="color: #008000">//Get Bytes from memory stream and write into IO stream</span>
                    <span style="color: #0000ff">byte</span>[] binaryData = <span style="color: #0000ff">new</span> Byte[stream.Length];
                    <span style="color: #0000ff">long</span> bytesRead = stream.Read(binaryData, 0, (<span style="color: #0000ff">int</span>)stream.Length);
                    fs.Write(binaryData, 0, binaryData.Length);
                }
            }
        }
    }
    <span style="color: #0000ff">catch</span>(Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(<span style="color: #006080">"Note: Please make sure that Height and Width of the chart is set properly."</span>);
        System.Diagnostics.Debug.WriteLine(ex.Message);
    }
}

<span style="color: #008000">/// &lt;summary&gt;</span>
<span style="color: #008000">/// Get image MemoryStream from WriteableBitmap</span>
<span style="color: #008000">/// &lt;/summary&gt;</span>
<span style="color: #008000">/// &lt;param name="bitmap"&gt;WriteableBitmap&lt;/param&gt;</span>
<span style="color: #008000">/// &lt;returns&gt;MemoryStream&lt;/returns&gt;</span>
<span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> MemoryStream GetImageStream(WriteableBitmap bitmap)
{
    <span style="color: #0000ff">byte</span>[][,] raster = ReadRasterInformation(bitmap);
    <span style="color: #0000ff">return</span> EncodeRasterInformationToStream(raster, ColorSpace.RGB);
} 

<span style="color: #008000">/// &lt;summary&gt;</span>
<span style="color: #008000">/// Reads raster information from WriteableBitmap</span>
<span style="color: #008000">/// &lt;/summary&gt;</span>
<span style="color: #008000">/// &lt;param name="bitmap"&gt;WriteableBitmap&lt;/param&gt;</span>
<span style="color: #008000">/// &lt;returns&gt;Array of bytes&lt;/returns&gt;</span>
<span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">byte</span>[][,] ReadRasterInformation(WriteableBitmap bitmap)
{
    <span style="color: #0000ff">int</span> width = bitmap.PixelWidth;
    <span style="color: #0000ff">int</span> height = bitmap.PixelHeight;
    <span style="color: #0000ff">int</span> bands = 3;
    <span style="color: #0000ff">byte</span>[][,] raster = <span style="color: #0000ff">new</span> <span style="color: #0000ff">byte</span>[bands][,];

    <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; bands; i++)
    {
        raster[i] = <span style="color: #0000ff">new</span> <span style="color: #0000ff">byte</span>[width, height];
    }

    <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> row = 0; row &lt; height; row++)
    {
        <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> column = 0; column &lt; width; column++)
        {
            <span style="color: #0000ff">int</span> pixel = bitmap.Pixels[width * row + column];
            raster[0][column, row] = (<span style="color: #0000ff">byte</span>)(pixel &gt;&gt; 16);
            raster[1][column, row] = (<span style="color: #0000ff">byte</span>)(pixel &gt;&gt; 8);
            raster[2][column, row] = (<span style="color: #0000ff">byte</span>)pixel;
        }
    }

    <span style="color: #0000ff">return</span> raster;
}

<span style="color: #008000">/// &lt;summary&gt;</span>
<span style="color: #008000">/// Encode raster information to MemoryStream</span>
<span style="color: #008000">/// &lt;/summary&gt;</span>
<span style="color: #008000">/// &lt;param name="raster"&gt;Raster information (Array of bytes)&lt;/param&gt;</span>
<span style="color: #008000">/// &lt;param name="colorSpace"&gt;ColorSpace used&lt;/param&gt;</span>
<span style="color: #008000">/// &lt;returns&gt;MemoryStream&lt;/returns&gt;</span>
<span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> MemoryStream EncodeRasterInformationToStream(<span style="color: #0000ff">byte</span>[][,] raster, ColorSpace colorSpace)
{
    ColorModel model = <span style="color: #0000ff">new</span> ColorModel { colorspace = ColorSpace.RGB };
    FluxJpeg.Core.Image img = <span style="color: #0000ff">new</span> FluxJpeg.Core.Image(model, raster);

    <span style="color: #008000">//Encode the Image as a JPEG</span>
    MemoryStream stream = <span style="color: #0000ff">new</span> MemoryStream();
    FluxJpeg.Core.Encoder.JpegEncoder encoder = <span style="color: #0000ff">new</span> FluxJpeg.Core.Encoder.JpegEncoder(img, 100, stream);
    encoder.Encode();

    <span style="color: #008000">// Back to the start</span>
    stream.Seek(0, SeekOrigin.Begin);

    <span style="color: #0000ff">return</span> stream;
}</pre>
</div>
<p>You can download the complete solution <a href="http://www.visifire.com/downloads/samples/managed/sl_save2image_121109.zip">here</a></p>
<p>(Hat tip to Visifire user <a href="http://www.visifire.com/forums/index.php?showuser=1267">Sagi Karni, Intel Corp</a>)</p>
<p>Cheers,<br />
Team Visifire</p>
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2009/11/12/exporting-visifire-silverlight-chart-as-image/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Step by step breakdown of Visifire rendering logic</title>
		<link>http://www.visifire.com/blog/2009/10/16/step-by-step-breakdown-of-visifire-rendering-logic/</link>
		<comments>http://www.visifire.com/blog/2009/10/16/step-by-step-breakdown-of-visifire-rendering-logic/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 12:03:00 +0000</pubDate>
		<dc:creator>Sunil</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tutorials and Samples]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Silverlight Charts]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=459</guid>
		<description><![CDATA[Introduction Since the release of Visifire, we have got a lot of positive response from users on the simplicity, looks, customizability of Visifire over other Charting Controls in the market. What made it possible is, Visifire’s underlying set of algorithms that determine the best Visualization for a given set of parameters. So even when you [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Since the release of Visifire, we have got a lot of positive response from users on the simplicity, looks, customizability of Visifire over other Charting Controls in the market. What made it possible is, Visifire’s underlying set of algorithms that determine the best Visualization for a given set of parameters. So even when you provide bare minimum data required for rendering, Visifire renders a nice looking Chart which has tooltips, default interactivity like explode in Pie Chart, auto font-color for labels depending on the Chart Background color, auto indexing of DataPoints when XValue is not provided, etc.</p>
<p>Though Visifire makes effort to find the best visualization for any given case, its not always enough for all the applications. So we do have relevant properties for making it possible to customize according to individual needs. In this blog am going to explain the default rendering behavior of Visifire and how one can override them according to his needs.</p>
<p><strong>1. Pictorial representation of Various elements/regions in a Chart</strong></p>
<p><strong></strong></p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img1.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Silverlight Chart Control" border="0" alt="Silverlight Chart Control" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img1_thumb.jpg" width="709" height="445" /></a></p>
<p><strong>2. A Minimal Chart</strong></p>
<p>Below is a Minimal Chart and the XAML required to create it.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="Img2" border="0" alt="Img2" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img2_thumb.jpg" width="503" height="304" /></a></p>
<div class="csharpcode">
<pre class="alt">&lt;vc:Chart xmlns:vc=<span class="str">&quot;clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts&quot;</span></pre>
<pre>          Width=<span class="str">&quot;500&quot;</span> Height=<span class="str">&quot;300&quot;</span>&gt;            </pre>
<pre class="alt">    &lt;vc:Chart.Series&gt;</pre>
<pre>&#160;</pre>
<pre class="alt">        &lt;vc:DataSeries&gt;</pre>
<pre>            &lt;vc:DataSeries.DataPoints&gt;</pre>
<pre class="alt">                &lt;vc:DataPoint YValue=<span class="str">&quot;207349&quot;</span> /&gt;</pre>
<pre>                &lt;vc:DataPoint YValue=<span class="str">&quot;274316&quot;</span> /&gt;</pre>
<pre class="alt">                &lt;vc:DataPoint YValue=<span class="str">&quot;318845&quot;</span> /&gt;</pre>
<pre>                &lt;vc:DataPoint YValue=<span class="str">&quot;345254&quot;</span> /&gt;</pre>
<pre class="alt">                &lt;vc:DataPoint YValue=<span class="str">&quot;351139&quot;</span> /&gt;</pre>
<pre>            &lt;/vc:DataSeries.DataPoints&gt;</pre>
<pre class="alt">        &lt;/vc:DataSeries&gt;</pre>
<pre>&#160;</pre>
<pre class="alt">    &lt;/vc:Chart.Series&gt;</pre>
<pre>&lt;/vc:Chart&gt;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>In the above XML we have defined YValue for all the DataPoints. When we look at the rendered chart, we can observe that the DataPoints have been numbered from 1 to 5. DataPoints are numbered automatically in the order of their appearance. If you want to override this default behavior, you can either set XValue for numbers or AxisXLabel in case you want to display string. Note that setting XValue will place DataPoints according to the position of XValue on X-Axis. Chart also shows ToolTip by default.</p>
<p>So by default the Chart adds</p>
<ol>
<li>XValue &#8211; index values </li>
<li>ToolTip </li>
<li>Comma for every thousandth digit on YAxis </li>
</ol>
<p><strong>3. Customizing Visifire</strong></p>
<p>Chart in the previous section is Minimal in the sense we have not set any property required to customize the Chart. Below are few of the common stuff that you might want to add to the Chart.</p>
<ol>
<li><a href="http://www.visifire.com/documentation/Visifire_Documentation/Reference/Chart_Elements_Reference/Title.htm">Title</a> </li>
<li><a href="http://www.visifire.com/documentation/Visifire_Documentation/Reference/Attribute_Reference/XValue.htm">XValue</a>/<a href="http://www.visifire.com/documentation/Visifire_Documentation/Reference/Attribute_Reference/AxisXLabel.htm">AxisXLabel</a> for each DataPoint </li>
<li><a href="http://www.visifire.com/documentation/Visifire_Documentation/Reference/Attribute_Reference/Prefix.htm">Prefix</a> a symbol to the labels on YAxis &#8211; $ for example to make Label to look like $50,000 </li>
<li>Customize Values shown in the <a href="http://www.visifire.com/documentation/Visifire_Documentation/Reference/Chart_Elements_Reference/ToolTip.htm">Tooltip</a> </li>
</ol>
<p>Below is how the Chart looks after customization</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img3.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img3" border="0" alt="Img3" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img3_thumb.jpg" width="506" height="306" /></a></p>
<div class="csharpcode">
<pre class="alt">&lt;vc:Chart xmlns:vc=<span class="str">&quot;clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts&quot;</span></pre>
<pre>           Width=<span class="str">&quot;500&quot;</span> Height=<span class="str">&quot;300&quot;</span>&gt;</pre>
<pre class="alt">     </pre>
<pre>     &lt;vc:Chart.Titles&gt;</pre>
<pre class="alt">         &lt;vc:Title Text=<span class="str">&quot;Product Sales by Month&quot;</span>&gt;&lt;/vc:Title&gt;    </pre>
<pre>     &lt;/vc:Chart.Titles&gt;</pre>
<pre class="alt">     </pre>
<pre>     &lt;vc:Chart.AxesY&gt;</pre>
<pre class="alt">         &lt;vc:Axis Prefix=<span class="str">&quot;$&quot;</span>&gt;&lt;/vc:Axis&gt;</pre>
<pre>     &lt;/vc:Chart.AxesY&gt;</pre>
<pre class="alt">     </pre>
<pre>     &lt;vc:Chart.Series&gt;</pre>
<pre class="alt">         &lt;vc:DataSeries ToolTipText=<span class="str">&quot;#AxisXLabel, Y = #YValue&quot;</span>&gt;</pre>
<pre>             &lt;vc:DataSeries.DataPoints&gt;</pre>
<pre class="alt">                 &lt;vc:DataPoint AxisXLabel=<span class="str">&quot;Jan&quot;</span> YValue=<span class="str">&quot;207349&quot;</span> /&gt;</pre>
<pre>                 &lt;vc:DataPoint AxisXLabel=<span class="str">&quot;Feb&quot;</span> YValue=<span class="str">&quot;274316&quot;</span> /&gt;</pre>
<pre class="alt">                 &lt;vc:DataPoint AxisXLabel=<span class="str">&quot;Mar&quot;</span> YValue=<span class="str">&quot;318845&quot;</span> /&gt;</pre>
<pre>                 &lt;vc:DataPoint AxisXLabel=<span class="str">&quot;Apr&quot;</span> YValue=<span class="str">&quot;345254&quot;</span> /&gt;</pre>
<pre class="alt">                 &lt;vc:DataPoint AxisXLabel=<span class="str">&quot;May&quot;</span> YValue=<span class="str">&quot;351139&quot;</span> /&gt;</pre>
<pre>             &lt;/vc:DataSeries.DataPoints&gt;</pre>
<pre class="alt">         &lt;/vc:DataSeries&gt;</pre>
<pre>     &lt;/vc:Chart.Series&gt;</pre>
<pre class="alt"> &lt;/vc:Chart&gt;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>In the above example I&#8217;ve used AxisXLabel, as the Labels on the XAxis are strings. If the values are numeric, then you can use XValue. In case you set both the properties, then the DataPoints are placed according to XValue and XValues are replaced by AxisXLabels wherever available. Below is an example.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img4.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img4" border="0" alt="Img4" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img4_thumb.jpg" width="505" height="305" /></a></p>
<p><strong></strong></p>
<p><strong></strong></p>
<div class="csharpcode">
<pre class="alt">&lt;vc:Chart xmlns:vc=<span class="str">&quot;clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts&quot;</span></pre>
<pre>          Width=<span class="str">&quot;500&quot;</span> Height=<span class="str">&quot;300&quot;</span>&gt;</pre>
<pre class="alt">    </pre>
<pre>    &lt;vc:Chart.Series&gt;</pre>
<pre class="alt">        &lt;vc:DataSeries ToolTipText=<span class="str">&quot;#AxisXLabel, Y = #YValue&quot;</span>&gt;</pre>
<pre>            &lt;vc:DataSeries.DataPoints&gt;</pre>
<pre class="alt">                &lt;vc:DataPoint XValue=<span class="str">&quot;1&quot;</span> YValue=<span class="str">&quot;207349&quot;</span> /&gt;</pre>
<pre>                &lt;vc:DataPoint XValue=<span class="str">&quot;3&quot;</span> YValue=<span class="str">&quot;274316&quot;</span> /&gt;</pre>
<pre class="alt">                &lt;vc:DataPoint XValue=<span class="str">&quot;4&quot;</span> YValue=<span class="str">&quot;318845&quot;</span> /&gt;</pre>
<pre>                &lt;vc:DataPoint XValue=<span class="str">&quot;5&quot;</span> AxisXLabel=<span class="str">&quot;Five&quot;</span> YValue=<span class="str">&quot;345254&quot;</span> /&gt;</pre>
<pre class="alt">                &lt;vc:DataPoint XValue=<span class="str">&quot;6&quot;</span> YValue=<span class="str">&quot;351139&quot;</span> /&gt;</pre>
<pre>            &lt;/vc:DataSeries.DataPoints&gt;</pre>
<pre class="alt">        &lt;/vc:DataSeries&gt;                </pre>
<pre>    &lt;/vc:Chart.Series&gt;</pre>
<pre class="alt">&#160;</pre>
<pre>&lt;/vc:Chart&gt;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><strong>4. How the PlotArea width is calculated and how to control it</strong></p>
<p>While allocating region for various elements in the Chart, PlotArea viewport width is determined at the end after allocating region for Title, Legend, AxisX, AxisY. So for example, if we place Legend to the right, then the viewport size reduces depending on the Legend Size. Below is an illustration.</p>
<p><strong><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img5.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img5" border="0" alt="Img5" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img5_thumb.jpg" width="503" height="303" /></a> </strong></p>
<p>You can see that the PlotArea &quot;Viewport&quot; width has reduced because of the Legend. But at the same time, the Actual PlotArea Size can extend further resulting in a ScrollBar. This can happen whenever ScrollingEnabled is set to true.</p>
<p>Through some trials, we have determined the relation between the DataPoint Width and Chart Size which makes the Chart to look good/readable and accordingly we are setting the PlotArea Width. Below is the algorithm.</p>
<p>If, <strong>( Max Difference of XValues / Min Difference of XValues ) &gt; MagicNumber</strong>, that means PlotArea width needs to be more than that of the viewport width &#8211; which results in ScrollBar. We found the equation for MagicNumber through trials with varying chart sizes and varying number of DataPoints. Below is how we calculate it.</p>
<p><strong>MagicNumber = Current PlotArea width * 35 / 550 </strong></p>
<p><strong></strong></p>
<p>Now, PlotArea width can be calculated as below.</p>
<p><strong>PlotArea width = ( Max Difference of XValues / Min Difference of XValues ) * 550 / 34</strong></p>
<p><strong></strong></p>
<p>For multi series Column and Bar Charts, we need to multiply 550 with appropriate number of series that get rendered side by side.</p>
<p><strong>5. How Datapoint width is calculated and how to control it</strong></p>
<p>In case of Column and Bar Charts, DataPointWidth is determined based on the two closest DataPoints. Say, the XValues of 4 DataPoints are {1, 4, 5, 7, 9}, then the closest two DataPoints are 2nd and 3rd with difference in XValue of 1. So, in order to be able to draw both the DataPoints without overlap, we need to divide the available space between the two. As a result of which, Maximum Width of DataPoints will be equal to the minimum difference between XValues.</p>
<p>Now, we also need to give some spacing between the two DataPoints which is determined as .1 * ( Minimum Difference of XValues ). So, the DataPoint width finally comes down to .9 * ( Minimum Difference of XValues ) . In case the Chart is MultiSeries, then we need to place multiple columns within the same region. So, the column width calculated as above is divided by the number of series needed to be drawn.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img6.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Img6" border="0" alt="Img6" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img6_thumb.jpg" width="506" height="306" /></a></p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img7.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img7" border="0" alt="Img7" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img7_thumb.jpg" width="506" height="305" /></a></p>
<p>In certain cases, the calculated width can go below 1px which will make Columns invisible. So, Visifire sets a lower limit of 2px to DataPoint width. You can also control the width of DataPoint by setting DataPointWidth property as a percentage of PlotArea ViewPort width. For example, setting the DataPointWidth to 5 will result in a Chart as below.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img8.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img8" border="0" alt="Img8" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img8_thumb.jpg" width="505" height="305" /></a></p>
<p>Please note that increasing/decreasing the Width of DataPoints will not change the relative position of DataPoints. So, if you increase the DataPointWidth over a certain range, columns will actually overlap. In the next section I&#8217;ll explain how you can overcome this limitation.</p>
<p><strong>6. How Axis, Interval and AxisLabels work</strong></p>
<p>Whenever you create a chart, by default Visifire tries to calculate the best possible Range and interval for Axis so that it is easier for the Humans to grasp/read. Human readable in the sense, it tries to make the interval a multiple of 1,2,5 or 10 and tries to keep the number of intervals around 8. So, whenever the interval is not 1, it might skip some of the AxisXLabel if you have defined.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img10.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img10" border="0" alt="Img10" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img10_thumb.jpg" width="504" height="306" /></a></p>
<div class="csharpcode">
<pre class="alt">&lt;vc:DataSeries.DataPoints&gt;</pre>
<pre>     &lt;vc:DataPoint XValue=<span class="str">&quot;1&quot;</span> YValue=<span class="str">&quot;207349&quot;</span> /&gt;</pre>
<pre class="alt">     &lt;vc:DataPoint XValue=<span class="str">&quot;3&quot;</span> YValue=<span class="str">&quot;274316&quot;</span> /&gt;</pre>
<pre>     &lt;vc:DataPoint XValue=<span class="str">&quot;4&quot;</span> AxisXLabel=<span class="str">&quot;Four&quot;</span> YValue=<span class="str">&quot;318845&quot;</span> /&gt;</pre>
<pre class="alt">     &lt;vc:DataPoint XValue=<span class="str">&quot;5&quot;</span> YValue=<span class="str">&quot;345254&quot;</span> /&gt;</pre>
<pre>     &lt;vc:DataPoint XValue=<span class="str">&quot;6&quot;</span> YValue=<span class="str">&quot;351139&quot;</span> /&gt;</pre>
<pre class="alt">     &lt;vc:DataPoint XValue=<span class="str">&quot;7&quot;</span> YValue=<span class="str">&quot;217349&quot;</span> /&gt;</pre>
<pre>     &lt;vc:DataPoint XValue=<span class="str">&quot;9&quot;</span> YValue=<span class="str">&quot;224316&quot;</span> /&gt;</pre>
<pre class="alt">     &lt;vc:DataPoint XValue=<span class="str">&quot;10&quot;</span> YValue=<span class="str">&quot;298845&quot;</span> /&gt;</pre>
<pre>     &lt;vc:DataPoint XValue=<span class="str">&quot;11&quot;</span> YValue=<span class="str">&quot;335254&quot;</span> /&gt;</pre>
<pre class="alt">     &lt;vc:DataPoint XValue=<span class="str">&quot;13&quot;</span> YValue=<span class="str">&quot;371139&quot;</span> /&gt;</pre>
<pre> &lt;/vc:DataSeries.DataPoints&gt;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Note that I&#8217;ve skipped all other elements apart from DataPoints collection just to keep the xaml compact. In the above example you can see that the interval is 2. So, if in case you set AxisXLabel for 3rd DataPoint, then it&#8217;ll not be shown. You can override this default behavior by setting the interval property of Axis to 1 as shown below.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img11.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img11" border="0" alt="Img11" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img11_thumb.jpg" width="505" height="306" /></a></p>
<div class="csharpcode">
<pre class="alt">&lt;vc:Chart.AxesX&gt;</pre>
<pre>    &lt;vc:Axis Interval=<span class="str">&quot;1&quot;</span>&gt;&lt;/vc:Axis&gt;</pre>
<pre class="alt">&lt;/vc:Chart.AxesX&gt;</pre>
<pre>&#160;</pre>
<pre class="alt">&lt;vc:Chart.Series&gt;</pre>
<pre>    &lt;vc:DataSeries ToolTipText=<span class="str">&quot;#AxisXLabel, Y = #YValue&quot;</span>&gt;</pre>
<pre class="alt">        &lt;vc:DataSeries.DataPoints&gt;</pre>
<pre>            &lt;vc:DataPoint XValue=<span class="str">&quot;1&quot;</span> YValue=<span class="str">&quot;207349&quot;</span> /&gt;</pre>
<pre class="alt">            &lt;vc:DataPoint XValue=<span class="str">&quot;3&quot;</span> YValue=<span class="str">&quot;274316&quot;</span> /&gt;</pre>
<pre>            &lt;vc:DataPoint XValue=<span class="str">&quot;4&quot;</span> AxisXLabel=<span class="str">&quot;Four&quot;</span> YValue=<span class="str">&quot;318845&quot;</span> /&gt;</pre>
<pre class="alt">            &lt;vc:DataPoint XValue=<span class="str">&quot;5&quot;</span> YValue=<span class="str">&quot;345254&quot;</span> /&gt;</pre>
<pre>            &lt;vc:DataPoint XValue=<span class="str">&quot;6&quot;</span> YValue=<span class="str">&quot;351139&quot;</span> /&gt;</pre>
<pre class="alt">            &lt;vc:DataPoint XValue=<span class="str">&quot;7&quot;</span> YValue=<span class="str">&quot;217349&quot;</span> /&gt;</pre>
<pre>            &lt;vc:DataPoint XValue=<span class="str">&quot;9&quot;</span> YValue=<span class="str">&quot;224316&quot;</span> /&gt;</pre>
<pre class="alt">            &lt;vc:DataPoint XValue=<span class="str">&quot;10&quot;</span> YValue=<span class="str">&quot;298845&quot;</span> /&gt;</pre>
<pre>            &lt;vc:DataPoint XValue=<span class="str">&quot;11&quot;</span> YValue=<span class="str">&quot;335254&quot;</span> /&gt;</pre>
<pre class="alt">            &lt;vc:DataPoint XValue=<span class="str">&quot;13&quot;</span> YValue=<span class="str">&quot;371139&quot;</span> /&gt;</pre>
<pre>        &lt;/vc:DataSeries.DataPoints&gt;</pre>
<pre class="alt">    &lt;/vc:DataSeries&gt;          </pre>
<pre>&lt;/vc:Chart.Series&gt;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>While rendering the Axis, Visifire tries to automatically place AxisLabels in such a way that they don&#8217;t overlap. Say, if we change the AxisXLabel from &quot;Four&quot; to &quot;XValue is Four&quot;, then it is obvious that the Label is long and it&#8217;ll overlap the neighboring AxisLabels. So, Visifire starts showing labels in 2 rows as shown below.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img12.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img12" border="0" alt="Img12" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img12_thumb.jpg" width="504" height="305" /></a></p>
<p>Now if we further increase the AxisXLabel to &quot;DataPoint XValue is Four&quot;, then it becomes difficult to show Labels in two rows. So the next alternative will be to rotate the AxisLabel so that it doesn&#8217;t overlap the neighboring AxisXLabels.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img13.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img13" border="0" alt="Img13" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img13_thumb.jpg" width="503" height="305" /></a></p>
<p>You can customize Axis by setting Interval, MinimumValue, MaximumValue, etc as mentioned in the following <a href="http://www.visifire.com/documentation/Visifire_Documentation/Reference/Chart_Elements_Reference/Axis.htm">document</a>.</p>
<p><strong>7. How Labels are placed</strong></p>
<p>Below is an image showing Labels in Visifire. In order to show Label, one needs to enable them by setting LabelEnabled to True in DataSeries.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img14.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Img14" border="0" alt="Img14" src="http://visifire.com/blog/wp-content/post_images/StepbystepbreakdownofVisifirerenderinglo_D34F/Img14_thumb.jpg" width="505" height="304" /></a></p>
<div class="csharpcode">
<pre class="alt">&lt;vc:DataSeries LabelEnabled=<span class="str">&quot;True&quot;</span> ToolTipText=<span class="str">&quot;#AxisXLabel, Y = #YValue&quot;</span>&gt;</pre>
<pre>    &lt;vc:DataSeries.DataPoints&gt;</pre>
<pre class="alt">        &lt;vc:DataPoint YValue=<span class="str">&quot;207349&quot;</span> /&gt;</pre>
<pre>        &lt;vc:DataPoint YValue=<span class="str">&quot;274316&quot;</span> /&gt;</pre>
<pre class="alt">        &lt;vc:DataPoint YValue=<span class="str">&quot;318845&quot;</span> /&gt;</pre>
<pre>        &lt;vc:DataPoint LabelText=<span class="str">&quot;Label&quot;</span> YValue=<span class="str">&quot;345254&quot;</span> /&gt;</pre>
<pre class="alt">        &lt;vc:DataPoint YValue=<span class="str">&quot;351139&quot;</span> /&gt;</pre>
<pre>        &lt;vc:DataPoint YValue=<span class="str">&quot;217349&quot;</span> /&gt;</pre>
<pre class="alt">        &lt;vc:DataPoint YValue=<span class="str">&quot;224316&quot;</span> /&gt;</pre>
<pre>        &lt;vc:DataPoint YValue=<span class="str">&quot;298845&quot;</span> /&gt;</pre>
<pre class="alt">        &lt;vc:DataPoint YValue=<span class="str">&quot;335254&quot;</span> /&gt;</pre>
<pre>        &lt;vc:DataPoint YValue=<span class="str">&quot;371139&quot;</span> /&gt;                           </pre>
<pre class="alt">    &lt;/vc:DataSeries.DataPoints&gt;</pre>
<pre>&lt;/vc:DataSeries&gt;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>See that Labels and AxisLabels are different. AxisLabel is one which is shown below the Axis and Labels are shows on/above the DataPoints.</p>
<p>You can observe that few of the Labels are outside the DataPoint and few are inside. Few have Black font color and few have White. Though the placement seems random at first place, it is not. Below I&#8217;ll explain the flow.</p>
<p>While placing Label for a DataPoint, Visifire first tries to place it horizonatally outside DataPoint. If the DataPoint width is more than the Label&#8217;s width, then Label is placed horizontally as in case of 4th DataPoint. If the DataPoint width is less than that of Label&#8217;s, then the Label is placed vertically. Now, whether the Label is placed on top of columns or inside the columns is determined by the availability of space outside the Column. If there is enough space outside the column, then the Labels are placed outside of DataPoint. If not, then the Labels are placed inside DataPoint.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2009/10/16/step-by-step-breakdown-of-visifire-rendering-logic/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating Silverlight Charts from SQL Data using ASP.Net and Visifire</title>
		<link>http://www.visifire.com/blog/2009/05/21/creating-silverlight-charts-from-sql-data-using-aspnet-and-visfire/</link>
		<comments>http://www.visifire.com/blog/2009/05/21/creating-silverlight-charts-from-sql-data-using-aspnet-and-visfire/#comments</comments>
		<pubDate>Thu, 21 May 2009 13:23:00 +0000</pubDate>
		<dc:creator>vivek</dc:creator>
				<category><![CDATA[Tutorials and Samples]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=356</guid>
		<description><![CDATA[Introduction In this tutorial am going to show you how to pull SQL data and create a nice chart out of it using Visifire. It just takes few minutes!! In order to create this sample, I chose Microsoft SQL Server Sample database Northwind.mdf. You can download it here. Visifire is available in two flavors. One [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>In this tutorial am going to show you how to pull SQL data and create a nice chart out of it using Visifire. It just takes few minutes!!</p>
<p>In order to create this sample, I chose Microsoft SQL Server Sample database Northwind.mdf. You can download it <a href="http://www.microsoft.com/downloads/details.aspx?familyid=06616212-0356-46a0-8da2-eebc53a68034&amp;displaylang=en">here</a>.</p>
<p>Visifire is available in two flavors. One in the form of an assembly which you can use within Silverlight applications and another one packaged as .xap file which you can embed within any webpage. Am using the latter one.</p>
<p>Visifire requires the Data to be furnished in the form of XML through a JavaScript API (Visifire2.js). You can either pass an XML string or specify the URI where XML data is available. In this example am using the latter method. In order to understand the basic XML structure required by Visifire, you can refer the <a href="http://visifire.com/visifire_charts_documentation.php">documentation</a>.</p>
<h2>Project Setup</h2>
<p>Create an “ASP.Net Web Application” project and add a new folder “Visifire”. Download the latest Visifire binaries from <a href="http://www.visifire.com/download_silverlight_charts.php">here</a>. Extract the Zip file and add two files named “SL.Visifire.Charts.xap” and “Visifire2.js” to the folder. Now, add NORTHWND.MDF file into App_Data folder in the solution.</p>
<p>Am using two aspx pages in this sample.</p>
<ol>
<li>Data.aspx – One which pull the Data from SQL and creates required XML structure out of it. Am using aspx page just to keep it simple.</li>
<li>Default.aspx – Chart is embedded into this page.</li>
</ol>
<p><a href="http://visifire.com/blog/wp-content/post_images/CreatingVisifireChartfromSQLDatainAS.Net_D7F7/solutionexplorer.jpg"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://visifire.com/blog/wp-content/post_images/CreatingVisifireChartfromSQLDatainAS.Net_D7F7/solutionexplorer_thumb.jpg" border="0" alt="solutionexplorer" width="269" height="279" /></a></p>
<p>Below are the steps that we are going to follow.</p>
<ol>
<li>Pull the SQL Data in Data.aspx.cs file.</li>
<li>Construct the Data XML inside Data.aspx.cs and return.</li>
<li>Embed the Chart into Default.aspx page and set the DataUri to Data.aspx.</li>
</ol>
<p> </p>
<h2>Pulling the Data From SQL Server DataBase</h2>
<p>Just to keep it simple, am going to pull the Data in an aspx page (Data.aspx.cs), build XML out of it and return.</p>
<p>Open Data.aspx file and remove all the html code except for Page directive. So the page should have only one line of code.</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border: silver 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">&lt;%@ Page Language=<span style="color: #006080">"C#"</span> AutoEventWireup=<span style="color: #006080">"true"</span> CodeFile=<span style="color: #006080">"Data.aspx.cs"</span> Inherits=<span style="color: #006080">"Data"</span> %&gt;</pre>
</div>
<p>Now open Data.aspx.cs file and add the following code to setup a SQL Server DataBase connection inside the Page_Load event handler as shown below.</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border: silver 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;"><span style="color: #008000">// Set the NORTHWND.MDF file path</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">String path = Server.MapPath(<span style="color: #006080">"App_Data/NORTHWND.MDF"</span>);

<span style="color: #008000">// Set the connection string</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">String connectionString = <span style="color: #006080">"Data Source=.\\SQLEXPRESS;AttachDbFilename="</span> + path + <span style="color: #006080">";Integrated Security=True;User Instance=True"</span>;

<span style="color: #008000">// Query DataBase</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">String query = <span style="color: #006080">"SELECT CategoryName, SUM(ProductSales) AS CategorySales"</span> </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">               + <span style="color: #006080">" FROM [Product Sales for 1997] "</span> </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">               + <span style="color: #006080">"GROUP BY CategoryName"</span>;

<span style="color: #008000">// Initialize the Sql connection</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">SqlConnection con = <span style="color: #0000ff">new</span> SqlConnection(connectionString);

<span style="color: #008000">// Open connection</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">con.Open();

<span style="color: #008000">// Initialize DataTable class</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">DataTable dt = <span style="color: #0000ff">new</span> DataTable();

<span style="color: #008000">// Initialize SqlDataAdapter class</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">SqlDataAdapter da = <span style="color: #0000ff">new</span> SqlDataAdapter();

<span style="color: #008000">// Set the Sql command</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">da.SelectCommand = <span style="color: #0000ff">new</span> SqlCommand(query, con);

<span style="color: #008000">// Fill DataSet with rows</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">da.Fill(dt);

<span style="color: #008000">// Close connection</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">con.Close();</pre>
</div>
<div> </div>
<h2>Creating the XML Data</h2>
<p>Now am going to build the Data XML that needs to be passed over to Visifire Chart control. Sample XML Data Looks like below.</p>
<div>
<div class="csharpcode"><!--CRLF--></div>
</div>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border: silver 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">&lt;vc:Chart xmlns:vc=<span style="color: #006080">"clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts"</span> Width=<span style="color: #006080">"500"</span> Height=<span style="color: #006080">"300"</span> Theme=<span style="color: #006080">"Theme1"</span> &gt;

    &lt;vc:Chart.AxesY&gt;        </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">        &lt;vc:Axis Prefix=<span style="color: #006080">"$"</span>&gt;&lt;/vc:Axis&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">    &lt;/vc:Chart.AxesY&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">    &lt;vc:Chart.Titles&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">        &lt;vc:Title Text=<span style="color: #006080">"Category wise Sales for the year 1997"</span> FontSize=<span style="color: #006080">"14"</span>/&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">    &lt;/vc:Chart.Titles&gt;

    &lt;vc:Chart.Series&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">        &lt;vc:DataSeries RenderAs=<span style="color: #006080">"Column"</span>&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">            &lt;vc:DataSeries.DataPoints&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">                &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Beverages"</span> YValue=<span style="color: #006080">"102074.3100"</span>/&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">                &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Condiments"</span> YValue=<span style="color: #006080">"55277.6000"</span>/&gt; </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">                &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Confections"</span> YValue=<span style="color: #006080">"80894.1400"</span>/&gt; </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">                &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Dairy Products"</span> YValue=<span style="color: #006080">"114749.7800"</span>/&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">                &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Grains/Cereals"</span> YValue=<span style="color: #006080">"55948.8200"</span>/&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">                &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Meat/Poultry"</span> YValue=<span style="color: #006080">"81338.0600"</span>/&gt; </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">                &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Produce"</span> YValue=<span style="color: #006080">"53019.9800"</span>/&gt;   </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">                &lt;vc:DataPoint AxisXLabel=<span style="color: #006080">"Seafood"</span> YValue=<span style="color: #006080">"65544.1800"</span>/&gt; </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">            &lt;/vc:DataSeries.DataPoints&gt; </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">        &lt;/vc:DataSeries&gt; </pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">    &lt;/vc:Chart.Series&gt;

&lt;/vc:Chart&gt;</pre>
</div>
<p>You can play around with the <a href="http://visifire.com/silverlight_chart_designer.php">Chart Designer</a> to get a better picture of Visifire’s basic features.</p>
<p>Below is the code which generates the required XML.</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border: silver 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;"><span style="color: #008000">// Initialize StringBuilder class</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">StringBuilder chartXml = <span style="color: #0000ff">new</span> StringBuilder();

<span style="color: #008000">// Append chart XML data</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;vc:Chart xmlns:vc=\"clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts\" Width=\"500\" Height=\"300\" Theme=\"Theme1\" &gt;"</span>);

chartXml.Append(<span style="color: #006080">"&lt;vc:Chart.AxesY&gt;"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;vc:Axis Prefix=\"$\"&gt;&lt;/vc:Axis&gt;"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;/vc:Chart.AxesY&gt;"</span>);

chartXml.Append(<span style="color: #006080">"&lt;vc:Chart.Titles&gt;"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;vc:Title Text=\"Category wise Sales for the year 1997\" FontSize=\"14\"/&gt;"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;/vc:Chart.Titles&gt;"</span>);

chartXml.Append(<span style="color: #006080">"&lt;vc:Chart.Series&gt;"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;vc:DataSeries RenderAs=\"Column\" &gt;"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;vc:DataSeries.DataPoints&gt;"</span>);

<span style="color: #0000ff">foreach</span> (DataRow dataRow <span style="color: #0000ff">in</span> dt.Rows)</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">    chartXml.Append(<span style="color: #006080">"&lt;vc:DataPoint AxisXLabel=\""</span> + dataRow[<span style="color: #006080">"CategoryName"</span>].ToString() + <span style="color: #006080">"\" YValue=\""</span> + dataRow[<span style="color: #006080">"CategorySales"</span>].ToString() + <span style="color: #006080">"\"/&gt;"</span>);

chartXml.Append(<span style="color: #006080">"&lt;/vc:DataSeries.DataPoints&gt;"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;/vc:DataSeries&gt;"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;/vc:Chart.Series&gt;"</span>);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">chartXml.Append(<span style="color: #006080">"&lt;/vc:Chart&gt;"</span>);

<span style="color: #008000">// Write object to an HTTP response stream</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">Response.Write(chartXml);</pre>
</div>
<p> </p>
<h2>Create Chart</h2>
<p>Now open Default.aspx page and add the following code. First we need to add a reference to Visifire2.js file inside the Head section of Default.aspx page.</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border: silver 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">&lt;head runat=<span style="color: #006080">"server"</span>&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">    &lt;script type=<span style="color: #006080">"text/javascript"</span> src=<span style="color: #006080">"./Visifire/Visifire2.js"</span>&gt;&lt;/script&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">&lt;/head&gt;</pre>
</div>
<p>Then inside the body, create a div element and add the JavaScript code which renders the Chart.</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border: silver 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">&lt;div id=<span style="color: #006080">"VisifireChart0"</span>&gt;

    &lt;script type=<span style="color: #006080">"text/javascript"</span>&gt;

        <span style="color: #008000">// Create Visifire object</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">        var vChart = <span style="color: #0000ff">new</span> Visifire2(<span style="color: #006080">'Visifire/SL.Visifire.Charts.xap'</span>, <span style="color: #006080">"MyChart"</span>, 500, 300);

        <span style="color: #008000">// Set Chart Data xml source</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">        vChart.setDataUri(<span style="color: #006080">"Data.aspx?reqtime="</span> + (<span style="color: #0000ff">new</span> Date()).getTime());

        <span style="color: #008000">// Render the chart</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New', courier, monospace; background-color: #f4f4f4; text-align: left; border-style: none; padding: 0px;">        vChart.render(<span style="color: #006080">"VisifireChart0"</span>);

    &lt;/script&gt;

&lt;/div&gt;</pre>
</div>
<p> </p>
<p>Make sure that the path for Visifire2.js and SL.Visifire.Charts.xap files are correct. Set Default.aspx as Start Page and run the application.</p>
<p>Below is a snapshot of the chart.</p>
<p><a href="http://visifire.com/blog/wp-content/post_images/CreatingVisifireChartfromSQLDatainAS.Net_D7F7/blogimage.jpg"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://visifire.com/blog/wp-content/post_images/CreatingVisifireChartfromSQLDatainAS.Net_D7F7/blogimage_thumb.jpg" border="0" alt="blogimage" width="457" height="291" /></a> <a href="http://11011.net/software/vspaste"></a></p>
<p> </p>
<p>You can download the complete solution <a href="http://www.visifire.com/downloads/samples/managed/visifirechartsample_210509.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2009/05/21/creating-silverlight-charts-from-sql-data-using-aspnet-and-visfire/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>DateTime Axis with Visifire</title>
		<link>http://www.visifire.com/blog/2009/03/20/datetime-axis-with-visifire/</link>
		<comments>http://www.visifire.com/blog/2009/03/20/datetime-axis-with-visifire/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 15:37:50 +0000</pubDate>
		<dc:creator>Chirag</dc:creator>
				<category><![CDATA[Tutorials and Samples]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=271</guid>
		<description><![CDATA[Current release includes a major feature – DateTime Axis. If the XValue of the DataPoints are of type DateTime, Visifire automatically switches XAxis to Date Axis. For more precision on the visualization following properties can be used. Two properties have been introduced: XValueType in DataSeries, and IntervalType in AxisX. XValueType can have any of these [...]]]></description>
			<content:encoded><![CDATA[<p>Current release includes a major feature – DateTime Axis. If the XValue of the DataPoints are of type DateTime, Visifire automatically switches XAxis to Date Axis. For more precision on the visualization following properties can be used.</p>
<p>Two properties have been introduced:</p>
<ol>
<li>XValueType in DataSeries, and</li>
<li>IntervalType in AxisX.</li>
</ol>
<p>XValueType can have any of these following values</p>
<ul>
<li>Auto (Default)</li>
<li>Numeric</li>
<li>Date</li>
<li>DateTime, or</li>
<li>Time</li>
</ul>
<p>IntervalType property can have any of these following values</p>
<ul>
<li>(Default) Auto</li>
<li>Number</li>
<li>Years</li>
<li>Months</li>
<li>Weeks</li>
<li>Days</li>
<li>Hours</li>
<li>Minutes</li>
<li>Seconds, or</li>
<li>Milliseconds</li>
</ul>
<p>By default the XValueType is set to Date, if XValue is of type DateTime. To consider both date &amp; time in the axis, XValueType should be set to DateTime. If you want to consider only the Time part of DateTime, it can be done so by setting XValueType to Time.</p>
<p>IntervalType will be set to the most relevant one internally, according to XValues. However, it can be set manually according to the requirement.</p>
<p>Below are some samples for DateTime Axis.</p>
<p><strong>DateTime Axis Example:</strong></p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">&lt;vc:Chart Name=<span style="color: #006080">"MyChart"</span> Theme=<span style="color: #006080">"Theme1"</span> xmlns:vc=<span style="color: #006080">"clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts"</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">          Width=<span style="color: #006080">"500"</span> Height=<span style="color: #006080">"300"</span> ScrollingEnabled=<span style="color: #006080">"False"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;vc:Chart.Titles&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;vc:Title Text=<span style="color: #006080">"DateTime Axis"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;/vc:Chart.Titles&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;vc:Chart.AxesX&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;vc:Axis IntervalType=<span style="color: #006080">"Days"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;/vc:Axis&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;/vc:Chart.AxesX&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;vc:Chart.Series&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;vc:DataSeries RenderAs=<span style="color: #006080">"Column"</span> XValueType=<span style="color: #006080">"DateTime"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">            &lt;vc:DataSeries.DataPoints&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"1/30/2000 12:00:12"</span> YValue=<span style="color: #006080">"20"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"2/15/2000 10:12:4"</span> YValue=<span style="color: #006080">"10"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"3/02/2000 23:00:6"</span> YValue=<span style="color: #006080">"30"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"2/03/2000 18:45:10"</span> YValue=<span style="color: #006080">"40"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"2/02/2000 12:00:00"</span> YValue=<span style="color: #006080">"15"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"2/28/2000 12:22:00"</span> YValue=<span style="color: #006080">"28"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">            &lt;/vc:DataSeries.DataPoints&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;/vc:DataSeries&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;/vc:Chart.Series&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">&lt;/vc:Chart&gt;</pre>
</div>
</div>
<p><a href="http://www.visifire.com/downloads/samples/embedded/datetime/demo/DateTimeAxis.htm"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Click to see DateTimeAxis in action" src="http://www.visifire.com/blog/wp-content/post_images/DateTimeAxiswithVisifire_125CA/DateTimeAxis.jpg" border="0" alt="Click to see DateTimeAxis in action" width="501" height="304" /></a></p>
<p><strong></strong></p>
<p><strong>Date Axis Example:</strong></p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">&lt;vc:Chart Name=<span style="color: #006080">"MyChart"</span> Theme=<span style="color: #006080">"Theme1"</span> xmlns:vc=<span style="color: #006080">"clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts"</span> Width=<span style="color: #006080">"500"</span> Height=<span style="color: #006080">"300"</span> ScrollingEnabled=<span style="color: #006080">"False"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;vc:Chart.Titles&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;vc:Title Text=<span style="color: #006080">"Date Axis"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;/vc:Chart.Titles&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;vc:Chart.AxesX&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;vc:Axis IntervalType=<span style="color: #006080">"Months"</span> Interval=<span style="color: #006080">"1"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;/vc:Axis&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;/vc:Chart.AxesX&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;vc:Chart.Series&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;vc:DataSeries RenderAs=<span style="color: #006080">"Column"</span> XValueType=<span style="color: #006080">"Date"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">            &lt;vc:DataSeries.DataPoints&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"1/5/2000 12:00:12"</span> YValue=<span style="color: #006080">"20"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"2/8/2000 10:12:4"</span> YValue=<span style="color: #006080">"10"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"3/2/2000 23:00:6"</span> YValue=<span style="color: #006080">"30"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"2/3/2000 18:45:10"</span> YValue=<span style="color: #006080">"40"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"4/2/2000 12:00:00"</span> YValue=<span style="color: #006080">"15"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                &lt;vc:DataPoint XValue=<span style="color: #006080">"5/6/2000 12:22:00"</span> YValue=<span style="color: #006080">"28"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">            &lt;/vc:DataSeries.DataPoints&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">        &lt;/vc:DataSeries&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">    &lt;/vc:Chart.Series&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">&lt;/vc:Chart&gt;</pre>
</div>
</div>
<p><a href="http://www.visifire.com/downloads/samples/embedded/datetime/demo/DateAxis.htm"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Click to see DateAxis in action" src="http://www.visifire.com/blog/wp-content/post_images/DateTimeAxiswithVisifire_125CA/DateAxis.jpg" border="0" alt="Click to see DateAxis in action" width="500" height="304" /></a></p>
<p><strong></strong></p>
<p><strong>Time Axis Example:</strong></p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">&lt;vc:Chart Name=<span style="color: #006080">"MyChart"</span> Theme=<span style="color: #006080">"Theme1"</span> xmlns:vc=<span style="color: #006080">"clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts"</span> Width=<span style="color: #006080">"500"</span> Height=<span style="color: #006080">"300"</span> ScrollingEnabled=<span style="color: #006080">"False"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">     &lt;vc:Chart.Titles&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">         &lt;vc:Title Text=<span style="color: #006080">"Time Axis"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">     &lt;/vc:Chart.Titles&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">     &lt;vc:Chart.AxesX&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">         &lt;vc:Axis IntervalType=<span style="color: #006080">"Seconds"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">         &lt;/vc:Axis&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">     &lt;/vc:Chart.AxesX&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">     &lt;vc:Chart.Series&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">         &lt;vc:DataSeries RenderAs=<span style="color: #006080">"Column"</span> XValueType=<span style="color: #006080">"Time"</span>&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">             &lt;vc:DataSeries.DataPoints&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                 &lt;vc:DataPoint XValue=<span style="color: #006080">"1/30/2000 1:00:12"</span> YValue=<span style="color: #006080">"20"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                 &lt;vc:DataPoint XValue=<span style="color: #006080">"2/15/2000 2:2:4"</span> YValue=<span style="color: #006080">"10"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                 &lt;vc:DataPoint XValue=<span style="color: #006080">"3/02/2000 2:12:6"</span> YValue=<span style="color: #006080">"30"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                 &lt;vc:DataPoint XValue=<span style="color: #006080">"2/03/2000 2:28:10"</span> YValue=<span style="color: #006080">"40"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                 &lt;vc:DataPoint XValue=<span style="color: #006080">"8/02/2000 3:12:6"</span> YValue=<span style="color: #006080">"30"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">                 &lt;vc:DataPoint XValue=<span style="color: #006080">"2/04/2000 8:12:10"</span> YValue=<span style="color: #006080">"40"</span>/&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">             &lt;/vc:DataSeries.DataPoints&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">         &lt;/vc:DataSeries&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">     &lt;/vc:Chart.Series&gt;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"> &lt;/vc:Chart&gt;</pre>
</div>
</div>
<p><a href="http://www.visifire.com/downloads/samples/embedded/datetime/demo/TimeAxis.htm"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Click to see TimeAxis in action" src="http://www.visifire.com/blog/wp-content/post_images/DateTimeAxiswithVisifire_125CA/TimeAxis.jpg" border="0" alt="Click to see TimeAxis in action" width="501" height="304" /></a></p>
<p>Cheers,</p>
<p>Team Visfire</p>
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2009/03/20/datetime-axis-with-visifire/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Drilldown Silverlight Charts using Visifire</title>
		<link>http://www.visifire.com/blog/2009/03/05/drilldown-silverlight-charts-using-visifire/</link>
		<comments>http://www.visifire.com/blog/2009/03/05/drilldown-silverlight-charts-using-visifire/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 10:24:25 +0000</pubDate>
		<dc:creator>Chirag</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tutorials and Samples]]></category>

		<guid isPermaLink="false">http://www.visifire.com/blog/?p=258</guid>
		<description><![CDATA[Creating Drilldown chart is a common requirement in any RIA dashboard. Drilldown charts give rich user experience. In this blog let’s see how we can create drilldown charts using Visifire. In this sample application, chart can be drilled down till 2 levels. The default chart would show yearly sales of a fictitious company for the [...]]]></description>
			<content:encoded><![CDATA[<p>Creating Drilldown chart is a common requirement in any RIA dashboard. Drilldown charts give rich user experience. In this blog let’s see how we can create drilldown charts using Visifire.</p>
<p>In this sample application, chart can be drilled down till 2 levels. The default chart would show <strong>yearly sales</strong> of a fictitious company for the period 2006-2008. On click of column representing the sales for an year, <strong>monthly sales for that year</strong> is shown up. Further it can be drilled down to find <strong>product wise sales for the selected month</strong>.</p>
<p>This sample uses Javascript API to generate charts. The complete application can be downloaded from <a href="http://www.visifire.com/downloads/samples/embedded/drilldown_sample_05032009/drilldown_sample_05032009.zip">here</a>. The code is completely commented &amp; explained wherever necessary. Refer the rest of the blog if you need more help.</p>
<p><a title="Silverlight Drilldown Chart" href="http://www.visifire.com/downloads/samples/embedded/drilldown_sample_05032009/demo/drilldown.html"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="Click to see the sample in action" src="http://www.visifire.com/blog/wp-content/post_images/DrilldownSilverlightChartsusingVisifire_D0CF/image.png" border="0" alt="Click to see the sample in action" width="689" height="633" /></a></p>
<p>Data can be pulled in from any data source. To keep the example simple let’s store the sales data in an array.</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">var sales;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #008000">// Create array for the Sales data</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">sales = [{year: 2006, month: <span style="color: #006080">"Jan"</span>, ProductX: 20000, ProductY: 25000, ProductZ: 15000},</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">         {year: 2006, month: <span style="color: #006080">"Feb"</span>, ProductX: 10000, ProductY: 23000, ProductZ: 25000},</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">         {year: 2006, month: <span style="color: #006080">"Mar"</span>, ProductX: 22000, ProductY: 38000, ProductZ: 83000},</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">         {year: 2006, month: <span style="color: #006080">"Apr"</span>, ProductX: 23456, ProductY: 32435, ProductZ: 24223},</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">         {year: 2006, month: <span style="color: #006080">"May"</span>, ProductX: 25142, ProductY: 32415, ProductZ: 10923},</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">         {year: 2006, month: <span style="color: #006080">"Jun"</span>, ProductX: 18254, ProductY: 15342, ProductZ: 10934},</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">         {year: 2006, month: <span style="color: #006080">"Jul"</span>, ProductX: 18562, ProductY: 19832, ProductZ: 10293},</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">         {year: 2006, month: <span style="color: #006080">"Aug"</span>, ProductX: 28376, ProductY: ..............</pre>
</div>
</div>
<p>Construct the XML string from the data stored in the array.</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">function getYearlySales()</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">{</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    isChart1Added = <span style="color: #0000ff">true</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    var myXAML;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    <span style="color: #008000">// Constructing Data XAML</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = <span style="color: #006080">'&lt;vc:Chart Theme="Theme2" Width="650" Height="450" ColorSet="Visifire1" Background="Black" xmlns:vc="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts" &gt;'</span> + <span style="color: #006080">"\n"</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:Chart.Titles&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:Title Text= "Yearly Sales" /&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;/vc:Chart.Titles&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:Chart.PlotArea&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:PlotArea Background= "#0A0A0A" /&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;/vc:Chart.PlotArea&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:Chart.AxesX&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:Axis Title="Year" /&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;/vc:Chart.AxesX&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:Chart.AxesY&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:Axis Title="Amount" Prefix="$" /&gt;'</span> + <span style="color: #006080">"\n"</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;/vc:Chart.AxesY&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:Chart.Series&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:DataSeries RenderAs="Column"&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:DataSeries.DataPoints&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    sales.sort(sortByYear);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    var totalSales = 0;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    currYear = sales[0].year;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    <span style="color: #0000ff">for</span> (var arrayIndex = 0; arrayIndex &lt; sales.length; arrayIndex++)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">    {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">        <span style="color: #0000ff">if</span>(sales[arrayIndex].year == currYear)</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">        {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">            currYear = sales[arrayIndex].year;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">            totalSales += sales[arrayIndex].ProductX + sales[arrayIndex].ProductY + sales[arrayIndex].ProductZ;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">        }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">        <span style="color: #0000ff">else</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">        {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">            myXAML = myXAML + <span style="color: #006080">'&lt;vc:DataPoint AxisXLabel="'</span> + currYear + <span style="color: #006080">'" YValue="'</span> + totalSales + <span style="color: #006080">'"/&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">            totalSales = 0;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">            currYear++;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">        }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    }</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;vc:DataPoint AxisXLabel="'</span> + currYear + <span style="color: #006080">'" YValue="'</span> + totalSales + <span style="color: #006080">'"/&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;/vc:DataSeries.DataPoints&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">"\n"</span> + <span style="color: #006080">'&lt;/vc:DataSeries&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;/vc:Chart.Series&gt;'</span> + <span style="color: #006080">"\n"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    myXAML = myXAML + <span style="color: #006080">'&lt;/vc:Chart&gt;'</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    <span style="color: #0000ff">return</span> myXAML;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">}</pre>
</div>
</div>
<p>First, create the chart for yearly sales. Next, attach an event handler for “MouseLeftButtonUp” event to the DataSeries. On fire of this event, this chart is replaced with a chart with monthly sales for the year represented by the selected DataPoint in that DataSeries. Event handler can be attached as shown in the code snippet below.</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #008000">// Attaching event handler for MouseLeftButtonUp event</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">vChart1.preLoad = function(args) {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    chart1 = args[0];</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">    chart1.Series[0].MouseLeftButtonUp = function(e) {</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">        onMouseUpMonthlySales(e.AxisXLabel); <span style="color: #008000">//Calling the function to replace the chart</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;">    };</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">};</pre>
</div>
</div>
<p>Use the same logic to replace this chart with a chart with product wise sales for the selected month. The crux of a drilldown chart is to attach an event handler to update the chart on fire of some event. I think we have accomplished the same swiftly in this sample. A link/button to return back to the previous state of the chart would give a holistic user experience.</p>
<p>You can see the sample in action <a href="http://www.visifire.com/downloads/samples/embedded/drilldown_sample_05032009/demo/drilldown.html">here</a>. The complete solution can be downloaded from <a href="http://www.visifire.com/downloads/samples/embedded/drilldown_sample_05032009/drilldown_sample_05032009.zip">here</a>.</p>
<p>Cheers,</p>
<p>Team Visifire.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.visifire.com/blog/2009/03/05/drilldown-silverlight-charts-using-visifire/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
