Jump to content
Software FX Community

Gaps in X Axis desired...code example...


User (Legacy)

Recommended Posts

I want to have gaps in a bar graph in the X Axis with DataTime type bound...here is my code

I also want to display the date in an alternate "CustomFormat" but it doesn't seem to work...

public Form2()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: find out why gaps don't show...

//

DataTable myDataTable = new DataTable();

myDataTable.Columns.AddRange(new DataColumn[]

{

new DataColumn("MyDate",typeof(System.DateTime)),

new DataColumn("MyValue",typeof(System.Int32))

}

);

myDataTable.Rows.Add(new object[] {DateTime.Now.AddDays(-2).Date, 40});

// Intentionally leave out a date to show a gap...

myDataTable.Rows.Add(new object[] {DateTime.Now.AddDays(0).Date, 30});

myDataTable.Rows.Add(new object[] {DateTime.Now.AddDays(1).Date, 20});

chart1.DataType[0] = DataType.Label;

chart1.DataType[1] = DataType.Value;

// TODO: why doesn't the label get formatted as below?

chart1.AxisX.LabelsFormat.CustomFormat = "dd-MMM-yyyy";

chart1.DataSource = myDataTable;

chart1.RecalcScale();

chart1.Refresh();

}

The graph should be something like, but when it displays the 24-AUG-2002 is skipped and the dates look like there is no gap, (see attached) but there is...

X

X X

X X X

X X X

23-AUG-2002 24-AUG-2002 25-AUG-2002 26-AUG-2002

Link to comment
Share on other sites

I want to have gaps in a bar graph in the X Axis with DataTime type bound...here is my code

I also want to display the date in an alternate "CustomFormat" but it doesn't seem to work...

public Form2()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: find out why gaps don't show...

//

DataTable myDataTable = new DataTable();

myDataTable.Columns.AddRange(new DataColumn[]

{

new DataColumn("MyDate",typeof(System.DateTime)),

new DataColumn("MyValue",typeof(System.Int32))

}

);

myDataTable.Rows.Add(new object[] {DateTime.Now.AddDays(-2).Date, 40});

// Intentionally leave out a date to show a gap...

myDataTable.Rows.Add(new object[] {DateTime.Now.AddDays(0).Date, 30});

myDataTable.Rows.Add(new object[] {DateTime.Now.AddDays(1).Date, 20});

chart1.DataType[0] = DataType.Label;

chart1.DataType[1] = DataType.Value;

// TODO: why doesn't the label get formatted as below?

chart1.AxisX.LabelsFormat.CustomFormat = "dd-MMM-yyyy";

chart1.DataSource = myDataTable;

chart1.RecalcScale();

chart1.Refresh();

}

The graph should be something like, but when it displays the 24-AUG-2002 is skipped and the dates look like there is no gap, (see attached) but there is...

X

X X

X X X

X X X

23-AUG-2002 24-AUG-2002 25-AUG-2002 26-AUG-2002

Link to comment
Share on other sites

1) Chart FX Lite does not support Date formatting. This is supported in the full version. The Formats supported are:

None,

Number,

Currency,

2)There will be as many bars as records in the result set. For a space to be left empty there has to be a record with the label you want and an empty (null) value. Chart FX will not automatically determine that one date is missing in your sequence.

--

FP

Software FX, Inc.

Link to comment
Share on other sites

1) Chart FX Lite does not support Date formatting. This is supported in the full version. The Formats supported are:

None,

Number,

Currency,

2)There will be as many bars as records in the result set. For a space to be left empty there has to be a record with the label you want and an empty (null) value. Chart FX will not automatically determine that one date is missing in your sequence.

--

FP

Software FX, Inc.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...