Epic Chart

How to implement

Step by step implementation in Visual Studio:
1. Right click your project and choose "Add reference"
2. Click the tab "browse"
3. Browse to EpicChart.dll and open file
4. For simplicity add "using EpicChart;" to your cs file
Now the control is ready to use!

Getting started

When you have your data and want to display it, all you need are these 3 lines of code:
Chart myChart = new Chart(500, 400, Color.White);
string strChartImgName = myChart.SaveMultipleBarGraph("c:\\graphs\\");
Now strChartImgName contains the name of your chart JPEG ex. "0805214134.jpg" and 0805214134.jpg is saved to c:\graphs\

Data input

Epic Chart can be used with three different types of data:
- DataTable (.NET)
Just use the "LoadData" method that is accurate for your datatype, see sample code below:
bool hasData = myChart.LoadDataFromDataTable(myDataTable);
bool hasData = myChart.LoadDataFromDB("select count(*) from table", "Data Source=localhost;Initial Cata...");
bool hasData = myChart.LoadDataFromXml("<xml></xml>");
bool hasData = myChart.LoadDataFromXmlFile("c:\\data.xml");
If the data is properly loaded, hasData will be True. If the data is of wrong type or if for example the path to the XML is wrong, it will be False. When the "LoadData" method returns True, all your data has been loaded and you are ready to choose your output.


Epic Chart saves your chart to a specified location or return the Bitmap object:
string strChartImgName = myChart.SaveMultipleBarGraph("c:\\graphs\\");
Bitmap myBitmap = myChart.DrawMultipleBarGraph();
Use the Save method if you need to save the graph; else use the Bitmap method.

DataTable Structure and methods

Epic chart will show every numeric column as data, if row contains an text field it will be shown as the "grouping text" for that row. Image bleow illustrates a DataTable with valid data:
DataTable will show:DataTable
If you dont want any "grouping text" only use numeric fields or use a diffrent overload of the "LoadDataFromDataTable" Method.

The "LoadDataFromDataTable" method has five overloads as shown below:
1. LoadDataFromDataTable(myDT, strListOfDataFields, strGrpTxtField);
2. LoadDataFromDataTable(myDT, strListOfDataFields);
3. LoadDataFromDataTable(myDT, strDataField, strGrpTxtField);
4. LoadDataFromDataTable(myDT, strDataField);
5. LoadDataFromDataTable(myDT);
Use the overloads if you have a big DataTable that contains inrelevant data. Specify your relevant data fields in a List<string> or if you only have one relevant field use a string and pass in to method. Since you only can have one "grouping text" field you pass it on to method as a simple string.

(Data to work with)

Code using:
LoadDataFromDataTable(myDT, strListOfDataFields, strGrpTxtField);
List<string> strListOfDataFields = new List<string>();
myChart.LoadDataFromDataTable(myDT, strListOfDataFields, "date");

This code will give us this graph:
Graph from LoadDataFromDataTable(myDT, strListOfDataFields, strGrpTxtField)

XML Format

To keep things as simple as possible, the XML format is the same as used in .NET on serialized objects. See the sample XML document below:
<?xml version="1.0" standalone="yes"?>
Use the Save method if you need to save the graph else use the Draw method to get the Bitmap object.

Visual settings

Epic Chart has a few settings for each type of graph. These are the settings for the "Multiple Bar Graph":
- 3d Deapth (default: 5 pixels)
- Show grid (default: not showing)
- Show legend (default: not showing)
- Show data on bars (default: not showing)

This code illustrates how to make a graph that shows the data on the bars and has a legend:
Chart myChart = new Chart(500, 114, Color.White);
myChart.ShowLegend = true;
myChart.ShowDataText = true;
string strChartImgName = myChart.SaveMultipleBarGraph("c:\\graphs\\");

And the generated graph will look like this:
Visual example

Sample code

This piece of code generates a bargraph from an DataTable with 2 data fields and 1 text field and saves it to a path:
DataTable used in this sample:

protected void Page_Load(object sender, EventArgs e)
DataTable myData = GetTestData();
List<string> myList = new List<string>();

Chart myChart = new Chart(400, 200);
myChart.LoadDataFromDataTable(myData, myList, "date");
string strImageName = myChart.SaveMultipleBarGraph("c:\\");
myImageBox.ImageUrl = "c:\\" + strImageName;

The aspx code for this will be:
<asp:image ID ="myImageBox" runat="server"></asp:image>