protected void Page_Load(object sender, EventArgs e) { if (!NThinChartControl1.Initialized) { // enable jittering (full scene antialiasing) NThinChartControl1.Settings.JitterMode = JitterMode.Enabled; NThinChartControl1.Panels.Clear(); // apply background image border NImageFrameStyle frame = new NImageFrameStyle(); frame.Type = ImageFrameType.Raised; frame.BackgroundColor = Color.White; frame.BorderStyle.Color = Color.Gainsboro; NThinChartControl1.BackgroundStyle.FrameStyle = frame; NThinChartControl1.BackgroundStyle.FillStyle = new NGradientFillStyle(Color.White, Color.GhostWhite); // set a chart title NLabel title = new NLabel("Postback Tool"); NThinChartControl1.Panels.Add(title); title.DockMode = PanelDockMode.Top; title.Padding = new NMarginsL(4, 6, 4, 6); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // configure the legend NLegend legend = new NLegend(); NThinChartControl1.Panels.Add(legend); legend.DockMode = PanelDockMode.Right; legend.Padding = new NMarginsL(1, 1, 3, 3); legend.FillStyle.SetTransparencyPercent(50); legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterLeftBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterRightBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterTopBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.VerticalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); // configure the chart NCartesianChart chart = new NCartesianChart(); NThinChartControl1.Panels.Add(chart); chart.Enable3D = true; chart.Fit3DAxisContent = true; chart.DisplayOnLegend = legend; chart.BoundsMode = BoundsMode.Fit; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.DockMode = PanelDockMode.Fill; chart.Padding = new NMarginsL( new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); // setup the X axis NAxis axisX = chart.Axis(StandardAxis.PrimaryX); NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)axisX.ScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; // add interlaced stripe for the Y axis NAxis axisY = chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)axisY.ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; scaleY.StripStyles.Add(stripStyle); // hide the depth axis chart.Axis(StandardAxis.Depth).Visible = false; // add a bar series and fill it with data NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Simple Bar Chart"; bar.BarShape = BarShape.SmoothEdgeBar; bar.Legend.Mode = SeriesLegendMode.DataPoints; bar.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); bar.DataLabelStyle.Visible = false; bar.AddDataPoint(new NDataPoint(16, "Spain")); bar.AddDataPoint(new NDataPoint(42, "France")); bar.AddDataPoint(new NDataPoint(56, "Germany")); bar.AddDataPoint(new NDataPoint(23, "Italy")); bar.AddDataPoint(new NDataPoint(47, "UK")); bar.AddDataPoint(new NDataPoint(38, "Sweden")); for (int i = 0; i < bar.Values.Count; i++) { bar.InteractivityStyles[i] = new NInteractivityStyle("Click on bar to make it red"); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(bar); NThinChartControl1.Controller.Tools.Add(new NPostbackTool()); } NThinChartControl1.Postback += new NPostbackEventHandler(NThinChartControl1_Postback); NThinChartControl1.Controller.Tools.Clear(); NTooltipTool tooltipTool = new NTooltipTool(); NThinChartControl1.Controller.Tools.Add(tooltipTool); NPostbackTool postbackTool = new NPostbackTool(); postbackTool.PostbackOnlyOnInteractiveItems = PostbackOnlyOnInteractiveItemsCheckBox.Checked; NThinChartControl1.Controller.Tools.Add(postbackTool); }
protected void Page_Load(object sender, System.EventArgs e) { // begin view init base.DefaultGridOrigin = new NPointF(30, 30); base.DefaultGridCellSize = new NSizeF(100, 50); base.DefaultGridSpacing = new NSizeF(50, 40); NDrawingDocument document = NThinDiagramControl1.Document; if (!NThinDiagramControl1.Initialized) { NThinDiagramControl1.View.Layout = CanvasLayout.Fit; // add the client mouse event tool NThinDiagramControl1.Controller.Tools.Add(new NPostbackTool()); document.BeginInit(); document.BackgroundStyle.FrameStyle.Visible = false; document.AutoBoundsPadding = new Nevron.Diagram.NMargins(10f, 10f, 10f, 10f); document.Style.FillStyle = new NColorFillStyle(Color.White); NBasicShapesFactory factory = new NBasicShapesFactory(document); NShape outerCircle = factory.CreateShape(BasicShapes.Circle); outerCircle.Bounds = new NRectangleF(0f, 0f, 200f, 200f); document.ActiveLayer.AddChild(outerCircle); NShape rect = factory.CreateShape(BasicShapes.Rectangle); rect.Bounds = new NRectangleF(42f, 42f, 50f, 50f); rect.Style.FillStyle = new NColorFillStyle(Color.LightBlue); rect.Style.InteractivityStyle = CreateInteractivityStyle("Rectangle"); rect.Tag = true; document.ActiveLayer.AddChild(rect); NShape triangle = factory.CreateShape(BasicShapes.Triangle); triangle.Bounds = new NRectangleF(121f, 57f, 60f, 55f); triangle.Style.FillStyle = new NColorFillStyle(Color.LightBlue); triangle.Style.InteractivityStyle = CreateInteractivityStyle("Triangle"); triangle.Tag = true; document.ActiveLayer.AddChild(triangle); NShape pentagon = factory.CreateShape(BasicShapes.Pentagon); pentagon.Bounds = new NRectangleF(60f, 120f, 54f, 50f); pentagon.Style.FillStyle = new NColorFillStyle(Color.LightBlue); pentagon.Style.InteractivityStyle = CreateInteractivityStyle("Pentagon"); pentagon.Tag = true; document.ActiveLayer.AddChild(pentagon); document.SizeToContent(); document.EndInit(); } // Create a few simple shapes with attached client mouse event interactivity NThinDiagramControl1.Postback += new NPostbackEventHandler(NThinDiagramControl1_Postback); NThinDiagramControl1.Controller.Tools.Clear(); NTooltipTool tooltipTool = new NTooltipTool(); NThinDiagramControl1.Controller.Tools.Add(tooltipTool); NPostbackTool postbackTool = new NPostbackTool(); // postbackTool.PostbackOnlyOnInteractiveItems = PostbackOnlyOnInteractiveItemsCheckBox.Checked; NThinDiagramControl1.Controller.Tools.Add(postbackTool); }