Jump to content
Software FX Community

Simple question, Hopefully..


User (Legacy)

Recommended Posts

Is it possible to have the Graph generate the xAxis data directly from the

dataset?

I would like to have the column names as the calues for the xAxis, Now I

know I can set them manually by doing

chart4.Legend[1] = "February";

chart4.Legend[2] = "March";

for example, But is it possible to have the Graph pick up the values

directly from the DataTable object?

Heres some code, that creates a dataset with 3 Columns and 2 rows, I would

like to have the column names along the xAxis and the values from the first

column specifed as the Graph

Hope you can help

Regards

Clive

DataTable myDataTable = new DataTable("MyDataTable");

// Declare DataColumn and DataRow variables.

DataColumn myDataColumn;

DataRow myDataRow;

chart4.ClearData(ClearDataFlag.Values);

// Create new DataColumn, set DataType, ColumnName and add to DataTable.

myDataColumn = new DataColumn();

myDataColumn.DataType = System.Type.GetType("System.String");

myDataColumn.ColumnName = "Type";

myDataTable.Columns.Add(myDataColumn);

// Create second column.

myDataColumn = new DataColumn();

myDataColumn.DataType = Type.GetType("System.Int32");

myDataColumn.ColumnName = "Jan";

myDataTable.Columns.Add(myDataColumn);

chart4.Legend[0] = "Jan";

// Create third column.

myDataColumn = new DataColumn();

myDataColumn.DataType = Type.GetType("System.Int32");

myDataColumn.ColumnName = "Feb";

myDataTable.Columns.Add(myDataColumn);

myDataRow = myDataTable.NewRow();

myDataRow["Type"] = "Expenses";

myDataRow["Jan"] = 12500;

myDataRow["Feb"] = 13500;

myDataTable.Rows.Add(myDataRow);

myDataRow = myDataTable.NewRow();

myDataRow["Type"] = "Fees";

myDataRow["Jan"] = 15500;

myDataRow["Feb"] = 14500;

myDataTable.Rows.Add(myDataRow);

chart4.DataSource = myDataTable;

Link to comment
Share on other sites

Is it possible to have the Graph generate the xAxis data directly from the

dataset?

I would like to have the column names as the calues for the xAxis, Now I

know I can set them manually by doing

chart4.Legend[1] = "February";

chart4.Legend[2] = "March";

for example, But is it possible to have the Graph pick up the values

directly from the DataTable object?

Heres some code, that creates a dataset with 3 Columns and 2 rows, I would

like to have the column names along the xAxis and the values from the first

column specifed as the Graph

Hope you can help

Regards

Clive

DataTable myDataTable = new DataTable("MyDataTable");

// Declare DataColumn and DataRow variables.

DataColumn myDataColumn;

DataRow myDataRow;

chart4.ClearData(ClearDataFlag.Values);

// Create new DataColumn, set DataType, ColumnName and add to DataTable.

myDataColumn = new DataColumn();

myDataColumn.DataType = System.Type.GetType("System.String");

myDataColumn.ColumnName = "Type";

myDataTable.Columns.Add(myDataColumn);

// Create second column.

myDataColumn = new DataColumn();

myDataColumn.DataType = Type.GetType("System.Int32");

myDataColumn.ColumnName = "Jan";

myDataTable.Columns.Add(myDataColumn);

chart4.Legend[0] = "Jan";

// Create third column.

myDataColumn = new DataColumn();

myDataColumn.DataType = Type.GetType("System.Int32");

myDataColumn.ColumnName = "Feb";

myDataTable.Columns.Add(myDataColumn);

myDataRow = myDataTable.NewRow();

myDataRow["Type"] = "Expenses";

myDataRow["Jan"] = 12500;

myDataRow["Feb"] = 13500;

myDataTable.Rows.Add(myDataRow);

myDataRow = myDataTable.NewRow();

myDataRow["Type"] = "Fees";

myDataRow["Jan"] = 15500;

myDataRow["Feb"] = 14500;

myDataTable.Rows.Add(myDataRow);

chart4.DataSource = myDataTable;

Link to comment
Share on other sites

Hello,

Yes this is possible through the DataType property of the chart object. You

can specify how each column in the table is to be used by placing this code

right before you set ChartFX's datasource.

chart1.DataType(0) = DataType.Label

chart1.DataType(1) = DataType.Value

JT

Software FX

Tech. Support

Support at SoftwareFX.com

"Clive" <clive.bennett@writeme_REMOVE_.com> wrote in message

news:w3qQjloFDHA.1600@webserver1.softwarefx.com...

> Is it possible to have the Graph generate the xAxis data directly from the

> dataset?

> I would like to have the column names as the calues for the xAxis, Now I

> know I can set them manually by doing

> chart4.Legend[1] = "February";

> chart4.Legend[2] = "March";

>

> for example, But is it possible to have the Graph pick up the values

> directly from the DataTable object?

>

> Heres some code, that creates a dataset with 3 Columns and 2 rows, I would

> like to have the column names along the xAxis and the values from the

first

> column specifed as the Graph

>

> Hope you can help

>

> Regards

> Clive

>

> DataTable myDataTable = new DataTable("MyDataTable");

