Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6239359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:22:48+00:00 2026-05-24T11:22:48+00:00

I have a chart control that works normally for all but one case. If

  • 0

I have a chart control that works normally for all but one case.

If I select a date range of 1 day, (7/27/2011 to 7/28/2011) or anything greater I see the trend line and can adjust the layout and formatting of the labels accordingly.

If I select one day (7/27/2011 – 7/27/2011) I see the series show up in the legend and the y-axis scales appropriately but no trend line is shown.

Each day has 144 datapoints and when I select one day of data I see 144 points come across if I export data from the chart into an XML file or put up a message box when I am building my series. I see the same results if I select multiple days, with the appropriate amount of days included.

I have datapoints every 10 minutes during each day and if I display a messagebox with the values that are being added to the series I see data when I am looking at the single day range so I assume that I should be seeing a trend line.

What am I missing here?

Here is the code for the chart:

<asp:chart id="Chart1" runat="server" Height="365px" 
      Width="700px" ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)" ImageType="Png" 
      BackColor="WhiteSmoke" BackSecondaryColor="White" BackGradientStyle="TopBottom" 
      palette="BrightPastel" BorderWidth="2" 
      BorderColor="26, 59, 105">
          <titles>
              <asp:Title ShadowColor="32, 0, 0, 0" Font="Trebuchet MS, 14.25pt, style=Bold" ShadowOffset="3" Text="Chart Title" Alignment="MiddleLeft" ForeColor="26, 59, 105"></asp:Title>
          </titles>
      <legends>
          <asp:Legend Enabled="True" IsTextAutoFit="False" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold"></asp:Legend>
          </legends>
      <borderskin skinstyle="Emboss"></borderskin>
          <chartareas>
              <asp:ChartArea Name="ChartArea1" BorderColor="64,                                64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="Gainsboro" ShadowColor="Transparent" BackGradientStyle="TopBottom">
               <axisy2 enabled="False"></axisy2>
               <axisx2 enabled="False"></axisx2>
                   <area3dstyle Rotation="10" perspective="10"   Inclination="15" IsRightAngleAxes="False" wallwidth="0" IsClustered="False"></area3dstyle>
                   <axisy linecolor="64, 64, 64, 64" IsLabelAutoFit="False" ArrowStyle="Triangle">
                   <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" />
           <majorgrid linecolor="64, 64, 64, 64" />
           </axisy>
           <axisx linecolor="64, 64, 64, 64" IsLabelAutoFit="False" ArrowStyle="Triangle">
                   <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" IsStaggered="False"/>
               <majorgrid linecolor="64, 64, 64, 64" />
        </axisx>
            </asp:ChartArea>
        </chartareas>
    </asp:chart>

And here is the code I am using to build the series:

foreach (TreeNode node in ChartTreeView.CheckedNodes)
{
    if(node.Text.Contains("XXX") )
    {
        Series series = Chart1.Series.Add(node.Text);
        series.ChartArea = "ChartArea1";
        series.ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), charts[1], true);
        SqlConnection sqlConnection = new SqlConnection(@"DATA GOES HERE FOR SQL");
        sqlConnection.Open();

            SqlCommand nodeQuery = new SqlCommand();
            nodeQuery.CommandText = "";
            if (node.Text.Contains("XXX"))
            {
                nodeQuery.CommandText = "SELECT (Date + CONVERT(datetime,Time)) As TimeStamp, (MW + kW) As Energy, [EquipmentID] FROM EquipmentData WHERE [EquipmentID] = '" + node.Text + "' AND (Date + CONVERT(datetime,Time)) BETWEEN '" + startDateFilter + "' AND '" + endDateFilter + "' and [SiteID] = "+ProjectNavigation.SelectedValue.ToString()+" ORDER BY TimeStamp";";
                nodeQuery.Connection = sqlConnection;

            }
            if (nodeQuery.CommandText != "")
            {
                SqlDataReader reader = nodeQuery.ExecuteReader();
                while (reader.Read())
                {
                    double value = (double)reader["Energy"];
                    DateTime TimeStamp = (DateTime)reader["TimeStamp"];
                    string equipID = (string)reader["EquipmentID"];

                    series.Points.AddXY(TimeStamp, value);

                }
                sqlConnection.Close();
            }
        }
    }
    Chart1.DataBind();

I don’t have an interval set in the .aspx file, but I looked through the chart samples provided for the charts and have tried using the following function to set the interval ranges:

public void SetAxisInterval(System.Web.UI.DataVisualization.Charting.Axis axis, double interval, DateTimeIntervalType intervalType)
    {
        SetAxisInterval(axis, interval, intervalType, 0, DateTimeIntervalType.Auto);
    }

    public void SetAxisInterval(System.Web.UI.DataVisualization.Charting.Axis axis, double interval, DateTimeIntervalType intervalType, double intervalOffset, DateTimeIntervalType intervalOffsetType)
    {
        // Set interval-related properties
        axis.Interval = interval;
        axis.IntervalType = intervalType;
        axis.IntervalOffset = intervalOffset;
        axis.IntervalOffsetType = intervalOffsetType;

    }

Calling it with the following for the case where the range of days is 0 days:

SetAxisInterval(Chart1.ChartAreas["ChartArea1"].AxisX, 10, DateTimeIntervalType.Minutes);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:22:49+00:00Added an answer on May 24, 2026 at 11:22 am

    The problem was in setting the minimum and maximum values for the X-axis on the chart.

    I had been setting the minimum and maximum to the start and end date which was not displaying data.

    DateTime startDateVal;
    DateTime endDateVal;
    
    TimeSpan span = DateTime.Parse(endDate.Text) - DateTime.Parse(startDate.Text);
    if (span.TotalDays > 0)
    {
        startDateVal = DateTime.Parse(startDate.Text);
        endDateVal = DateTime.Parse(endDate.Text;
    }
    else
    {
        startDateVal = DateTime.Parse(startDate.Text);
        endDateVal = DateTime.Parse(endDate.Text).AddDays(1);
    }
    
    Chart1.ChartAreas["ChartArea1"].AxisX.Minimum = startDateVal.ToOADate();
    Char1t.ChartAreas["ChartArea1"].AxisX.Maximum = endDateVal.ToOADate();
    

    Using the code above to force the maximum to be midnight the day after the currently selected day fixed the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the new ASP control Chart, but I have some problems with
Good day all I have the following question: I would like to use Chart
I have a chart control in XAML, and datapoints that are bind to the
I have a problem with WPF Toolkit Chart Control. I can't add text values
I have chart.png with data in it that I would like to put a
I have a chart generated from Google Charts that can be found here: Chart
I have a chart (code to replicate will be below) that has two lines
I have a program with a large c# chart control. I am allowing zooming
I have a zedgraph control where I got at the the basic line chart
I have a page containing a Chart object that I use as the default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.