Jump to content
Software FX Community

Big time AxisX formating problems


User (Legacy)

Recommended Posts

Pulling my hair out for the second straight day now trying to format dates

correctly on the X axis. It simply doesn't work as documented.

Please explain how the chart attached to this message shows markers at

1/15/2005 and 1/31/2005 (and the third point is unlabeled) when the data

array has dates of 1/1/2005, 2/1/2005, and 3/1/2005! Using the latest 6.2

build (Web Form).

Also attached is a capture of the data array that is passed to the list

provider.

This is basically all the code:

Link to comment
Share on other sites

This is basically all the code:

DateTime date1, date2, date3;

date1 = new DateTime(2005, 1, 1);

date2 = new DateTime(2005, 2, 1);

date3 = new DateTime(2005, 3, 1);

ArrayList xValues = new ArrayList();

ArrayList yValues = new ArrayList();

xValues.Add(date1); xValues.Add(date2); xValues.Add(date3);

yValues.Add(3); yValues.Add(9); yValues.Add(3);

object[] arrays = new object[2];

arrays[0] = xValues;

arrays[1] = yValues;

chart1.Series[0].Gallery = Gallery.Lines;

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

ListProvider listProvider = new ListProvider(arrays);

chart1.DataSourceSettings.DataSource = listProvider;

post-2107-13922366089613_thumb.png

post-2107-13922377275734_thumb.png

Link to comment
Share on other sites

The main thing you need to understand here is that the X-Axis labels are NOT

directly related to each one of your values, X-Axis labels are displayed

based on a range (Min and Max) and a step providing an even labeling across

the axis.

If you want to label each point instead of label the axis as a whole, what

you need to do is set those dates as labels and not as X-Values. Here is

how:

chart1.DataType[0] = DataType.Label;

chart1.DataSourceSettings.DataSource = listProvider;

Now having said that, if you do want to keep your X-Axis independent of your

points (kind of like the Y-Axis) then you can do a lot of things to

customize it the way you want it.

The first thing you need to do is the Chart gallery to Lines as follows:

chart1.Gallery = Gallery.Lines;

Otherwise, Gallery will remain at Bar (Default) and the X-Axis will behave

completely different. The reasons for this are explained in the

documentation under Data-Driven labels, but if you are not interested in Bar

charts then you can simply add the line above, once you do this you will get

labels at 1/15, 1/31, 2/15 and 2/28.Chart FX chose a step of 1/2 a month,

starting on 12/31/04.

--

Francisco Padron

www.chartfx.com

post-2107-13922366091024_thumb.png

post-2107-13922377277418_thumb.png

Link to comment
Share on other sites

> The main thing you need to understand here is that the X-Axis labels are

NOT

> directly related to each one of your values, X-Axis labels are displayed

> based on a range (Min and Max) and a step providing an even labeling

across

> the axis.

That explanation makes sense but what doesn't make sense is that a point

with a date of 1/1/2005 is plotted DIRECTLY above the X axis label of

1/15/2005. It's like there is a complete disconnect between the plotted

points and the X axis scaling/labeling. The center point (2/1/2005) is

roughly correct (though the X axis is labeled 1/31/2005) but the two outer

points are just not right.

> If you want to label each point instead of label the axis as a whole, what

> you need to do is set those dates as labels and not as X-Values. Here is

> how:

>

> chart1.DataType[0] = DataType.Label;

This is what I'll try next. Thanks.

Link to comment
Share on other sites

> If you want to label each point instead of label the axis as a whole, what

> you need to do is set those dates as labels and not as X-Values. Here is

> how:

>

> chart1.DataType[0] = DataType.Label;

The problem with that approach is now the points are evenly spaced

regardless of the actual time interval between them. Definately not what I

want.

Link to comment
Share on other sites

> That explanation makes sense but what doesn't make sense is that a point

> with a date of 1/1/2005 is plotted DIRECTLY above the X axis label of

> 1/15/2005

As I said before, this "incorrect" labeling is caused by the wrong Gallery

type being selected. Addin the line:

chart1.Gallery = Gallery.Lines;

Fixes this problem.

--

Francisco Padron

www.chartfx.com

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...