ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Using Dataset for ASP.Net programming
Posted by Harish on Nov-24-2008 20:56
Hi,

I am using dataset in my program and want to generate the graph from the data available in the dataset. also would like to check if chartdirector support AJAX.

  Re: Using Dataset for ASP.Net programming
Posted by Peter Kwan on Nov-25-2008 00:59
Hi Harish,

By DataSet, I assume you mean the System.Data.DataSet object.

ChartDirector accepts array variables as input. Most of the sample code fills the array variables with hard coded data for demonstration purposes. In your real code, you may fill the array variables with data from your DataSet instead. Usually, it is a simple loop copies reads data from your DataSet to the array variables.

ChartDirector also has a utility class called DBTable that can copy a column of data in a DataTable to an array variable. For example, with a DataSet, the code would be like:

//assume ds is your System.Data.DataSet object - get data from the first table in the DataSet
DBTable table1 = new DBTable(ds.Tables[0]);

//assume first column contains text labels
string[] labels = table1.getColAsString(0);

//assume second column contains data values
double[] data = table1.getCol(1);

.... now can use data and labels to draw a pie chart or a bar chart, etc ....

ChartDirector fully supports AJAX. You may use ChartDirector with the standard ASP.NET AJAX framework. There are also some AJAX examples that come with ChartDirector to demonstrate advanced AJAX features. You may refer to "Zoomable and Scrollable Charts" in the ChartDirector documentation for more details.

Hope this can help.

Regards
Peter Kwan

  Re: Using Dataset for ASP.Net programming
Posted by Bill Cantor on Nov-26-2011 09:03
Attachments:
What if I have an Array data using ASP.NET, I want it to plot in graph. Let say in my code
below:

double[, ,] GraphData;
  GraphData = new double[7, 20]; //where 7, number of columns, maximum of 20 rows
                for (int i = 0; i < NumRows; i++)
                {
GraphData[1,i] = double.Parse(PerDayArray[1, i]);
GraphData[2,i] = double.Parse(PerDayArray[2, i]);
GraphData[3,i] = double.Parse(PerDayArray[3, i]);
GraphData[4,i] = double.Parse(PerDayArray[4, i]);
GraphData[5,i] = double.Parse(PerDayArray[5, i]);
GraphData[6,i] = double.Parse(PerDayArray[6, i]);
GraphData[7,i] = double.Parse(PerDayArray[7, i]);
}

how to I call the GraphData array and dispaly into graph?
Please response ASAP co'z I need this in my project. TIA
arraydata.txt
double[, ,] GraphData;
  GraphData = new double[7, 20]; //where 7, number of columns, maximum of 20 rows
                for (int i = 0; i < NumRows; i++)
                {
 GraphData[1,i] = double.Parse(PerDayArray[1, i]);
 GraphData[2,i] = double.Parse(PerDayArray[2, i]);
 GraphData[3,i] = double.Parse(PerDayArray[3, i]);
 GraphData[4,i] = double.Parse(PerDayArray[4, i]);
 GraphData[5,i] = double.Parse(PerDayArray[5, i]);
 GraphData[6,i] = double.Parse(PerDayArray[6, i]);
 GraphData[7,i] = double.Parse(PerDayArray[7, i]);
}

  Re: Using Dataset for ASP.Net programming
Posted by Peter Kwan on Nov-28-2011 18:34
Hi Bill,

You may simply copy the data to a single dimension array and them pass them to ChartDirector.

For example:

double[] myData = new double[NumRows];
for (int i = 0; i < GraphData.GetLength(0); ++i)
{
     //copy to single dimension array
     for (int j = 0; j < NumRows; ++j)
           myData[j] = GraphData[i, j];

     //pass to ChartDirector
     c.addLineLayer(myData, -1, "My Line " + i);
}

(Note: I see that in your code, you use 1, 2, 3, 4, 5, 6, 7 as the array index. I believe they should be 0, 1, 2, 3, 4, 5, 6.)

Hope this can help.

Regards
Peter Kwan