title: how to increment y axis values by 15 minutes using ms chart controls
body: <p>I am working with the MS chart controls stackedcolumn chart type and I want the y axis labels to increment by 15 minute intervals between 4 pm and 9 pm.  I have attached an image of what the chart looks like and have attached  the sample code that generated the image.</p>
  
  <p><img src="https://i.stack.imgur.com/klpG2.jpg" alt="alt text"> </p>
  
  <pre><code>&lt;asp:Chart ID="Chart1" runat="server" Height="296px" Width="412px" BackColor="#D3DFF0"
      Palette="BrightPastel" BorderDashStyle="Solid" BackGradientStyle="TopBottom"
      BorderWidth="2" BorderColor="26, 59, 105"&gt;
      &lt;Legends&gt;
          &lt;asp:Legend TitleFont="Microsoft Sans Serif, 8pt, style=Bold" BackColor="Transparent"
              Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="False" Enabled="False"
              Name="Default"&gt;
          &lt;/asp:Legend&gt;
      &lt;/Legends&gt;
      &lt;BorderSkin SkinStyle="Emboss"&gt;&lt;/BorderSkin&gt;
      &lt;Series&gt;
          &lt;asp:Series Name="Series1" ChartType="StackedColumn" BorderColor="180, 26, 59, 105"
              Color="220, 65, 140, 240" YValueType="Time" IsValueShownAsLabel="True" 
              LabelFormat="{0:HH:mm:ss}"&gt;
          &lt;/asp:Series&gt;
          &lt;asp:Series Name="Series2" ChartType="StackedColumn" BorderColor="180, 26, 59, 105"
              Color="220, 252, 180, 65" YValueType="Time" IsValueShownAsLabel="True" 
              LabelFormat="{0:HH:mm:ss}"&gt;
          &lt;/asp:Series&gt;
          &lt;asp:Series Name="Series3" ChartType="StackedColumn" BorderColor="180, 26, 59, 105"
              Color="220, 224, 64, 10" YValueType="Time" IsValueShownAsLabel="True" 
              LabelFormat="{0:HH:mm:ss}"&gt;
          &lt;/asp:Series&gt;
          &lt;asp:Series Name="Series4" ChartType="StackedColumn" BorderColor="180, 26, 59, 105"
              Color="220, 5, 100, 146" YValueType="Time" IsValueShownAsLabel="True" 
              LabelFormat="{0:HH:mm:ss}"&gt;
          &lt;/asp:Series&gt;
      &lt;/Series&gt;
      &lt;ChartAreas&gt;
          &lt;asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid"
              BackSecondaryColor="Transparent" BackColor="64, 165, 191, 228" ShadowColor="Transparent"
              BackGradientStyle="TopBottom"&gt;
              &lt;Area3DStyle Rotation="10" Inclination="15" WallWidth="0" /&gt;
              &lt;Position Y="3" Height="92" Width="92" X="2"&gt;&lt;/Position&gt;
              &lt;AxisY LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8"&gt;
                  &lt;LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" /&gt;
                  &lt;MajorGrid LineColor="64, 64, 64, 64" /&gt;
              &lt;/AxisY&gt;
              &lt;AxisX LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8"&gt;
                  &lt;LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" /&gt;
                  &lt;MajorGrid LineColor="64, 64, 64, 64" /&gt;
              &lt;/AxisX&gt;
          &lt;/asp:ChartArea&gt;
      &lt;/ChartAreas&gt;
  &lt;/asp:Chart&gt;
  </code></pre>
  
  <p>And in the code behind I bind some testing data:</p>
  
  <pre><code> private void BindChart()
      {
          Random random = new Random();
  
          //each series is a class?
  
          //section count to be determined dynamically
          //is the number of 'pool sections' (a pool can hold mulitiple classes)
  
          int intSectionCount = 4;
  
          for (int pointIndex = 0; pointIndex &lt; intSectionCount; pointIndex++)
          {
              //Series are the number of classes per section and the points are the start times of the class?
              //these numbers stack on top of each other.
              //What if vacant time slots or grace periods alloted to time before classes start
  
              //determine real datetime based on excel spreadsheet data
  
  
              int sec = 0;
              int min = ((int)random.Next(1, 2) == 1) ? 0 : 30;
              int hour = (int)random.Next(16, 18);
              int day = DateTime.Now.Day;
              int month = DateTime.Now.Month;
              int year = DateTime.Now.Year;
  
              System.DateTime y = new DateTime(year, month, day, hour, min, sec);
  
  
              Chart1.Series["Series1"].Points.AddY(y.ToOADate());
  
              //increment
              y = y.AddMinutes(30);
  
              Chart1.Series["Series2"].Points.AddY(y.ToOADate());
  
  
              //increment
              y = y.AddMinutes(30);
              Chart1.Series["Series3"].Points.AddY(y.ToOADate());
  
  
              //increment
              y = y.AddMinutes(30);
              Chart1.Series["Series4"].Points.AddY(y.ToOADate());
  
  
              //Chart1.Series["Series1"].Points.AddY(Math.Round((double)random.Next(45, 95),0));
              //Chart1.Series["Series2"].Points.AddY(Math.Round((double)random.Next(5, 75),0));
              //Chart1.Series["Series3"].Points.AddY(Math.Round((double)random.Next(5, 95),0));
              //Chart1.Series["Series4"].Points.AddY(Math.Round((double)random.Next(35, 95),0));
          }           
      }
  
   Chart1.ChartAreas[0].AxisY.Minimum = (new DateTime(2010, 10, 31, 16, 00, 00)).ToOADate();
          Chart1.ChartAreas[0].AxisY.Maximum = (new DateTime(2010, 10, 31, 21, 00, 00)).ToOADate();
          Chart1.ChartAreas[0].AxisY.IsReversed = true;
  </code></pre>