> // Declare DataColumn and DataRow variables.

>

> DataColumn myDataColumn;

> DataRow myDataRow;

>

> chart4.ClearData(ClearDataFlag.Values);

>

> // Create new DataColumn, set DataType, ColumnName and add to

DataTable.

> myDataColumn = new DataColumn();

> myDataColumn.DataType = System.Type.GetType("System.String");

> myDataColumn.ColumnName = "Type";

> myDataTable.Columns.Add(myDataColumn);

>

> // Create second column.

> myDataColumn = new DataColumn();

> myDataColumn.DataType = Type.GetType("System.Int32");

> myDataColumn.ColumnName = "Jan";

> myDataTable.Columns.Add(myDataColumn);

> chart4.Legend[0] = "Jan";

>

> // Create third column.

> myDataColumn = new DataColumn();

> myDataColumn.DataType = Type.GetType("System.Int32");

> myDataColumn.ColumnName = "Feb";

> myDataTable.Columns.Add(myDataColumn);

>

> myDataRow = myDataTable.NewRow();

> myDataRow["Type"] = "Expenses";

> myDataRow["Jan"] = 12500;

> myDataRow["Feb"] = 13500;

> myDataTable.Rows.Add(myDataRow);

>

> myDataRow = myDataTable.NewRow();

> myDataRow["Type"] = "Fees";

> myDataRow["Jan"] = 15500;

> myDataRow["Feb"] = 14500;

> myDataTable.Rows.Add(myDataRow);

>

> chart4.DataSource = myDataTable;

>

>

Link to comment
Share on other sites

Hello,

Yes this is possible through the DataType property of the chart object. You

can specify how each column in the table is to be used by placing this code

right before you set ChartFX's datasource.

chart1.DataType(0) = DataType.Label

chart1.DataType(1) = DataType.Value

JT

Software FX

Tech. Support

Support at SoftwareFX.com

"Clive" <clive.bennett@writeme_REMOVE_.com> wrote in message

news:w3qQjloFDHA.1600@webserver1.softwarefx.com...

> Is it possible to have the Graph generate the xAxis data directly from the

> dataset?

> I would like to have the column names as the calues for the xAxis, Now I

> know I can set them manually by doing

> chart4.Legend[1] = "February";

> chart4.Legend[2] = "March";

>

> for example, But is it possible to have the Graph pick up the values

> directly from the DataTable object?

>

> Heres some code, that creates a dataset with 3 Columns and 2 rows, I would

> like to have the column names along the xAxis and the values from the

first

> column specifed as the Graph

>

> Hope you can help

>

> Regards

> Clive

>

> DataTable myDataTable = new DataTable("MyDataTable");

> // Declare DataColumn and DataRow variables.

>

> DataColumn myDataColumn;

> DataRow myDataRow;

>

> chart4.ClearData(ClearDataFlag.Values);

>

> // Create new DataColumn, set DataType, ColumnName and add to

DataTable.

> myDataColumn = new DataColumn();

> myDataColumn.DataType = System.Type.GetType("System.String");

> myDataColumn.ColumnName = "Type";

> myDataTable.Columns.Add(myDataColumn);

>

> // Create second column.

> myDataColumn = new DataColumn();

> myDataColumn.DataType = Type.GetType("System.Int32");

> myDataColumn.ColumnName = "Jan";

> myDataTable.Columns.Add(myDataColumn);

> chart4.Legend[0] = "Jan";

>

> // Create third column.

> myDataColumn = new DataColumn();

> myDataColumn.DataType = Type.GetType("System.Int32");

> myDataColumn.ColumnName = "Feb";

> myDataTable.Columns.Add(myDataColumn);

>

> myDataRow = myDataTable.NewRow();

> myDataRow["Type"] = "Expenses";

> myDataRow["Jan"] = 12500;

> myDataRow["Feb"] = 13500;

> myDataTable.Rows.Add(myDataRow);

>

> myDataRow = myDataTable.NewRow();

> myDataRow["Type"] = "Fees";

> myDataRow["Jan"] = 15500;

> myDataRow["Feb"] = 14500;

> myDataTable.Rows.Add(myDataRow);

>

> chart4.DataSource = myDataTable;

>

>

Link to comment
Share on other sites

There is something here I can't understand. You said:

"I would like to have the column names along the xAxis and the values from

the first column specifed as the Graph "

You can either have one series per column (default) or you can have one

series per row (using DataStyle.Transpose).

To have one series per row and use the column names as X-Axis labels, you

need to do:

chart1.DataSourceSettings.DataStyle |= DataStyle.Transpose;

BEFORE you bind the chart to the data source.

Also, check out other properties in DataSourceSettings for more options.

--

FP

Software FX, Inc.

Link to comment
Share on other sites

There is something here I can't understand. You said:

"I would like to have the column names along the xAxis and the values from

the first column specifed as the Graph "

You can either have one series per column (default) or you can have one

series per row (using DataStyle.Transpose).

To have one series per row and use the column names as X-Axis labels, you

need to do:

chart1.DataSourceSettings.DataStyle |= DataStyle.Transpose;

BEFORE you bind the chart to the data source.

Also, check out other properties in DataSourceSettings for more options.

--

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...