Jump to content
Software FX Community

Dates on X Axis don't scale right

User (Legacy)

Recommended Posts

If I have a line graph, with the any values for the following dates:









It treats them all as equal values. Rather than the graph putting larger

interval spaces between 4/1-5/1-6/1 (because each are a month), it treats

them as regular labels, and all as days... doesn't scale right. It should

know that it's 30 days between 4/1 and 5/1 and 6/1, but only one day between


How do I fix this?

Link to comment
Share on other sites


Passing data manually.

"SoftwareFX Support" <noreply@softwarefx.com> wrote in message


> 1) What type of Chart are you creating (Bar, Lines. etc.) ?


> 2) How are you passing the data to this chart ?


> --

> Francisco Padron

> www.chartfx.com


Link to comment
Share on other sites

Well, its very hard to help when you provide so little information. Posting 

the critical section of code usually speaks tons, in this case that would be

the code that passes the data to the chart.

Make sure you are passing those Dates as X-Values not as mere labels, by

doing so you will allow Chart FX to get the actual value not just a string.

Once the X-Values are set, they will be used to position each point in the



Francisco Padron


Link to comment
Share on other sites

It seems that the XValue is the key I was missing, however, when I use 

XValue, my labels disappear?

See the following code function, and image.

private void renderChart()


SoftwareFX.ChartFX.Internet.Server.Chart Chart1;

Chart1 = new SoftwareFX.ChartFX.Internet.Server.Chart(this);

Chart1.GalleryObj = SoftwareFX.ChartFX.Gallery.Lines;

Chart1.Border = true;

Chart1.OpenData(SoftwareFX.ChartFX.COD.Values, 1, 10);

Chart1.OpenData(SoftwareFX.ChartFX.COD.XValues, 1, 10);

string [] dates = new string[10];

dates[0] = "1/1/2005";

dates[1] = "2/1/2005";

dates[2] = "3/1/2005";

dates[3] = "4/1/2005";

dates[4] = "5/1/2005";

dates[5] = "5/2/2005";

dates[6] = "5/3/2005";

dates[7] = "5/4/2005";

dates[8] = "5/5/2005";

dates[9] = "5/6/2005";

Random rnd = new Random(DateTime.Now.Millisecond);

for(int i=0;i<10;i++)


Chart1.Value[0, i] = Convert.ToDouble(rnd.NextDouble()*100);

Chart1.XValue[0, i] = Convert.ToDateTime(dates[i]).ToOADate();

Chart1.AxisX.Label[i] = Convert.ToDateTime(dates[i]).ToShortDateString();


Chart1.AxisX.LabelsFormat.Format = SoftwareFX.ChartFX.AxisFormat.Date;

Chart1.AxisX.AutoScale = false;

Chart1.AxisY.AutoScale = true;





Chart.InnerHtml = Chart1.GetHtmlTag(600, 300);


catch(System.Exception ex)


Chart.InnerHtml = "Could not render Chart chart due to: " + ex.Message;



Link to comment
Share on other sites

You don't want to assign labels at all, just X-Values, the labels Chart FX 

will display will be based on the data passes through X-Values.

Delete the line:

Chart1.AxisX.Label[i] = Convert.ToDateTime(dates[i]).ToShortDateString();

Performance/Style Suggestion: Use DateTime instead of strings to represent

your date values.


Francisco Padron




Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...