﻿<?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>Programming By A Tool &#187; Charting</title>
	<atom:link href="http://byatool.com/tag/charting/feed/" rel="self" type="application/rss+xml" />
	<link>http://byatool.com</link>
	<description>Send all complaints to idontcare@byatool.com.</description>
	<lastBuildDate>Fri, 10 Sep 2010 17:02:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Microsoft Charting Controls: Adding Charts Dynamically</title>
		<link>http://byatool.com/ui/microsoft-charting-controls-adding-dynamically/</link>
		<comments>http://byatool.com/ui/microsoft-charting-controls-adding-dynamically/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 21:31:18 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[UI]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Dynamic Controls]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=122</guid>
		<description><![CDATA[So this is kind of repost as I had already posted this at StackOverflow but I thought it might have some merit here. Whatever. Charts are hot right now so I&#8217;m going to push the damned bandwagon. You don&#8217;t like it? Well then go do something to yourself that you would consider rude for me [...]]]></description>
			<content:encoded><![CDATA[<p>So this is kind of repost as I had already posted this at <a href="http://www.stackoverflow.com">StackOverflow</a> but I thought it might have some merit here. Whatever. Charts are hot right now so I&#8217;m going to push the damned bandwagon. You don&#8217;t like it? Well then go do something to yourself that you would consider rude for me to suggest it. Anyways, this might have been overkill but hey, that&#8217;s me.</p>
<pre lang="csharp">
protected void Page_Load(object sender, EventArgs e)
{
Bench benchList;
FoodIntake foodIntakeList;
Panel panelChartHolder;

panelChartHolder = new Panel();
Controls.Add(panelChartHolder);

benchList = Bench.GetAll();
AddNewCharts(benchList, panelChartHolder, GetBenchXValue, GetBenchYValue);

foodIntakeList = FoodIntake.GetAll();
AddNewCharts(foodIntakeList, panelChartHolder, GetFoodIntakeXValue, GetFoodIntakeYValue);
}
</pre>
<p>Ok so this first part is simple. Create a panel to hold the charts you are adding, get the lists you want represented by the charts and call the method to create the charts.</p>
<pre>  <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> AddNewCharts(T[] listToAdd, <span style="color: #33cccc;">Panel</span> panelToAddTo,
     <span style="color: #33cccc;">Func</span>&lt;T, <span style="color: #33cccc;">DateTime</span>&gt; xMethod, <span style="color: #33cccc;">Func</span>&lt;T, <span style="color: #33cccc;">Int32</span>&gt;)
  {

    <span style="color: #33cccc;">ChartArea</span> mainArea;
    <span style="color: #33cccc;">Chart</span> mainChart;
    <span style="color: #33cccc;">Series</span> mainSeries;

    mainChart = <span style="color: #0000ff;">new</span> <span style="color: #33cccc;">Chart</span>();
    mainSeries = <span style="color: #0000ff;">new</span> <span style="color: #33cccc;">Series</span>(<span style="color: #ff0000;">"MainSeries"</span>);

    <span style="color: #0000ff;">for</span> (<span style="color: #33cccc;">Int32</span> loopCounter = 0; loopCounter &lt; listToAdd.Length; loopCounter++)
    {
      mainSeries.Points.AddXY(xMethod(listToAdd[loopCounter]),
        yMethod(listToAdd[loopCounter]));
    }

    mainChart.Series.Add(mainSeries);
    mainArea = <span style="color: #0000ff;">new</span> <span style="color: #33cccc;">ChartArea</span>(<span style="color: #ff0000;">"MainArea"</span>);
    mainChart.ChartAreas.Add(mainArea);

    panelToAddTo.Controls.Add(mainChart);
  }</pre>
<p>As you can see, I just created a new chart, added a series to it, and added a ChartArea to it. Next part is pretty much just looping through the collection and adding each item in it to the list itself. It uses the passed in delegate methods (Func) to get the X and Y values.</p>
<p>Last part holds the four methods responsible for getting the X and Y values from the two lists. Basically I did this to allow the chart creating method to be a generic as possible. Might be overkill.</p>
<pre>  <span style="color: #0000ff;">private</span> <span style="color: #33cccc;">DateTime</span> GetBenchXValue(Bench currentBench)
  {
    <span style="color: #0000ff;">return</span> currentBench.DateLifted;
  }

  <span style="color: #0000ff;">private</span> <span style="color: #33cccc;">Int32</span> GetBenchYValue(Bench currentBench)
  {
    <span style="color: #0000ff;">return</span> currentBench.BenchAmount;
  }

  <span style="color: #0000ff;">private</span> <span style="color: #33cccc;">DateTime</span> GetFoodIntakeXValue(FoodIntake currentIntake)
  {
    <span style="color: #0000ff;">return</span> currentIntake.DateEaten;
  }

  <span style="color: #0000ff;">private</span> <span style="color: #33cccc;">Int32</span> GetFoodIntakeYValue(FoodIntake currentIntake)
  {
    <span style="color: #0000ff;">return</span> currentIntake.Calories;
  }</pre>
<p>And so when you run this, you will get two graphs side by side. Mind you, they will be very plain as there are million different properties that can be set to improve the look. I guess the main point of this was to show that it&#8217;s pretty easy to create graphs dynamically using any kind of object list. You know what? Screw you. This is my blog and I&#8217;ll post whatever I want to. If you don&#8217;t like that then you can just come back at a later time and read something else I post. Yeah so there.</p>
<pre>  <span style="color: #0000ff;">using</span> System;
  <span style="color: #0000ff;">using</span> System.Web.UI.DataVisualization.Charting;
  <span style="color: #0000ff;">using</span> System.Web.UI.WebControls;</pre>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/ui/microsoft-charting-control-so-easy-an-idiot-can-use-it-and-i-have/" title="Microsoft Charting Control: So easy an idiot can use it&#8230; And I have.">Microsoft Charting Control: So easy an idiot can use it&#8230; And I have.</a></li><li><a href="http://byatool.com/general-coding/the-switch-remover/" title="The Switch Remover: Convert Switch Statements to Dictionaries">The Switch Remover: Convert Switch Statements to Dictionaries</a></li><li><a href="http://byatool.com/mvc/asp-net-mvc-upload-image-to-database-and-show-image-dynamically-using-a-view/" title="ASP.Net MVC: Upload Image to Database and Show Image &#8220;Dynamically&#8221; Using a View">ASP.Net MVC: Upload Image to Database and Show Image &#8220;Dynamically&#8221; Using a View</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/ui/microsoft-charting-controls-adding-dynamically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft Charting Control: So easy an idiot can use it&#8230; And I have.</title>
		<link>http://byatool.com/ui/microsoft-charting-control-so-easy-an-idiot-can-use-it-and-i-have/</link>
		<comments>http://byatool.com/ui/microsoft-charting-control-so-easy-an-idiot-can-use-it-and-i-have/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 15:49:58 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[UI]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Dynamic Controls]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=111</guid>
		<description><![CDATA[So just recently it was announced that there was a new charting control out for .Net/Visual Studios so I thought I would give it shot. How hard could it be? Well considering it took me 2? years to figure out my Playstation 3 had a wireless card, an uphill battle wasn&#8217;t out of the question. [...]]]></description>
			<content:encoded><![CDATA[<p>So just recently it was announced that there was a new charting control out for .Net/Visual Studios so I thought I would give it shot. How hard could it be? Well considering it took me 2? years to figure out my Playstation 3 had a wireless card, an uphill battle wasn&#8217;t out of the question.</p>
<p>So what the hell has to be done first? Well you need the 3.5 Framework (Sucks if you don&#8217;t have that) and <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ab99342f-5d1a-413d-8319-81da479ab0d7&amp;displaylang=en" target="_blank">service pack 1</a> (Which doesn&#8217;t suck as much but still annoying. I WANT EASY THINGS).<br />
Have those? Great, way to be in the know. Now for the next step, more downloads. Here is the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&amp;DisplayLang=en" target="_self">charting install</a> and you need <a href="http://www.microsoft.com/downloads/details.aspx?familyid=1D69CE13-E1E5-4315-825C-F14D33A303E9&amp;displaylang=en" target="_blank">this too</a> to see the actual tool in your toolbox. AMAZING. Now you just have to run the installs, which oddly enough are easy to do. First time for everything.</p>
<p>So now you have them installed right? Ok well do the normal project create/startup, add a new page, and view Design. Go to the old toolbox and look under the Data tab. (Don&#8217;t ask me why it&#8217;s there because I don&#8217;t know and will be compelled to cut you.) Now under the chance you don&#8217;t see it there you either didn&#8217;t install the second download or you have to add the namespace the control falls under. No problem. Just right click the Data tab and select &#8220;Choose Items&#8221;. Now in the.Net Framework Components tab look for the Namespace &#8220;System.Web.UI.DataVisiualization.Charting&#8221; and you should see the name Chart to the right of it. Select that item.</p>
<p>Ok, so now there should be a Chart control in your ToolBox in the Data Tab. You can now drag that thing over. Now in the markup you should see:</p>
<p><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">&lt;</span></span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Chart</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ID</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Chart1&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">runat</span><span style="font-size: x-small; color: #0000ff;">=&#8221;server&#8221;&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">  &lt;</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Name</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Series1&#8243;&gt;</span><span style="font-size: x-small; color: #0000ff;">&lt;/</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">  &lt;/</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">&lt;</span><span style="font-size: x-small; color: #a31515;">ChartAreas</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">ChartArea</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Name</span><span style="font-size: x-small; color: #0000ff;">=&#8221;ChartArea1&#8243;&gt;</span><span style="font-size: x-small; color: #0000ff;">&lt;/</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">ChartArea</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;/</span><span style="font-size: x-small; color: #a31515;">ChartAreas</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">&lt;/</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Chart</span><span style="font-size: x-small; color: #0000ff;">&gt;</span></p>
<p>If that doesn&#8217;t excite you, then I don&#8217;t know what will. Anyhow, it&#8217;s actually very simple. Series is the line or whatever you are representing the data as and the chart area is what holds the series(s). Seems easy enough, but don&#8217;t worry, it gets easier. Now for this example I&#8217;m going to actually have two series and they are going to represent amount of weight Bench Pressed and the caloric intake for a given day. Best thing I could come up with right now since today was bench day.</p>
<p><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">&lt;</span></span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Chart</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ID</span><span style="font-size: x-small; color: #0000ff;">=&#8221;chartMain&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">runat</span><span style="font-size: x-small; color: #0000ff;">=&#8221;server&#8221;&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span></p>
<p><span style="font-size: x-small; color: #0000ff;">  &lt;</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Name</span><span style="font-size: x-small; color: #0000ff;">=&#8221;seriesBenchAmount&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Name</span><span style="font-size: x-small; color: #0000ff;">=&#8221;seriesFoodIntake&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">  &lt;/</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">  &lt;</span><span style="font-size: x-small; color: #a31515;">ChartAreas</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">ChartArea</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Name</span><span style="font-size: x-small; color: #0000ff;">=&#8221;chartAreaMain&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">  &lt;/</span><span style="font-size: x-small; color: #a31515;">ChartAreas</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><br />
<span style="font-size: x-small; color: #0000ff;">&lt;/</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Chart</span><span style="font-size: x-small; color: #0000ff;">&gt;</span></p>
<p>Yeah that&#8217;s pretty good. So now what I need is to throw some fake data at it, and to do that I created a Bench table and a FoodIntake table followed by using Linq To Sql to create the needed classes. When all was said and done I could easily do this:</p>
<pre>  private const String CHART_AREA_MAIN = "chartAreaMain";
  private const String SERIES_BENCH_AMOUNT = "seriesBenchAmount";
  private const String SERIES_FOOD_INTAKE = "seriesFoodIntake";

  <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">void</span> Page_Load(<span style="color: #0000ff;">object</span> sender, <span style="color: #33cccc;">EventArgs</span> e)
  {
    <span style="color: #33cccc;">Bench</span>[] benchList;
    <span style="color: #33cccc;">Series</span> currentSeries;
    <span style="color: #33cccc;">FoodIntake</span>[] foodIntakeList;

    benchList = Bench.GetAllBenches();
    currentSeries = chartMain.Series[SERIES_BENCH_AMOUNT];
    <span style="color: #0000ff;">for</span> (<span style="color: #33cccc;">Int32</span> loopCounter = 0; loopCounter &lt; benchList.Length; loopCounter++)
    {
      currentSeries.Points.AddXY(benchList[loopCounter].DateLifted,
         benchList[loopCounter].BenchAmount);
    }

    foodIntakeList = FoodIntake.GetAll();
    currentSeries = chartMain.Series[SERIES_FOOD_INTAKE];
    <span style="color: #0000ff;">for</span>(<span style="color: #33cccc;">Int32</span> loopCounter = 0; loopCounter &lt; foodIntakeList.Length; loopCounter++)
    {
      currentSeries.Points.AddXY(foodIntakeList[loopCounter].DateEaten,
          foodIntakeList[loopCounter].Calories / 10);
      }
  }</pre>
<p>Now believe it or not, that&#8217;s all you have to do to get a graph. Pretty easy to say the least. Now the graph that you get will be default everything (And in this case it gives you a bar graph) but still at least that&#8217;s something to work with. (Note that I cheated with the food intake by dividing by 10. Unfortunately the graph would look odd with a day of 3500 calories and a 325 bench.)</p>
<p>Now maybe you want this to be a line graph&#8230; Whatever can we do?</p>
<pre>protected override void CreateChildControls()
{
    base.CreateChildControls();
    <span style="color: #33cccc;">Series</span> currentSeries;
    <span style="color: #33cccc;">ChartArea</span> currentArea; 

    currentSeries = chartMain.Series[SERIES_BENCH_AMOUNT];
    currentSeries.XValueType = <span style="color: #33cccc;">ChartValueType</span>.DateTime;
    currentSeries.YValueType = <span style="color: #33cccc;">ChartValueType</span>.Int32;
    currentSeries.ChartType = <span style="color: #33cccc;">SeriesChartType</span>.Line;
    currentSeries.BorderWidth = 3; currentSeries.MarkerStyle = <span style="color: #33cccc;">MarkerStyle</span>.Square;

    currentSeries = chartMain.Series[SERIES_FOOD_INTAKE];
    currentSeries.XValueType = <span style="color: #33cccc;">ChartValueType</span>.DateTime;
    currentSeries.YValueType = <span style="color: #33cccc;">ChartValueType</span>.Int32;
    currentSeries.ChartType = <span style="color: #33cccc;">SeriesChartType</span>.Line;
    currentSeries.MarkerStyle = <span style="color: #33cccc;">MarkerStyle</span>.Circle;
    currentSeries.MarkerColor = <span style="color: #33cccc;">Color</span>.Red;
    currentSeries.BorderWidth = 3;

    currentArea = chartMain.ChartAreas[CHART_AREA_MAIN];
    currentArea.Area3DStyle.Enable3D = <span style="color: #0000ff;">false</span>;
}</pre>
<p>So what&#8217;s all this? Well this:</p>
<div id="attachment_118" class="wp-caption alignnone" style="width: 307px"><a href="http://byatool.com/wp-content/uploads/2008/12/chartplainline.jpg"><img class="size-medium wp-image-118" title="chartplainline" src="http://byatool.com/wp-content/uploads/2008/12/chartplainline.jpg" alt="I MADE THIS!!11" width="297" height="289" /></a><p class="wp-caption-text">I MADE THIS!!11</p></div>
<p>So pretty, yah? So what does it all mean?</p>
<pre>    currentSeries.XValueType = <span style="color: #33cccc;">ChartValueType</span>.DateTime;
    currentSeries.YValueType = <span style="color: #33cccc;">ChartValueType</span>.Int32;</pre>
<p>Well this is pretty simple, this merely sets the types for the X and Y axis. I told you it was simple.</p>
<pre>    currentSeries.ChartType = <span style="color: #33cccc;">SeriesChartType</span>.Line;</pre>
<p>If you can&#8217;t figure that one out, try another profession like engineering.</p>
<pre>    currentSeries.MarkerStyle = <span style="color: #33cccc;">MarkerStyle</span>.Circle;
    currentSeries.MarkerColor = <span style="color: #33cccc;">Color</span>.Red;</pre>
<p>Ok these three things are used to control how the points on the lines (Markers) actually look. Pretty self explanatory once the word &#8220;marker&#8221; is translated.</p>
<pre>    currentSeries.BorderWidth = 3;</pre>
<p>This is the thickness of the line itself.</p>
<pre>    currentArea.Area3DStyle.Enable3D = <span style="color: #0000ff;">false</span>;</pre>
<p>If you guessed this was a way to make the grid 3d, you were right on and probably able remind yourself to breathe at a maximum 3 times a day.</p>
<p>So now you are thinking you have this down to an expert level and I say,&#8221;sure why not?&#8221; &#8216;cept with a little work on the mark up I could make it look like this:</p>
<div id="attachment_119" class="wp-caption alignnone" style="width: 310px"><a href="http://byatool.com/wp-content/uploads/2008/12/chartadvancedline.jpg"><img class="size-medium wp-image-119" title="chartadvancedline" src="http://byatool.com/wp-content/uploads/2008/12/chartadvancedline-300x208.jpg" alt="OoooOooOo" width="300" height="208" /></a><p class="wp-caption-text">OoooOooOo</p></div>
<p>And just like Beloch said in Raiders of the Lost Arc before his face exploded, &#8220;It&#8217;s Bewtifewl!&#8221;</p>
<p>Now for the Usings!!11</p>
<pre>    <span style="color: #33cccc;">using</span> System;
    <span style="color: #33cccc;">using</span> System.Drawing;
    <span style="color: #33cccc;">using</span> System.Web.UI.DataVisualization.Charting;</pre>
<p>And the final markup:</p>
<p><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">&lt;</span></span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Chart</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ID</span><span style="font-size: x-small; color: #0000ff;">=&#8221;chartMain&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">runat</span><span style="font-size: x-small; color: #0000ff;">=&#8221;server&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Palette</span><span style="font-size: x-small; color: #0000ff;">=&#8221;EarthTones&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BackColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Azure&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ImageType</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Jpeg&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ImageLocation</span><span style="font-size: x-small; color: #0000ff;">=&#8221;~/ChartImages/ChartPic_#SEQ(300,3)&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Width</span><span style="font-size: x-small; color: #0000ff;">=&#8221;412px&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Height</span><span style="font-size: x-small; color: #0000ff;">=&#8221;296px&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BorderDashStyle</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Solid&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BackGradientStyle</span><span style="font-size: x-small; color: #0000ff;">=&#8221;TopBottom&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BorderWidth</span><span style="font-size: x-small; color: #0000ff;">=&#8221;2&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BorderColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;181, 64, 1&#8243;&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">  &lt;</span><span style="font-size: x-small; color: #a31515;">series</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Name</span><span style="font-size: x-small; color: #0000ff;">=&#8221;seriesBenchAmount&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">MarkerSize</span><span style="font-size: x-small; color: #0000ff;">=&#8221;3&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BorderWidth</span><span style="font-size: x-small; color: #0000ff;">=&#8221;3&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ShadowColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Black&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BorderColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;180, 26, 59, 105&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Color</span><span style="font-size: x-small; color: #0000ff;">=&#8221;220, 65, 140, 240&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ShadowOffset</span><span style="font-size: x-small; color: #0000ff;">=&#8221;2&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Series</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Name</span><span style="font-size: x-small; color: #0000ff;">=&#8221;seriesFoodIntake&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">MarkerSize</span><span style="font-size: x-small; color: #0000ff;">=&#8221;3&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BorderWidth</span><span style="font-size: x-small; color: #0000ff;">=&#8221;3&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ShadowColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Black&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BorderColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;180, 26, 59, 105&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Color</span><span style="font-size: x-small; color: #0000ff;">=&#8221;220, 224, 64, 10&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ShadowOffset</span><span style="font-size: x-small; color: #0000ff;">=&#8221;2&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">  &lt;/</span><span style="font-size: x-small; color: #a31515;">series</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"></p>
<p></span></span></p>
<p><span style="font-size: x-small; color: #0000ff;">  &lt;</span><span style="font-size: x-small; color: #a31515;">chartareas</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">ChartArea</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Name</span><span style="font-size: x-small; color: #0000ff;">=&#8221;chartAreaMain&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BorderColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;64, 64, 64, 64&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BorderDashStyle</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Solid&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BackSecondaryColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;White&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BackColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;OldLace&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">ShadowColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Transparent&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">BackGradientStyle</span><span style="font-size: x-small; color: #0000ff;">=&#8221;TopBottom&#8221;&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">      &lt;</span><span style="font-size: x-small; color: #a31515;">area3dstyle</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Rotation</span><span style="font-size: x-small; color: #0000ff;">=&#8221;25&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Perspective</span><span style="font-size: x-small; color: #0000ff;">=&#8221;9&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">LightStyle</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Realistic&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Inclination</span><span style="font-size: x-small; color: #0000ff;">=&#8221;40&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;"><span style="color: #0000ff;">          </span>IsRightAngleAxes</span><span style="font-size: x-small; color: #0000ff;">=&#8221;False&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">WallWidth</span><span style="font-size: x-small; color: #0000ff;">=&#8221;3&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">IsClustered</span><span style="font-size: x-small; color: #0000ff;">=&#8221;False&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">      &lt;</span><span style="font-size: x-small; color: #a31515;">axisy</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">LineColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;64, 64, 64, 64&#8243;&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">        &lt;</span><span style="font-size: x-small; color: #a31515;">LabelStyle</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Font</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Trebuchet MS, 8.25pt, style=Bold&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">        &lt;</span><span style="font-size: x-small; color: #a31515;">MajorGrid</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">LineColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;64, 64, 64, 64&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">      &lt;/</span><span style="font-size: x-small; color: #a31515;">axisy</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">      &lt;</span><span style="font-size: x-small; color: #a31515;">axisx</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">LineColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;64, 64, 64, 64&#8243;&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">        &lt;</span><span style="font-size: x-small; color: #a31515;">LabelStyle</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">Font</span><span style="font-size: x-small; color: #0000ff;">=&#8221;Trebuchet MS, 8.25pt, style=Bold&#8221;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">        &lt;</span><span style="font-size: x-small; color: #a31515;">MajorGrid</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;">LineColor</span><span style="font-size: x-small; color: #0000ff;">=&#8221;64, 64, 64, 64&#8243;</span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;">/&gt;</span><span style="font-size: x-small;"> </span><br />
<span style="font-size: x-small; color: #0000ff;">      &lt;/</span><span style="font-size: x-small; color: #a31515;">axisx</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">    &lt;/</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">ChartArea</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">  &lt;/</span><span style="font-size: x-small; color: #a31515;">chartareas</span><span style="font-size: x-small; color: #0000ff;">&gt;</span><span style="font-size: x-small;"><span style="font-size: x-small;"> </span></span><br />
<span style="font-size: x-small; color: #0000ff;">&lt;/</span><span style="font-size: x-small; color: #a31515;">asp</span><span style="font-size: x-small; color: #0000ff;">:</span><span style="font-size: x-small; color: #a31515;">Chart</span><span style="font-size: x-small; color: #0000ff;">&gt;</span></p>
<div  class="related_post_title">Related Posts</div><ul class="related_post"><li><a href="http://byatool.com/ui/microsoft-charting-controls-adding-dynamically/" title="Microsoft Charting Controls: Adding Charts Dynamically">Microsoft Charting Controls: Adding Charts Dynamically</a></li><li><a href="http://byatool.com/general-coding/the-switch-remover/" title="The Switch Remover: Convert Switch Statements to Dictionaries">The Switch Remover: Convert Switch Statements to Dictionaries</a></li><li><a href="http://byatool.com/mvc/asp-net-mvc-upload-image-to-database-and-show-image-dynamically-using-a-view/" title="ASP.Net MVC: Upload Image to Database and Show Image &#8220;Dynamically&#8221; Using a View">ASP.Net MVC: Upload Image to Database and Show Image &#8220;Dynamically&#8221; Using a View</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://byatool.com/ui/microsoft-charting-control-so-easy-an-idiot-can-use-it-and-i-have/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
