See Also

DataEngine Members  | dotnetCHARTING Namespace

Language

Visual Basic

C#

Show All

See Also Languages dotnetCHARTING Send comments on this topic.

DataEngine Class

Acquires and manipulates data from databases or other sources, then creates a SeriesCollection which is consumed by the chart control.

For a list of all members of this type, see DataEngine members.

Object Model


Inheritance Hierarchy

System.Object
   dotnetCHARTING.DataEngine

Syntax

[Visual Basic]
Public Class DataEngine
[C#]
public class DataEngine

Example

[Visual Basic] 

<%@ Page Language="VB" debug="true" Description="dotnetCHARTING Component"%>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>


<script runat="server">
Sub Page_Load(sender As Object ,e As EventArgs )

    'set global properties
    Chart.Title="Item sales"
    Chart.XAxis.Label.Text ="months"
    Chart.YAxis.FormatString="currency"
    Chart.TempDirectory="temp"
    Chart.Debug=true
    Chart.ShadingEffect = true
    Chart.Size="800X500"
    Chart.LegendBox.Position = LegendBoxPosition.None
    Chart.DefaultSeries.DefaultElement.ToolTip = "%yValue"

    'Add a series
    Dim de As DataEngine
    de = new DataEngine()
    de.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("../../database/chartsample.mdb")
    de.StartDate=new DateTime (2002,1,1,0,0,0)
    de.EndDate = new DateTime (2002,12,31,23,59,59)
    de.DateGrouping = TimeInterval.Year
    de.SqlStatement= "SELECT OrderDate,Total, Name FROM Orders WHERE OrderDate >= #STARTDATE# AND OrderDate <= #ENDDATE# ORDER BY OrderDate"


    Dim sc As SeriesCollection
    sc = de.GetSeries()
   'customize element settings
   'set the color for different customers in each month based on their total sale.
   Dim sr As dotnetCHARTING.Series
   Dim el As dotnetCHARTING.Element
    for each sr in sc
        for each el in sr.Elements
              if (el.YValue < 3500)
                el.Color = Color.Red
              else if (el.YValue < 5000)
                  el.Color = Color.Yellow
              else
                  el.Color = Color.Green
              end if
          Next el
    Next sr

    Chart.SeriesCollection.Add(sc)
End Sub
</script>
<HTML><HEAD><TITLE>Data Engine Sample</TITLE></HEAD>
<BODY>
<DIV align=center>
 <dotnet:Chart id="Chart" runat="server"/>
</DIV>
</BODY>
</BODY>
</HTML>

[C#] 

<%@ Page Language="C#"  debug="true" Description="dotnetCHARTING Component"%> 
<%@ Register TagPrefix="dotnet"  Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%> 
<%@ Import Namespace="System.Drawing" %> 
 
 
<script runat="server"> 
void Page_Load(Object sender,EventArgs e) 

    //set global properties 
    Chart.Title="Item sales"; 
    Chart.XAxis.Label.Text ="months"; 
    Chart.YAxis.FormatString="currency"; 
    Chart.TempDirectory="temp"; 
    Chart.Debug=true; 
    Chart.ShadingEffect = true; 
    Chart.LegendBox.Position = LegendBoxPosition.None; 
    Chart.Size="800X500"; 
    Chart.DefaultSeries.DefaultElement.ToolTip = "%yValue"; 
      
    //Add a series 
     DataEngine de = new DataEngine(); 
    de.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("../../database/chartsample.mdb");   
    de.StartDate=new DateTime (2002,1,1,0,0,0); 
    de.EndDate = new DateTime (2002,12,31,23,59,59); 
    de.DateGrouping = TimeInterval.Year; 
    de.SqlStatement= @"SELECT OrderDate,Total, Name FROM Orders  WHERE OrderDate >= #STARTDATE# AND OrderDate <= #ENDDATE# ORDER BY OrderDate";  
   SeriesCollection sc = de.GetSeries(); 
   // customize element settings 
   //set the color for different customers in each month based on their total sale. 
    foreach(dotnetCHARTING.Series sr in sc) 
    { 
        foreach(dotnetCHARTING.Element el in sr.Elements) 
        { 
              if (el.YValue < 3500) 
              { 
                   el.Color = Color.Red; 
                    
              } 
              else if (el.YValue < 5000) 
              { 
                   el.Color = Color.Yellow; 
              } 
              else 
              { 
                  el.Color = Color.Green; 
 
              } 
          } 
     } 
 
    Chart.SeriesCollection.Add(sc); 
     

</script> 
<HTML><HEAD><TITLE>Data Engine Sample</TITLE></HEAD> 
<BODY> 
<DIV align=center> 
 <dotnet:Chart id="Chart"  runat="server"/> 
</DIV> 
</BODY> 
</BODY> 
</HTML>

See Also

DataEngine Members  | dotnetCHARTING Namespace

 

 


2002 - 2005 Webavail Productions Inc. & Corporate Web Solutions Ltd.. All Rights Reserved.