Jump to content
Software FX Community

X-Axis values not displayed


Recommended Posts


I am creating a chart for my website, the website is being developed using ASP.NET with C# code, the development evnironment is VS2005 on XP, the data behind the chart comes from an Oracle database.

I have the chart below on the website

Posted Image

What I am wanting to do is have the dates (which are the headers in the table) lined along the x-axis of the chart, the code I have is given below;

DataView view = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);DataTable table = view.ToTable();

Chart1.DataSource = table;



The data return from the sql query is as follows;


327   15/05/2008

329   08/05/2008

416   01/05/2008

143   25/04/2008

156   17/04/2008

1   11/04/2008

6   17/03/2008

1   07/03/2008

2   31/01/2008

1   25/01/2008

129 10/01/2008


Also if instead of the date I wanted to have the month only (so for example JAN instead of 01/01/20008) is this possible?


Thank you in advance.


Link to comment
Share on other sites

The image is not displaying. Try adding it as an attachment not as a link.

What you are describing is one of the most common cases for databinding, if your datatable contains two columns, one numeric and one DateTime, the chart will automatically display what you are looking for: dates in the X-Axis, values on the Y-Axis. If you are not getting this check that the types in the datatable columns are correct and please describe what the problem is.

As for displaying the month only:

chart.AxisX.LabelsFormat.Format = AxisFormat.Date;

chart.AxisX.LabelsFormat.CustomFormat = "MMM";


Link to comment
Share on other sites

Hi Frank,

Thank you for your response.  I am still having problems trying to display the dates along the x-axis of the chart.  I have copied in an image of what I have at the moment. 

Posted Image

The dates that are in the headers of the data editor, I also want them to be lined up along the x-axis of the chart.  In the chart wizard I set the chart to show the x-axis however it is not showing, and I am not sure why that is.  The code I have is;


ASP.NET code to define chart;


ChartFX:Chart ID="Chart1" runat="server" CodePage="0" EmbeddedData="False"

Height="300px" InsideColor="Transparent" MainClient="True" Palette="Nature.Sky" Width="737px" NSeries="3" NValues="3" BorderEffect="Raised">


<ChartFX:TitleDockable />



<ChartFX:SeriesAttributes />

<ChartFX:SeriesAttributes />

<ChartFX:SeriesAttributes />


<AxisX LabelAngle="90" Title-Text="Dates" Visible="true">





C# code;

Chart1.AxisX.Visible = true;


Any help would be gratefully received.


Kind regards

Link to comment
Share on other sites


I am still having trouble trying to get the dates displayed along the x-axis of my chart and was hoping that someone would be able to help me, the SQL returns two columns of data the first of which is a number, the second is a DATE.  I am trying to get the dates to line along the x-axis, the values are being displayed in the chart OK however the values are not being lined along the bottom of the x-axis as I wish.

Any help would be gratefully received as I have been struggling with this for a while now.  I have set the graph to show the axis during the set up using the wizard.  I have run out of ideas as to what may be wrong, any help would be great.  Code fragments are given in the posts above.

Many thanks

Link to comment
Share on other sites

I see the problem now.

I didn't realize your dates went backward. Most recent first. The X-Axis Date labeling only works with dates in ascending order.

You need to pass the dates in ascending order. If you want to displayed them on descending order on the chart, simply invert the X-Axis as follows:

chart.AxisX.Inverted = true;

Notice that by passing dates in the X-Axis you are creating a true Date axis in which labels will be displayed at regular intervals (like months, years, etc.) according to available space. There is no guarantee that each point will have a label.

You also have the alternative of having your dates converted to strings. In this case, the meaning of the date will be lost and each point will simply have a string attached to it. In order to do this you need to fill the DataType array to specify you want the second column to be treated as labels, not as X-Values (default). In this situation the order of the data is irrelevant as there is no value associated to each label. The X-Axis becomes categorical.

Link to comment
Share on other sites

Hi Frank,

Thank you for your response, once I changed the dates to ascending order the x-axis was displayed on the graph however as they are only displayed at regular intervals I am just wanting to convert the dates to a string and just display the string under all the bars in the chart.  I am unsure as to how I would fill the DataType array to specify the second column should be treated as a string rather than a Date?  Would you possible be able to send a code sample to illustrate how this would be done.

Many thanks for all your help.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...