void NThinChartControl1_Postback(object sender, ThinWeb.NPostbackEventArgs e) { NHitTestResult hitTestResult = NThinChartControl1.HitTest(e.MousePosition.X, e.MousePosition.Y); int dataPointIndex = hitTestResult.DataPointIndex; if (dataPointIndex != -1) { NBarSeries barSeries = (NBarSeries)hitTestResult.Series; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(barSeries); barSeries.FillStyles[dataPointIndex] = new NColorFillStyle(Color.Red); } else { NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(NThinChartControl1.Charts[0]); } }
protected void Page_Load(object sender, EventArgs e) { if (!NThinChartControl1.Initialized) { NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = NThinChartControl1.Labels.AddHeader("Data Pan Tool"); title.TextStyle.TextFormat = GraphicsCore.TextFormat.XML; title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend NThinChartControl1.Legends.Clear(); // setup chart NChart chart = NThinChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); scaleY.StripStyles.Add(stripStyle); scaleY.RoundToTickMax = false; scaleY.RoundToTickMin = false; // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Back }; scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleX.RoundToTickMax = false; scaleX.RoundToTickMin = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup point series NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point); point.Name = "Point1"; point.DataLabelStyle.Visible = false; point.FillStyle = new NColorFillStyle(Color.FromArgb(160, DarkOrange)); point.BorderStyle.Width = new NLength(0); point.Size = new NLength(2, NRelativeUnit.ParentPercentage); point.PointShape = PointShape.Ellipse; // instruct the point series to use custom X values point.UseXValues = true; // generate some random X values GenerateXYData(point); NThinChartControl1.RecalcLayout(); chart.Axis(StandardAxis.PrimaryX).PagingView.ZoomIn(new NRange1DD(-0.5, 0.5), 0.0001); chart.Axis(StandardAxis.PrimaryY).PagingView.ZoomIn(new NRange1DD(-0.5, 0.5), 0.0001); // apply layout ApplyLayoutTemplate(0, NThinChartControl1, chart, title, null); NThinChartControl1.Controller.SetActivePanel(chart); } // code common for load/postback NThinChartControl1.ServerSettings.EnableTiledZoom = UseTilingCheckBox.Checked; NChart chart1 = NThinChartControl1.Charts[0]; chart1.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = ShowScrollbarsCheckBox.Checked; chart1.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = ShowScrollbarsCheckBox.Checked; NDataPanTool dataPanTool = new NDataPanTool(); if (UpdateRangeInTitleCheckBox.Checked) { dataPanTool.DataPanCallback = new MyDataPanCallback(); NThinChartControl1.ScrollCallback = new MyScrollCallback(); NThinChartControl1.RecalcLayout(); NThinChartControl1.Labels[0].Text = FormatLabel(chart1.Axis(StandardAxis.PrimaryX).Scale.RulerRange, chart1.Axis(StandardAxis.PrimaryY).Scale.RulerRange); } else { dataPanTool.DataPanCallback = null; NThinChartControl1.ScrollCallback = null; NThinChartControl1.Labels[0].Text = "Data Pan Tool"; } NThinChartControl1.Controller.Tools.Clear(); NThinChartControl1.Controller.Tools.Add(dataPanTool); if (UpdateRangeInTitleCheckBox.Checked) { NThinChartControl1.Labels[0].Text = FormatLabel(chart1.Axis(StandardAxis.PrimaryX).Scale.RulerRange, chart1.Axis(StandardAxis.PrimaryY).Scale.RulerRange); } }
protected void Page_Load(object sender, EventArgs e) { if (!NThinChartControl1.Initialized) { NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false; NThinChartControl1.BackgroundStyle.FillStyle = new NColorFillStyle(Color.FromArgb(244, 244, 244)); // set a chart title NLabel title = NThinChartControl1.Labels.AddHeader("CSS Customization"); title.TextStyle.TextFormat = GraphicsCore.TextFormat.XML; title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend NThinChartControl1.Legends.Clear(); // setup chart NChart chart = NThinChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; chart.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = true; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); scaleY.StripStyles.Add(stripStyle); scaleY.RoundToTickMax = false; scaleY.RoundToTickMin = false; // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Back }; scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleX.RoundToTickMax = false; scaleX.RoundToTickMin = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup point series NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point); point.Name = "Point1"; point.DataLabelStyle.Visible = false; point.FillStyle = new NColorFillStyle(Color.FromArgb(160, DarkOrange)); point.BorderStyle.Width = new NLength(0); point.Size = new NLength(2, NRelativeUnit.ParentPercentage); point.PointShape = PointShape.Ellipse; // instruct the point series to use custom X values point.UseXValues = true; // generate some random X values GenerateXYData(point); NThinChartControl1.RecalcLayout(); chart.Axis(StandardAxis.PrimaryX).PagingView.ZoomIn(new NRange1DD(-0.5, 0.5), 0.0001); chart.Axis(StandardAxis.PrimaryY).PagingView.ZoomIn(new NRange1DD(-0.5, 0.5), 0.0001); // apply layout ApplyLayoutTemplate(0, NThinChartControl1, chart, title, null); NThinChartControl1.ServerSettings.EnableTiledZoom = true; NThinChartControl1.Controller.SetActivePanel(chart); // configure tools NThinChartControl1.Controller.Tools.Clear(); NDataPanTool dataPanTool = new NDataPanTool(); dataPanTool.Exclusive = true; dataPanTool.Enabled = true; NThinChartControl1.Controller.Tools.Add(dataPanTool); NDataZoomTool dataZoomTool = new NDataZoomTool(); dataZoomTool.Exclusive = true; dataZoomTool.Enabled = false; NThinChartControl1.Controller.Tools.Add(dataZoomTool); NThinChartControl1.Controller.Tools.Add(new NTooltipTool()); NThinChartControl1.Controller.Tools.Add(new NCursorTool()); NThinChartControl1.Toolbar.Visible = true; NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataPanToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator()); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleTooltipToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleCursorToolAction())); // show loader images NThinChartControl1.ServerSettings.ShowLoaderImagesForAxisTiles = true; NThinChartControl1.ServerSettings.ShowLoaderImagesForPlotTiles = true; // customize the CSS NThinChartControl1.ServerSettings.Css.StatePressed = @"border: 1px solid rgb(255, 0, 0); background: rgb(252, 226, 203);"; NThinChartControl1.ServerSettings.Css.StateHover = @"border: 1px solid rgb(178, 0, 0); background: rgb(255, 255, 255);"; NThinChartControl1.ServerSettings.Css.StateDefault = @"margin: 0px; padding: 2px; border : 1px solid rgb(200, 200, 200); background: rgb(255, 255, 255);"; NThinChartControl1.ServerSettings.Css.ToolbarSeparator = @"width: 10px; height: 22px; font-size : 0px; background-color: rgb(255, 255, 255);"; NThinChartControl1.ServerSettings.Css.View = @"margin-left: 0px; margin-right: 0px; margin-top: 1px; margin-bottom: 0px; padding: 0px; border : 1px solid rgb(204, 204, 204);"; NThinChartControl1.ServerSettings.Css.Scrollbar = @"margin : 0px; padding : 0px; border : 1px solid rgb(204, 204, 204); background: rgb(255, 255, 255);"; // reflects view css margin + padding + border inflate NThinChartControl1.ServerSettings.Css.ViewInflate = new NSize(2, 3); // switch to JQuery 1.6.1 NThinChartControl1.ServerSettings.JQuery.SourceType = JQuerySourceType.Url; NThinChartControl1.ServerSettings.JQuery.Url = @"http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"; } }