Check out 3 new chart types in FusionCharts 3.15

Introducing 3 new chart types - Sankey, Chord & Sunburst

Check Them Out

Data Engine API

Static Source#

Create#

The code to create a StaticSource is given below:

StaticSource source = new StaticSource(dataTable);
Were you able to implement this?

Dispose#

The code to dispose the StaticSource object is given below:

source.Dispose()
Were you able to implement this?

MSSQL Source#

Apart from Static Source, the DataEngine of FusionCharts.NET also lets you use data from an MSSQL server. Here's how you should proceed to do that:

Configure data source#

Before the FusionCharts DataEngine can fetch data from MSSQL, it needs to connect to the server. The DataEngine can do so in one of the following ways:

SQL Authentication

If the MSSQL server has SQL authentication, refer to the command given below:

/* create object */
/* SQL Authentication */

MsSqlClass msSql = new MsSqlClass("username", "password", "servername", "databasename", sourcetype, "sourcename")
Were you able to implement this?

Windows Authentication

If the MSSQL server has Windows authentication, refer to the command given below:

/* create object */
/* Windows Authentication */
MsSqlClass msSql = new MsSqlClass("servername","databasename", sourcetype, "sourcename")|
Were you able to implement this?

Connection String

If you want to use a different type of authentication apart from the two given above, you need to provide a connection string to the DataEngine. Refer to the command given below:

/* create object */
/* provide connection string from user end */
MsSqlClass msSql = new MsSqlClass("connectionstring", sourcetype, "sourcename")
Were you able to implement this?

CSV File#

Local/another network file#

The code to fetch data from a CSV file stored in the local computer is given below:

CsvFileSource csvFileSource = new CsvFileSource("filePath");
Were you able to implement this?

File from another network#

The code to fetch data from a CSV file stored in another network is given below:

CsvFileSource csvFileSource = new CsvFileSource("filePath", "userName", "password");
Were you able to implement this?

Dispose#

The code to dispose the csvFileSource object is given below:

csvFileSource.Dispose();
Were you able to implement this?

JSON File#

Local/another network file#

The code to fetch data from a JSON file stored in the local computer is given below:

JsonFileSource jsonFileSource = new JsonFileSource("filePath");
Were you able to implement this?

File from another network#

The code to fetch data from a JSON file stored in another network is given below:

JsonFileSource jsonFileSource = new JsonFileSource("filePath", "userName", "password");
Were you able to implement this?

Dispose#

The code to dispose the JsonFileSource object is given below:

jsonFileSource.Dispose();
Were you able to implement this?

MSSQL Source#

Apart from Static Source, the DataEngine of FusionCharts.NET also lets you use data from an MSSQL server. Here's how you should proceed to do that:

Configure data source#

Before the FusionCharts DataEngine can fetch data from MSSQL, it needs to connect to the server. The DataEngine can do so in one of the following ways:

SQL Authentication

If the MSSQL server has SQL authentication, refer to the code given below:

/* create object */
/* SQL Authentication */

MsSqlClass msSql = new MsSqlClass("username", "password","servername","databasename", sourcetype, "sourcename")|
Were you able to implement this?

In the above code:

  • username is the username for the MSSQL server

  • password is the password for the MSSQL server

  • servername is the name of the MSSQL server

  • databasename is the name of the database you want DataEngine to connect to

  • sourcetype is the type of data source you want DataEngine to fetch the data from. It is an enum of type DataBaseClass.SourceType. It can take the values of TABLE, VIEW, or QUERY.

  • sourcename is the name of the data source. If you want DataEngine to use a table or a view as the source, provide the name of the respective table/view. If you want to use the result of a query as the source, provide the query string.

Windows Authentication

If the MSSQL server has Windows authentication, refer to the code given below:

/* create object */
/* Windows Authentication */
MsSqlClass msSql = new MsSqlClass("servername","databasename", sourcetype, "sourcename")|
Were you able to implement this?

