<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Alex Gorev's Weblog : Microsoft</title><link>http://blogs.msdn.com/alexgor/archive/tags/Microsoft/default.aspx</link><description>Tags: Microsoft</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Aligning Multiple Series with Categorical Values</title><link>http://blogs.msdn.com/alexgor/archive/2009/03/27/aligning-multiple-series-with-categorical-values.aspx</link><pubDate>Fri, 27 Mar 2009 07:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9512979</guid><dc:creator>alexgor</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/alexgor/comments/9512979.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alexgor/commentrss.aspx?PostID=9512979</wfw:commentRss><description>&lt;H3&gt;Binding Categorical Data Overview&lt;/H3&gt;
&lt;P&gt;Binding chart to the data source with categorical values is pretty simple and usually requires just one line of code:&lt;/P&gt;&amp;nbsp;&amp;nbsp; 
&lt;DIV style="BORDER-RIGHT: #7f9db9 1px solid; BORDER-TOP: #7f9db9 1px solid; FONT-SIZE: 11px; OVERFLOW: auto; BORDER-LEFT: #7f9db9 1px solid; LINE-HEIGHT: 100%! important; BORDER-BOTTOM: #7f9db9 1px solid; FONT-FAMILY: courier new; BACKGROUND-COLOR: white"&gt;
&lt;TABLE class="" style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; MARGIN: 2px 0px; WIDTH: 99%; BORDER-BOTTOM: #eee 0px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #fff; BORDER-RIGHT-WIDTH: 0px" cellSpacing=0 cellPadding=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="PADDING-LEFT: 10px; FONT-SIZE: 11px; BORDER-BOTTOM: #f7f7f7 1px solid; FONT-FAMILY: courier new; WHITE-SPACE: nowrap"&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=""&gt;&lt;FONT style="FONT-SIZE: 11px"&gt;Chart1.Series[&lt;/FONT&gt;&lt;FONT style="COLOR: blue"&gt;"Series1"&lt;/FONT&gt;&lt;FONT style="FONT-SIZE: 11px"&gt;].Points.DataBind(mySource, &lt;/FONT&gt;&lt;FONT style="COLOR: blue"&gt;"ProductName"&lt;/FONT&gt;&lt;FONT style="FONT-SIZE: 11px"&gt;, &lt;/FONT&gt;&lt;FONT style="COLOR: blue"&gt;"Sales"&lt;/FONT&gt;&lt;FONT style="FONT-SIZE: 11px"&gt;);&amp;nbsp; &lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;It is important to understand that after &lt;STRONG&gt;DataBind&lt;/STRONG&gt; method creates series DataPoint objects, their &lt;STRONG&gt;XValue&lt;/STRONG&gt; property will always be set to zero and category is saved in the &lt;STRONG&gt;AxisLabel&lt;/STRONG&gt; property. Position of each data point along the category axis is determined using the index of the object in &lt;STRONG&gt;Series.Points&lt;/STRONG&gt; collection. Below is an example of what your chart may look like:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image002_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image002_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=246 alt=clip_image002 src="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image002_thumb.jpg" width=490 border=0 mce_src="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image002_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;H3&gt;Alignment of Multiple Series&lt;/H3&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image002_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image002_2.jpg"&gt;&lt;/A&gt;
&lt;P&gt;When you bind multiple series with categorical values you may run into some un-expected results based on how you prepare your data source. For example, let's imagine that our two chart series are bound to this data:&lt;/P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=400 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;&lt;STRONG&gt;Series 1&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;&lt;STRONG&gt;Series 2&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product A = 320&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;Product B = 420&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product B = 580&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;Product E = 830&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product C = 980&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product E = 100&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product F = 220&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;As you can notice, we have less categories for the second series and their order does not match categories from the first series. If we try binding chart to this data we will end up with the chart shown below. Chart uses index of the data point to position them along the axis and we end up with orange series points in the wrong position. I added data point labels so that it would easier to see the issue.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image004_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image004_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=246 alt=clip_image004 src="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image004_thumb.jpg" width=490 border=0 mce_src="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image004_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In order to resolve this we can modify our data source to contain same number of categories in the same order like this:&lt;/P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=400 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;&lt;STRONG&gt;Series 1&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;&lt;STRONG&gt;Series 2&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product A = 320&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;Product A = Null&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product B = 580&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;Product B = 420&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product C = 980&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;Product C = Null&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product E = 100&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;Product E = 830&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=199&gt;Product F = 220&lt;/TD&gt;
&lt;TD class="" vAlign=top width=199&gt;Product F = Null&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;Simpler approach is just to make a single call to &lt;STRONG&gt;Chart.AlignDataPointsByAxisLabel&lt;/STRONG&gt; method which will automatically align the two series by inserting empty points and the end result will look like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image006_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image006_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=246 alt=clip_image006 src="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image006_thumb.jpg" width=490 border=0 mce_src="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/DisplayingMultipleSerieswithCategoricalV_12CBF/clip_image006_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Alex.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9512979" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alexgor/archive/tags/Chart/default.aspx">Chart</category><category domain="http://blogs.msdn.com/alexgor/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/alexgor/archive/tags/Microsoft+Chart+Control/default.aspx">Microsoft Chart Control</category></item><item><title>Microsoft Chart control for .NET Framework Released!</title><link>http://blogs.msdn.com/alexgor/archive/2008/10/27/microsoft-chart-control-for-net-framework-released.aspx</link><pubDate>Mon, 27 Oct 2008 06:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9017444</guid><dc:creator>alexgor</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/alexgor/comments/9017444.aspx</comments><wfw:commentRss>http://blogs.msdn.com/alexgor/commentrss.aspx?PostID=9017444</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;I glad to announce the release of&amp;nbsp;Microsoft Chart for .NET Framework 3.5 SP1, which includes the ASP.NET and Windows Forms Chart Controls. Our Data Visualization team in SSRS worked really hard to deliver those controls!&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;&lt;IMG title="Chart samples" style="WIDTH: 644px; HEIGHT: 128px" height=128 alt="Chart samples" src="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/ImagesPlaceHolder_C305/ChartSamples_thumb_1.jpg" width=644 align=absMiddle mce_src="http://blogs.msdn.com/blogfiles/alexgor/WindowsLiveWriter/ImagesPlaceHolder_C305/ChartSamples_thumb_1.jpg"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;Here is where you can download it:&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;&lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=130F7986-BF49-4FE5-9CA8-910AE6EA442C&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=130F7986-BF49-4FE5-9CA8-910AE6EA442C&amp;amp;displaylang=en"&gt;Microsoft Chart Controls for Microsoft .NET Framework 3.5&lt;/A&gt; – This installs the ASP.NET and Windows Forms Controls.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The assemblies will be installed in the GAC as well as in the “%Program File%\Microsoft Chart Controls\Assemblies” folder.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If you build an application using the controls, your setup and deployment should add MSChart.exe installer as a pre-requisite.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;&lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=581FF4E3-749F-4454-A5E3-DE4C463143BD&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=581FF4E3-749F-4454-A5E3-DE4C463143BD&amp;amp;displaylang=en"&gt;Microsoft Chart Controls for Microsoft .NET Framework 3.5 Language Pack&lt;/A&gt; – This installs the language pack for the Chart Controls.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It is available in 23 .NET Framework languages.&lt;/FONT&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;&lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=1D69CE13-E1E5-4315-825C-F14D33A303E9&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=1D69CE13-E1E5-4315-825C-F14D33A303E9&amp;amp;displaylang=en"&gt;Microsoft Chart Controls Add-on for Microsoft Visual Studio 2008&lt;/A&gt; – This installs the IntelliSense file in English for the controls and also adds the controls to the toolbox for ASP.NET and Windows Forms.&lt;/FONT&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;FONT face=Calibri&gt;Where to&amp;nbsp;find more information?&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&lt;A class="" href="http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/threads/" target=_blank mce_href="http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/threads/"&gt;Microsoft Chart Forum&lt;/A&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;&lt;A class="" href="http://code.msdn.microsoft.com/mschart" target=_blank mce_href="http://code.msdn.microsoft.com/mschart"&gt;ASP.NET Samples&lt;/A&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;&lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EE8F6F35-B087-4324-9DBA-6DD5E844FD9F&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EE8F6F35-B087-4324-9DBA-6DD5E844FD9F&amp;amp;displaylang=en"&gt;Documentation&lt;/A&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;Alex.&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9017444" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/alexgor/archive/tags/Chart/default.aspx">Chart</category><category domain="http://blogs.msdn.com/alexgor/archive/tags/Windows+Forms/default.aspx">Windows Forms</category><category domain="http://blogs.msdn.com/alexgor/archive/tags/.NET+Framework/default.aspx">.NET Framework</category><category domain="http://blogs.msdn.com/alexgor/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/alexgor/archive/tags/Microsoft/default.aspx">Microsoft</category></item></channel></rss>