ASPX Code
<%@ Page language="c#" MasterPageFile="~/SampleCode/SamplesMasterPage.master" Inherits="SmartWebControls.SampleCode.Simple" CodeFile="Simple.aspx.cs" %>
<%@ Register TagPrefix="swc" Namespace="SmartWebControls" Assembly="SmartWebControls.SmartChart" %>
<asp:Content ID="content" runat="server" ContentPlaceHolderID="cphMain">
<div id="divTitle">Displaying an OrgChart with a Background Image using SmartChartLite</div>
<swc:SmartChartPro id="WebSmartChart1" runat="server" Width="733px"
Height="375px" DrawShadows="True"
BackgroundImage="~/SampleCode/SmartChartPro/images/seal.jpg"
DataTitleFields="name,title,duties" DataNodeName="person"
DataKeyField="id" ShadowColor="Gray" DataFields="name,title" BoxColor="LightGray"
BoxGradient="True" BoxTextColor="Black"
ChartDepth="5" SmartChartDirectory="~/ImageFolder" AllowDrillDown="True" FontStyle="Bold"
ShadowOffset="5" title="Agency Organization Chart" TitleColor="MidnightBlue" MaxChildrenPerLevelGroup="8"
ImageHeight="50" ImageWidth="50" OutputType="Image" />
</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 Simple : System.Web.UI.Page {
protected void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
WebSmartChart1.DataSource = LoadData();
WebSmartChart1.DataBind();
}
}
private XmlDocument LoadData() {
string xmlPath = Server.MapPath("~/SampleCode/SmartChartLite/XML/OrgChart.xml");
XmlDocument doc = new XmlDocument();
doc.Load(xmlPath);
return doc;
}
private void Rectangle_PreRender(object sender, SmartChartEventArgs e) {
}
private void Title_PreRender(object sender, SmartChartEventArgs e) {
// Graphics g = e.SmartChartGraphics;
// RectangleF rec = e.SmartChartRectangle;
// SolidBrush brush = new SolidBrush(Color.Red);
// g.FillRectangle(brush,rec);
}
private void Rectangle_Render(object sender, SmartChartEventArgs e) {
// if (e.SmartChartDataKeyField == "200") {
// Graphics g = e.SmartChartGraphics;
// RectangleF rec = new RectangleF(e.SmartChartRectangle.X,e.SmartChartRectangle.Y,
// e.SmartChartRectangle.Width,e.SmartChartRectangle.Height);
// g.DrawRectangle(new Pen(Color.Red,2),(int)rec.X,(int)rec.Y,(int)rec.Width,(int)rec.Height);
// }
}
}
}