Converting Data within a DataSet to an OrgChart and Embedding Images
This example shows how images can be embedded directly into SmartChart items by using the ImageField, ImageHeight and ImageWidth properties of the control. Click the View Code link above to see the code for this example.

Organization Chart
-
Lin Thomas
CIO



-
Paul Johnson
Director





-
-
-
Greg Jones
Web Manager
Jack Doe
PC Manager
Ben Jones
Exchange Manager
ASPX Code

<%@ Page language="c#" MasterPageFile="~/SampleCode/SamplesMasterPage.master" Inherits="SmartWebControls.SampleCode.EmbeddedImages" CodeFile="EmbeddedImages.aspx.cs" %>
<%@ Register TagPrefix="swc" Namespace="SmartWebControls" Assembly="SmartWebControls.SmartChart" %>
<asp:Content ID="content" runat="server" ContentPlaceHolderID="cphMain">
    <br />
        <div id="divTitle">Converting Data within a DataSet to an OrgChart and Embedding Images</div>
            <div id="divInstructions">
                This example shows how images can be embedded directly into SmartChart items by using the ImageField,
                ImageHeight and ImageWidth properties of the control.  Click the View Code link above
                to see the code for this example.
            </div>
            <p></p>
            <swc:SmartChartPro id="WebSmartChart1" title="Organization Chart" runat="server" TextOnly="False" ImageField="image"
                ImageWidth="50" ImageHeight="50" MaxChildrenPerLevelGroup="8" TitleColor="MidnightBlue"
                ShadowOffset="5" FontStyle="Bold" AllowDrillDown="True"
                ChartDepth="6" BoxTextColor="Navy" BoxGradient="True" BoxColor="LightGray" DataFields="name,title"
                DataKeyField="id" DataNodeName="person" DataTitleFields="name,title,duties" DrawShadows="True"
                Height="400px" Width="733px" OutputType="Html" LineColor="Black" ShadowColor="LightGray"
                AllowDragDrop="True"></swc:SmartChartPro>

</asp:Content>

C# Code:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using SmartWebControls;

namespace SmartWebControls.SampleCode {
    /// <summary>
    /// Summary description for WebForm1.
    /// </summary>
    public partial class EmbeddedImages : System.Web.UI.Page {

        protected void Page_Load(object sender, System.EventArgs e) {
            this.WebSmartChart1.SmartChartTitleRendering += new EventHandler<SmartChartEventArgs>(this.WebSmartChart1_SmartChartTitleRendering);

            if (!Page.IsPostBack) {
                DataSet ds = new DataSet();
                ds.ReadXml(Server.MapPath("~/SampleCode/SmartChartPro/XML/OrgChartDataSet.xml"));
                DataColumn colChild = ds.Tables[0].Columns["pid"];
                DataColumn colParent = ds.Tables[0].Columns["id"];
                DataRelation relation = new DataRelation("ParentChild",colParent,colChild);
                relation.Nested = true;
                ds.Relations.Add(relation);
                WebSmartChart1.DataSource = ds;
                WebSmartChart1.DataBind();
            }
        }

        //#### A few Potential Event Handlers for SmartChart Events
        private void Rectangle_PreRender(object sender, SmartChartEventArgs e) {

        }

        private void WebSmartChart1_SmartChartTitleRendering(object sender, SmartChartEventArgs e) {
            //Could change title on the fly by handling this event
            //1.  We can cancel the event completely which prevents the title from drawing
            //e.Cancel = true;

            //2.  We can manipulate the title 
            //e.Item.BackColor = Color.Red;
        }

        private void Rectangle_Render(object sender, SmartChartEventArgs e) {
            //Could change data on rectangle by handling this event
        }

    }
}