<%@ Page language="c#" MasterPageFile="~/SampleCode/SamplesMasterPage.master" Inherits="SmartWebControls.SampleCode.ScrollableSmartChart" CodeFile="ScrollableSmartChart.aspx.cs" %> <%@ Register TagPrefix="swc" Namespace="SmartWebControls" Assembly="SmartWebControls.SmartChart" %> <asp:Content ID="content" runat="server" ContentPlaceHolderID="cphMain"> <div id="divTitle">Scrollable SmartChart</div> <div id="divInstructions"> This sample demonstrates how the ScrollContainerHeight and ScrollContainerWidth properties can be used to place the SmartChart control in a scrollable container. </div> <p /> <div style="border:1px solid black;width:700px;"> <swc:SmartChartPro id="SmartChart1" title="SmartChartRectangleRender Event Demo" runat="server" ShowToolbar="True" AllowEditing="True" AllowDragDrop="True" ShadowColor="LightGray" Font-Names="Verdana" Font-Bold="True" RoundBoxEdgesAmount="10" OutputType="Html" Height="472px" Width="1168px" ImageWidth="90" ImageHeight="70" TitleColor="MidnightBlue" ShadowOffset="5" AllowDrillDown="True" BoxTextColor="Navy" BoxGradient="True" BoxColor="LightGray" MaxTextLength="25" DataFields="name,title,contact" DataKeyField="id" DataNodeName="person" DataTitleFields="name,desc,contact" BackgroundImage="" DrawShadows="True" HighlightChildrenOnMouseOver="True" ToolbarCssClass="toolbar" HasParentImagePath="~/SampleCode/SmartChartPro/Images/up.gif" HasChildrenImagePath="~/SampleCode/SmartChartPro/Images/down.gif" DrillDownType="SmartChartItem" HasChildrenImageVSpace="2" ChartDepth="6" AllowDeleting="True" ScrollContainerHeight="450px" ScrollContainerWidth="700px"></swc:SmartChartPro> </div> <asp:Panel ID="pnlSave" Runat="server" Visible="False"> <strong>SmartChart data saved (see save event handler in code-behind file).</strong> </asp:Panel> </asp:Content>
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; 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 System.Drawing.Drawing2D; namespace SmartWebControls.SampleCode { /// <summary> /// Summary description for ScrollableSmartChart. /// </summary> public partial class ScrollableSmartChart : System.Web.UI.Page { protected override void OnInit(EventArgs e) { base.OnInit(e); this.SmartChart1.SmartChartDeleting += new EventHandler<SmartChartEventArgs>(this.SmartChart1_SmartChartDeleting); this.SmartChart1.SmartChartSaving += new EventHandler<SmartChartSaveEventArgs>(this.SmartChart1_SmartChartSaving); this.SmartChart1.SmartChartRectangleRendering += new EventHandler<SmartChartEventArgs>(this.SmartChart1_SmartChartRectangleRendering); } protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { string xmlPath = Server.MapPath("~/SampleCode/SmartChartPro/XML/OrgChart.xml"); XmlDocument doc = new XmlDocument(); doc.Load(xmlPath); //Hook up event to event handler SmartChart1.DataSource = doc; SmartChart1.DataBind(); } } /// <summary> /// Before the SmartChart renders the chart demonstrate how to change the background. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SmartChart1_SmartChartRectangleRendering(object sender, SmartWebControls.SmartChartEventArgs e) { if (e.Item.DataItem != null) { SmartWebControls.SmartChartItem item = e.Item; Color boxColor = Color.Empty; //Grab appropriate title key from DataKeyField values and use it to access the text value string title = item.DataItem["title"].ToString().ToLower(); if (title.IndexOf("mgr") != -1) { //Found a node that has what we want item.BackColor = Color.ForestGreen; item.ForeColor = Color.White; } if (title.IndexOf("developer") != -1) { //Found a node that has what we want item.ForeColor = Color.White; item.BackColor = Color.Firebrick; } } } private void SmartChart1_SmartChartSaving(object sender, SmartChartSaveEventArgs e) { //Save data back to database or else where this.SmartChart1.Visible = false; this.pnlSave.Visible = true; XmlDocument doc = (XmlDocument)e.Result; //Save doc.... doc.Save(path); } private void SmartChart1_SmartChartDeleting(object sender, SmartWebControls.SmartChartEventArgs e) { } } }