In the above code:

  • servername is the name of the MSSQL server

  • databasename is the name of the database you want DataEngine to connect to

  • sourcetype is the type of data source you want DataEngine to fetch the data from. It is an enum of type DataBaseClass.SourceType. It can take the values of TABLE, VIEW, or QUERY.

  • sourcename is the name of the data source. If you want the DataEngine to use a table or a view as the source, provide the name of the respective table/view. If you want the DataEngine to use the result of a query as the source, provide the query string.

Connection String

If you want to use a different type of authentication apart from the two given above, you need to provide a connection string to the DataEngine. Refer to the code given below:

/* create object */
/* provide connection string from user end */
MsSqlClass msSql = new MsSqlClass("connectionstring", sourcetype, "sourcename")|
Were you able to implement this?

In the above code:

  • connectionstring is the connection string.

  • sourcetype is the type of data source you want DataEngine to fetch the data from. It is an enum of type DataBaseClass.SourceType. It can take the values of TABLE, VIEW, or QUERY.

  • sourcename is the name of the data source. If you want the DataEngine to use a table or a view as the source, provide the name of the respective table/view. If you want to use the result of a query as the source, provide the query string.

DataModel#

Create#

The code to create a DataModel is given below:

DataModel model = new DataModel();
Were you able to implement this?

Dispose#

The code to dispose the DataModel object is given below:

model.Dispose()
Were you able to implement this?

Add DataSource to DataModel object#

The code to add a DataSource to the DataModel is given below:

model.DataSources.Add(source);
Were you able to implement this?

Retrieve Data from DataModel#

The code to retrieve data from the DataModel is given below:

DataTable table = model.Data // Output of the data format is DataTable
Were you able to implement this?

DataModel Schema#

ColumnSchema of the DataModel data is used to get the schema.

The code is given below:

List<Schema> modelSchema = model.ColumnSchema
Were you able to implement this?

Set Date/Time format#

To set the date/time format of the data, set the DataSourceDateformat property of DataModel instance.

The code is given below:

model.DataSourceDateformat = "MM/dd/yyyy hh:mm tt";
Were you able to implement this?

Set Culture#

To set the culture to en-US, set the Culture of the model.

The code is given below:

model.Culture = new CultureInfo("en-us");
Were you able to implement this?

To set the maximum year till which the dates will be returned with the year in yy format, set the year value to TwoDigitYearMax under Calendar.

The code is given below:

model.Culture.Calendar.TwoDigitYearMax = 2010;
Were you able to implement this?

Add Filter#

To apply filter to the data of the chart, set the properties of following filter instances:

Null#

To apply the null filter to the data of the chart, set the nullOperation instance of the DataModel as shown below:

DataModel nullOperation = model.Where("Country is null"); //Country is the Column name
Were you able to implement this?

Not Null#

To apply the not null filter to the data of the chart, set the notNullOperation instance of the DataModel as shown below:

DataModel notNullOperation = model.Where("Country is not null");
Were you able to implement this?

Equal#

To apply equal filter operation, set the equalOperation instance of the DataModel as shown below:

DataModel equalOperation = model.Where("Country = United States");
Were you able to implement this?

Not Equal#

To apply not equal filter operation, set the notEqualOperation instance of the DataModel as shown below:

DataModel notEqualOperation = model.Where("Country != United States");
Were you able to implement this?

Greater#

To apply greater filter operation, set the greaterOperation instance of the DataModel as shown below:

DataModel greaterOperation = model.Where("Sales > 100");
Were you able to implement this?

Greater or Equal#

To apply greater or equal filter operation, set the greaterEqualOperation instance of the DataModel as shown below:

DataModel greaterEqualOperation = model.Where("Quantity >= 3");
Were you able to implement this?

Less#

To apply less filter operation, set the lessOperation instance of the DataModel as shown below:

DataModel lessOperation = model.Where("Sales < 100");
Were you able to implement this?

Less or Equal#

To apply less or equal filter operation, set the lessEqualOperation instance of the DataModel as shown below:

DataModel lessEqualOperation = model.Where("Quantity <= 3");
Were you able to implement this?

Between#

To apply between filter operation, set the betweenOperation instance of the DataModel as shown below:

DataModel betweenOperation = model.Where("Order Date is between 1/22/2011 to 1/24/2011");
Were you able to implement this?

Begins with#

To apply begins with filter operation, set the beginsWithOperation instance of the DataModel as shown below:

DataModel beginsWithOperation = model.Where("Country begins with A");
Were you able to implement this?

Contains#

To apply contains filter operation, set the containsOperation instance of the DataModel as shown below:

DataModel containsOperation = model.Where("Country contains d");
Were you able to implement this?

Ends with#

To apply ends with filter operation, set the endsWithOperation instance of the DataModel as shown below:

DataModel endsWithOperation = model.Where("Country ends with a");
Were you able to implement this?

Logical Operator#

To apply logical operators to the data, set it's instance of the DataModel as shown below:

AND Operator

DataModel andOperator = model.Where("Order Date is between 1/22/2011 to 1/24/2011 and Country = United States");
Were you able to implement this?

OR Operator

DataModel orOperator = model.Where("Name starts with I or Name starts with A");
Were you able to implement this?

Pivot#

To apply pivot operation to the data, set the pivotModel instance of the DataModel as shown below:

DataModel pivotModel = model.Pivot(row, column, aggregation);
Were you able to implement this?

Pagination#

To code to set the page size is given below:

model.PageSize = 15;
Were you able to implement this?

The code to get records from specific pages is given below:

DataModel dataModel = model.GetItemsFromPages(2, 3);
Were you able to implement this?

Top#

The code to apply topRecords operation is given below:

DataModel newModel = model.TopRecords(5);
Were you able to implement this?

Select#

The code to apply select operation to the data is given below:

DataModel newModel = model.SelectColumns("Country","Sales");
Were you able to implement this?

Create/Dispose GroupColumn#

Create#

The code to create instance of GroupColumn class is shown below:

This instance will be used to group more than one column of a tabular data.

GroupColumn model = new GroupColumn {
    "Sales",
    "Quantity",
    "Shipping Cost"
};
Were you able to implement this?

Dispose#

The code to dispose the grouped column is given below:

model.Dispose()
Were you able to implement this?

Create/Dispose SortColumn#

Create#

The code to create instance of SortColumn class is shown below:

This instance will be used to sort more than one column of a tabular data.

SortColumn model = new SortColumn {
    {"1994",SortColumn.Order.DESC },
      {"1995",SortColumn.Order.DESC },
      {"1996",SortColumn.Order.DESC }
};
Were you able to implement this?

Dispose#

THe code to dispose the sorted column is given below:

model.Dispose()
Were you able to implement this?

Create/Dispose Aggregation class#

Create#

The code to create instance of Aggregation class is shown below:

This instance will be used to aggregate more than one column of a tabular data.

Aggregation model = new Aggregation {
    { "Quantity", Aggregation.Function.COUNT },
    { "Sales", Aggregation.Function.SUM }
};
Were you able to implement this?

Dispose#

The code to dispose the aggregated is given below:

model.Dispose()
Were you able to implement this?

Create/Dispose Calculated Column#

Create#

To create a new calculated column, you need to create an instance of the CalculatedColumns class. Refer to the code given below:

CalculatedColumns calculatedColumns = new CalculatedColumns {
    {"SellingPrice - (Cost * Unit)","Profit" },
    {"ExpiryYear - ManufactureYear","Validity" }
};
Were you able to implement this?

Dispose#

The code to dispose the calculatedColumns object is given below:

calculatedColumn.Dispose();
Were you able to implement this?